Class HistoryFileManager


  • public class HistoryFileManager
    extends Object
    History storage file manager which saves and loads history on disk
    • Field Detail

      • updateJobIntervalInMilliseconds

        protected int updateJobIntervalInMilliseconds
        Defines interval between update jobs. Intended to be overriden in tests.
    • Constructor Detail

      • HistoryFileManager

        public HistoryFileManager​(String accountId,
                                  HistoryStorage historyStorage)
        Constructs the history file manager instance
        Parameters:
        accountId - accound id
        historyStorage - history storage
    • Method Detail

      • startUpdateJob

        public void startUpdateJob()
        Starts a job to periodically save history on disk
      • stopUpdateJob

        public void stopUpdateJob()
        Stops a job to periodically save history on disk
      • getItemSize

        public int getItemSize​(Object item)
                        throws com.fasterxml.jackson.core.JsonProcessingException
        Helper function to calculate object size in bytes in utf-8 encoding
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • setStartNewOrderIndex

        public void setStartNewOrderIndex​(int index)
        Sets the index of the earliest changed historyOrder record
        Parameters:
        index - of the earliest changed record
      • setStartNewDealIndex

        public void setStartNewDealIndex​(int index)
        Sets the index of the earliest changed deal record
        Parameters:
        index - of the earliest changed record
      • updateDiskStorage

        public CompletableFuture<Void> updateDiskStorage()
        Saves unsaved history items to disk storage
        Returns:
        completable future which resolves when disk storage is updated
      • deleteStorageFromDisk

        public CompletableFuture<Void> deleteStorageFromDisk()
        Deletes storage files from disk
        Returns:
        completable future which resolves when the storage is deleted