Class AbstractFileMessageStorage

java.lang.Object
com.epam.fixengine.storage.file.AbstractFileMessageStorage
All Implemented Interfaces:
MessageStorage
Direct Known Subclasses:
ChronicleQueueStorage, FlatFileMessageStorage, MMFIndexedMessageStorage

public abstract class AbstractFileMessageStorage extends Object implements MessageStorage
Abstract file storage implementation. The base functionality of this class.
  • Field Details

    • NEW_LINE

      protected static final byte[] NEW_LINE
    • channel

      protected FileChannel channel
    • accessFile

      protected RandomAccessFile accessFile
    • configuration

      protected com.epam.fixengine.configuration.Configuration configuration
    • maskedTags

      protected Map<byte[],Set<Integer>> maskedTags
    • storageTimestamp

      protected StorageTimestamp storageTimestamp
    • isForcedFlush

      protected boolean isForcedFlush
  • Constructor Details

    • AbstractFileMessageStorage

      @Deprecated protected AbstractFileMessageStorage()
      Deprecated.
      use AbstractFileMessageStorage(Configuration configuration)
    • AbstractFileMessageStorage

      protected AbstractFileMessageStorage(com.epam.fixengine.configuration.Configuration configuration)
  • Method Details

    • getFormatLength

      protected int getFormatLength()
    • getPrefixFormat

      protected byte[] getPrefixFormat(long timestamp)
    • getFile

      public String getFile()
      Gets the file.
    • setFile

      public void setFile(String file)
      Sets the file.
      Parameters:
      file - the file
    • setFileLocator

      public void setFileLocator(LogFileLocator fileLocator)
    • setBackupFileLocator

      public void setBackupFileLocator(LogFileLocator fileLocator)
    • retrieveMessages

      public abstract void retrieveMessages(long from, long to, MessageStorageListener listener, boolean blocking) throws IOException
      Description copied from interface: MessageStorage
      Retrieves message from storage.
      Specified by:
      retrieveMessages in interface MessageStorage
      Parameters:
      from - the from sequence number
      to - the to sequence number
      listener - the callback listener
      blocking - if parameter is true, the execution start in current thread context, otherwise in the new thread context.
      Throws:
      IOException - - if error occurred.
      See Also:
    • retrieveMessage

      public byte[] retrieveMessage(long num) throws IOException
      Description copied from interface: MessageStorage
      Retrieves message from storage.
      Specified by:
      retrieveMessage in interface MessageStorage
      Parameters:
      num - the sequence number of message
      Returns:
      the retrieved message
      Throws:
      IOException - - if error occurred.
      See Also:
    • initialize

      public long initialize() throws IOException
      Initialize the storage.
      Specified by:
      initialize in interface MessageStorage
      Returns:
      the last sequence number
      Throws:
      IOException - - if I/O error occurred
    • openStorageFile

      protected void openStorageFile() throws IOException
      Throws:
      IOException
    • initialized

      protected boolean initialized()
    • getNextSequenceNumber

      protected abstract long getNextSequenceNumber() throws IOException
      Gets next sequence number.
      Throws:
      IOException - - if I/O error occurred
    • appendMessage

      public void appendMessage(byte[] message, int offset, int length) throws IOException
      Description copied from interface: MessageStorage
      Appends message to storage.
      Specified by:
      appendMessage in interface MessageStorage
      Parameters:
      message - the message
      offset - the initial offset
      length - the length
      Throws:
      IOException - - if error occurred.
    • appendMessage

      public void appendMessage(byte[] message) throws IOException
      Description copied from interface: MessageStorage
      Appends message to storage.
      Specified by:
      appendMessage in interface MessageStorage
      Parameters:
      message - the message
      Throws:
      IOException - - if error occurred.
      See Also:
    • appendMessageInternal

      @Deprecated public long appendMessageInternal(Date date, byte[] message, int offset, int length) throws IOException
      Deprecated.
      use AbstractFileMessageStorage#appendMessageInternal(long timestamp,byte[] message,int offset,int length)
      Appends message to storage
      Parameters:
      date - the date parameter
      message - the array of bytes
      offset -
      length -
      Throws:
      IOException - - if I/O error occurred
    • appendMessageInternal

      public abstract long appendMessageInternal(long timestamp, byte[] message, int offset, int length) throws IOException
      Appends message to storage
      Parameters:
      timestamp - the timestamp parameter
      message - the array of bytes
      offset -
      length -
      Throws:
      IOException - - if I/O error occurred
    • backupStorage

      public void backupStorage(SessionParameters sessionParameters) throws IOException
      Description copied from interface: MessageStorage
      Backup the storage.
      Specified by:
      backupStorage in interface MessageStorage
      Parameters:
      sessionParameters - the session parameters
      Throws:
      IOException
    • openStorage

      protected void openStorage()
    • backupStorageFile

      protected void backupStorageFile(String fullPathToStorageFile, String fullPathToDestinationBackupFile) throws IOException
      Backups storage file.
      Parameters:
      fullPathToStorageFile - the path to file of in/out file
      fullPathToDestinationBackupFile - the destination place to backup file
      Throws:
      IOException
    • backupFile

      protected void backupFile(String fullPathToStorageFile, String fullPathToDestinationBackupFile) throws IOException
      Throws:
      IOException
    • deleteStorageFile

      protected void deleteStorageFile(String fullPathToStorageFile)
      Deletes storage file.
      Parameters:
      fullPathToStorageFile - the path to in/out file
    • deleteFile

      protected void deleteFile(String fullPathToStorageFile)
    • close

      public void close() throws IOException
      Close the storage.
      Specified by:
      close in interface MessageStorage
      Throws:
      IOException - - if I/O error occurred
    • isClosed

      protected boolean isClosed()
      Returns true if storage is closed.