com.epam.fixengine.storage.file
Class AbstractFileMessageStorage

java.lang.Object
  extended by com.epam.fixengine.storage.file.AbstractFileMessageStorage
All Implemented Interfaces:
MessageStorage
Direct Known Subclasses:
FlatFileMessageStorage, MMFIndexedMessageStorage

public abstract class AbstractFileMessageStorage
extends Object
implements MessageStorage

Abstract file storage implementation. The base functionality of this class.


Field Summary
protected  RandomAccessFile accessFile
           
protected  Calendar calendar
           
protected  FileChannel channel
           
protected  Configuration configuration
           
 
Constructor Summary
protected AbstractFileMessageStorage()
          Deprecated. 
protected AbstractFileMessageStorage(Configuration configuration)
           
 
Method Summary
 void appendMessage(byte[] message)
          Appends message to storage.
 void appendMessage(byte[] message, int offset, int length)
          Appends message to storage.
 long appendMessageInternal(Date date, byte[] message, int offset, int length)
          Deprecated. 
abstract  long appendMessageInternal(long timestamp, byte[] message, int offset, int length)
          Appends message to storage
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.
 String getFile()
          Gets the file.
protected  int getFormatLength()
           
protected abstract  long getNextSequenceNumber()
          Gets next sequence number.
protected  byte[] getPrefixFormat(long timestamp)
           
 long initialize()
          Initialize the storage.
protected  boolean initialized()
           
protected  boolean isClosed()
          Returns true if storage is closed.
protected  void openStorageFile()
           
 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 setFile(String file)
          Sets the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channel

protected FileChannel channel

accessFile

protected RandomAccessFile accessFile

calendar

protected Calendar calendar

configuration

protected Configuration configuration
Constructor Detail

AbstractFileMessageStorage

@Deprecated
protected AbstractFileMessageStorage()
Deprecated. 


AbstractFileMessageStorage

protected AbstractFileMessageStorage(Configuration configuration)
Method Detail

getFormatLength

protected int getFormatLength()

getPrefixFormat

protected byte[] getPrefixFormat(long timestamp)

getFile

public String getFile()
Gets the file.


setFile

public void setFile(String file)
Sets the file.

Parameters:
file - the file

setBackupFileLocator

public void setBackupFileLocator(LogFileLocator fileLocator)

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 interface MessageStorage
Parameters:
from - the from sequence number
to - the to sequence number
listener - the callback listener
blocking - if parameter is true, the execution start in current
thread context, otherwise in the new thread context.
Throws:
IOException - - if error occurred.
See Also:
MessageStorage.retrieveMessages(long, long, com.epam.fixengine.storage.MessageStorageListener, boolean)

retrieveMessage

public byte[] retrieveMessage(long num)
                       throws IOException
Description copied from interface: MessageStorage
Retrieves message from storage.

Specified by:
retrieveMessage in interface MessageStorage
Parameters:
num - the sequence number of message
Returns:
the retrieved message
Throws:
IOException - - if error occurred.
See Also:
MessageStorage.retrieveMessage(long)

initialize

public long initialize()
                throws IOException
Initialize the storage.

Specified by:
initialize in interface MessageStorage
Returns:
the last sequence number
Throws:
IOException - - if I/O error occurred

openStorageFile

protected void openStorageFile()
                        throws IOException
Throws:
IOException

initialized

protected boolean initialized()

getNextSequenceNumber

protected abstract long getNextSequenceNumber()
                                       throws IOException
Gets next sequence number.

Throws:
IOException - - if I/O error occurred

appendMessage

public void appendMessage(byte[] message,
                          int offset,
                          int length)
                   throws IOException
Description copied from interface: MessageStorage
Appends message to storage.

Specified by:
appendMessage in interface MessageStorage
Parameters:
message - the message
offset - the initial offset
length - the length
Throws:
IOException - - if error occurred.

appendMessage

public void appendMessage(byte[] message)
                   throws IOException
Description copied from interface: MessageStorage
Appends message to storage.

Specified by:
appendMessage in interface MessageStorage
Parameters:
message - the message
Throws:
IOException - - if error occurred.
See Also:
MessageStorage.appendMessage(byte[])

appendMessageInternal

@Deprecated
public long appendMessageInternal(Date date,
                                             byte[] message,
                                             int offset,
                                             int length)
                           throws IOException
Deprecated. 

Appends message to storage

Parameters:
date - the date parameter
message - the array of bytes
offset -
length - @throws IOException - if I/O error occurred
Throws:
IOException

appendMessageInternal

public abstract long appendMessageInternal(long timestamp,
                                           byte[] message,
                                           int offset,
                                           int length)
                                    throws IOException
Appends message to storage

Parameters:
timestamp - the timestamp parameter
message - the array of bytes
offset -
length - @throws IOException - if I/O error occurred
Throws:
IOException

backupStorage

public void backupStorage(SessionParameters sessionParameters)
                   throws IOException
Description copied from interface: MessageStorage
Backup the storage.

Specified by:
backupStorage in interface MessageStorage
Parameters:
sessionParameters - the session parameters
Throws:
IOException

backupStorageFile

protected void backupStorageFile(String fullPathToStorageFile,
                                 String fullPathToDestinationBackupFile)
                          throws IOException
Backups storage file.

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

backupFile

protected void backupFile(String fullPathToStorageFile,
                          String fullPathToDestinationBackupFile)
                   throws IOException
Throws:
IOException

deleteStorageFile

protected void deleteStorageFile(String fullPathToStorageFile)
Deletes storage file.

Parameters:
fullPathToStorageFile - the path to in/out file

deleteFile

protected void deleteFile(String fullPathToStorageFile)

close

public void close()
           throws IOException
Close the storage.

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

isClosed

protected boolean isClosed()
Returns true if storage is closed.



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