Package com.epam.fixengine.storage.file
Class MMFIndexedMessageStorage
java.lang.Object
com.epam.fixengine.storage.file.AbstractFileMessageStorage
com.epam.fixengine.storage.file.MMFIndexedMessageStorage
- All Implemented Interfaces:
MessageStorage
WARNING: This implementation used class which is Sun proprietary API(HotSpot VM).
WARNING: Can persist message with sequence number is not greater than 178,956,969.
User: Mykhailo_Sereda Date: 16.05.12 Time: 11:38-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected longprotected byte[]protected intstatic final intprotected intprotected longprotected booleanFields inherited from class com.epam.fixengine.storage.file.AbstractFileMessageStorage
accessFile, channel, configuration, isForcedFlush, maskedTags, NEW_LINE, storageTimestamp -
Constructor Summary
ConstructorsConstructorDescriptionMMFIndexedMessageStorage(com.epam.fixengine.configuration.Configuration config) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendMessage(byte[] timestampFormatted, byte[] message) Appends message to storage with the given formatted timestampFormatted.voidappendMessage(byte[] timestampFormatted, byte[] message, int offset, int length) Appends message to storage with the given formatted timestamp.longappendMessageInternal(byte[] timestampFormatted, byte[] message, int offset, int length) longappendMessageInternal(long timestamp, byte[] message, int offset, int length) Appends message to storageprotected longappendMessageToFile(long timestamp, byte[] timestampFormatted, byte[] message, int offset, int length) protected voidbackupStorageFile(String fullPathToStorageFile, String fullPathToDestinationBackupFile) Backups storage file.voidclose()Close the storage.protected voiddeleteStorageFile(String fullPathToStorageFile) Deletes storage file.protected intprotected longprotected longGets next sequence number.longOpens the indexed file.protected byte[]readFromStorage(FileChannel readChannel, long readFrom, int msgLen) voidretrieveMessages(long from, long to, MessageStorageListener listener, boolean blocking) Retrieves message from storage.Methods inherited from class com.epam.fixengine.storage.file.AbstractFileMessageStorage
appendMessage, appendMessage, appendMessageInternal, backupFile, backupStorage, deleteFile, getFile, getPrefixFormat, initialized, isClosed, openStorage, openStorageFile, retrieveMessage, setBackupFileLocator, setFile, setFileLocator
-
Field Details
-
MAX_SEQNUM
public static final int MAX_SEQNUM- See Also:
-
timestamp
protected long timestamp -
dateFormattedBuffer
protected byte[] dateFormattedBuffer -
timestampsInLogs
protected boolean timestampsInLogs -
storageGrowSize
protected int storageGrowSize -
channelPosition
protected long channelPosition -
channelLength
protected long channelLength -
indexGrowSize
protected int indexGrowSize
-
-
Constructor Details
-
MMFIndexedMessageStorage
public MMFIndexedMessageStorage(com.epam.fixengine.configuration.Configuration config)
-
-
Method Details
-
initialize
Opens the indexed file. Make mapped byte buffers- Specified by:
initializein interfaceMessageStorage- Overrides:
initializein classAbstractFileMessageStorage- Returns:
- last send sequence number
- Throws:
IOException- - if I/O errors occurred- See Also:
-
getFormatLength
protected int getFormatLength()- Overrides:
getFormatLengthin classAbstractFileMessageStorage
-
appendMessage
public void appendMessage(byte[] timestampFormatted, byte[] message, int offset, int length) throws IOException Description copied from interface:MessageStorageAppends message to storage with the given formatted timestamp.- Parameters:
timestampFormatted- the message timestampmessage- the messageoffset- the initial offsetlength- the length- Throws:
IOException- - if error occurred.
-
appendMessage
Description copied from interface:MessageStorageAppends message to storage with the given formatted timestampFormatted.- Parameters:
timestampFormatted- the message timestampFormattedmessage- the message- Throws:
IOException- - if error occurred.
-
appendMessageInternal
public long appendMessageInternal(byte[] timestampFormatted, byte[] message, int offset, int length) throws IOException - Throws:
IOException
-
appendMessageInternal
public long appendMessageInternal(long timestamp, byte[] message, int offset, int length) throws IOException Description copied from class:AbstractFileMessageStorageAppends message to storage- Specified by:
appendMessageInternalin classAbstractFileMessageStorage- Parameters:
timestamp- the timestamp parametermessage- the array of bytes- Throws:
IOException- - if I/O error occurred- See Also:
-
retrieveMessages
public void retrieveMessages(long from, long to, MessageStorageListener listener, boolean blocking) throws IOException Retrieves message from storage.- Specified by:
retrieveMessagesin interfaceMessageStorage- Specified by:
retrieveMessagesin classAbstractFileMessageStorage- Parameters:
from- the start sequence positionto- the end sequence positionlistener- the callback listenerblocking- if sets to true the method call not blocking- Throws:
IOException- - if error occurred.- See Also:
-
readFromStorage
protected byte[] readFromStorage(FileChannel readChannel, long readFrom, int msgLen) throws IOException - Throws:
IOException
-
appendMessageToFile
protected long appendMessageToFile(long timestamp, byte[] timestampFormatted, byte[] message, int offset, int length) throws IOException - Throws:
IOException
-
getNextSequenceNumber
Description copied from class:AbstractFileMessageStorageGets next sequence number.- Specified by:
getNextSequenceNumberin classAbstractFileMessageStorage- Throws:
IOException- - if I/O error occurred- See Also:
-
getLastStoragePosition
- Throws:
IOException
-
backupStorageFile
protected void backupStorageFile(String fullPathToStorageFile, String fullPathToDestinationBackupFile) throws IOException Description copied from class:AbstractFileMessageStorageBackups storage file.- Overrides:
backupStorageFilein classAbstractFileMessageStorage- Parameters:
fullPathToStorageFile- the path to file of in/out filefullPathToDestinationBackupFile- the destination place to backup file- Throws:
IOException
-
deleteStorageFile
Description copied from class:AbstractFileMessageStorageDeletes storage file.- Overrides:
deleteStorageFilein classAbstractFileMessageStorage- Parameters:
fullPathToStorageFile- the path to in/out file
-
close
Close the storage.- Specified by:
closein interfaceMessageStorage- Overrides:
closein classAbstractFileMessageStorage- Throws:
IOException- - if I/O error occurred
-