Codota Logo
GenericObjectPool.setTestWhileIdle
Code IndexAdd Codota to your IDE (free)

How to use
setTestWhileIdle
method
in
org.apache.commons.pool.impl.GenericObjectPool

Best Java code snippets using org.apache.commons.pool.impl.GenericObjectPool.setTestWhileIdle (Showing top 20 results out of 315)

  • Common ways to obtain GenericObjectPool
private void myMethod () {
GenericObjectPool g =
  • Codota Iconnew GenericObjectPool()
  • Codota Iconnew GenericObjectPool(null)
  • Codota IconPoolableObjectFactory factory;new GenericObjectPool(factory)
  • Smart code suggestions by Codota
}
origin: apache/hive

objectPool.setMinIdle(connectionMinIlde);
objectPool.setTestOnBorrow(testOnBorrow);
objectPool.setTestWhileIdle(testWhileIdle);
objectPool.setMinEvictableIdleTimeMillis(evictionTimeMillis);
objectPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRuns);
origin: commons-pool/commons-pool

/**
 * Sets my configuration.
 *
 * @param conf configuration to use.
 * @see GenericObjectPool.Config
 */
public void setConfig(GenericObjectPool.Config conf) {
  synchronized (this) {
    setMaxIdle(conf.maxIdle);
    setMinIdle(conf.minIdle);
    setMaxActive(conf.maxActive);
    setMaxWait(conf.maxWait);
    setWhenExhaustedAction(conf.whenExhaustedAction);
    setTestOnBorrow(conf.testOnBorrow);
    setTestOnReturn(conf.testOnReturn);
    setTestWhileIdle(conf.testWhileIdle);
    setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun);
    setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis);
    setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis);
    setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis);
    setLifo(conf.lifo);
  }
  allocate();
}
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.commons-dbcp

/**
 * Sets the <code>testWhileIdle</code> property. This property determines
 * whether or not the idle object evictor will validate connections.  For a
 * <code>true</code> value to have any effect, the 
 * <code>validationQuery</code> property must be set to a non-null string.
 * 
 * @param testWhileIdle new value for testWhileIdle property
 */
public synchronized void setTestWhileIdle(boolean testWhileIdle) {
  this.testWhileIdle = testWhileIdle;
  if (connectionPool != null) {
    connectionPool.setTestWhileIdle(testWhileIdle);
  }
}
origin: org.apache.openjpa/openjpa-all

/**
 * Sets the <code>testWhileIdle</code> property. This property determines
 * whether or not the idle object evictor will validate connections.  For a
 * <code>true</code> value to have any effect, the 
 * <code>validationQuery</code> property must be set to a non-null string.
 * 
 * @param testWhileIdle new value for testWhileIdle property
 */
public synchronized void setTestWhileIdle(boolean testWhileIdle) {
  this.testWhileIdle = testWhileIdle;
  if (connectionPool != null) {
    connectionPool.setTestWhileIdle(testWhileIdle);
  }
}
origin: org.apache.commons/com.springsource.org.apache.commons.dbcp

/**
 * Sets the <code>testWhileIdle</code> property. This property determines
 * whether or not the idle object evictor will validate connections.  For a
 * <code>true</code> value to have any effect, the 
 * <code>validationQuery</code> property must be set to a non-null string.
 * 
 * @param testWhileIdle new value for testWhileIdle property
 */
public synchronized void setTestWhileIdle(boolean testWhileIdle) {
  this.testWhileIdle = testWhileIdle;
  if (connectionPool != null) {
    connectionPool.setTestWhileIdle(testWhileIdle);
  }
}
origin: org.idevlab/rjc

/**
 * Sets the <code>testWhileIdle</code> property. This property determines
 * whether or not the idle object evictor will validate connections.  For a
 * <code>true</code> value to have any effect, the
 * <code>validationQuery</code> property must be set to a non-null string.
 *
 * @param testWhileIdle new value for testWhileIdle property
 */
public synchronized void setTestWhileIdle(boolean testWhileIdle) {
  this.testWhileIdle = testWhileIdle;
  if (connectionPool != null) {
    connectionPool.setTestWhileIdle(testWhileIdle);
  }
}
origin: org.onehippo.cms7.hst.components/hst-session-pool

/**
 * Sets the <code>testWhileIdle</code> property. This property determines
 * whether or not the idle object evictor will validate connections.  For a
 * <code>true</code> value to have any effect, the 
 * <code>validationQuery</code> property must be set to a non-null string.
 * 
 * @param testWhileIdle new value for testWhileIdle property
 */
public void setTestWhileIdle(boolean testWhileIdle) {
  this.testWhileIdle = testWhileIdle;
  if (sessionPool != null) {
    sessionPool.setTestWhileIdle(testWhileIdle);
  }
}
origin: stackoverflow.com

GenericObjectPool connectionPool = new GenericObjectPool(null);
 connectionPool.setMinEvictableIdleTimeMillis(1000 * 60 * 30);
 connectionPool.setTimeBetweenEvictionRunsMillis(1000 * 60 * 30);
 connectionPool.setNumTestsPerEvictionRun(3);
 connectionPool.setTestOnBorrow(true);
 connectionPool.setTestWhileIdle(false);
 connectionPool.setTestOnReturn(false);
 props = new Properties();
 props.put("user", username);
 props.put("password", password);
 ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, props);
 PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, "SELECT 1", false, true);
 PoolingDataSource dataSource = new PoolingDataSource(connectionPool);
origin: apache/lens

public static DataSource getPoolingDataSourceFromConf(Configuration conf) {
 final ConnectionFactory cf = new DriverManagerConnectionFactory(
   conf.get(LensConfConstants.SERVER_DB_JDBC_URL, LensConfConstants.DEFAULT_SERVER_DB_JDBC_URL),
   conf.get(LensConfConstants.SERVER_DB_JDBC_USER, LensConfConstants.DEFAULT_SERVER_DB_USER),
   conf.get(LensConfConstants.SERVER_DB_JDBC_PASS, LensConfConstants.DEFAULT_SERVER_DB_PASS));
 final GenericObjectPool connectionPool = new GenericObjectPool();
 connectionPool.setTestOnBorrow(false);
 connectionPool.setTestOnReturn(false);
 connectionPool.setTestWhileIdle(true);
 new PoolableConnectionFactory(cf, connectionPool, null,
   conf.get(LensConfConstants.SERVER_DB_VALIDATION_QUERY, LensConfConstants.DEFAULT_SERVER_DB_VALIDATION_QUERY),
   false, false).setDefaultAutoCommit(true);
 return new PoolingDataSource(connectionPool);
}
origin: shunyang/thrift-all

@Override
public void afterPropertiesSet() throws Exception {
  // 对象池
  objectPool = new GenericObjectPool<TTransport>();
  //
  ((GenericObjectPool<TTransport>) objectPool).setMaxActive(maxActive);
  ((GenericObjectPool<TTransport>) objectPool).setMaxIdle(maxIdle);
  ((GenericObjectPool<TTransport>) objectPool).setMinIdle(minIdle);
  ((GenericObjectPool<TTransport>) objectPool).setMaxWait(maxWait);
  ((GenericObjectPool<TTransport>) objectPool).setTestOnBorrow(testOnBorrow);
  ((GenericObjectPool<TTransport>) objectPool).setTestOnReturn(testOnReturn);
  ((GenericObjectPool<TTransport>) objectPool).setTestWhileIdle(testWhileIdle);
  ((GenericObjectPool<TTransport>) objectPool).setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
  // 设置factory
  ThriftPoolableObjectFactory thriftPoolableObjectFactory = new ThriftPoolableObjectFactory(serviceIP, servicePort, conTimeOut);
  ((GenericObjectPool<TTransport>) objectPool).setFactory(thriftPoolableObjectFactory);
}
origin: org.apache.commons/com.springsource.org.apache.commons.dbcp

pool.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun());
pool.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
pool.setTestWhileIdle(getTestWhileIdle());
origin: org.apache.commons/com.springsource.org.apache.commons.pool

/**
 * Sets my configuration.
 *
 * @param conf configuration to use.
 * @see GenericObjectPool.Config
 */
public synchronized void setConfig(GenericObjectPool.Config conf) {
  setMaxIdle(conf.maxIdle);
  setMinIdle(conf.minIdle);
  setMaxActive(conf.maxActive);
  setMaxWait(conf.maxWait);
  setWhenExhaustedAction(conf.whenExhaustedAction);
  setTestOnBorrow(conf.testOnBorrow);
  setTestOnReturn(conf.testOnReturn);
  setTestWhileIdle(conf.testWhileIdle);
  setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun);
  setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis);
  setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis);
  setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis);
  setLifo(conf.lifo);
  allocate();
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-pool

/**
 * Sets my configuration.
 *
 * @param conf configuration to use.
 * @see GenericObjectPool.Config
 */
public synchronized void setConfig(GenericObjectPool.Config conf) {
  setMaxIdle(conf.maxIdle);
  setMinIdle(conf.minIdle);
  setMaxActive(conf.maxActive);
  setMaxWait(conf.maxWait);
  setWhenExhaustedAction(conf.whenExhaustedAction);
  setTestOnBorrow(conf.testOnBorrow);
  setTestOnReturn(conf.testOnReturn);
  setTestWhileIdle(conf.testWhileIdle);
  setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun);
  setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis);
  setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis);
  setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis);
  setLifo(conf.lifo);
  allocate();
}
origin: org.apache.openjpa/openjpa-all

/**
 * Creates a connection pool for this datasource.  This method only exists
 * so subclasses can replace the implementation class.
 */
protected void createConnectionPool() {
  // Create an object pool to contain our active connections
  GenericObjectPool gop;
  if ((abandonedConfig != null) && (abandonedConfig.getRemoveAbandoned())) {
    gop = new AbandonedObjectPool(null,abandonedConfig);
  }
  else {
    gop = new GenericObjectPool();
  }
  gop.setMaxActive(maxActive);
  gop.setMaxIdle(maxIdle);
  gop.setMinIdle(minIdle);
  gop.setMaxWait(maxWait);
  gop.setTestOnBorrow(testOnBorrow);
  gop.setTestOnReturn(testOnReturn);
  gop.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
  gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
  gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
  gop.setTestWhileIdle(testWhileIdle);
  connectionPool = gop;
}
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.commons-dbcp

/**
 * Creates a connection pool for this datasource.  This method only exists
 * so subclasses can replace the implementation class.
 */
protected void createConnectionPool() {
  // Create an object pool to contain our active connections
  GenericObjectPool gop;
  if ((abandonedConfig != null) && (abandonedConfig.getRemoveAbandoned())) {
    gop = new AbandonedObjectPool(null,abandonedConfig);
  }
  else {
    gop = new GenericObjectPool();
  }
  gop.setMaxActive(maxActive);
  gop.setMaxIdle(maxIdle);
  gop.setMinIdle(minIdle);
  gop.setMaxWait(maxWait);
  gop.setTestOnBorrow(testOnBorrow);
  gop.setTestOnReturn(testOnReturn);
  gop.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
  gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
  gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
  gop.setTestWhileIdle(testWhileIdle);
  connectionPool = gop;
}
origin: org.apache.openjpa/openjpa-all

/**
 * Sets my configuration.
 *
 * @param conf configuration to use.
 * @see GenericObjectPool.Config
 */
public void setConfig(GenericObjectPool.Config conf) {
  synchronized (this) {
    setMaxIdle(conf.maxIdle);
    setMinIdle(conf.minIdle);
    setMaxActive(conf.maxActive);
    setMaxWait(conf.maxWait);
    setWhenExhaustedAction(conf.whenExhaustedAction);
    setTestOnBorrow(conf.testOnBorrow);
    setTestOnReturn(conf.testOnReturn);
    setTestWhileIdle(conf.testWhileIdle);
    setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun);
    setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis);
    setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis);
    setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis);
    setLifo(conf.lifo);
  }
  allocate();
}
origin: org.apache.commons/pool

/**
 * Sets my configuration.
 *
 * @param conf configuration to use.
 * @see GenericObjectPool.Config
 */
public void setConfig(GenericObjectPool.Config conf) {
  synchronized (this) {
    setMaxIdle(conf.maxIdle);
    setMinIdle(conf.minIdle);
    setMaxActive(conf.maxActive);
    setMaxWait(conf.maxWait);
    setWhenExhaustedAction(conf.whenExhaustedAction);
    setTestOnBorrow(conf.testOnBorrow);
    setTestOnReturn(conf.testOnReturn);
    setTestWhileIdle(conf.testWhileIdle);
    setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun);
    setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis);
    setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis);
    setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis);
    setLifo(conf.lifo);
  }
  allocate();
}
origin: org.idevlab/rjc

private synchronized GenericObjectPool createPool() {
  if (closed) {
    throw new RedisException("Data source is closed");
  }
  if (connectionPool == null) {
    GenericObjectPool gop = new GenericObjectPool();
    gop.setMaxActive(maxActive);
    gop.setMaxIdle(maxIdle);
    gop.setMinIdle(minIdle);
    gop.setMaxWait(maxWait);
    gop.setTestOnBorrow(testOnBorrow);
    gop.setTestOnReturn(testOnReturn);
    gop.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
    gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
    gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    gop.setTestWhileIdle(testWhileIdle);
    connectionPool = gop;
    createConnectionFactory();
    try {
      for (int i = 0; i < initialSize; i++) {
        connectionPool.addObject();
      }
    } catch (Exception e) {
      throw new RedisException("Error preloading the connection pool", e);
    }
  }
  return connectionPool;
}
origin: com.nesscomputing/ness-syslog4j

protected void configureGenericObjectPool(GenericObjectPool<AbstractSyslogWriter> genericObjectPool) throws SyslogRuntimeException {
  SyslogPoolConfigIF poolConfig = null;
  try {
    poolConfig = (SyslogPoolConfigIF) this.syslog.getConfig();
  } catch (ClassCastException cce) {
    throw new SyslogRuntimeException("config must implement interface SyslogPoolConfigIF");
  }
  genericObjectPool.setMaxActive(poolConfig.getMaxActive());
  genericObjectPool.setMaxIdle(poolConfig.getMaxIdle());
  genericObjectPool.setMaxWait(poolConfig.getMaxWait());
  genericObjectPool.setMinEvictableIdleTimeMillis(poolConfig.getMinEvictableIdleTimeMillis());
  genericObjectPool.setMinIdle(poolConfig.getMinIdle());
  genericObjectPool.setNumTestsPerEvictionRun(poolConfig.getNumTestsPerEvictionRun());
  genericObjectPool.setSoftMinEvictableIdleTimeMillis(poolConfig.getSoftMinEvictableIdleTimeMillis());
  genericObjectPool.setTestOnBorrow(poolConfig.isTestOnBorrow());
  genericObjectPool.setTestOnReturn(poolConfig.isTestOnReturn());
  genericObjectPool.setTestWhileIdle(poolConfig.isTestWhileIdle());
  genericObjectPool.setTimeBetweenEvictionRunsMillis(poolConfig.getTimeBetweenEvictionRunsMillis());
  genericObjectPool.setWhenExhaustedAction(poolConfig.getWhenExhaustedAction());
}
origin: org.graylog2/syslog4j

protected void configureGenericObjectPool(GenericObjectPool genericObjectPool) throws SyslogRuntimeException {
  SyslogPoolConfigIF poolConfig = null;
  try {
    poolConfig = (SyslogPoolConfigIF) this.syslog.getConfig();
  } catch (ClassCastException cce) {
    throw new SyslogRuntimeException("config must implement interface SyslogPoolConfigIF");
  }
  genericObjectPool.setMaxActive(poolConfig.getMaxActive());
  genericObjectPool.setMaxIdle(poolConfig.getMaxIdle());
  genericObjectPool.setMaxWait(poolConfig.getMaxWait());
  genericObjectPool.setMinEvictableIdleTimeMillis(poolConfig.getMinEvictableIdleTimeMillis());
  genericObjectPool.setMinIdle(poolConfig.getMinIdle());
  genericObjectPool.setNumTestsPerEvictionRun(poolConfig.getNumTestsPerEvictionRun());
  genericObjectPool.setSoftMinEvictableIdleTimeMillis(poolConfig.getSoftMinEvictableIdleTimeMillis());
  genericObjectPool.setTestOnBorrow(poolConfig.isTestOnBorrow());
  genericObjectPool.setTestOnReturn(poolConfig.isTestOnReturn());
  genericObjectPool.setTestWhileIdle(poolConfig.isTestWhileIdle());
  genericObjectPool.setTimeBetweenEvictionRunsMillis(poolConfig.getTimeBetweenEvictionRunsMillis());
  genericObjectPool.setWhenExhaustedAction(poolConfig.getWhenExhaustedAction());
}
org.apache.commons.pool.implGenericObjectPoolsetTestWhileIdle

Javadoc

When true, objects will be PoolableObjectFactory#validateObjectby the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.

Popular methods of GenericObjectPool

  • <init>
    Create a new GenericObjectPool using the specified values.
  • returnObject
    Returns an object instance to the pool. If #getMaxIdle() is set to a positive value and the number
  • borrowObject
    Borrows an object from the pool. If there is an idle instance available in the pool, then either th
  • setMaxActive
    Sets the cap on the number of objects that can be allocated by the pool (checked out to clients, or
  • close
    Closes the pool. Once the pool is closed, #borrowObject()will fail with IllegalStateException, but #
  • setMaxIdle
    Sets the cap on the number of "idle" instances in the pool. If maxIdle is set too low on heavily loa
  • setMinIdle
    Sets the minimum number of objects allowed in the pool before the evictor thread (if active) spawns
  • setTimeBetweenEvictionRunsMillis
    Sets the number of milliseconds to sleep between runs of the idle object evictor thread. When non-po
  • setMinEvictableIdleTimeMillis
    Sets the minimum amount of time an object may sit idle in the pool before it is eligible for evictio
  • setMaxWait
    Sets the maximum amount of time (in milliseconds) the #borrowObject method should block before throw
  • setTestOnBorrow
    When true, objects will be PoolableObjectFactory#validateObjectbefore being returned by the #borrowO
  • setWhenExhaustedAction
    Sets the action to take when the #borrowObject method is invoked when the pool is exhausted (the max
  • setTestOnBorrow,
  • setWhenExhaustedAction,
  • getNumActive,
  • getNumIdle,
  • setNumTestsPerEvictionRun,
  • setTestOnReturn,
  • invalidateObject,
  • clear,
  • addObject

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • Kernel (java.awt.image)
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • JList (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now