Package com.epam.fixengine.storage.file
Class AbstractFileMessageStorage
java.lang.Object
com.epam.fixengine.storage.file.AbstractFileMessageStorage
- All Implemented Interfaces:
MessageStorage
- Direct Known Subclasses:
ChronicleQueueStorage,FlatFileMessageStorage,MMFIndexedMessageStorage
Abstract file storage implementation.
The base functionality of this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RandomAccessFileprotected FileChannelprotected com.epam.fixengine.configuration.Configurationprotected booleanprotected static final byte[]protected StorageTimestamp -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDeprecated.use AbstractFileMessageStorage(Configuration configuration)protectedAbstractFileMessageStorage(com.epam.fixengine.configuration.Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendMessage(byte[] message) Appends message to storage.voidappendMessage(byte[] message, int offset, int length) Appends message to storage.abstract longappendMessageInternal(long timestamp, byte[] message, int offset, int length) Appends message to storagelongappendMessageInternal(Date date, byte[] message, int offset, int length) Deprecated.use AbstractFileMessageStorage#appendMessageInternal(long timestamp,byte[] message,int offset,int length)protected voidbackupFile(String fullPathToStorageFile, String fullPathToDestinationBackupFile) voidbackupStorage(SessionParameters sessionParameters) Backup the storage.protected voidbackupStorageFile(String fullPathToStorageFile, String fullPathToDestinationBackupFile) Backups storage file.voidclose()Close the storage.protected voiddeleteFile(String fullPathToStorageFile) protected voiddeleteStorageFile(String fullPathToStorageFile) Deletes storage file.getFile()Gets the file.protected intprotected abstract longGets next sequence number.protected byte[]getPrefixFormat(long timestamp) longInitialize the storage.protected booleanprotected booleanisClosed()Returns true if storage is closed.protected voidprotected voidbyte[]retrieveMessage(long num) Retrieves message from storage.abstract voidretrieveMessages(long from, long to, MessageStorageListener listener, boolean blocking) Retrieves message from storage.voidsetBackupFileLocator(LogFileLocator fileLocator) voidSets the file.voidsetFileLocator(LogFileLocator fileLocator) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.epam.fixengine.storage.MessageStorage
appendMessage, appendMessage
-
Field Details
-
NEW_LINE
protected static final byte[] NEW_LINE -
channel
-
accessFile
-
configuration
protected com.epam.fixengine.configuration.Configuration configuration -
maskedTags
-
storageTimestamp
-
isForcedFlush
protected boolean isForcedFlush
-
-
Constructor Details
-
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
Gets the file. -
setFile
Sets the file.- Parameters:
file- the file
-
setFileLocator
-
setBackupFileLocator
-
retrieveMessages
public abstract void retrieveMessages(long from, long to, MessageStorageListener listener, boolean blocking) throws IOException Description copied from interface:MessageStorageRetrieves message from storage.- Specified by:
retrieveMessagesin interfaceMessageStorage- Parameters:
from- the from sequence numberto- the to sequence numberlistener- the callback listenerblocking- 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
Description copied from interface:MessageStorageRetrieves message from storage.- Specified by:
retrieveMessagein interfaceMessageStorage- Parameters:
num- the sequence number of message- Returns:
- the retrieved message
- Throws:
IOException- - if error occurred.- See Also:
-
initialize
Initialize the storage.- Specified by:
initializein interfaceMessageStorage- Returns:
- the last sequence number
- Throws:
IOException- - if I/O error occurred
-
openStorageFile
- Throws:
IOException
-
initialized
protected boolean initialized() -
getNextSequenceNumber
Gets next sequence number.- Throws:
IOException- - if I/O error occurred
-
appendMessage
Description copied from interface:MessageStorageAppends message to storage.- Specified by:
appendMessagein interfaceMessageStorage- Parameters:
message- the messageoffset- the initial offsetlength- the length- Throws:
IOException- - if error occurred.
-
appendMessage
Description copied from interface:MessageStorageAppends message to storage.- Specified by:
appendMessagein interfaceMessageStorage- 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 parametermessage- the array of bytesoffset-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 parametermessage- the array of bytesoffset-length-- Throws:
IOException- - if I/O error occurred
-
backupStorage
Description copied from interface:MessageStorageBackup the storage.- Specified by:
backupStoragein interfaceMessageStorage- 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 filefullPathToDestinationBackupFile- the destination place to backup file- Throws:
IOException
-
backupFile
protected void backupFile(String fullPathToStorageFile, String fullPathToDestinationBackupFile) throws IOException - Throws:
IOException
-
deleteStorageFile
Deletes storage file.- Parameters:
fullPathToStorageFile- the path to in/out file
-
deleteFile
-
close
Close the storage.- Specified by:
closein interfaceMessageStorage- Throws:
IOException- - if I/O error occurred
-
isClosed
protected boolean isClosed()Returns true if storage is closed.
-