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
Modifier and TypeFieldDescriptionprotected RandomAccessFile
protected FileChannel
protected com.epam.fixengine.configuration.Configuration
protected boolean
protected static final byte[]
protected StorageTimestamp
-
Constructor Summary
ModifierConstructorDescriptionprotected
Deprecated.use AbstractFileMessageStorage(Configuration configuration)protected
AbstractFileMessageStorage
(com.epam.fixengine.configuration.Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendMessage
(byte[] message) Appends message to storage.void
appendMessage
(byte[] message, int offset, int length) Appends message to storage.abstract long
appendMessageInternal
(long timestamp, byte[] message, int offset, int length) Appends message to storagelong
appendMessageInternal
(Date date, byte[] message, int offset, int length) Deprecated.use AbstractFileMessageStorage#appendMessageInternal(long timestamp,byte[] message,int offset,int length)protected void
backupFile
(String fullPathToStorageFile, String fullPathToDestinationBackupFile) void
backupStorage
(SessionParameters sessionParameters) Backup the storage.protected void
backupStorageFile
(String fullPathToStorageFile, String fullPathToDestinationBackupFile) Backups storage file.void
close()
Close the storage.protected void
deleteFile
(String fullPathToStorageFile) protected void
deleteStorageFile
(String fullPathToStorageFile) Deletes storage file.getFile()
Gets the file.protected int
protected abstract long
Gets next sequence number.protected byte[]
getPrefixFormat
(long timestamp) long
Initialize the storage.protected boolean
protected boolean
isClosed()
Returns true if storage is closed.protected void
protected void
byte[]
retrieveMessage
(long num) Retrieves message from storage.abstract void
retrieveMessages
(long from, long to, MessageStorageListener listener, boolean blocking) Retrieves message from storage.void
setBackupFileLocator
(LogFileLocator fileLocator) void
Sets the file.void
setFileLocator
(LogFileLocator fileLocator) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:MessageStorage
Retrieves message from storage.- Specified by:
retrieveMessages
in 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:MessageStorage
Retrieves message from storage.- Specified by:
retrieveMessage
in 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:
initialize
in 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:MessageStorage
Appends message to storage.- Specified by:
appendMessage
in interfaceMessageStorage
- Parameters:
message
- the messageoffset
- the initial offsetlength
- the length- Throws:
IOException
- - if error occurred.
-
appendMessage
Description copied from interface:MessageStorage
Appends message to storage.- Specified by:
appendMessage
in 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:MessageStorage
Backup the storage.- Specified by:
backupStorage
in 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:
close
in interfaceMessageStorage
- Throws:
IOException
- - if I/O error occurred
-
isClosed
protected boolean isClosed()Returns true if storage is closed.
-