com.teraspaces.qwfix
Class FIXSessionPersistence

java.lang.Object
  extended by com.teraspaces.qwfix.FIXSessionPersistence

public final class FIXSessionPersistence
extends Object

Represents a persistent storage of the FIX message log of a FIXSession. This class cannot be inherited.


Method Summary
static boolean exists(String logPath, String persistenceName)
          Determines whether the specified FIXSessionPersistence exists.
static boolean existsPartially(String logPath, String persistenceName)
          Determines whether any file name that represent the specified FIXSessionPersistence exists.
 int getEnginePersistenceID()
          Gets the zero based index of the current persistence in FIXEngine.getSessionPersistences().
 int getExpectedIncomingSeq()
          Gets the expected message sequence number to be received from the recipient.
 int getGlobalPersistenceID()
          Gets the zero based global index of this persistence in FIXEngine.getGlobalSessionPersistences().
 int getMaximumIncomingSeq()
          Gets the maximum sequence number received from the recipient.
 int getNextOutgoingAdminQueueSeq()
          Gets the next sequence number of the outgoing administrative message queue.
 int getNextOutgoingAppQueueSeq()
          Gets the next sequence number of the outgoing application message queue.
 int getNextSendingSeq()
          Gets the "real" message sequence number that can be assigned to the next FIXMessage to the recipient over the wire.
 FIXMessage getOutgoingAdminMessage(int internalSeq)
          Gets the sent administrative message by specified internal sequence number.
 FIXMessage getOutgoingAppMessage(int internalSeq)
          Gets the sent application message.
 String getPersistenceName()
          Gets the name of the persistence.
 FIXMessage getReceivedMessage(int msgSeqNum)
          Gets the received message by specified MsgSeqNum.
 FIXMessage getSentMessage(int msgSeqNum)
          Gets the outgoing message by specified actual MsgSeqNum.
 FIXSession getSession()
          Gets the session.
 int getSessionPersistenceID()
          Gets the zero based index of the current persistence in FIXSession.getPersistences().
 DateTime getStartTimeUtc()
          Gets the start time in UTC format.
 boolean isActive()
          Gets a value indicating whether this instance is active.
 boolean isCurrentActive()
          Gets a value indicating whether this instance is currently active.
static void move(String logPath, String sourcePersistenceName, String destPersistenceName)
          Renames the specified persistence.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

exists

public static boolean exists(String logPath,
                             String persistenceName)
Determines whether the specified FIXSessionPersistence exists.

Parameters:
logPath - the log path
persistenceName - the persistence name
Returns:
true, if persistence exists

existsPartially

public static boolean existsPartially(String logPath,
                                      String persistenceName)
Determines whether any file name that represent the specified FIXSessionPersistence exists. Note: if this method returns true it usually indicates an error.

Parameters:
logPath - the log path
persistenceName - the persistence name
Returns:
true if the any file that represents a FIXSessionPersistence exist; otherwise, false

move

public static void move(String logPath,
                        String sourcePersistenceName,
                        String destPersistenceName)
Renames the specified persistence.

Parameters:
logPath - the log path
sourcePersistenceName - the source persistence name
destPersistenceName - the destination persistence name

getSession

public FIXSession getSession()
Gets the session.

Returns:
the session

getPersistenceName

public String getPersistenceName()
Gets the name of the persistence.

Returns:
the persistence name

isCurrentActive

public boolean isCurrentActive()
Gets a value indicating whether this instance is currently active.

A FIXSession may have at most one currently active FIXSessionPersistence (see IsCurrentActive), while a FIXSession may have more than one Active FIXSessionPersistences (only in case that the session is a 24 hour session; a new active persistence may be created every day).

Returns:
true if this instance is currently active; otherwise, false
See Also:
isActive()

isActive

public boolean isActive()
Gets a value indicating whether this instance is active.

A FIXSession may have at most one currently active FIXSessionPersistence (see isCurrentActive()), while a FIXSession may have more than one Active FIXSessionPersistences (only in case that the session is a 24 hour session; a new active persistence may be created every day).

Returns:
true if this instance is active; otherwise, false
See Also:
isCurrentActive()

getStartTimeUtc

public DateTime getStartTimeUtc()
Gets the start time in UTC format.

Returns:
the start time in UTC format

getGlobalPersistenceID

public int getGlobalPersistenceID()
Gets the zero based global index of this persistence in FIXEngine.getGlobalSessionPersistences().

The GlobalPersistenceID is an ID assigned internally by the system. The runtime maintains a list of all FIXSessionPersistence in the system. The GlobalPersistenceID is a 0 based index of the current FIXSessionPersistence in the list.

Normally this value should be the same as getEnginePersistenceID(), unless there are more than 1 FIXEngine in the process.

Returns:
the global persistence id
See Also:
getEnginePersistenceID()

getEnginePersistenceID

public int getEnginePersistenceID()
Gets the zero based index of the current persistence in FIXEngine.getSessionPersistences().

Returns:
the engine persistence ID
See Also:
getGlobalPersistenceID()

getSessionPersistenceID

public int getSessionPersistenceID()
Gets the zero based index of the current persistence in FIXSession.getPersistences().

Returns:
the session persistence ID

getNextOutgoingAppQueueSeq

public int getNextOutgoingAppQueueSeq()
Gets the next sequence number of the outgoing application message queue. The value is "1" based instead of 0 based.

The sequence number is the internal sequence number used to identify the application messages sent by calling sendMessage().

The internal sequence of an outgoing message may be different than the "real" MsgSeqNum in the FIX message received by the receipient.

Returns:
the sequence number

getNextOutgoingAdminQueueSeq

public int getNextOutgoingAdminQueueSeq()
Gets the next sequence number of the outgoing administrative message queue.

The sequence number is the internal sequence number used to identify the administrative messages sent to the recipient.

The internal sequence of an outgoing message may be different than the "real" MsgSeqNum in the FIX message received by the recipient.

Returns:
the sequence number

getNextSendingSeq

public int getNextSendingSeq()
Gets the "real" message sequence number that can be assigned to the next FIXMessage to the recipient over the wire.

Returns:
the next message sequence number

getExpectedIncomingSeq

public int getExpectedIncomingSeq()
                           throws IOException
Gets the expected message sequence number to be received from the recipient.

Returns:
expected message sequence number
Throws:
IOException - Signals that an I/O exception has occurred.

getMaximumIncomingSeq

public int getMaximumIncomingSeq()
Gets the maximum sequence number received from the recipient.

This number may be different than getExpectedIncomingSeq() because the session may be in resend process due to early unexpected network outrage.

Returns:
the maximum incoming seq

getReceivedMessage

public FIXMessage getReceivedMessage(int msgSeqNum)
Gets the received message by specified MsgSeqNum.

The method may return null if the message received did not pass validation (in that case the message can not be properly constructed) or the message is a lost administrative message and was "gap filled" during reconnection recovery process.

This method will automatically put the message to the top if the internal LRU message cache.

Parameters:
msgSeqNum - MsgSeqNum of the incoming message
Returns:
the FIXMessage, or null if the message is invalid or lost.

getOutgoingAppMessage

public FIXMessage getOutgoingAppMessage(int internalSeq)
Gets the sent application message.

This method gets the application message in the outgoing queue. Note the message is enqueued during call to SendMessage()()(). Depends on the system load and network conditions, the message may have not yet been "actually" sent over the wire. So the message may noy have a "real" MsgSeqNum yet. That's why we use a "internal sequence number" as parameter.

The internalSeq should have a value between 1 and getNextOutgoingAppQueueSeq().

The value of MsgSeqNum field in the FIXMessage instance is the internal sequence number, not the same sequence the receipient seen in the message received. In order to get the real MsgSeqNum, call getSentMessage(int) method.

This method will automatically put the message to the top if the internal LRU message cache.

Parameters:
internalSeq - the internal sequence number
Returns:
the FIX message

getOutgoingAdminMessage

public FIXMessage getOutgoingAdminMessage(int internalSeq)
Gets the sent administrative message by specified internal sequence number.

The internalSeq is used to internally identify the administrative messages sent to the recipient, which may be different than the "real" MsgSeqNum in the FIX message received by the recipient.

The internalSeq should have a value between 1 and getNextOutgoingAdminQueueSeq().

The value of MsgSeqNum field in the FIXMessage instance is the internal sequence number, not the same sequence the recipient seen in the message received. In order to get the real MsgSeqNum, call getSentMessage(int) method.

This method will automatically put the message to the top if the internal LRU message cache.

Parameters:
internalSeq - internal sequence number
Returns:
the message

getSentMessage

public FIXMessage getSentMessage(int msgSeqNum)
Gets the outgoing message by specified actual MsgSeqNum.

Parameters:
msgSeqNum - actual MsgSeqNum
Returns:
the instance of outgoing FIXMessage specified by actual MsgSeqNum