Skip to content
Commits on Source (15)
......@@ -6,3 +6,4 @@ Database : PostgreSQL|MySQL|...
Driver version : x.x.x
```
-----------------------------------------------------------------------------------------
*Have you searched the CLOSED issues already? How about checking [stackoverflow](https://stackoverflow.com/search?q=HikariCP)?*
......@@ -6,7 +6,6 @@ dist:
before_script:
- if [[ "x$JDK" == *'x9'* ]]; then export MAVEN_SKIP_RC=true; fi
- if [[ "x$JDK" != *'x9'* ]]; then export COVERALLS=coveralls:report; fi
script:
- export JDK8_HOME=$(jdk_switcher home oraclejdk8)
......@@ -32,5 +31,7 @@ matrix:
install: /bin/true
script:
- mvn package -Dskip.unit.tests=true -Dmaven.javadoc.skip=true -V -B
- mvn test $COVERALLS -V -P coverage
- mvn package -Dmaven.javadoc.skip=true -V -B
after_success:
- bash <(curl -s https://codecov.io/bash)
HikariCP Changes
Changes in 2.7.7
* fixed issue whereby configuration through the HikariConfigMXBean could not be altered due
to the sealed configuration change introduced in 2.7.5.
Changes in 2.7.6
* issue 1064 fixed regression where HikariConfig.copyStateTo() propagated the "sealed" status
of the source configuration to the target configuration -- preventing further changes.
Changes in 2.7.5
* issue 1061/pull 1062 fixed compatibility issue with requery.io caused by HikariCP's
proxied Statement class returning a driver-native ResultSet instance from getGeneratedKeys()
instead of returning a HikariCP proxied ResultSet.
* pull 1058 enable quantiles on Prometheus metrics.
* pull 1055 fixed incorrect JavaDoc for HikariConfigMXBean.getMinimumIdle() method.
* issue 1045/pull 1047 added Automatic-Module-Name to jar manifest to ensure that the Java 8
library plays well with the Java 9 module system.
* introduced the concept of a "sealed" configuration. Once a pool is started, attempts to
alter its configuration outside of the HikariConfigMXBean will result in an IllegalStateException.
Changes in 2.7.4
* pull 1026 added support for SQL Server's specific isolation level (SNAPSHOT).
* issue 926/pull 1022 HikariJNDIFactory should not throw a NamingException or else
cascading to other object factories cannot occur.
Changes in 2.7.3
* issue 1003 added PostgreSQL SQL State 0A000 to list of unrecoverable states calling
for eviction.
* pull 1002 updated micrometer support due to API changes in their release candidate.
Changes in 2.7.2
* issue 983 fix logic that determines how many idle connections can be removed, without
violating the minimumIdle contract.
* pull 987 add thread name to leak detection messages.
* issue 982 fix classloader order, try the ThreadContext classloader before other
classloaders.
* pull 977 log better messages when connection is evicted.
* fallback to four digit random pool suffix when SecurityManager prevents writing
to system properties for the purpose of JVM-wide unique pool identifiers.
Changes in 2.7.1
* issue 968 Wrong label order in MicrometerMetricsTracker for the connection usage
......@@ -9,6 +64,14 @@ Changes in 2.7.1
intended to cause parkNanos() to be called every 256 iterations. Thanks to @ztkmkoo
for finding this.
Changes in 2.4.13
* backport more efficient contention handling in ConcurrentBag.requite from 2.6.x
branch.
* issue 955 fix possible race condition when Statements are closed on different
threads from which they were created.
Changes in 2.7.0
* added support for micrometer metrics (currently Alpha-level support).
......
......@@ -2,7 +2,6 @@
[![][Build Status img]][Build Status]
[![][Coverage Status img]][Coverage Status]
[![][Dependency Status img]][Dependency Status]
[![][license img]][license]
[![][Maven Central img]][Maven Central]
[![][Javadocs img]][Javadocs]
......@@ -14,20 +13,12 @@ Fast, simple, reliable. HikariCP is a "zero-overhead" production ready JDBC con
----------------------------------------------------
_Java 8 maven artifact:_
_Java 8/9 maven artifact:_
```xml
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.0</version>
</dependency>
```
_Java 9 Early Access maven artifact:_
```xml
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java9ea</artifactId>
<version>2.6.1</version>
<version>2.7.7</version>
</dependency>
```
_Java 7 maven artifact (*maintenance mode*):_
......@@ -35,7 +26,7 @@ _Java 7 maven artifact (*maintenance mode*):_
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java7</artifactId>
<version>2.4.12</version>
<version>2.4.13</version>
</dependency>
```
_Java 6 maven artifact (*maintenance mode*):_
......@@ -108,7 +99,7 @@ HikariCP comes with *sane* defaults that perform well in most deployments withou
<sup>&#128206;</sup>&nbsp;*HikariCP uses milliseconds for all time values.*
&#128680;&nbsp;HikariCP relies on accurate timers for both performance and reliability. It is *imperative* that your server is synchronized with a time-source such as an NTP server. *Especially* if your server is running within a virtual machine. Why? [Read more here](https://dba.stackexchange.com/questions/171002/choice-of-connection-pooling-library-for-vm-deploys/171020). **Do not rely on hypervisor settings to "synchronize" the clock of the virtual machine. Configure time-source synchronization inside the virtual machine.** If you come asking for support on an issue that turns out to be caused by lack time synchronization, you will be taunted publicly on Twitter.
&#128680;&nbsp;HikariCP relies on accurate timers for both performance and reliability. It is *imperative* that your server is synchronized with a time-source such as an NTP server. *Especially* if your server is running within a virtual machine. Why? [Read more here](https://dba.stackexchange.com/a/171020). **Do not rely on hypervisor settings to "synchronize" the clock of the virtual machine. Configure time-source synchronization inside the virtual machine.** If you come asking for support on an issue that turns out to be caused by lack time synchronization, you will be taunted publicly on Twitter.
##### Essentials
......@@ -171,14 +162,16 @@ This property controls the maximum amount of time that a connection is allowed t
pool. **This setting only applies when ``minimumIdle`` is defined to be less than ``maximumPoolSize``.**
Whether a connection is retired as idle or not is subject to a maximum variation of +30
seconds, and average variation of +15 seconds. A connection will never be retired as idle *before*
this timeout. A value of 0 means that idle connections are never removed from the pool. The minimum
this timeout. Once the pool reaches ``minimumIdle`` connections, connections will no longer be
retired, even if idle. A value of 0 means that idle connections are never removed from the pool. The minimum
allowed value is 10000ms (10 seconds).
*Default: 600000 (10 minutes)*
&#8986;``maxLifetime``<br/>
This property controls the maximum lifetime of a connection in the pool. An in-use connection will
never be retired, only when it is closed will it then be removed. **We strongly recommend setting
this value, and it should be at least 30 seconds less than any database or infrastructure imposed
never be retired, only when it is closed will it then be removed. On a connection-by-connection
basis, minor negative attenuation is applied to avoid mass-extinction in the pool. **We strongly recommend
setting this value, and it should be at least 30 seconds less than any database or infrastructure imposed
connection time limit.** A value of 0 indicates no maximum lifetime (infinite lifetime), subject of
course to the ``idleTimeout`` setting.
*Default: 1800000 (30 minutes)*
......@@ -311,6 +304,11 @@ frameworks. When this property is specified, the ``dataSourceClassName`` propert
DataSource-specific properties will be ignored.
*Default: none*
&#128288;``schema``<br/>
This property sets the default *schema* for databases that support the concept of schemas.
If this property is not specified, the default schema defined by the JDBC driver is used.
*Default: driver default*
&#10145;``threadFactory``<br/>
This property is only available via programmatic configuration or IoC container. This property
allows you to set the instance of the ``java.util.concurrent.ThreadFactory`` that will be used
......@@ -357,8 +355,9 @@ and will negatively impact your application performance compared to driver-provi
Like Statement caching, most major database vendors support statement logging through
properties of their own driver. This includes Oracle, MySQL, Derby, MSSQL, and others. Some
even support slow query logging. For those few databases that do not support it, [log4jdbc](https://github.com/arthurblake/log4jdbc) or [jdbcdslog-exp](https://code.google.com/p/jdbcdslog-exp/) are
good options.
even support slow query logging. For those few databases that do not support it, several options are available.
We have received [a report that p6spy works well](https://github.com/brettwooldridge/HikariCP/issues/57#issuecomment-354647631),
and also note the availability of [log4jdbc](https://github.com/arthurblake/log4jdbc) and [jdbcdslog-exp](https://code.google.com/p/jdbcdslog-exp/).
----------------------------------------------------
......@@ -419,7 +418,7 @@ location of a properties file. If you intend to use this option, construct a ``
instance using the default constructor and the properties file will be loaded.
### Performance Tips
[MySQL Performnace Tips](https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration)
[MySQL Performance Tips](https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration)
### Popular DataSource Class Names
......@@ -434,14 +433,14 @@ Here is a list of JDBC *DataSource* classes for popular databases:
| Database | Driver | *DataSource* class |
|:---------------- |:------------ |:-------------------|
| Apache Derby | Derby | org.apache.derby.jdbc.ClientDataSource |
| Firebird | Jaybird | org.firebirdsql.pool.FBSimpleDataSource |
| Firebird | Jaybird | org.firebirdsql.ds.FBSimpleDataSource |
| H2 | H2 | org.h2.jdbcx.JdbcDataSource |
| HSQLDB | HSQLDB | org.hsqldb.jdbc.JDBCDataSource |
| IBM DB2 | IBM JCC | com.ibm.db2.jcc.DB2SimpleDataSource |
| IBM Informix | IBM Informix | com.informix.jdbcx.IfxDataSource |
| MS SQL Server | Microsoft | com.microsoft.sqlserver.jdbc.SQLServerDataSource |
| ~~MySQL~~ | Connector/J | ~~com.mysql.jdbc.jdbc2.optional.MysqlDataSource~~ |
| MySQL/MariaDB | MariaDB | org.mariadb.jdbc.MySQLDataSource |
| MariaDB | MariaDB | org.mariadb.jdbc.MariaDbDataSource |
| Oracle | Oracle | oracle.jdbc.pool.OracleDataSource |
| OrientDB | OrientDB | com.orientechnologies.orient.jdbc.OrientDataSource |
| PostgreSQL | pgjdbc-ng | com.impossibl.postgres.jdbc.PGDataSource |
......@@ -486,10 +485,14 @@ Don't forget the [Wiki](https://github.com/brettwooldridge/HikariCP/wiki) for ad
&#8658; slf4j library<br/>
### Sponsors
High-performance projects can never have too many tools! We would like to thank the following companies:
Thanks to [ej-technologies](https://www.ej-technologies.com) for their excellent all-in-one profiler, [JProfiler](https://www.ej-technologies.com/products/jprofiler/overview.html).
YourKit supports open source projects with its full-featured Java Profiler. Click the YourKit logo below to learn more.<br/>
[![](https://github.com/brettwooldridge/HikariCP/wiki/yklogo.png)](http://www.yourkit.com/java/profiler/index.jsp)<br/>
### Contributions
Please perform changes and submit pull requests from the ``dev`` branch instead of ``master``. Please set your editor to use spaces instead of tabs, and adhere to the apparent style of the code you are editing. The ``dev`` branch is always more "current" than the ``master`` if you are looking to live life on the edge.
......@@ -497,11 +500,8 @@ Please perform changes and submit pull requests from the ``dev`` branch instead
[Build Status]:https://travis-ci.org/brettwooldridge/HikariCP
[Build Status img]:https://travis-ci.org/brettwooldridge/HikariCP.svg?branch=dev
[Coverage Status]:https://coveralls.io/r/brettwooldridge/HikariCP?branch=dev
[Coverage Status img]:https://coveralls.io/repos/brettwooldridge/HikariCP/badge.svg?branch=dev
[Dependency Status]:https://www.versioneye.com/user/projects/551ce51c3661f1bee50004e0
[Dependency Status img]:https://www.versioneye.com/user/projects/551ce51c3661f1bee50004e0/badge.svg?style=flat
[Coverage Status]:https://codecov.io/gh/brettwooldridge/HikariCP
[Coverage Status img]:https://codecov.io/gh/brettwooldridge/HikariCP/branch/dev/graph/badge.svg
[license]:LICENSE
[license img]:https://img.shields.io/badge/license-Apache%202-blue.svg
......
codecov:
notify:
require_ci_to_pass: yes
coverage:
precision: 2
round: down
range: "50..80"
status:
project: yes
patch: yes
changes: no
parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no
comment:
layout: "reach, diff, flags, files, footer"
behavior: default
require_changes: no
hikaricp (2.7.9-1) unstable; urgency=medium
* Team upload.
* New upstream release
- Refreshed the patches
* Made the generated HirakiProxy* classes reproducible
* Removed the -java-doc package
* Standards-Version updated to 4.4.0
-- Emmanuel Bourg <ebourg@apache.org> Mon, 09 Sep 2019 15:54:06 +0200
hikaricp (2.7.1-2) unstable; urgency=medium
Team upload.
......
......@@ -9,11 +9,10 @@ Build-Depends: debhelper (>= 10),
libjavassist-java,
libmaven-bundle-plugin-java,
libmaven-exec-plugin-java,
libmaven-javadoc-plugin-java,
libpostgresql-jdbc-java,
maven-debian-helper (>= 2.1)
Build-Depends-Indep: libslf4j-java
Standards-Version: 4.1.0
Standards-Version: 4.4.0
Vcs-Git: https://salsa.debian.org/java-team/hikaricp.git
Vcs-Browser: https://salsa.debian.org/java-team/hikaricp
Homepage: https://github.com/brettwooldridge/HikariCP
......@@ -27,16 +26,3 @@ Description: high-performance JDBC connection pool library
Java. It aims at being simple, robust, reliable and extremely fast. HikariCP
comes with sane defaults that perform well in most deployments without
additional tweaking.
Package: libhikaricp-java-doc
Architecture: all
Section: doc
Depends: ${maven:Depends}, ${misc:Depends}
Suggests: ${maven:DocOptionalDepends}
Description: high-performance JDBC connection pool library - documentation
HikariCP is a high performance, low overhead JDBC connection pool library for
Java. It aims at being simple, robust, reliable and extremely fast. HikariCP
comes with sane defaults that perform well in most deployments without
additional tweaking.
.
This package contains the API javadoc.
Document: libhikaricp-java-api
Title: API Javadoc for HikariCP
Author: Brett Wooldridge
Abstract: This is the API Javadoc provided by the HikariCP library.
Section: Programming
Format: HTML
Index: /usr/share/doc/libhikaricp-java/api/index.html
Files: /usr/share/doc/libhikaricp-java/api/*
target/site/apidocs/* /usr/share/doc/libhikaricp-java/api
......@@ -26,4 +26,4 @@
+ -->
<profile>
<id>coverage</id>
<id>release-sign-artifacts</id>
Description: Makes the generated HirakiProxy* classes reproducible by using deterministic data structures in JavassistProxyFactory
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/src/main/java/com/zaxxer/hikari/util/JavassistProxyFactory.java
+++ b/src/main/java/com/zaxxer/hikari/util/JavassistProxyFactory.java
@@ -24,7 +24,7 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -134,14 +134,14 @@
targetCt.setModifiers(Modifier.PUBLIC);
// Make a set of method signatures we inherit implementation for, so we don't generate delegates for these
- Set<String> superSigs = new HashSet<>();
+ Set<String> superSigs = new LinkedHashSet<>();
for (CtMethod method : superCt.getMethods()) {
if ((method.getModifiers() & Modifier.FINAL) == Modifier.FINAL) {
superSigs.add(method.getName() + method.getSignature());
}
}
- Set<String> methods = new HashSet<>();
+ Set<String> methods = new LinkedHashSet<>();
Set<Class<?>> interfaces = getAllInterfaces(primaryInterface);
for (Class<?> intf : interfaces) {
CtClass intfCt = classPool.getCtClass(intf.getName());
@@ -227,7 +227,7 @@
private static Set<Class<?>> getAllInterfaces(Class<?> clazz)
{
- Set<Class<?>> interfaces = new HashSet<>();
+ Set<Class<?>> interfaces = new LinkedHashSet<>();
for (Class<?> intf : Arrays.asList(clazz.getInterfaces())) {
if (intf.getInterfaces().length > 0) {
interfaces.addAll(getAllInterfaces(intf));
skip-hibernate-prometheus-micrometer
drop-java9-classifier.patch
reproducible-proxy-factory.patch
......@@ -5,9 +5,9 @@ Forwarded: no (debain-specific)
--- a/pom.xml
+++ b/pom.xml
@@ -367,6 +367,11 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>-Xlint</compilerArgs>
+ <excludes>
+ <exclude>**/com/zaxxer/hikari/metrics/prometheus/**</exclude>
+ <exclude>**/com/zaxxer/hikari/metrics/micrometer/**</exclude>
......@@ -18,20 +18,24 @@ Forwarded: no (debain-specific)
--- a/src/main/java/com/zaxxer/hikari/pool/HikariPool.java
+++ b/src/main/java/com/zaxxer/hikari/pool/HikariPool.java
@@ -45,8 +45,6 @@
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.ThreadPoolExecutor;
@@ -24,12 +24,10 @@
import com.zaxxer.hikari.metrics.PoolStats;
import com.zaxxer.hikari.metrics.dropwizard.CodahaleHealthChecker;
import com.zaxxer.hikari.metrics.dropwizard.CodahaleMetricsTrackerFactory;
-import com.zaxxer.hikari.metrics.micrometer.MicrometerMetricsTrackerFactory;
import com.zaxxer.hikari.util.ConcurrentBag;
import com.zaxxer.hikari.util.ConcurrentBag.IBagStateListener;
import com.zaxxer.hikari.util.SuspendResumeLock;
import com.zaxxer.hikari.util.UtilityElf.DefaultThreadFactory;
-import io.micrometer.core.instrument.MeterRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -275,9 +273,6 @@
if (metricRegistry instanceof MetricRegistry) {
@@ -276,9 +274,6 @@
if (metricRegistry != null && safeIsAssignableFrom(metricRegistry, "com.codahale.metrics.MetricRegistry")) {
setMetricsTrackerFactory(new CodahaleMetricsTrackerFactory((MetricRegistry) metricRegistry));
}
- else if (metricRegistry instanceof MeterRegistry) {
- else if (metricRegistry != null && safeIsAssignableFrom(metricRegistry, "io.micrometer.core.instrument.MeterRegistry")) {
- setMetricsTrackerFactory(new MicrometerMetricsTrackerFactory((MeterRegistry) metricRegistry));
- }
else {
......
#!/usr/bin/make -f
%:
dh $@ -Nlibhikaricp-java-doc
get-orig-source:
uscan --download-current-version --force-download --no-symlink
dh $@
......@@ -65,8 +65,10 @@ Where ``150`` is the connection establishment time, ``<pool>`` is one of [*hikar
<sup>* Note that the times provided in the raw data is the number of microseconds (μs) since the start of the test. For graphing purposes, raw data for each pool was trimmed such that the first entry has 0 requests enqueued, and the last entry has all connections completed. </sup>
--------------------
#### Apache DBCP vs HikariCP
In case you missed the *time-scale* in the graphs above, here is a properly scaled comparable; Apache DBCP on top, HikariCP on the bottom.
### Apache DBCP vs HikariCP
:point_right: In case you missed the *time-scale* in the graphs above, here is a properly scaled comparable.
Apache DBCP on *top*, HikariCP on the *bottom*.
[![](https://github.com/brettwooldridge/HikariCP/wiki/Spike-Compare.png)](https://github.com/brettwooldridge/HikariCP/wiki/Spike-Compare.png)
......@@ -85,7 +87,7 @@ Consider this hypothetical scenario:
There is a pool with five connections in-use, and zero idle (available) connections. Then, a new thread
comes in requesting a connection.
```
"How the the prime directive apply in this case?" We'll answer with a question of our own:
"How does the prime directive apply in this case?" We'll answer with a question of our own:
> If the thread is directed to create a new connection, and that connection takes 150ms to establish, what happens if one of the five in-use connections is returned to the pool?
......
......@@ -8,27 +8,28 @@
<artifact.classifier />
<felix.bundle.plugin.version>3.3.0</felix.bundle.plugin.version>
<felix.version>5.6.2</felix.version>
<felix.version>5.6.8</felix.version>
<hibernate.version>5.2.10.Final</hibernate.version>
<javassist.version>3.22.0-CR1</javassist.version>
<jndi.version>0.11.4.1</jndi.version>
<maven.release.version>2.5.3</maven.release.version>
<metrics.version>3.2.2</metrics.version>
<micrometer.version>0.10.0.RELEASE</micrometer.version>
<simpleclient.version>0.0.22</simpleclient.version>
<mockito.version>2.8.9</mockito.version>
<metrics.version>3.2.4</metrics.version>
<micrometer.version>1.0.0</micrometer.version>
<simpleclient.version>0.0.26</simpleclient.version>
<mockito.version>2.10.0</mockito.version>
<pax.exam.version>4.11.0</pax.exam.version>
<pax.url.version>2.5.2</pax.url.version>
<postgresql.version>42.1.4</postgresql.version>
<slf4j.version>1.7.25</slf4j.version>
<log4j.version>2.8.2</log4j.version>
<commons.csv.version>1.4</commons.csv.version>
<h2.version>1.4.195</h2.version>
<log4j.version>2.9.0</log4j.version>
<commons.csv.version>1.5</commons.csv.version>
<h2.version>1.4.196</h2.version>
<junit.version>4.12</junit.version>
</properties>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.1</version>
<version>2.7.9</version>
<packaging>bundle</packaging>
<name>HikariCP</name>
......@@ -44,7 +45,7 @@
<connection>scm:git:git@github.com:brettwooldridge/HikariCP.git</connection>
<developerConnection>scm:git:git@github.com:brettwooldridge/HikariCP.git</developerConnection>
<url>git@github.com:brettwooldridge/HikariCP.git</url>
<tag>HikariCP-2.7.1</tag>
<tag>HikariCP-2.7.9</tag>
</scm>
<licenses>
......@@ -135,7 +136,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.4.jre7</version>
<version>${postgresql.version}</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -268,7 +269,6 @@
<executions>
<!-- Prepares the property pointing to the JaCoCo runtime agent which is passed as VM argument when Maven the Surefire plugin is executed. -->
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
......@@ -286,7 +286,7 @@
</execution>
<!-- Ensures that the code coverage report for unit tests is created after unit tests have been run. -->
<execution>
<id>post-unit-test</id>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
......@@ -294,8 +294,6 @@
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
<excludes>
<exclude>**/com/zaxxer/hikari/pool/HikariProxy*</exclude>
<exclude>**/com/zaxxer/hikari/metrics/**</exclude>
......@@ -313,6 +311,7 @@
<configuration>
<classifier>${artifact.classifier}</classifier>
<instructions>
<Automatic-Module-Name>com.zaxxer.hikari</Automatic-Module-Name>
<Bundle-Name>HikariCP</Bundle-Name>
<Export-Package>
com.zaxxer.hikari,
......@@ -362,11 +361,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>3.7.0</version>
<extensions>true</extensions>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>-Xlint</compilerArgs>
</configuration>
</plugin>
......@@ -454,29 +454,6 @@
</properties>
</profile>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<executions>
<execution>
<id>coveralls</id>
<phase>verify</phase>
<goals>
<goal>jacoco</goal>
</goals>
<inherited>false</inherited>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release-sign-artifacts</id>
<activation>
......
......@@ -112,12 +112,9 @@ public interface HikariConfigMXBean
void setMaxLifetime(long maxLifetimeMs);
/**
* The property controls the maximum size that the pool is allowed to reach, including both idle and in-use
* connections. Basically this value will determine the maximum number of actual connections to the database
* backend.
* <p>
* When the pool reaches this size, and no idle connections are available, calls to getConnection() will
* block for up to connectionTimeout milliseconds before timing out.
* The property controls the minimum number of idle connections that HikariCP tries to maintain in the pool,
* including both idle and in-use connections. If the idle connections dip below this value, HikariCP will
* make a best effort to restore them quickly and efficiently.
*
* @return the minimum number of connections in the pool
*/
......
......@@ -16,6 +16,13 @@
package com.zaxxer.hikari;
import com.zaxxer.hikari.metrics.MetricsTrackerFactory;
import com.zaxxer.hikari.pool.HikariPool;
import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.sql.DataSource;
import java.io.Closeable;
import java.io.PrintWriter;
import java.sql.Connection;
......@@ -23,14 +30,7 @@ import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.zaxxer.hikari.metrics.MetricsTrackerFactory;
import com.zaxxer.hikari.pool.HikariPool;
import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException;
import static com.zaxxer.hikari.pool.HikariPool.POOL_SHUTDOWN;
/**
* The HikariCP pooled DataSource.
......@@ -47,10 +47,14 @@ public class HikariDataSource extends HikariConfig implements DataSource, Closea
private volatile HikariPool pool;
/**
* Default constructor. Setters be used to configure the pool. Using
* Default constructor. Setters are used to configure the pool. Using
* this constructor vs. {@link #HikariDataSource(HikariConfig)} will
* result in {@link #getConnection()} performance that is slightly lower
* due to lazy initialization checks.
*
* The first call to {@link #getConnection()} starts the pool. Once the pool
* is started, the configuration is "sealed" and no further configuration
* changes are possible -- except via {@link HikariConfigMXBean} methods.
*/
public HikariDataSource()
{
......@@ -59,20 +63,31 @@ public class HikariDataSource extends HikariConfig implements DataSource, Closea
}
/**
* Construct a HikariDataSource with the specified configuration.
* Construct a HikariDataSource with the specified configuration. The
* {@link HikariConfig} is copied and the pool is started by invoking this
* constructor.
*
* The {@link HikariConfig} can be modified without affecting the HikariDataSource
* and used to initialize another HikariDataSource instance.
*
* @param configuration a HikariConfig instance
*/
public HikariDataSource(HikariConfig configuration)
{
configuration.validate();
configuration.copyState(this);
configuration.copyStateTo(this);
LOGGER.info("{} - Starting...", configuration.getPoolName());
pool = fastPathPool = new HikariPool(this);
LOGGER.info("{} - Start completed.", configuration.getPoolName());
this.seal();
}
// ***********************************************************************
// DataSource methods
// ***********************************************************************
/** {@inheritDoc} */
@Override
public Connection getConnection() throws SQLException
......@@ -95,6 +110,7 @@ public class HikariDataSource extends HikariConfig implements DataSource, Closea
LOGGER.info("{} - Starting...", getPoolName());
try {
pool = result = new HikariPool(this);
this.seal();
}
catch (PoolInitializationException pie) {
if (pie.getCause() instanceof SQLException) {
......@@ -209,6 +225,10 @@ public class HikariDataSource extends HikariConfig implements DataSource, Closea
return false;
}
// ***********************************************************************
// HikariConfigMXBean methods
// ***********************************************************************
/** {@inheritDoc} */
@Override
public void setMetricRegistry(Object metricRegistry)
......@@ -263,6 +283,20 @@ public class HikariDataSource extends HikariConfig implements DataSource, Closea
}
}
// ***********************************************************************
// HikariCP-specific methods
// ***********************************************************************
/**
* Returns {@code true} if the pool as been started and is not suspended or shutdown.
*
* @return {@code true} if the pool as been started and is not suspended or shutdown.
*/
public boolean isRunning()
{
return pool != null && pool.poolState != POOL_SHUTDOWN;
}
/**
* Get the {@code HikariPoolMXBean} for this HikariDataSource instance. If this method is called on
* a {@code HikariDataSource} that has been constructed without a {@code HikariConfig} instance,
......