Files
2019-02-11 17:36:12 +00:00

301 lines
9.5 KiB
C++

/*
* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
*
* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
* and international copyright treaties.
*
* Access to and use of the software is governed by the terms of the applicable OnixS Software
* Services Agreement (the Agreement) and Customer end user license agreements granting
* a non-assignable, non-transferable and non-exclusive license to use the software
* for it's own data processing purposes under the terms defined in the Agreement.
*
* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
* of this source code or associated reference material to any other location for further reproduction
* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
*
* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
* the terms of the Agreement is a violation of copyright law.
*/
#pragma once
#include <iosfwd>
#include <set>
#include <string>
#include <vector>
#include <OnixS/ICE/iMpact/MarketData/ABI.h>
#include <OnixS/ICE/iMpact/MarketData/Enumerations.h>
#include <OnixS/ICE/iMpact/MarketData/LogSettings.h>
#include <OnixS/ICE/iMpact/MarketData/ThreadAffinity.h>
namespace OnixS { namespace ICE { namespace iMpact { namespace MarketData {
/// Defines snapshot recovery options.
struct ONIXS_ICE_IMPACT_MD_API SnapshotRecoveryOptions
{
/**
* Snapshot Recovery Timeout In Milliseconds
* \li -1 - to wait indefinitely for snapshots (default)
* \li 0 - not to use snapshots at all
* \li >0 - the number of milliseconds to wait
*/
int snapshotRecoveryTimeoutInMilliseconds;
/**
* Maximum Number Of Snaphot Recovery Attempts
* \li -1 - unlimited (default)
* \li 0 - not to use snapshots at all
* \li >0 - the number of attempts
*/
int maximumNumberOfSnaphotRecoveryAttempts;
/**
* Maximum size of the snapshot message queue
* \li -1 - unlimited (default)
* \li >=0 - the size of the queue
*/
int maximumSizeOfSnapshotMessageQueue;
/**
* Maximum size of the live message queue
* \li -1 - unlimited
* \li >=0 - the size of the queue
*
* \note Default value is 200000.
*/
int maximumSizeOfLiveMessageQueue;
/// Initializes instance with default values.
SnapshotRecoveryOptions();
/// Returns string representation.
std::string toString() const;
};
/// Standard output operator.
ONIXS_ICE_IMPACT_MD_API std::ostream& operator<<(std::ostream&, const SnapshotRecoveryOptions&);
/// Ordered list of logs to be replayed.
typedef std::vector<std::string> LogList;
/// Read-write iterator over ordered list of logs to be replayed.
typedef std::vector<std::string>::iterator LogListEntry;
/// Log replay input stream.
class LogReplayInputStream
{
public:
/**
* Called when log player wants to read data from stream.
*
* \param data buffer to read data into
* \param size max size to read
*
* \returns \c 0 in case of EOF, actually read bytes count otherwise
*
* \note Implementation is free to throw any exceptions.
* Player would react differently depending on exception type.
*
* Particularly:
* - \c std::ios_base::failure -- serious problem on getting data means
* do not try any further reading from stream and terminate playing;
*
* Absolutely all exceptions are reported via error handler.
* Description string will be available for children of \c std::exception.
*/
virtual size_t read(char* const data, size_t size) = 0;
protected:
/// Deletion is not supposed through interface of this class.
virtual ~LogReplayInputStream() {}
};
/// Defines set of settings which affect behavior of the Handler.
struct ONIXS_ICE_IMPACT_MD_API HandlerSettings
{
/**
* Path to the license directory.
*
* \note Default value is \e "./" (the current directory).
* \note A home directory also used to search a license.
*/
std::string licenseDirectory;
/**
* Log files are stored in this directory.
*
* \note Default value is \e "./" (the current directory).
*/
std::string logDirectory;
/**
* Template of log file name without extension.
*
* \note Default value is \e "IceImpactMulticastPriceFeedHandlerCpp".
*/
std::string logFileNamePrefix;
/**
* Log verbosity.
*
* \note Default value is LogLevels::Info.
*/
LogLevel logLevel;
/**
* Additional options to control which data is to be logged.
* Ignored if logging is disabled.
*
* \note The default value is \c AdvancedLogOptions::Default.
*/
AdvancedLogOptionSet advancedLogOptions;
/**
* Defines path to connectivity configuration which defines multicast
* groups, types of markets which belong to the groups and
* connection info for multicast feeds for the groups.
*/
std::string connectivityConfiguration;
/**
* Specifies one or more network interfaces to use while
* joining the multicast group; use semi-colon delimited
* list if more than one.
*
* \note On Linux the network interface is specifed
* by its name, on Windows - by IP address.
*
* \note If the value is empty or absent then the
* default networking interface is used.
*/
std::string networkInterface;
/**
* This option determines the size in bytes of a buffer that is used by multicast transport.
* By default, buffer size is 4MiB (4194304 bytes).
*
* \attention On Linux, the kernel doubles this value (to allow space for bookkeeping overhead)
* when it is set using setsockopt, and this doubled value is returned by getsockopt.
* For more details please see [`man 6 socket`](http://linux.die.net/man/7/socket).
*/
size_t udpBufferSize;
/**
* Specifies maximal time interval in seconds between two
* network packets. If no data is received during specified
* time frame, warning is reported.
*
* \note The default value is \c 36000.
*/
time_t heartbeatInterval;
/**
* Specifies maximal sequence gap margin between first
* and last received network packets in internal queue.
*
* \note Default value is \c 10000.
*/
size_t sequenceGapMargin;
/**
* Specifies maximal time interval in milliseconds to
* wait network packet with next expected sequence number.
*
* \note Default value is \c 10000.
*/
size_t gapTimeoutInMilliseconds;
/// Specifies snapshot recovery options.
SnapshotRecoveryOptions snapshotRecoveryOptions;
/**
* Defines set of CPUs by their indices (starting from zero)
* allowed for thread used by the Handler while
* processing market data to be executed on.
*
* \note By default set is empty thus allowing threads
* to be executed on any CPU available in the system.
*/
ThreadAffinity processingThreadAffinity;
/**
* List of logs to be replated.
*
* \attention Must be stored in 'oldest to recent' order.
*/
LogList logs;
/// User defined input stream for log replay logs will be ignored
LogReplayInputStream* inputStream;
/**
* Log player speed multiplier.
*
* This is an \f$ m \f$ in the formula \f$ mT+k \f$ to calculate delays between packets,
* where \f$ T \f$ is original delay. Values less than \c 1 means reduced speed, greather
* than \c 1 means increased speed. Default value is \c 1.0 which means a normal speed.
*/
float logPlayerSpeedMultiplier;
/**
* Log player speed auxilary delay.
*
* This is an \f$ k \f$ in the formula \f$ mT+k \f$ to calculate delays between packets,
* where \f$ T \f$ is original delay. Default value is \c 0.
*/
unsigned logPlayerSpeedAuxDelay;
/**
* Track top of the book only.
*
* This flag should be set to true when only top of the book updates are needed.
*
* Default value is \c false.
*/
bool trackTopOfTheBookOnly;
/**
* Receive product definitions only.
*
* This flag should be set to true when only product definitions are needed.
*
* Default value is \c false.
*/
bool receiveProductDefinitionsOnly;
/**
* Max multicast message block size.
*
* This option determines the size in bytes of a buffer that is used
* as a storage for the incoming mulsticast message block.
*
* By default, the size set at 1400 bytes.
*/
size_t maxMulticastMessageBlockSize;
/**
* Path to the product definition cache directory.
*
* If a value is set and it is a valid path to a directory,
* the product definition cache will be created and used on the
* daily basis. If the value is not set, the cache will not be
* created an product definitions will be downloaded by establishing
* a TCP connection to ICE server.
*
* \note Default value is empty string (cache is disabled).
*/
std::string productDefinitionCacheDirectory;
/// Initializes instance with default values for control parameters.
HandlerSettings();
/// Returns string representation.
std::string toString() const;
};
/// Make it printable to formatted C++ I/O streams.
ONIXS_ICE_IMPACT_MD_API std::ostream& operator<<(std::ostream&, const HandlerSettings&);
}}}} // namespace MarketData, iMpact, ICE, OnixS