quickfix_ruby_ud 2.0.7-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +257 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +137 -0
- data/ext/quickfix/DOMDocument.h +70 -0
- data/ext/quickfix/DataDictionary.cpp +679 -0
- data/ext/quickfix/DataDictionary.h +607 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
- data/ext/quickfix/DataDictionaryProvider.h +67 -0
- data/ext/quickfix/DatabaseConnectionID.h +98 -0
- data/ext/quickfix/DatabaseConnectionPool.h +84 -0
- data/ext/quickfix/Dictionary.cpp +157 -0
- data/ext/quickfix/Dictionary.h +89 -0
- data/ext/quickfix/Event.h +89 -0
- data/ext/quickfix/Except.h +39 -0
- data/ext/quickfix/Exceptions.h +257 -0
- data/ext/quickfix/Field.h +654 -0
- data/ext/quickfix/FieldConvertors.cpp +86 -0
- data/ext/quickfix/FieldConvertors.h +800 -0
- data/ext/quickfix/FieldMap.cpp +254 -0
- data/ext/quickfix/FieldMap.h +327 -0
- data/ext/quickfix/FieldNumbers.h +44 -0
- data/ext/quickfix/FieldTypes.cpp +62 -0
- data/ext/quickfix/FieldTypes.h +817 -0
- data/ext/quickfix/Fields.h +30 -0
- data/ext/quickfix/FileLog.cpp +176 -0
- data/ext/quickfix/FileLog.h +110 -0
- data/ext/quickfix/FileStore.cpp +369 -0
- data/ext/quickfix/FileStore.h +131 -0
- data/ext/quickfix/FixCommonFields.h +13 -0
- data/ext/quickfix/FixFieldNumbers.h +6132 -0
- data/ext/quickfix/FixFields.h +6133 -0
- data/ext/quickfix/FixValues.h +5790 -0
- data/ext/quickfix/Group.cpp +44 -0
- data/ext/quickfix/Group.h +78 -0
- data/ext/quickfix/HostDetailsProvider.cpp +79 -0
- data/ext/quickfix/HostDetailsProvider.h +44 -0
- data/ext/quickfix/HtmlBuilder.h +178 -0
- data/ext/quickfix/HttpConnection.cpp +914 -0
- data/ext/quickfix/HttpConnection.h +74 -0
- data/ext/quickfix/HttpMessage.cpp +229 -0
- data/ext/quickfix/HttpMessage.h +112 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +49 -0
- data/ext/quickfix/HttpServer.cpp +152 -0
- data/ext/quickfix/HttpServer.h +76 -0
- data/ext/quickfix/Initiator.cpp +310 -0
- data/ext/quickfix/Initiator.h +151 -0
- data/ext/quickfix/Log.cpp +71 -0
- data/ext/quickfix/Log.h +254 -0
- data/ext/quickfix/Message.cpp +617 -0
- data/ext/quickfix/Message.h +419 -0
- data/ext/quickfix/MessageCracker.h +171 -0
- data/ext/quickfix/MessageSorters.cpp +101 -0
- data/ext/quickfix/MessageSorters.h +185 -0
- data/ext/quickfix/MessageStore.cpp +182 -0
- data/ext/quickfix/MessageStore.h +164 -0
- data/ext/quickfix/Mutex.h +120 -0
- data/ext/quickfix/MySQLConnection.h +187 -0
- data/ext/quickfix/MySQLLog.cpp +262 -0
- data/ext/quickfix/MySQLLog.h +158 -0
- data/ext/quickfix/MySQLStore.cpp +323 -0
- data/ext/quickfix/MySQLStore.h +161 -0
- data/ext/quickfix/MySQLStubs.h +203 -0
- data/ext/quickfix/NullStore.cpp +40 -0
- data/ext/quickfix/NullStore.h +89 -0
- data/ext/quickfix/OdbcConnection.h +241 -0
- data/ext/quickfix/OdbcLog.cpp +230 -0
- data/ext/quickfix/OdbcLog.h +109 -0
- data/ext/quickfix/OdbcStore.cpp +313 -0
- data/ext/quickfix/OdbcStore.h +124 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +111 -0
- data/ext/quickfix/Parser.h +50 -0
- data/ext/quickfix/PostgreSQLConnection.h +163 -0
- data/ext/quickfix/PostgreSQLLog.cpp +263 -0
- data/ext/quickfix/PostgreSQLLog.h +157 -0
- data/ext/quickfix/PostgreSQLStore.cpp +327 -0
- data/ext/quickfix/PostgreSQLStore.h +160 -0
- data/ext/quickfix/PostgreSQLStubs.h +203 -0
- data/ext/quickfix/Queue.h +66 -0
- data/ext/quickfix/QuickfixRuby.cpp +131900 -0
- data/ext/quickfix/QuickfixRuby.h +56 -0
- data/ext/quickfix/Responder.h +41 -0
- data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
- data/ext/quickfix/SSLSocketAcceptor.h +186 -0
- data/ext/quickfix/SSLSocketConnection.cpp +434 -0
- data/ext/quickfix/SSLSocketConnection.h +221 -0
- data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
- data/ext/quickfix/SSLSocketInitiator.h +203 -0
- data/ext/quickfix/SSLStubs.h +129 -0
- data/ext/quickfix/Session.cpp +1437 -0
- data/ext/quickfix/Session.h +343 -0
- data/ext/quickfix/SessionFactory.cpp +314 -0
- data/ext/quickfix/SessionFactory.h +84 -0
- data/ext/quickfix/SessionID.h +136 -0
- data/ext/quickfix/SessionSettings.cpp +165 -0
- data/ext/quickfix/SessionSettings.h +283 -0
- data/ext/quickfix/SessionState.h +260 -0
- data/ext/quickfix/Settings.cpp +160 -0
- data/ext/quickfix/Settings.h +56 -0
- data/ext/quickfix/SharedArray.h +274 -0
- data/ext/quickfix/SocketAcceptor.cpp +216 -0
- data/ext/quickfix/SocketAcceptor.h +77 -0
- data/ext/quickfix/SocketConnection.cpp +256 -0
- data/ext/quickfix/SocketConnection.h +102 -0
- data/ext/quickfix/SocketConnector.cpp +112 -0
- data/ext/quickfix/SocketConnector.h +76 -0
- data/ext/quickfix/SocketInitiator.cpp +241 -0
- data/ext/quickfix/SocketInitiator.h +76 -0
- data/ext/quickfix/SocketMonitor.h +26 -0
- data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
- data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
- data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
- data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
- data/ext/quickfix/SocketServer.cpp +163 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
- data/ext/quickfix/ThreadedSocketConnection.h +89 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
- data/ext/quickfix/TimeRange.cpp +227 -0
- data/ext/quickfix/TimeRange.h +215 -0
- data/ext/quickfix/Utility.cpp +639 -0
- data/ext/quickfix/Utility.h +255 -0
- data/ext/quickfix/UtilitySSL.cpp +1612 -0
- data/ext/quickfix/UtilitySSL.h +274 -0
- data/ext/quickfix/Values.h +63 -0
- data/ext/quickfix/config-all.h +10 -0
- data/ext/quickfix/config.h +10 -0
- data/ext/quickfix/config_unix.h +178 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/dirent_windows.h +838 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
- data/ext/quickfix/double-conversion/bignum.cc +766 -0
- data/ext/quickfix/double-conversion/bignum.h +144 -0
- data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
- data/ext/quickfix/double-conversion/cached-powers.h +64 -0
- data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
- data/ext/quickfix/double-conversion/diy-fp.h +118 -0
- data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
- data/ext/quickfix/double-conversion/double-conversion.h +543 -0
- data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
- data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
- data/ext/quickfix/double-conversion/ieee.h +402 -0
- data/ext/quickfix/double-conversion/strtod.cc +557 -0
- data/ext/quickfix/double-conversion/strtod.h +45 -0
- data/ext/quickfix/double-conversion/utils.h +374 -0
- data/ext/quickfix/extconf.rb +76 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +77 -0
- data/ext/quickfix/pugixml.cpp +13237 -0
- data/ext/quickfix/pugixml.hpp +1516 -0
- data/ext/quickfix/scope_guard.hpp +215 -0
- data/ext/quickfix/stdint_msvc.h +254 -0
- data/ext/quickfix/strptime.h +7 -0
- data/lib/2.4/quickfix.so +0 -0
- data/lib/2.5/quickfix.so +0 -0
- data/lib/2.6/quickfix.so +0 -0
- data/lib/2.7/quickfix.so +0 -0
- data/lib/3.0/quickfix.so +0 -0
- data/lib/3.1/quickfix.so +0 -0
- data/lib/3.2/quickfix.so +0 -0
- data/lib/3.3/quickfix.so +0 -0
- data/lib/3.4/quickfix.so +0 -0
- data/lib/quickfix40.rb +274 -0
- data/lib/quickfix41.rb +351 -0
- data/lib/quickfix42.rb +1184 -0
- data/lib/quickfix43.rb +3504 -0
- data/lib/quickfix44.rb +14040 -0
- data/lib/quickfix50.rb +20051 -0
- data/lib/quickfix50sp1.rb +23596 -0
- data/lib/quickfix50sp2.rb +412444 -0
- data/lib/quickfix_fields.rb +79393 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +65 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1282 -0
- data/spec/FIX42.xml +2743 -0
- data/spec/FIX43.xml +4230 -0
- data/spec/FIX44.xml +6600 -0
- data/spec/FIX50.xml +8142 -0
- data/spec/FIX50SP1.xml +9506 -0
- data/spec/FIX50SP2.xml +26069 -0
- data/spec/FIXT11.xml +252 -0
- data/test/DataDictionaryTestCase.rb +268 -0
- data/test/DictionaryTestCase.rb +112 -0
- data/test/FieldBaseTestCase.rb +24 -0
- data/test/MessageStoreTestCase.rb +19 -0
- data/test/MessageTestCase.rb +368 -0
- data/test/SessionSettingsTestCase.rb +41 -0
- metadata +247 -0
@@ -0,0 +1,187 @@
|
|
1
|
+
/* -*- C++ -*- */
|
2
|
+
|
3
|
+
/****************************************************************************
|
4
|
+
** Copyright (c) 2001-2014
|
5
|
+
**
|
6
|
+
** This file is part of the QuickFIX FIX Engine
|
7
|
+
**
|
8
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
9
|
+
** license as defined by quickfixengine.org and appearing in the file
|
10
|
+
** LICENSE included in the packaging of this file.
|
11
|
+
**
|
12
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
13
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
14
|
+
**
|
15
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
16
|
+
**
|
17
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
18
|
+
** not clear to you.
|
19
|
+
**
|
20
|
+
****************************************************************************/
|
21
|
+
|
22
|
+
#ifndef FIX_MYSQLCONNECTION_H
|
23
|
+
#define FIX_MYSQLCONNECTION_H
|
24
|
+
|
25
|
+
#ifndef HAVE_MYSQL
|
26
|
+
#error MySQLConnection.h included, but HAVE_MYSQL not defined
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#ifdef HAVE_MYSQL
|
30
|
+
|
31
|
+
#ifdef _MSC_VER
|
32
|
+
#pragma warning(disable : 4503 4355 4786 4290)
|
33
|
+
#pragma comment(lib, "libMySQL")
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#include "DatabaseConnectionID.h"
|
37
|
+
#include "DatabaseConnectionPool.h"
|
38
|
+
#include "Mutex.h"
|
39
|
+
#include <errmsg.h>
|
40
|
+
#include <mysql.h>
|
41
|
+
|
42
|
+
#undef MYSQL_PORT
|
43
|
+
|
44
|
+
namespace FIX {
|
45
|
+
class MySQLQuery {
|
46
|
+
public:
|
47
|
+
MySQLQuery(const std::string &query)
|
48
|
+
: m_result(0),
|
49
|
+
m_query(query) {}
|
50
|
+
|
51
|
+
~MySQLQuery() {
|
52
|
+
if (m_result) {
|
53
|
+
mysql_free_result(m_result);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
bool execute(MYSQL *pConnection) {
|
58
|
+
int retry = 0;
|
59
|
+
|
60
|
+
do {
|
61
|
+
if (m_result) {
|
62
|
+
mysql_free_result(m_result);
|
63
|
+
}
|
64
|
+
int errcode = mysql_query(pConnection, m_query.c_str());
|
65
|
+
m_result = mysql_store_result(pConnection);
|
66
|
+
if (errcode == 0) {
|
67
|
+
return true;
|
68
|
+
}
|
69
|
+
m_status = mysql_errno(pConnection);
|
70
|
+
m_reason = mysql_error(pConnection);
|
71
|
+
mysql_ping(pConnection);
|
72
|
+
retry++;
|
73
|
+
} while (retry <= 1);
|
74
|
+
return success();
|
75
|
+
}
|
76
|
+
|
77
|
+
bool success() { return m_status == 0; }
|
78
|
+
|
79
|
+
int rows() { return (int)mysql_num_rows(m_result); }
|
80
|
+
|
81
|
+
const std::string &reason() { return m_reason; }
|
82
|
+
|
83
|
+
char *getValue(int row, int column) {
|
84
|
+
if (m_rows.empty()) {
|
85
|
+
MYSQL_ROW row = 0;
|
86
|
+
while ((row = mysql_fetch_row(m_result))) {
|
87
|
+
m_rows.push_back(row);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
return m_rows[row][column];
|
91
|
+
}
|
92
|
+
|
93
|
+
void throwException() EXCEPT(IOException) {
|
94
|
+
if (!success()) {
|
95
|
+
throw IOException("Query failed [" + m_query + "] " + reason());
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
private:
|
100
|
+
MYSQL_RES *m_result;
|
101
|
+
int m_status;
|
102
|
+
std::string m_query;
|
103
|
+
std::string m_reason;
|
104
|
+
std::vector<MYSQL_ROW> m_rows;
|
105
|
+
};
|
106
|
+
|
107
|
+
class MySQLConnection {
|
108
|
+
public:
|
109
|
+
MySQLConnection(const DatabaseConnectionID &id)
|
110
|
+
: m_connectionID(id) {
|
111
|
+
connect();
|
112
|
+
}
|
113
|
+
|
114
|
+
MySQLConnection(
|
115
|
+
const std::string &database,
|
116
|
+
const std::string &user,
|
117
|
+
const std::string &password,
|
118
|
+
const std::string &host,
|
119
|
+
short port)
|
120
|
+
: m_connectionID(database, user, password, host, port) {
|
121
|
+
connect();
|
122
|
+
}
|
123
|
+
|
124
|
+
~MySQLConnection() {
|
125
|
+
if (m_pConnection) {
|
126
|
+
mysql_close(m_pConnection);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
const DatabaseConnectionID &connectionID() { return m_connectionID; }
|
131
|
+
|
132
|
+
bool connected() {
|
133
|
+
Locker locker(m_mutex);
|
134
|
+
return mysql_ping(m_pConnection) == 0;
|
135
|
+
}
|
136
|
+
|
137
|
+
bool reconnect() {
|
138
|
+
Locker locker(m_mutex);
|
139
|
+
return mysql_ping(m_pConnection) == 0;
|
140
|
+
}
|
141
|
+
|
142
|
+
bool execute(MySQLQuery &pQuery) {
|
143
|
+
Locker locker(m_mutex);
|
144
|
+
return pQuery.execute(m_pConnection);
|
145
|
+
}
|
146
|
+
|
147
|
+
private:
|
148
|
+
void connect() {
|
149
|
+
short port = m_connectionID.getPort();
|
150
|
+
m_pConnection = mysql_init(NULL);
|
151
|
+
if (!mysql_real_connect(
|
152
|
+
m_pConnection,
|
153
|
+
m_connectionID.getHost().c_str(),
|
154
|
+
m_connectionID.getUser().c_str(),
|
155
|
+
m_connectionID.getPassword().c_str(),
|
156
|
+
m_connectionID.getDatabase().c_str(),
|
157
|
+
port,
|
158
|
+
0,
|
159
|
+
0)) {
|
160
|
+
if (!connected()) {
|
161
|
+
throw ConfigError(
|
162
|
+
std::string("Unable to connect to mysql database: ") + "'" + m_connectionID.getDatabase()
|
163
|
+
+ "': " + m_connectionID.getUser() + '@' + m_connectionID.getHost() + ":" + std::to_string(port) + " ["
|
164
|
+
+ mysql_error(m_pConnection) + "]");
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
#if (MYSQL_VERSION_ID > 80000)
|
169
|
+
bool reconnect = true;
|
170
|
+
mysql_options(m_pConnection, MYSQL_OPT_RECONNECT, &reconnect);
|
171
|
+
#else
|
172
|
+
my_bool reconnect = 1;
|
173
|
+
mysql_options(m_pConnection, MYSQL_OPT_RECONNECT, static_cast<char *>(&reconnect));
|
174
|
+
#endif
|
175
|
+
}
|
176
|
+
|
177
|
+
MYSQL *m_pConnection;
|
178
|
+
DatabaseConnectionID m_connectionID;
|
179
|
+
Mutex m_mutex;
|
180
|
+
};
|
181
|
+
|
182
|
+
typedef DatabaseConnectionPool<MySQLConnection> MySQLConnectionPool;
|
183
|
+
typedef std::unique_ptr<MySQLConnectionPool> MySQLConnectionPoolPtr;
|
184
|
+
} // namespace FIX
|
185
|
+
|
186
|
+
#endif // FIX_MYSQLCONNECTION_H
|
187
|
+
#endif // HAVE_MYSQL
|
@@ -0,0 +1,262 @@
|
|
1
|
+
/****************************************************************************
|
2
|
+
** Copyright (c) 2001-2014
|
3
|
+
**
|
4
|
+
** This file is part of the QuickFIX FIX Engine
|
5
|
+
**
|
6
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
7
|
+
** license as defined by quickfixengine.org and appearing in the file
|
8
|
+
** LICENSE included in the packaging of this file.
|
9
|
+
**
|
10
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
11
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
12
|
+
**
|
13
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
14
|
+
**
|
15
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
16
|
+
** not clear to you.
|
17
|
+
**
|
18
|
+
****************************************************************************/
|
19
|
+
|
20
|
+
#ifdef _MSC_VER
|
21
|
+
#include "stdafx.h"
|
22
|
+
#else
|
23
|
+
#include "config.h"
|
24
|
+
#endif
|
25
|
+
|
26
|
+
#ifdef HAVE_MYSQL
|
27
|
+
|
28
|
+
#include "MySQLLog.h"
|
29
|
+
#include "SessionID.h"
|
30
|
+
#include "SessionSettings.h"
|
31
|
+
#include "Utility.h"
|
32
|
+
#include "strptime.h"
|
33
|
+
#include <fstream>
|
34
|
+
|
35
|
+
namespace FIX {
|
36
|
+
|
37
|
+
const std::string MySQLLogFactory::DEFAULT_DATABASE = "quickfix";
|
38
|
+
const std::string MySQLLogFactory::DEFAULT_USER = "root";
|
39
|
+
const std::string MySQLLogFactory::DEFAULT_PASSWORD = "";
|
40
|
+
const std::string MySQLLogFactory::DEFAULT_HOST = "localhost";
|
41
|
+
const short MySQLLogFactory::DEFAULT_PORT = 0;
|
42
|
+
|
43
|
+
MySQLLog::MySQLLog(const SessionID &sessionID, const DatabaseConnectionID &connectionID, MySQLConnectionPool *pool)
|
44
|
+
: m_pConnectionPool(pool) {
|
45
|
+
init();
|
46
|
+
m_pSessionID = new SessionID(sessionID);
|
47
|
+
m_pConnection = m_pConnectionPool->create(connectionID);
|
48
|
+
}
|
49
|
+
|
50
|
+
MySQLLog::MySQLLog(const DatabaseConnectionID &connectionID, MySQLConnectionPool *pool)
|
51
|
+
: m_pConnectionPool(pool),
|
52
|
+
m_pSessionID(0) {
|
53
|
+
init();
|
54
|
+
m_pConnection = m_pConnectionPool->create(connectionID);
|
55
|
+
}
|
56
|
+
|
57
|
+
MySQLLog::MySQLLog(
|
58
|
+
const SessionID &sessionID,
|
59
|
+
const std::string &database,
|
60
|
+
const std::string &user,
|
61
|
+
const std::string &password,
|
62
|
+
const std::string &host,
|
63
|
+
short port)
|
64
|
+
: m_pConnectionPool(0) {
|
65
|
+
init();
|
66
|
+
m_pSessionID = new SessionID(sessionID);
|
67
|
+
m_pConnection = new MySQLConnection(database, user, password, host, port);
|
68
|
+
}
|
69
|
+
|
70
|
+
MySQLLog::MySQLLog(
|
71
|
+
const std::string &database,
|
72
|
+
const std::string &user,
|
73
|
+
const std::string &password,
|
74
|
+
const std::string &host,
|
75
|
+
short port)
|
76
|
+
: m_pConnectionPool(0),
|
77
|
+
m_pSessionID(0) {
|
78
|
+
m_pConnection = new MySQLConnection(database, user, password, host, port);
|
79
|
+
}
|
80
|
+
|
81
|
+
void MySQLLog::init() {
|
82
|
+
setIncomingTable("messages_log");
|
83
|
+
setOutgoingTable("messages_log");
|
84
|
+
setEventTable("event_log");
|
85
|
+
}
|
86
|
+
|
87
|
+
MySQLLog::~MySQLLog() {
|
88
|
+
if (m_pConnectionPool) {
|
89
|
+
m_pConnectionPool->destroy(m_pConnection);
|
90
|
+
} else {
|
91
|
+
delete m_pConnection;
|
92
|
+
}
|
93
|
+
delete m_pSessionID;
|
94
|
+
}
|
95
|
+
|
96
|
+
Log *MySQLLogFactory::create() {
|
97
|
+
std::string database;
|
98
|
+
std::string user;
|
99
|
+
std::string password;
|
100
|
+
std::string host;
|
101
|
+
short port;
|
102
|
+
|
103
|
+
init(m_settings.get(), database, user, password, host, port);
|
104
|
+
DatabaseConnectionID id(database, user, password, host, port);
|
105
|
+
MySQLLog *result = new MySQLLog(id, m_connectionPoolPtr.get());
|
106
|
+
initLog(m_settings.get(), *result);
|
107
|
+
return result;
|
108
|
+
}
|
109
|
+
|
110
|
+
Log *MySQLLogFactory::create(const SessionID &s) {
|
111
|
+
std::string database;
|
112
|
+
std::string user;
|
113
|
+
std::string password;
|
114
|
+
std::string host;
|
115
|
+
short port;
|
116
|
+
|
117
|
+
Dictionary settings;
|
118
|
+
if (m_settings.has(s)) {
|
119
|
+
settings = m_settings.get(s);
|
120
|
+
}
|
121
|
+
|
122
|
+
init(settings, database, user, password, host, port);
|
123
|
+
DatabaseConnectionID id(database, user, password, host, port);
|
124
|
+
MySQLLog *result = new MySQLLog(s, id, m_connectionPoolPtr.get());
|
125
|
+
initLog(settings, *result);
|
126
|
+
return result;
|
127
|
+
}
|
128
|
+
|
129
|
+
void MySQLLogFactory::init(
|
130
|
+
const Dictionary &settings,
|
131
|
+
std::string &database,
|
132
|
+
std::string &user,
|
133
|
+
std::string &password,
|
134
|
+
std::string &host,
|
135
|
+
short &port) {
|
136
|
+
database = DEFAULT_DATABASE;
|
137
|
+
user = DEFAULT_USER;
|
138
|
+
password = DEFAULT_PASSWORD;
|
139
|
+
host = DEFAULT_HOST;
|
140
|
+
port = DEFAULT_PORT;
|
141
|
+
|
142
|
+
if (m_useSettings) {
|
143
|
+
try {
|
144
|
+
database = settings.getString(MYSQL_LOG_DATABASE);
|
145
|
+
} catch (ConfigError &) {}
|
146
|
+
|
147
|
+
try {
|
148
|
+
user = settings.getString(MYSQL_LOG_USER);
|
149
|
+
} catch (ConfigError &) {}
|
150
|
+
|
151
|
+
try {
|
152
|
+
password = settings.getString(MYSQL_LOG_PASSWORD);
|
153
|
+
} catch (ConfigError &) {}
|
154
|
+
|
155
|
+
try {
|
156
|
+
host = settings.getString(MYSQL_LOG_HOST);
|
157
|
+
} catch (ConfigError &) {}
|
158
|
+
|
159
|
+
try {
|
160
|
+
port = (short)settings.getInt(MYSQL_LOG_PORT);
|
161
|
+
} catch (ConfigError &) {}
|
162
|
+
} else {
|
163
|
+
database = m_database;
|
164
|
+
user = m_user;
|
165
|
+
password = m_password;
|
166
|
+
host = m_host;
|
167
|
+
port = m_port;
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
void MySQLLogFactory::initLog(const Dictionary &settings, MySQLLog &log) {
|
172
|
+
try {
|
173
|
+
log.setIncomingTable(settings.getString(MYSQL_LOG_INCOMING_TABLE));
|
174
|
+
} catch (ConfigError &) {}
|
175
|
+
|
176
|
+
try {
|
177
|
+
log.setOutgoingTable(settings.getString(MYSQL_LOG_OUTGOING_TABLE));
|
178
|
+
} catch (ConfigError &) {}
|
179
|
+
|
180
|
+
try {
|
181
|
+
log.setEventTable(settings.getString(MYSQL_LOG_EVENT_TABLE));
|
182
|
+
} catch (ConfigError &) {}
|
183
|
+
}
|
184
|
+
|
185
|
+
void MySQLLogFactory::destroy(Log *pLog) { delete pLog; }
|
186
|
+
|
187
|
+
void MySQLLog::clear() {
|
188
|
+
std::stringstream whereClause;
|
189
|
+
|
190
|
+
whereClause << "WHERE ";
|
191
|
+
|
192
|
+
if (m_pSessionID) {
|
193
|
+
whereClause << "BeginString = \"" << m_pSessionID->getBeginString().getValue() << "\" "
|
194
|
+
<< "AND SenderCompID = \"" << m_pSessionID->getSenderCompID().getValue() << "\" "
|
195
|
+
<< "AND TargetCompID = \"" << m_pSessionID->getTargetCompID().getValue() << "\" ";
|
196
|
+
|
197
|
+
if (m_pSessionID->getSessionQualifier().size()) {
|
198
|
+
whereClause << "AND SessionQualifier = \"" << m_pSessionID->getSessionQualifier() << "\"";
|
199
|
+
}
|
200
|
+
} else {
|
201
|
+
whereClause << "BeginString = NULL AND SenderCompID = NULL && TargetCompID = NULL";
|
202
|
+
}
|
203
|
+
|
204
|
+
std::stringstream incomingQuery;
|
205
|
+
std::stringstream outgoingQuery;
|
206
|
+
std::stringstream eventQuery;
|
207
|
+
|
208
|
+
incomingQuery << "DELETE FROM " << m_incomingTable << " " << whereClause.str();
|
209
|
+
outgoingQuery << "DELETE FROM " << m_outgoingTable << " " << whereClause.str();
|
210
|
+
eventQuery << "DELETE FROM " << m_eventTable << " " << whereClause.str();
|
211
|
+
|
212
|
+
MySQLQuery incoming(incomingQuery.str());
|
213
|
+
MySQLQuery outgoing(outgoingQuery.str());
|
214
|
+
MySQLQuery event(eventQuery.str());
|
215
|
+
m_pConnection->execute(incoming);
|
216
|
+
m_pConnection->execute(outgoing);
|
217
|
+
m_pConnection->execute(event);
|
218
|
+
}
|
219
|
+
|
220
|
+
void MySQLLog::backup() {}
|
221
|
+
|
222
|
+
void MySQLLog::insert(const std::string &table, const std::string value) {
|
223
|
+
UtcTimeStamp time = UtcTimeStamp::now();
|
224
|
+
int year, month, day, hour, minute, second, millis;
|
225
|
+
time.getYMD(year, month, day);
|
226
|
+
time.getHMS(hour, minute, second, millis);
|
227
|
+
|
228
|
+
char sqlTime[100];
|
229
|
+
STRING_SPRINTF(sqlTime, "%d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
|
230
|
+
|
231
|
+
char *valueCopy = new char[(value.size() * 2) + 1];
|
232
|
+
mysql_escape_string(valueCopy, value.c_str(), value.size());
|
233
|
+
|
234
|
+
std::stringstream queryString;
|
235
|
+
queryString << "INSERT INTO " << table << " "
|
236
|
+
<< "(time, time_milliseconds, beginstring, sendercompid, targetcompid, session_qualifier, text) "
|
237
|
+
<< "VALUES ("
|
238
|
+
<< "'" << sqlTime << "','" << millis << "',";
|
239
|
+
|
240
|
+
if (m_pSessionID) {
|
241
|
+
queryString << "\"" << m_pSessionID->getBeginString().getValue() << "\","
|
242
|
+
<< "\"" << m_pSessionID->getSenderCompID().getValue() << "\","
|
243
|
+
<< "\"" << m_pSessionID->getTargetCompID().getValue() << "\",";
|
244
|
+
if (m_pSessionID->getSessionQualifier() == "") {
|
245
|
+
queryString << "NULL" << ",";
|
246
|
+
} else {
|
247
|
+
queryString << "\"" << m_pSessionID->getSessionQualifier() << "\",";
|
248
|
+
}
|
249
|
+
} else {
|
250
|
+
queryString << "NULL, NULL, NULL, NULL, ";
|
251
|
+
}
|
252
|
+
|
253
|
+
queryString << "\"" << valueCopy << "\")";
|
254
|
+
delete[] valueCopy;
|
255
|
+
|
256
|
+
MySQLQuery query(queryString.str());
|
257
|
+
m_pConnection->execute(query);
|
258
|
+
}
|
259
|
+
|
260
|
+
} // namespace FIX
|
261
|
+
|
262
|
+
#endif // HAVE_MYSQL
|
@@ -0,0 +1,158 @@
|
|
1
|
+
/* -*- C++ -*- */
|
2
|
+
|
3
|
+
/****************************************************************************
|
4
|
+
** Copyright (c) 2001-2014
|
5
|
+
**
|
6
|
+
** This file is part of the QuickFIX FIX Engine
|
7
|
+
**
|
8
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
9
|
+
** license as defined by quickfixengine.org and appearing in the file
|
10
|
+
** LICENSE included in the packaging of this file.
|
11
|
+
**
|
12
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
13
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
14
|
+
**
|
15
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
16
|
+
**
|
17
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
18
|
+
** not clear to you.
|
19
|
+
**
|
20
|
+
****************************************************************************/
|
21
|
+
|
22
|
+
#ifndef FIX_MYSQLLOG_H
|
23
|
+
#define FIX_MYSQLLOG_H
|
24
|
+
|
25
|
+
#ifndef HAVE_MYSQL
|
26
|
+
#error MySQLLog.h included, but HAVE_MYSQL not defined
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#ifdef HAVE_MYSQL
|
30
|
+
|
31
|
+
#ifdef _MSC_VER
|
32
|
+
#pragma warning(disable : 4503 4355 4786 4290)
|
33
|
+
#pragma comment(lib, "libMySQL")
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#include "Log.h"
|
37
|
+
#include "MySQLConnection.h"
|
38
|
+
#include "SessionSettings.h"
|
39
|
+
#include <fstream>
|
40
|
+
#include <string>
|
41
|
+
|
42
|
+
namespace FIX {
|
43
|
+
/// MySQL based implementation of Log.
|
44
|
+
class MySQLLog : public Log {
|
45
|
+
public:
|
46
|
+
MySQLLog(const SessionID &sessionID, const DatabaseConnectionID &connectionID, MySQLConnectionPool *pool);
|
47
|
+
MySQLLog(const DatabaseConnectionID &connectionID, MySQLConnectionPool *pool);
|
48
|
+
MySQLLog(
|
49
|
+
const SessionID &sessionID,
|
50
|
+
const std::string &database,
|
51
|
+
const std::string &user,
|
52
|
+
const std::string &password,
|
53
|
+
const std::string &host,
|
54
|
+
short port);
|
55
|
+
MySQLLog(
|
56
|
+
const std::string &database,
|
57
|
+
const std::string &user,
|
58
|
+
const std::string &password,
|
59
|
+
const std::string &host,
|
60
|
+
short port);
|
61
|
+
|
62
|
+
~MySQLLog();
|
63
|
+
|
64
|
+
void clear();
|
65
|
+
void backup();
|
66
|
+
void setIncomingTable(const std::string &incomingTable) { m_incomingTable = incomingTable; }
|
67
|
+
void setOutgoingTable(const std::string &outgoingTable) { m_outgoingTable = outgoingTable; }
|
68
|
+
void setEventTable(const std::string &eventTable) { m_eventTable = eventTable; }
|
69
|
+
|
70
|
+
void onIncoming(const std::string &value) { insert(m_incomingTable, value); }
|
71
|
+
void onOutgoing(const std::string &value) { insert(m_outgoingTable, value); }
|
72
|
+
void onEvent(const std::string &value) { insert(m_eventTable, value); }
|
73
|
+
|
74
|
+
private:
|
75
|
+
void init();
|
76
|
+
void insert(const std::string &table, const std::string value);
|
77
|
+
|
78
|
+
std::string m_incomingTable;
|
79
|
+
std::string m_outgoingTable;
|
80
|
+
std::string m_eventTable;
|
81
|
+
MySQLConnection *m_pConnection;
|
82
|
+
MySQLConnectionPool *m_pConnectionPool;
|
83
|
+
SessionID *m_pSessionID;
|
84
|
+
};
|
85
|
+
|
86
|
+
/// Creates a MySQL based implementation of Log.
|
87
|
+
class MySQLLogFactory : public LogFactory {
|
88
|
+
public:
|
89
|
+
static const std::string DEFAULT_DATABASE;
|
90
|
+
static const std::string DEFAULT_USER;
|
91
|
+
static const std::string DEFAULT_PASSWORD;
|
92
|
+
static const std::string DEFAULT_HOST;
|
93
|
+
static const short DEFAULT_PORT;
|
94
|
+
|
95
|
+
MySQLLogFactory(const SessionSettings &settings)
|
96
|
+
: m_settings(settings),
|
97
|
+
m_useSettings(true) {
|
98
|
+
bool poolConnections = false;
|
99
|
+
try {
|
100
|
+
poolConnections = settings.get().getBool(MYSQL_LOG_USECONNECTIONPOOL);
|
101
|
+
} catch (ConfigError &) {}
|
102
|
+
|
103
|
+
m_connectionPoolPtr = MySQLConnectionPoolPtr(new MySQLConnectionPool(poolConnections));
|
104
|
+
}
|
105
|
+
|
106
|
+
MySQLLogFactory(
|
107
|
+
const std::string &database,
|
108
|
+
const std::string &user,
|
109
|
+
const std::string &password,
|
110
|
+
const std::string &host,
|
111
|
+
short port)
|
112
|
+
: m_database(database),
|
113
|
+
m_user(user),
|
114
|
+
m_password(password),
|
115
|
+
m_host(host),
|
116
|
+
m_port(port),
|
117
|
+
m_useSettings(false) {
|
118
|
+
m_connectionPoolPtr = MySQLConnectionPoolPtr(new MySQLConnectionPool(false));
|
119
|
+
}
|
120
|
+
|
121
|
+
MySQLLogFactory()
|
122
|
+
: m_database(DEFAULT_DATABASE),
|
123
|
+
m_user(DEFAULT_USER),
|
124
|
+
m_password(DEFAULT_PASSWORD),
|
125
|
+
m_host(DEFAULT_HOST),
|
126
|
+
m_port(DEFAULT_PORT),
|
127
|
+
m_useSettings(false) {
|
128
|
+
m_connectionPoolPtr = MySQLConnectionPoolPtr(new MySQLConnectionPool(false));
|
129
|
+
}
|
130
|
+
|
131
|
+
Log *create();
|
132
|
+
Log *create(const SessionID &);
|
133
|
+
void destroy(Log *);
|
134
|
+
|
135
|
+
private:
|
136
|
+
void init(
|
137
|
+
const Dictionary &settings,
|
138
|
+
std::string &database,
|
139
|
+
std::string &user,
|
140
|
+
std::string &password,
|
141
|
+
std::string &host,
|
142
|
+
short &port);
|
143
|
+
|
144
|
+
void initLog(const Dictionary &settings, MySQLLog &log);
|
145
|
+
|
146
|
+
MySQLConnectionPoolPtr m_connectionPoolPtr;
|
147
|
+
SessionSettings m_settings;
|
148
|
+
std::string m_database;
|
149
|
+
std::string m_user;
|
150
|
+
std::string m_password;
|
151
|
+
std::string m_host;
|
152
|
+
short m_port;
|
153
|
+
bool m_useSettings;
|
154
|
+
};
|
155
|
+
} // namespace FIX
|
156
|
+
|
157
|
+
#endif // FIX_MYSQLLOG_H
|
158
|
+
#endif // HAVE_MYSQL
|