Skip to content

Instantly share code, notes, and snippets.

@carlo-rtr
Last active December 20, 2015 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlo-rtr/6074470 to your computer and use it in GitHub Desktop.
Save carlo-rtr/6074470 to your computer and use it in GitHub Desktop.
Dropwizard GenericObjectPool configuration
/*
Returns the maximum amount of time (in milliseconds) the borrowObject() method should block before throwing an exception when the pool is exhausted and the "when exhausted" action is WHEN_EXHAUSTED_BLOCK.
Defaulted to 1 second by DW
*/
pool.setMaxWait(configuration.getMaxWaitForConnection().toMilliseconds());
/*
Returns the minimum number of objects allowed in the pool before the evictor thread (if active) spawns new objects.
Defaulted to 1 in DW
*/
pool.setMinIdle(configuration.getMinSize());
/*
Returns the maximum number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time.
Defaulted to 8 in DW
*/
pool.setMaxActive(configuration.getMaxSize());
/*
Returns the cap on the number of "idle" instances in the pool.
Defaulted to 8 in DW
*/
pool.setMaxIdle(configuration.getMaxSize());
/*
Indicates whether or not idle objects should be validated using the factory's PoolableObjectFactory.validateObject
(T) method. Objects that fail to validate will be dropped from the pool. This setting has no effect unless
timeBetweenEvictionRunsMillis > 0. The default setting for this parameter is false.
Defaulted to false in DW
*/
pool.setTestWhileIdle(configuration.isCheckConnectionWhileIdle());
/*
indicates how long the eviction thread should sleep before "runs" of examining idle objects. When non-positive, // no eviction thread will be launched.
Defaulted to 10s
*/
pool.setTimeBetweenEvictionRunsMillis(configuration.getCheckConnectionHealthWhenIdleFor()
.toMilliseconds());
/*
specifies the minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due to idle time
Defaulted to 60s
*/
pool.setMinEvictableIdleTimeMillis(configuration.getCloseConnectionIfIdleFor()
.toMilliseconds());
// specifies the behavior of the borrowObject() method when the pool is exhausted:
pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment