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

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

Best Java code snippets using org.apache.commons.pool.impl.GenericObjectPool.setWhenExhaustedAction (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: 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.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: NationalSecurityAgency/datawave

/**
 * configure the pool
 * 
 * @throws Exception
 */
protected void configurePool(int capacity, byte type) throws Exception {
  Preconditions.checkArgument(capacity > 0);
  
  factory = new ScannerQueueFactory(capacity);
  
  this.capacity = capacity;
  
  scannerPool = new GenericObjectPool(factory);
  // set the max capacity
  scannerPool.setMaxActive(capacity);
  // amount of time to wait for a connection
  scannerPool.setMaxWait(5000);
  // block
  scannerPool.setWhenExhaustedAction(type);
  
  this.type = type;
  
}

origin: uk.org.mygrid.resources/boca-model

private void setupPool(GenericObjectPool pool, RepositoryConnectionFactory factory, int maxActive, int maxIdle, long blockWait) {
  pool.setFactory(factory);
  pool.setMaxActive(maxActive);
  pool.setMaxIdle(maxIdle);
  pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
  pool.setMaxWait(blockWait);
}
origin: org.eobjects.analyzerbeans/AnalyzerBeans-core

/**
 * Creates a connection pool that can be used for one or more
 * {@link PooledServiceSession} objects.
 * 
 * @param maxConnections
 * @return
 */
public static GenericObjectPool<Integer> createConnectionPool(int maxConnections) {
  GenericObjectPool<Integer> connectionPool = new GenericObjectPool<Integer>(new ConnectionPoolObjectFactory());
  connectionPool.setMaxActive(maxConnections);
  connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
  return connectionPool;
}
origin: datacleaner/DataCleaner

/**
 * Creates a connection pool that can be used for one or more
 * {@link PooledServiceSession} objects.
 *
 * @param maxConnections
 * @return
 */
public static GenericObjectPool<Integer> createConnectionPool(final int maxConnections) {
  final GenericObjectPool<Integer> connectionPool = new GenericObjectPool<>(new ConnectionPoolObjectFactory());
  connectionPool.setMaxActive(maxConnections);
  connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
  return connectionPool;
}
origin: alexo/wro4j

/**
 * Creates a {@link GenericObjectPool}. Override this method to set custom objectPool configurations.
 */
protected GenericObjectPool<T> newObjectPool(final ObjectFactory<T> objectFactory) {
 final int maxActive = Math.max(2, Runtime.getRuntime().availableProcessors());
 final GenericObjectPool<T> pool = new GenericObjectPool<T>(new BasePoolableObjectFactory<T>() {
  @Override
  public T makeObject()
   throws Exception {
   return objectFactory.create();
  }
 });
 pool.setMaxActive(maxActive);
 pool.setMaxIdle(MAX_IDLE);
 pool.setMaxWait(MAX_WAIT);
 /**
  * Use WHEN_EXHAUSTED_GROW strategy, otherwise the pool object retrieval can fail. More details here:
  * <a>http://code.google.com/p/wro4j/issues/detail?id=364</a>
  */
 pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
 // make object eligible for eviction after a predefined amount of time.
 pool.setSoftMinEvictableIdleTimeMillis(EVICTABLE_IDLE_TIME);
 pool.setTimeBetweenEvictionRunsMillis(EVICTABLE_IDLE_TIME);
 return pool;
}
origin: ro.isdc.wro4j/wro4j-extensions

/**
 * Creates a {@link GenericObjectPool}. Override this method to set custom objectPool configurations.
 */
protected GenericObjectPool<T> newObjectPool(final ObjectFactory<T> objectFactory) {
 final int maxActive = Math.max(2, Runtime.getRuntime().availableProcessors());
 final GenericObjectPool<T> pool = new GenericObjectPool<T>(new BasePoolableObjectFactory<T>() {
  @Override
  public T makeObject()
   throws Exception {
   return objectFactory.create();
  }
 });
 pool.setMaxActive(maxActive);
 pool.setMaxIdle(MAX_IDLE);
 pool.setMaxWait(MAX_WAIT);
 /**
  * Use WHEN_EXHAUSTED_GROW strategy, otherwise the pool object retrieval can fail. More details here:
  * <a>http://code.google.com/p/wro4j/issues/detail?id=364</a>
  */
 pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
 // make object eligible for eviction after a predefined amount of time.
 pool.setSoftMinEvictableIdleTimeMillis(EVICTABLE_IDLE_TIME);
 pool.setTimeBetweenEvictionRunsMillis(EVICTABLE_IDLE_TIME);
 return pool;
}
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.openjpa/openjpa-all

pool.setMaxIdle(maxIdle);
pool.setMaxWait(maxWait);
pool.setWhenExhaustedAction(whenExhaustedAction(maxActive, maxWait));
pool.setTestOnBorrow(getTestOnBorrow());
pool.setTestOnReturn(getTestOnReturn());
origin: uk.org.mygrid.resources/boca-model

  private PoolableConnectionFactory initializeConnectionFactory(int type, int maxActive, RepositoryConnectionConfiguration configuration) {
    // Will use in jndi
    // DataSource ds = (DataSource) ctx.lookup(RepositoryProperties.getDatabaseJndiName(properties));
    try {
      Class.forName(configuration.getDriverClassName());
    } catch (ClassNotFoundException e1) {
      throw new BocaRuntimeException(ExceptionConstants.DB.CODES.INVALID_CONFIG_ERROR, ExceptionConstants.DB.SUBCODES.DRIVER_NAME, e1, configuration.getDriverClassName());
    }
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(configuration.getJDBCUrl(), configuration.getUser(), configuration.getPassword());
    connectionPool = new GenericObjectPool();
    connectionPool.setMaxActive(maxActive);
    connectionPool.setMinIdle(1);
    connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
    connectionPool.setMaxWait(30000);
    connectionPool.setMaxActive(maxActive);
    //KeyedObjectPoolFactory statementPool = new GenericKeyedObjectPoolFactory(null, 1000);
    pcf = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);// (type ==
    // RepositoryConnection.RO
    // || type
    // ==
    // RepositoryConnection.QUERY),
    // true);
    if ((type == RepositoryConnection.RO || type == RepositoryConnection.QUERY))
      pcf.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
    return pcf;
  }
}
origin: org.apache.commons/com.springsource.org.apache.commons.dbcp

pool.setMaxIdle(maxIdle);
pool.setMaxWait(maxWait);
pool.setWhenExhaustedAction(whenExhaustedAction(maxActive, maxWait));
pool.setTestOnBorrow(getTestOnBorrow());
pool.setTestOnReturn(getTestOnReturn());
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.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

/**
 * 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: apache/servicemix-bundles

/**
 * Subclasses can override this if they want to return a specific Commons pool.
 * They should apply any configuration properties to the pool here.
 * <p>Default is a GenericObjectPool instance with the given pool size.
 * @return an empty Commons {@code ObjectPool}.
 * @see org.apache.commons.pool.impl.GenericObjectPool
 * @see #setMaxSize
 */
protected ObjectPool createObjectPool() {
  GenericObjectPool gop = new GenericObjectPool(this);
  gop.setMaxActive(getMaxSize());
  gop.setMaxIdle(getMaxIdle());
  gop.setMinIdle(getMinIdle());
  gop.setMaxWait(getMaxWait());
  gop.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
  gop.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
  gop.setWhenExhaustedAction(getWhenExhaustedAction());
  return gop;
}
origin: springframework/spring-aop

/**
 * Subclasses can override this if they want to return a specific Commons pool.
 * They should apply any configuration properties to the pool here.
 * <p>Default is a GenericObjectPool instance with the given pool size.
 * @return an empty Commons <code>ObjectPool</code>.
 * @see org.apache.commons.pool.impl.GenericObjectPool
 * @see #setMaxSize
 */
protected ObjectPool createObjectPool() {
  GenericObjectPool gop = new GenericObjectPool(this);
  gop.setMaxActive(getMaxSize());
  gop.setMaxIdle(getMaxIdle());
  gop.setMinIdle(getMinIdle());
  gop.setMaxWait(getMaxWait());
  gop.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
  gop.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
  gop.setWhenExhaustedAction(getWhenExhaustedAction());
  return 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.implGenericObjectPoolsetWhenExhaustedAction

Javadoc

Sets the action to take when the #borrowObject method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).

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
  • getNumActive
    Return the number of instances currently borrowed from this pool.
  • setTestOnBorrow,
  • getNumActive,
  • getNumIdle,
  • setTestWhileIdle,
  • setNumTestsPerEvictionRun,
  • setTestOnReturn,
  • invalidateObject,
  • clear,
  • addObject

Popular in Java

  • Start an intent from android
  • getContentResolver (Context)
  • compareTo (BigDecimal)
  • getExternalFilesDir (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Hashtable (java.util)
    Hashtable is a synchronized implementation of Map. All optional operations are supported.Neither key
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • 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