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
Modifier and TypeFieldDescriptionprotected long
protected long
protected byte[]
protected int
static final int
protected int
protected long
protected boolean
Fields inherited from class com.epam.fixengine.storage.file.AbstractFileMessageStorage
accessFile, channel, configuration, isForcedFlush, maskedTags, NEW_LINE, storageTimestamp
-
Constructor Summary
ConstructorDescriptionMMFIndexedMessageStorage
(com.epam.fixengine.configuration.Configuration config) -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendMessage
(byte[] timestampFormatted, byte[] message) Appends message to storage with the given formatted timestampFormatted.void
appendMessage
(byte[] timestampFormatted, byte[] message, int offset, int length) Appends message to storage with the given formatted timestamp.long
appendMessageInternal
(byte[] timestampFormatted, byte[] message, int offset, int length) long
appendMessageInternal
(long timestamp, byte[] message, int offset, int length) Appends message to storageprotected long
appendMessageToFile
(long timestamp, byte[] timestampFormatted, byte[] message, int offset, int length) protected void
backupStorageFile
(String fullPathToStorageFile, String fullPathToDestinationBackupFile) Backups storage file.void
close()
Close the storage.protected void
deleteStorageFile
(String fullPathToStorageFile) Deletes storage file.protected int
protected long
protected long
Gets next sequence number.long
Opens the indexed file.protected byte[]
readFromStorage
(FileChannel readChannel, long readFrom, int msgLen) void
retrieveMessages
(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:
initialize
in interfaceMessageStorage
- Overrides:
initialize
in classAbstractFileMessageStorage
- Returns:
- last send sequence number
- Throws:
IOException
- - if I/O errors occurred- See Also:
-
getFormatLength
protected int getFormatLength()- Overrides:
getFormatLength
in classAbstractFileMessageStorage
-
appendMessage
public void appendMessage(byte[] timestampFormatted, byte[] message, int offset, int length) throws IOException Description copied from interface:MessageStorage
Appends 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:MessageStorage
Appends 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:AbstractFileMessageStorage
Appends message to storage- Specified by:
appendMessageInternal
in 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:
retrieveMessages
in interfaceMessageStorage
- Specified by:
retrieveMessages
in 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:AbstractFileMessageStorage
Gets next sequence number.- Specified by:
getNextSequenceNumber
in 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:AbstractFileMessageStorage
Backups storage file.- Overrides:
backupStorageFile
in classAbstractFileMessageStorage
- Parameters:
fullPathToStorageFile
- the path to file of in/out filefullPathToDestinationBackupFile
- the destination place to backup file- Throws:
IOException
-
deleteStorageFile
Description copied from class:AbstractFileMessageStorage
Deletes storage file.- Overrides:
deleteStorageFile
in classAbstractFileMessageStorage
- Parameters:
fullPathToStorageFile
- the path to in/out file
-
close
Close the storage.- Specified by:
close
in interfaceMessageStorage
- Overrides:
close
in classAbstractFileMessageStorage
- Throws:
IOException
- - if I/O error occurred
-