Skip to content

Commit 0998dad

Browse files
authored
Merge pull request #618 from the-thing/614/replace_proxool_with_hikari_cp
Replace Proxool with HikariCP
2 parents 90fda65 + 980929b commit 0998dad

File tree

14 files changed

+279
-211
lines changed

14 files changed

+279
-211
lines changed

quickfixj-all/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
com.sleepycat*;resolution:=optional,
7878
org.apache.maven*;resolution:=optional,
7979
org.codehaus.plexus*;resolution:=optional,
80-
org.logicalcobwebs.proxool*;resolution:=optional,
80+
com.zaxxer*;resolution:=optional,
8181
org.dom4j*;resolution:=optional,
8282
*
8383
</Import-Package>

quickfixj-core/pom.xml

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -126,59 +126,21 @@
126126
<artifactId>slf4j-api</artifactId>
127127
<version>${slf4j.version}</version>
128128
</dependency>
129-
<dependency>
130-
<groupId>com.cloudhopper.proxool</groupId>
131-
<artifactId>proxool</artifactId>
132-
<version>0.9.1</version>
133-
<optional>true</optional>
134-
<exclusions>
135-
<!-- bug in proxool pom - should be test scope -->
136-
<exclusion>
137-
<groupId>avalon-framework</groupId>
138-
<artifactId>avalon-framework-api</artifactId>
139-
</exclusion>
140-
<!-- we use slf4j which provides this API -->
141-
<exclusion>
142-
<groupId>commons-logging</groupId>
143-
<artifactId>commons-logging</artifactId>
144-
</exclusion>
145-
</exclusions>
146-
</dependency>
147-
<dependency>
148-
<groupId>com.cloudhopper.proxool</groupId>
149-
<artifactId>proxool-cglib</artifactId>
150-
<version>0.9.1</version>
151-
<optional>true</optional>
152-
<exclusions>
153-
<!-- bug in proxool pom - should be test scope -->
154-
<exclusion>
155-
<groupId>avalon-framework</groupId>
156-
<artifactId>avalon-framework-api</artifactId>
157-
</exclusion>
158-
<!-- we use slf4j which provides this API -->
159-
<exclusion>
160-
<groupId>commons-logging</groupId>
161-
<artifactId>commons-logging</artifactId>
162-
</exclusion>
163-
</exclusions>
164-
</dependency>
165-
<dependency>
166-
<!-- slf4j facade for JCL which is required by proxool -->
167-
<groupId>org.slf4j</groupId>
168-
<artifactId>jcl-over-slf4j</artifactId>
169-
<version>${slf4j.version}</version>
170-
<scope>runtime</scope>
171-
<optional>true</optional>
172-
</dependency>
173129
<dependency>
174130
<groupId>com.sleepycat</groupId>
175131
<artifactId>je</artifactId>
176132
<version>18.3.12</version>
177133
<optional>true</optional>
178134
</dependency>
179-
</dependencies>
135+
<dependency>
136+
<groupId>com.zaxxer</groupId>
137+
<artifactId>HikariCP</artifactId>
138+
<version>4.0.3</version>
139+
</dependency>
140+
</dependencies>
141+
180142

181-
<build>
143+
<build>
182144
<resources>
183145
</resources>
184146

quickfixj-core/src/main/doc/usermanual/installation.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,10 @@ <h4>Optional run-time libraries:</h4>
119119
use Log4J logging.</td>
120120
</tr>
121121
<tr>
122-
<td nowrap="nowrap">proxool.jar</td>
122+
<td nowrap="nowrap">HikariCP.jar</td>
123123
<td>This JAR provided database connection pooling capabilities. It is required
124124
if you are using the JDBC store or log.</td>
125125
</tr>
126-
<tr>
127-
<td nowrap="nowrap">jcl104-over-slf4j.jar</td>
128-
<td>Adapts Jakarta Commons Logging to SLF4J. Required if you are using an optional
129-
library that depends on Jakarta Commons Logging. Currently, this includes Proxool
130-
(needed by JDBC store and log for connection pooling).</td>
131-
</tr>
132126
<tr>
133127
<td nowrap="nowrap">sleepycat-je.jar</td>
134128
<td>Needed if the SleepyCat JE message store is used.</td>

quickfixj-core/src/main/doc/usermanual/usage/configuration.html

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,8 @@ <H3>QuickFIX Settings</H3>
972972
<TD><I>JdbcDriver</I></TD>
973973
<TD>JDBC driver for JDBC logger. Also used for JDBC log.</TD>
974974
<TD>Class name for the JDBC driver. Specify driver properties directly will cause the
975-
creation of a Proxool data source that supports connection pooling. If you are using a
976-
database with it's own pooling data source (e.g., Oracle) then use the <code>setDataSource()</code>
975+
creation of a HikariCP data source that supports connection pooling. If you are using a
976+
database with its own pooling data source (e.g., Oracle) then use the <code>setDataSource()</code>
977977
method on the Jdbc-related factories to set the data source directly.</TD>
978978
<TD>&nbsp;</TD>
979979
<TR ALIGN="left" VALIGN="middle">
@@ -1033,39 +1033,69 @@ <H3>QuickFIX Settings</H3>
10331033
<TD>Any nonempty string.</TD>
10341034
<TD>"" (empty string)</TD>
10351035
</TR>
1036-
10371036
<TR ALIGN="left" VALIGN="middle">
10381037
<TD><I>JdbcMaxActiveConnection</I></TD>
10391038
<TD>Specifies the maximum number of connections to the database.</TD>
1040-
<TD>Any number</TD>
1039+
<TD>Positive number</TD>
10411040
<TD>32</TD>
10421041
</TR>
10431042
<TR ALIGN="left" VALIGN="middle">
1044-
<TD><I>JdbcMaxActiveTime</I></TD>
1045-
<TD>Specifies if the housekeeper comes across a thread that has been active for longer than
1046-
this (milliseconds) then it will kill it. So make sure you set this to a number bigger than your
1047-
slowest expected response!</TD>
1048-
<TD>Any number</TD>
1049-
<TD>5000</TD>
1043+
<TD><I>JdbcMinIdleConnection</I></TD>
1044+
<TD>Controls the minimum number of idle connections that HikariCP tries to maintain in
1045+
the pool, including both idle and in-use connections. If the idle connections dip
1046+
below this value, HikariCP will make the best effort to restore them quickly and
1047+
efficiently.
1048+
</TD>
1049+
<TD>[0, JdbcMaxActiveConnection]</TD>
1050+
<TD>Same as JdbcMaxActiveConnection</TD>
10501051
</TR>
10511052
<TR ALIGN="left" VALIGN="middle">
10521053
<TD><I>JdbcMaxConnectionLifeTime</I></TD>
10531054
<TD>Specifies the maximum amount of time that a connection exists for before
10541055
it is killed (milliseconds).</TD>
1055-
<TD>Any number</TD>
1056-
<TD>28800000</TD>
1057-
</TR>
1058-
<TR ALIGN="left" VALIGN="middle">
1059-
<TD><I>JdbcSimultaneousBuildThrottle</I></TD>
1060-
<TD>Specifies the maximum number of connections we can be building at any one time.
1061-
That is, the number of new connections that have been requested but aren't yet
1062-
available for use. Because connections can be built using more than one thread
1063-
(for instance, when they are built on demand) and it takes a finite time between
1064-
deciding to build the connection and it becoming available we need some way of
1065-
ensuring that a lot of threads don't all decide to build a connection at once.
1066-
(We could solve this in a smarter way - and indeed we will one day)</TD>
1067-
<TD>Any number</TD>
1068-
<TD>32</TD>
1056+
<TD>Positive</TD>
1057+
<TD>28800000 ms (8 hours)</TD>
1058+
</TR>
1059+
<TR ALIGN="left" VALIGN="middle">
1060+
<TD><I>JdbcConnectionTimeout</I></TD>
1061+
<TD>Set the maximum number of milliseconds that a client will wait for a connection from the
1062+
pool. If this time is exceeded without a connection becoming available, an SQLException
1063+
will be thrown from javax.sql.DataSource.getConnection().</TD>
1064+
<TD>Non-negative number</TD>
1065+
<TD>250 ms</TD>
1066+
</TR>
1067+
<TR ALIGN="left" VALIGN="middle">
1068+
<TD><I>JdbcConnectionIdleTimeout</I></TD>
1069+
<TD>Controls the maximum amount of time that a connection is allowed to sit idle in the pool.
1070+
Whether a connection is retired as idle or not is subject to a maximum variation of +30 seconds, and
1071+
average variation of +15 seconds. A connection will never be retired as idle before this timeout.
1072+
A value of 0 means that idle connections are never removed from the pool.</TD>
1073+
<TD>Non-negative number</TD>
1074+
<TD>600000 ms (10 minutes)</TD>
1075+
</TR>
1076+
<TR ALIGN="left" VALIGN="middle">
1077+
<TD><I>JdbcConnectionKeepaliveTime</I></TD>
1078+
<TD>Controls the keepalive interval for a connection in the pool. An in-use connection will never be
1079+
tested by the keepalive thread, only when it is idle will it be tested.</TD>
1080+
<TD>Non-negative number</TD>
1081+
<TD>0 ms</TD>
1082+
</TR>
1083+
<TR ALIGN="left" VALIGN="middle">
1084+
<TD><I>JdbcConnectionKeepaliveTime</I></TD>
1085+
<TD>Controls the keepalive interval for a connection in the pool. An in-use connection will never be
1086+
tested by the keepalive thread, only when it is idle will it be tested.</TD>
1087+
<TD>Non-negative number</TD>
1088+
<TD>0 ms</TD>
1089+
</TR>
1090+
<TR ALIGN="left" VALIGN="middle">
1091+
<TD><I>JdbcConnectionTestQuery</I></TD>
1092+
<TD>Set the SQL query to be executed to test the validity of connections. Using the JDBC4
1093+
Connection.isValid() method to test connection validity can be more efficient on some
1094+
databases and is recommended. If your driver supports JDBC4 we strongly recommend not
1095+
setting this property.</TD>
1096+
<TD>Valid SQL query</TD>
1097+
<TD></TD>
1098+
</TR>
10691099
</TR>
10701100

10711101
<TR ALIGN="center" VALIGN="middle">

quickfixj-core/src/main/java/quickfix/JdbcLog.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class JdbcLog extends AbstractLog {
5555
private final Map<String, String> deleteItemsSqlCache = new HashMap<>();
5656

5757
public JdbcLog(SessionSettings settings, SessionID sessionID, DataSource ds)
58-
throws SQLException, ClassNotFoundException, ConfigError, FieldConvertError {
58+
throws SQLException, ConfigError, FieldConvertError {
5959
this.sessionID = sessionID;
6060
dataSource = ds == null
6161
? JdbcUtil.getDataSource(settings, sessionID)
@@ -109,8 +109,8 @@ private void createCachedSql() {
109109
}
110110

111111
private void createInsertItemSql(String tableName) {
112-
insertItemSqlCache.put(tableName, "INSERT INTO " + tableName + " (time, "
113-
+ getIDColumns(extendedSessionIdSupported) + ", text) " + "VALUES (?,"
112+
insertItemSqlCache.put(tableName, "INSERT INTO " + tableName + " (time,"
113+
+ getIDColumns(extendedSessionIdSupported) + ",text) " + "VALUES (?,"
114114
+ getIDPlaceholders(extendedSessionIdSupported) + ",?)");
115115
}
116116

quickfixj-core/src/main/java/quickfix/JdbcSetting.java

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package quickfix;
2121

22+
import javax.sql.DataSource;
23+
2224
/**
2325
* Class for storing JDBC setting constants shared by both the log and message
2426
* store classes.
@@ -103,40 +105,62 @@ public class JdbcSetting {
103105
public static final String SETTING_JDBC_SESSION_ID_DEFAULT_PROPERTY_VALUE = "JdbcSessionIdDefaultPropertyValue";
104106

105107
/**
106-
* Specifies the maximum number of connections to the database
107-
*
108-
* @see <a href="http://proxool.sourceforge.net/properties.html">http://proxool.sourceforge.net/properties.html</a>
108+
* Controls the maximum size that the pool is allowed to reach, including both idle and in-use connections.
109+
* Basically this value will determine the maximum number of actual connections to the database backend.
110+
* A reasonable value for this is best determined by your execution environment. When the pool reaches this size,
111+
* and no idle connections are available, calls to {@link DataSource#getConnection()} will block for up to
112+
* {@link JdbcSetting#SETTING_JDBC_CONNECTION_TIMEOUT} milliseconds before timing out.
109113
*/
110114
public static final String SETTING_JDBC_MAX_ACTIVE_CONNECTION = "JdbcMaxActiveConnection";
111115

112116
/**
113-
* Specifies if the housekeeper comes across a thread that has been active for longer than
114-
* this then it will kill it. So make sure you set this to a number bigger than your
115-
* slowest expected response!
116-
*
117-
* @see <a href="http://proxool.sourceforge.net/properties.html">http://proxool.sourceforge.net/properties.html</a>
117+
* Controls the minimum number of idle connections that HikariCP tries to maintain in the pool.
118+
* If the idle connections dip below this value and total connections in the pool are less than
119+
* {@link JdbcSetting#SETTING_JDBC_MAX_ACTIVE_CONNECTION}, HikariCP will make the best effort to add
120+
* additional connections quickly and efficiently. However, for maximum performance and responsiveness
121+
* to spike demands, we recommend not setting this value and instead allowing HikariCP to act as a fixed
122+
* size connection pool.
118123
*/
119-
public static final String SETTING_JDBC_MAX_ACTIVE_TIME = "JdbcMaxActiveTime";
124+
public static final String SETTING_JDBC_MIN_IDLE_CONNECTION = "JdbcMinIdleConnection";
120125

121126
/**
122-
* Specifies the maximum amount of time that a connection exists for before
123-
* it is killed (milliseconds).
124-
*
125-
* @see <a href="http://proxool.sourceforge.net/properties.html">http://proxool.sourceforge.net/properties.html</a>
127+
* Controls the maximum lifetime of a connection in the pool. An in-use connection will never be retired, only when
128+
* it is closed will it then be removed. On a connection-by-connection basis, minor negative attenuation is applied to
129+
* avoid mass-extinction in the pool. We strongly recommend setting this value, and it should be several seconds shorter
130+
* than any database or infrastructure imposed connection time limit. A value of 0 indicates no maximum lifetime (infinite
131+
* lifetime), subject of course to the {@link JdbcSetting#SETTING_JDBC_CONNECTION_IDLE_TIMEOUT} setting.
126132
*/
127133
public static final String SETTING_JDBC_MAX_CONNECTION_LIFETIME = "JdbcMaxConnectionLifeTime";
128134

129135
/**
130-
* Specifies the maximum number of connections we can be building at any one time.
131-
* That is, the number of new connections that have been requested but aren't yet
132-
* available for use. Because connections can be built using more than one thread
133-
* (for instance, when they are built on demand) and it takes a finite time between
134-
* deciding to build the connection and it becoming available we need some way of
135-
* ensuring that a lot of threads don't all decide to build a connection at once.
136-
* (We could solve this in a smarter way - and indeed we will one day)
137-
*
138-
* @see <a href="http://proxool.sourceforge.net/properties.html">http://proxool.sourceforge.net/properties.html</a>
136+
* Controls the maximum number of milliseconds that a client (that's you) will wait for a connection from the pool. If this time
137+
* is exceeded without a connection becoming available, an SQLException will be thrown. Lowest acceptable connection timeout is 250 ms.
139138
*/
140-
public static final String SETTING_JDBC_SIMULTANEOUS_BUILD_THROTTLE = "JdbcSimultaneousBuildThrottle";
139+
public static final String SETTING_JDBC_CONNECTION_TIMEOUT = "JdbcConnectionTimeout";
141140

141+
/**
142+
* Controls the maximum amount of time that a connection is allowed to sit idle in the pool.
143+
* This setting only applies when {@link JdbcSetting#SETTING_JDBC_MIN_IDLE_CONNECTION} is defined to be less than
144+
* {@link JdbcSetting#SETTING_JDBC_MAX_ACTIVE_CONNECTION}. Idle connections will not be retired once the pool
145+
* reaches {@link JdbcSetting#SETTING_JDBC_MIN_IDLE_CONNECTION} connections.
146+
*/
147+
public static final String SETTING_JDBC_CONNECTION_IDLE_TIMEOUT = "JdbcConnectionIdleTimeout";
148+
149+
/**
150+
* Controls how frequently HikariCP will attempt to keep a connection alive, in order to prevent it from being timed out by the
151+
* database or network infrastructure. This value must be less than the {@link JdbcSetting#SETTING_JDBC_MAX_CONNECTION_LIFETIME} value.
152+
* A "keepalive" will only occur on an idle connection. When the time arrives for a "keepalive" against a given connection, that connection
153+
* will be removed from the pool, "pinged", and then returned to the pool. The 'ping' is one of either: invocation of the JDBC4
154+
* {@link java.sql.Connection#isValid(int)} method, or execution of the {@link JdbcSetting#SETTING_JDBC_CONNECTION_TEST_QUERY}. Typically, the duration
155+
* out-of-the-pool should be measured in single digit milliseconds or even sub-millisecond, and therefore should have little or no noticeable
156+
* performance impact. The minimum allowed value is 30000ms (30 seconds), but a value in the range of minutes is most desirable.
157+
*/
158+
public static final String SETTING_JDBC_CONNECTION_KEEPALIVE_TIME = "JdbcConnectionKeepaliveTime";
159+
160+
/**
161+
* If your driver supports JDBC4 we strongly recommend not setting this property. This is for "legacy" drivers that do not support the
162+
* JDBC4 {@link java.sql.Connection#isValid(int)} API. This is the query that will be executed just before a connection is given to you
163+
* from the pool to validate that the connection to the database is still alive.
164+
*/
165+
public static final String SETTING_JDBC_CONNECTION_TEST_QUERY = "JdbcConnectionTestQuery";
142166
}

0 commit comments

Comments
 (0)