com.epam.fixengine.storage.file
Class MMFIndexedMessageStorage

java.lang.Object
  extended by com.epam.fixengine.storage.file.AbstractFileMessageStorage
      extended by com.epam.fixengine.storage.file.MMFIndexedMessageStorage
All Implemented Interfaces:
MessageStorage

public class MMFIndexedMessageStorage
extends AbstractFileMessageStorage

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
protected  long channelLength
           
protected  long channelPosition
           
protected  byte[] dateFormattedBuffer
           
protected  int indexGrowSize
           
protected  int storageGrowSize
           
protected  long timestamp
           
protected  boolean timestampsInLogs
           
 
Fields inherited from class com.epam.fixengine.storage.file.AbstractFileMessageStorage
accessFile, calendar, channel, configuration
 
Constructor Summary
MMFIndexedMessageStorage(Configuration config)
           
 
Method Summary
 long appendMessageInternal(long timestamp, byte[] message, int offset, int length)
          Appends message to storage
protected  long appendMessageToFile(long timestamp, 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 getFormatLength()
           
protected  long getLastStoragePosition()
           
protected  long getNextSequenceNumber()
          Gets next sequence number.
 long initialize()
          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, openStorageFile, retrieveMessage, setBackupFileLocator, setFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 Detail

MMFIndexedMessageStorage

public MMFIndexedMessageStorage(Configuration config)
Method Detail

initialize

public long initialize()
                throws IOException
Opens the indexed file. Make mapped byte buffers

Specified by:
initialize in interface MessageStorage
Overrides:
initialize in class AbstractFileMessageStorage
Returns:
last send sequence number
Throws:
IOException - - if I/O errors occurred
See Also:
AbstractFileMessageStorage.initialize()

getFormatLength

protected int getFormatLength()
Overrides:
getFormatLength in class AbstractFileMessageStorage

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 class AbstractFileMessageStorage
Parameters:
timestamp - the timestamp parameter
message - the array of bytes
length - @throws IOException - if I/O error occurred
Throws:
IOException
See Also:
AbstractFileMessageStorage.appendMessageInternal(long, byte[], int, int)

retrieveMessages

public void retrieveMessages(long from,
                             long to,
                             MessageStorageListener listener,
                             boolean blocking)
                      throws IOException
Retrieves message from storage.

Specified by:
retrieveMessages in interface MessageStorage
Specified by:
retrieveMessages in class AbstractFileMessageStorage
Parameters:
from - the start sequence position
to - the end sequence position
listener - the callback listener
blocking - if sets to true the method call not blocking
Throws:
java.io.IOException, - IllegalArgumentException
IOException - - if error occurred.
See Also:
FlatFileMessageStorage

readFromStorage

protected byte[] readFromStorage(FileChannel readChannel,
                                 long readFrom,
                                 int msgLen)
                          throws IOException
Throws:
IOException

appendMessageToFile

protected long appendMessageToFile(long timestamp,
                                   byte[] message,
                                   int offset,
                                   int length)
                            throws IOException
Throws:
IOException

getNextSequenceNumber

protected long getNextSequenceNumber()
                              throws IOException
Description copied from class: AbstractFileMessageStorage
Gets next sequence number.

Specified by:
getNextSequenceNumber in class AbstractFileMessageStorage
Throws:
IOException - - if I/O error occurred
See Also:
AbstractFileMessageStorage.getNextSequenceNumber()

getLastStoragePosition

protected long getLastStoragePosition()
                               throws IOException
Throws:
IOException

backupStorageFile

protected void backupStorageFile(String fullPathToStorageFile,
                                 String fullPathToDestinationBackupFile)
                          throws IOException
Description copied from class: AbstractFileMessageStorage
Backups storage file.

Overrides:
backupStorageFile in class AbstractFileMessageStorage
Parameters:
fullPathToStorageFile - the path to file of in/out file
fullPathToDestinationBackupFile - the destination place to backup file
Throws:
IOException

deleteStorageFile

protected void deleteStorageFile(String fullPathToStorageFile)
Description copied from class: AbstractFileMessageStorage
Deletes storage file.

Overrides:
deleteStorageFile in class AbstractFileMessageStorage
Parameters:
fullPathToStorageFile - the path to in/out file

close

public void close()
           throws IOException
Close the storage.

Specified by:
close in interface MessageStorage
Overrides:
close in class AbstractFileMessageStorage
Throws:
IOException - - if I/O error occurred


Copyright © 2000-2014 EPAM Systems. All Rights Reserved.