congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
GenericObjectPool.setTestOnBorrow
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: apache/hive

objectPool.setMaxIdle(connectionMaxIlde);
objectPool.setMinIdle(connectionMinIlde);
objectPool.setTestOnBorrow(testOnBorrow);
objectPool.setTestWhileIdle(testWhileIdle);
objectPool.setMinEvictableIdleTimeMillis(evictionTimeMillis);
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.apache.openjpa/openjpa-all

/**
 * Sets the {@link #testOnBorrow} property. This property determines
 * whether or not the pool will validate objects before they are borrowed
 * from the pool. For a <code>true</code> value to have any effect, the 
 * <code>validationQuery</code> property must be set to a non-null string.
 * 
 * @param testOnBorrow new value for testOnBorrow property
 */
public synchronized void setTestOnBorrow(boolean testOnBorrow) {
  this.testOnBorrow = testOnBorrow;
  if (connectionPool != null) {
    connectionPool.setTestOnBorrow(testOnBorrow);
  }
}
origin: org.idevlab/rjc

/**
 * Sets the {@link #testOnBorrow} property. This property determines
 * whether or not the pool will validate objects before they are borrowed
 * from the pool. For a <code>true</code> value to have any effect, the
 * <code>validationQuery</code> property must be set to a non-null string.
 *
 * @param testOnBorrow new value for testOnBorrow property
 */
public synchronized void setTestOnBorrow(boolean testOnBorrow) {
  this.testOnBorrow = testOnBorrow;
  if (connectionPool != null) {
    connectionPool.setTestOnBorrow(testOnBorrow);
  }
}
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.commons-dbcp

/**
 * Sets the {@link #testOnBorrow} property. This property determines
 * whether or not the pool will validate objects before they are borrowed
 * from the pool. For a <code>true</code> value to have any effect, the 
 * <code>validationQuery</code> property must be set to a non-null string.
 * 
 * @param testOnBorrow new value for testOnBorrow property
 */
public synchronized void setTestOnBorrow(boolean testOnBorrow) {
  this.testOnBorrow = testOnBorrow;
  if (connectionPool != null) {
    connectionPool.setTestOnBorrow(testOnBorrow);
  }
}
origin: org.apache.commons/com.springsource.org.apache.commons.dbcp

/**
 * Sets the {@link #testOnBorrow} property. This property determines
 * whether or not the pool will validate objects before they are borrowed
 * from the pool. For a <code>true</code> value to have any effect, the 
 * <code>validationQuery</code> property must be set to a non-null string.
 * 
 * @param testOnBorrow new value for testOnBorrow property
 */
public synchronized void setTestOnBorrow(boolean testOnBorrow) {
  this.testOnBorrow = testOnBorrow;
  if (connectionPool != null) {
    connectionPool.setTestOnBorrow(testOnBorrow);
  }
}
origin: org.onehippo.cms7.hst.components/hst-session-pool

/**
 * Sets the {@link #testOnBorrow} property. This property determines
 * whether or not the pool will validate objects before they are borrowed
 * from the pool. For a <code>true</code> value to have any effect, the 
 * <code>validationQuery</code> property must be set to a non-null string.
 * 
 * @param testOnBorrow new value for testOnBorrow property
 */
public void setTestOnBorrow(boolean testOnBorrow) {
  this.testOnBorrow = testOnBorrow;
  if (sessionPool != null) {
    sessionPool.setTestOnBorrow(testOnBorrow);
  }
}
origin: stackoverflow.com

 GenericObjectPool connectionPool = new GenericObjectPool(null);
...
connectionPool.setTestOnBorrow(true); // test the connection before its made
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI,username, password);

final String validationQuery = null;
KeyedObjectPoolFactory statementPool = new GenericKeyedObjectPoolFactory(null);
PoolableConnectionFactory factory = new PoolableConnectionFactory(connectionFactory, connectionPool,
    statementPool, validationQuery, defaultReadOnly, defaultAutoCommit);

factory.setValidationQuery("select 1");    // validate the connection with this statement
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: org.apache.servicemix/servicemix-ftp

public void afterPropertiesSet() throws Exception {
  if (pool == null) {
    GenericObjectPool goPool = new GenericObjectPool();
    goPool.setTestOnBorrow(true);
    goPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
    pool = goPool;
  }
  pool.setFactory(this);
}
origin: stackoverflow.com

 private ObjectPool getNewConnectionPool(DataSource mySqlDataSource) {
  try {
    GenericObjectPool pool = new GenericObjectPool(null, 10); 
    pool.setTestOnBorrow(true);
    ConnectionFactory factory = new DataSourceConnectionFactory(mySqlDataSource);
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(factory, pool, null, "SELECT 1 FROM DUAL", false, true);
    Class.forName("org.apache.commons.dbcp.PoolingDriver");
    PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
    driver.registerPool("myPool", pool);
    return poolableConnectionFactory.getPool();
  } catch (Exception e) {
    throw new RuntimeException("Unable to initialize connetion pooling", e);
  }
}
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.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

/**
 * 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/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.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.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.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());
}
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());
}
org.apache.commons.pool.implGenericObjectPoolsetTestOnBorrow

Javadoc

When true, objects will be PoolableObjectFactory#validateObjectbefore being returned by the #borrowObjectmethod. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.

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
  • setWhenExhaustedAction
    Sets the action to take when the #borrowObject method is invoked when the pool is exhausted (the max
  • getNumActive
    Return the number of instances currently borrowed from this pool.
  • setWhenExhaustedAction,
  • getNumActive,
  • getNumIdle,
  • setTestWhileIdle,
  • setNumTestsPerEvictionRun,
  • setTestOnReturn,
  • invalidateObject,
  • clear,
  • addObject

Popular in Java

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now