B2BITS FIX Antenna HFT  1.0.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
Engine::FileMsgStorageT< FileT > Class Template Reference

FileT message storage. More...

#include <FileMsgStorage.h>

+ Inheritance diagram for Engine::FileMsgStorageT< FileT >:
+ Collaboration diagram for Engine::FileMsgStorageT< FileT >:

Public Types

typedef std::map< typename
LogFileT< FileT >::MsgHandle,
typename IndexFileT< FileT >
::Data > 
RejectedMapT
 
typedef std::map< typename
LogFileT< FileT >::SeqNum,
typename LogFileT< FileT >
::MsgHandle > 
ToBeResentCollection
 
- Public Types inherited from Engine::MsgStorage
typedef std::vector
< StorableMsg * > 
FixMsgs
 
typedef std::deque< std::string > OutgoingMessages
 
enum  StorageType { PRIMARY_STORAGE = 0, BACKUP_STORAGE }
 Defines type of the storage. More...
 

Public Member Functions

 FileMsgStorageT (StorageType type, const std::string &baseName, FileT &outFile, FileT &outIndexFile, FileT &inFile, FileT &inIndexFile, Utils::FilePropertiesT< System::FileEx > *configInfo, bool flushStreams, StorageMgr::PersistentSessionInfo *info)
 Constructor. More...
 
virtual const std::string * getBaseFilePath () const
 Reimplemented from MsgStorage. More...
 
virtual bool getBoolConfigInfo (const std::string &aKey, bool *aValue) const
 Retrieves configuration information. More...
 
bool getConfigInfo (const std::string &aKey, std::string *val) const
 Reimplemented from MsgStorage. More...
 
int getInSeqNum ()
 
virtual bool getIntConfigInfo (const std::string &aKey, int *aValue) const
 Retrieves configuration information. More...
 
int getMaxSeqNum ()
 Reimplemented from MsgStorage. More...
 
int getMinSeqNum ()
 Reimplemented from MsgStorage. More...
 
virtual RejectMsgStoragegetRejectStorage ()
 Reimplemented from MsgStorage. More...
 
virtual System::u64 getSessionGlobalID () const
 
virtual System::u64 getSessionInternalState () const
 
int getStoredInSeqNum () const
 Returns current incoming seqNum from config. More...
 
int getStoredOutSeqNum () const
 Returns current outgoing seqNum from config. More...
 
virtual bool hasRejectedMessage ()
 Reimplemented from RejectMsgStorage. More...
 
virtual bool isPersistentStorage () const
 Reimplemented from MsgStorage. More...
 
virtual bool isStorageCorrupted () const
 Checks if the storage is corrupted. More...
 
int load (FIXVersion preferredVersion=NA)
 Reimplemented from MsgStorage. More...
 
void loadInMemoryCache (ToBeResentCollection &toBeResent, int beginSeqNum, int endSeqNum, int currentOutSeqNum)
 
virtual bool logLocal (StorableMsg const *pMsg, const RawMsg &aRawMsg)
 Reimplemented from MsgStorage. More...
 
virtual bool logLocal (StorableMsg const *pMsg, const char *pRawMsg, int size)
 Stores the given outgoing message and then destroys it. More...
 
virtual void logRemote (StorableMsg const *pMsg, const RawMsg &rawMsg)
 Reimplemented from MsgStorage. More...
 
virtual void logRemote (StorableMsg const *pMsg, const char *pRawMsg, int size)
 Logs the message from the remote FIX engine. More...
 
void markAsTerminated (bool correctlyTerminated)
 Reimplemented from MsgStorage. More...
 
virtual bool markRejected (const RawMsg &msg)
 Reimplemented from RejectMsgStorage. More...
 
CacheHolderBaseprepareLocalRetriving (int beginSeqNum, int endSeqNum, int currentOutSeqNum)
 Prepare for cache message walk process like a series of retrieveLocal() calls returns an object whose lifetime is bound to the whole series of retrieveLocal() calls when retrieveLocal() calls are complete, the object should be destroyed by the caller. More...
 
bool retrieveLocal (CacheHolderBase *cacheHolder, ProtocolID protocolID, MsgList *pMsgs, int aBeginSeqNum, int aEndSeqNum=0, FIXVersion preferredVersion=NA)
 Reimplemented from MsgStorage. More...
 
virtual bool retrieveLocal (int outSeqNum, std::string *msg, int currentOutSeqNum)
 Locates sent message (with seqNum=outSeqNum) and returns it into msg. More...
 
virtual void retrieveRejectedMessages (Utils::Strings *pMessages)
 Reimplemented from RejectMsgStorage. More...
 
void retrieveRemote (ProtocolID protocolID, MsgList *pMessages, const MsgTypes &msgTypes, const FixFieldsList &fieldFilter, int beginSeqNum, int endSeqNum=0, FIXVersion fixVersion=NA)
 Fills input list with messages that satisfy selection criteria. More...
 
virtual void setBoolConfigInfo (const std::string &aKey, bool aValue)
 Sets the configuration information. More...
 
void setConfigInfo (const std::string &aKey, const std::string &val)
 Reimplemented from MsgStorage. More...
 
virtual void setIntConfigInfo (const std::string &aKey, int aValue)
 Sets the configuration information. More...
 
virtual void setMaxRemoteSeqNum (int msgSeqNum)
 Reimplemented from MsgStorage. More...
 
virtual void setMinSeqNum (int msgSeqNum)
 Reimplemented from MsgStorage. More...
 
virtual void setRemoteSeqNum (int msgSeqNum)
 Reimplemented from MsgStorage. More...
 
virtual void setSessionGlobalID (const System::u64 globalID)
 
virtual void setSessionInternalState (const System::u64 internalState)
 
virtual void syncMessageStorage ()
 
bool tryMarkRejected (const RawMsg &msg, const ToBeResentCollection &toBeResent)
 
virtual bool unmarkRejected (const RawMsg &msg, const RawMsg &newMsg)
 Reimplemented from RejectMsgStorage. More...
 
virtual ~FileMsgStorageT ()
 
- Public Member Functions inherited from Engine::MsgStorage
virtual void clear ()
 Clears the storage. More...
 
StorageType currentConnectionType () const
 Returns type of the storage. More...
 
 MsgStorage (StorageType type)
 Constructor. More...
 
virtual bool retrieveLocal (CacheHolderBase *cacheHolder, ProtocolID protocolID, std::vector< FIXMessage * > *apMsgs, int aBeginSeqNum, int aEndSeqNum=0, FIXVersion preferredVersion=NA)=0
 Locates sent messages. More...
 
virtual void retrieveRemote (ProtocolID protocolID, std::vector< FIXMessage * > *pMessages, const MsgTypes &msgTypes, const std::vector< FixField > &fieldFilter, int beginSeqNum, int endSeqNum=0, FIXVersion fixVersion=NA)=0
 Fills input list with messages that satisfy selection criteria. More...
 
virtual void setLastSentSeqNum (int value)
 Updates MsgSeqNum of outgoing messages. More...
 
virtual ~MsgStorage ()
 Destructor. More...
 
- Public Member Functions inherited from Engine::RejectMsgStorage
virtual ~RejectMsgStorage ()
 

Static Public Member Functions

static bool rebuildIndexS (const std::string &logPath, const std::string &idxPath, const RestoreOptions &options)
 Store messages in range [aBeginSeqNum, aEndSeqNum] into the pMsgs container. More...
 

Protected Member Functions

virtual bool rebuildIndex (const std::string &logPath, const std::string &idxPath, const RestoreOptions &options)
 
- Protected Member Functions inherited from Engine::MsgStorage
void clearFixMsgs (FixMsgs &aMsgs)
 Clears collection (delete all its elements). More...
 

Friends

class ::TestApplication
 
class TestSeqNo
 

Additional Inherited Members

- Static Public Attributes inherited from Engine::MsgStorage
static const System::u64 SessionInternalStateNA = 0
 
- Protected Attributes inherited from Engine::MsgStorage
StorageType currentConnectionType_
 

Detailed Description

template<typename FileT>
class Engine::FileMsgStorageT< FileT >

FileT message storage.

Member Typedef Documentation

template<typename FileT >
typedef std::map<typename LogFileT<FileT>::MsgHandle, typename IndexFileT<FileT>::Data> Engine::FileMsgStorageT< FileT >::RejectedMapT
template<typename FileT >
typedef std::map<typename LogFileT<FileT>::SeqNum, typename LogFileT<FileT>::MsgHandle> Engine::FileMsgStorageT< FileT >::ToBeResentCollection

Constructor & Destructor Documentation

template<typename FileT >
Engine::FileMsgStorageT< FileT >::FileMsgStorageT ( StorageType  type,
const std::string &  baseName,
FileT &  outFile,
FileT &  outIndexFile,
FileT &  inFile,
FileT &  inIndexFile,
Utils::FilePropertiesT< System::FileEx > *  configInfo,
bool  flushStreams,
StorageMgr::PersistentSessionInfo info 
)

Constructor.

Parameters
baseNameBase file name.
outFile- file to store outgoing messages.
outIndexFile- index file.
inFile- file to store incoming messages.
inIndexFile- index file.
flushStreams- if true then all input/output will be flushed after each operation.
template<typename FileT >
virtual Engine::FileMsgStorageT< FileT >::~FileMsgStorageT ( )
virtual

Member Function Documentation

template<typename FileT >
virtual const std::string* Engine::FileMsgStorageT< FileT >::getBaseFilePath ( ) const
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::getBoolConfigInfo ( const std::string &  aKey,
bool *  aValue 
) const
virtual

Retrieves configuration information.

Parameters
aKey- parameter key
aValue- parameter result value
Returns
true if parameter is enabled

Implements Engine::MsgStorage.

template<typename FileT >
bool Engine::FileMsgStorageT< FileT >::getConfigInfo ( const std::string &  aKey,
std::string *  val 
) const
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
int Engine::FileMsgStorageT< FileT >::getInSeqNum ( )
virtual

Reimplemented from Engine::MsgStorage.

template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::getIntConfigInfo ( const std::string &  aKey,
int *  aValue 
) const
virtual

Retrieves configuration information.

Parameters
aKey- parameter key
aValue- parameter result value
Returns
true if parameter is enabled

Implements Engine::MsgStorage.

template<typename FileT >
int Engine::FileMsgStorageT< FileT >::getMaxSeqNum ( )
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
int Engine::FileMsgStorageT< FileT >::getMinSeqNum ( )
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual RejectMsgStorage* Engine::FileMsgStorageT< FileT >::getRejectStorage ( )
virtual

Reimplemented from MsgStorage.

Reimplemented from Engine::MsgStorage.

template<typename FileT >
virtual System::u64 Engine::FileMsgStorageT< FileT >::getSessionGlobalID ( ) const
virtual

Reimplemented from Engine::MsgStorage.

template<typename FileT >
virtual System::u64 Engine::FileMsgStorageT< FileT >::getSessionInternalState ( ) const
virtual

Reimplemented from Engine::MsgStorage.

template<typename FileT >
int Engine::FileMsgStorageT< FileT >::getStoredInSeqNum ( ) const

Returns current incoming seqNum from config.

template<typename FileT >
int Engine::FileMsgStorageT< FileT >::getStoredOutSeqNum ( ) const

Returns current outgoing seqNum from config.

template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::hasRejectedMessage ( )
virtual

Reimplemented from RejectMsgStorage.

Implements Engine::RejectMsgStorage.

template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::isPersistentStorage ( ) const
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::isStorageCorrupted ( ) const
virtual

Checks if the storage is corrupted.

Returns
true if the storage contains corrupted messages, false otherwise

Implements Engine::MsgStorage.

template<typename FileT >
int Engine::FileMsgStorageT< FileT >::load ( FIXVersion  preferredVersion = NA)

Reimplemented from MsgStorage.

Reimplemented from MsgStorage. Reads the messages from the message log.

Returns
the MsgSeq of the message that was read last; otherwise -1
template<typename FileT >
void Engine::FileMsgStorageT< FileT >::loadInMemoryCache ( ToBeResentCollection toBeResent,
int  beginSeqNum,
int  endSeqNum,
int  currentOutSeqNum 
)
template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::logLocal ( StorableMsg const *  pMsg,
const RawMsg aRawMsg 
)
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::logLocal ( StorableMsg const *  pMsg,
const char *  pRawMsg,
int  size 
)
virtual

Stores the given outgoing message and then destroys it.

Returns
false if the message with such sequence number already exists in the storage; otherwise true.
Parameters
apMsg- storage message
nSeqNum- message number
pRawMsg- message buffer pointer
size- message buffer size

Implements Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::logRemote ( StorableMsg const *  pMsg,
const RawMsg rawMsg 
)
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::logRemote ( StorableMsg const *  pMsg,
const char *  pRawMsg,
int  size 
)
virtual

Logs the message from the remote FIX engine.

Parameters
msgSeqNum- message number
pRawMsg- message buffer pointer
size- message buffer size

Implements Engine::MsgStorage.

template<typename FileT >
void Engine::FileMsgStorageT< FileT >::markAsTerminated ( bool  correctlyTerminated)
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::markRejected ( const RawMsg msg)
virtual

Reimplemented from RejectMsgStorage.

Implements Engine::RejectMsgStorage.

template<typename FileT >
CacheHolderBase* Engine::FileMsgStorageT< FileT >::prepareLocalRetriving ( int  beginSeqNum,
int  endSeqNum,
int  currentOutSeqNum 
)
virtual

Prepare for cache message walk process like a series of retrieveLocal() calls returns an object whose lifetime is bound to the whole series of retrieveLocal() calls when retrieveLocal() calls are complete, the object should be destroyed by the caller.

Returned pointer can have NULL value. To control the lifetime, should be used in conjunction with std::auto_ptr<> The implementaion would typically load the messages from an external storage to memory to prepare for a series of retrieveLocal() calls

Implements Engine::MsgStorage.

template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::rebuildIndex ( const std::string &  logPath,
const std::string &  idxPath,
const RestoreOptions options 
)
protectedvirtual

Implements Engine::MsgStorage.

template<typename FileT >
static bool Engine::FileMsgStorageT< FileT >::rebuildIndexS ( const std::string &  logPath,
const std::string &  idxPath,
const RestoreOptions options 
)
static

Store messages in range [aBeginSeqNum, aEndSeqNum] into the pMsgs container.

template<typename FileT >
bool Engine::FileMsgStorageT< FileT >::retrieveLocal ( CacheHolderBase cacheHolder,
ProtocolID  protocolID,
MsgList pMsgs,
int  aBeginSeqNum,
int  aEndSeqNum = 0,
FIXVersion  preferredVersion = NA 
)

Reimplemented from MsgStorage.

template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::retrieveLocal ( int  outSeqNum,
std::string *  msg,
int  currentOutSeqNum 
)
virtual

Locates sent message (with seqNum=outSeqNum) and returns it into msg.

Returns
true if message was found, false otherwize

Implements Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::retrieveRejectedMessages ( Utils::Strings pMessages)
virtual

Reimplemented from RejectMsgStorage.

Implements Engine::RejectMsgStorage.

template<typename FileT >
void Engine::FileMsgStorageT< FileT >::retrieveRemote ( ProtocolID  protocolID,
MsgList pMessages,
const MsgTypes msgTypes,
const FixFieldsList fieldFilter,
int  beginSeqNum,
int  endSeqNum = 0,
FIXVersion  fixVersion = NA 
)

Fills input list with messages that satisfy selection criteria.

Warning
It's caller's responsibility to release returned messages.
template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::setBoolConfigInfo ( const std::string &  aKey,
bool  aValue 
)
virtual

Sets the configuration information.

Parameters
aKey- parameter key
aValue- parameter value

Implements Engine::MsgStorage.

template<typename FileT >
void Engine::FileMsgStorageT< FileT >::setConfigInfo ( const std::string &  aKey,
const std::string &  val 
)
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::setIntConfigInfo ( const std::string &  aKey,
int  aValue 
)
virtual

Sets the configuration information.

Parameters
aKey- parameter key
aValue- parameter value

Implements Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::setMaxRemoteSeqNum ( int  msgSeqNum)
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::setMinSeqNum ( int  msgSeqNum)
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::setRemoteSeqNum ( int  msgSeqNum)
virtual

Reimplemented from MsgStorage.

Implements Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::setSessionGlobalID ( const System::u64  globalID)
virtual

Reimplemented from Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::setSessionInternalState ( const System::u64  internalState)
virtual

Reimplemented from Engine::MsgStorage.

template<typename FileT >
virtual void Engine::FileMsgStorageT< FileT >::syncMessageStorage ( )
virtual

Implements Engine::MsgStorage.

template<typename FileT >
bool Engine::FileMsgStorageT< FileT >::tryMarkRejected ( const RawMsg msg,
const ToBeResentCollection toBeResent 
)
template<typename FileT >
virtual bool Engine::FileMsgStorageT< FileT >::unmarkRejected ( const RawMsg msg,
const RawMsg newMsg 
)
virtual

Reimplemented from RejectMsgStorage.

Implements Engine::RejectMsgStorage.

Friends And Related Function Documentation

template<typename FileT >
friend class ::TestApplication
friend
template<typename FileT >
friend class TestSeqNo
friend