List of usage examples for org.apache.commons.pool.impl GenericObjectPool DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS
long DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS
To view the source code for org.apache.commons.pool.impl GenericObjectPool DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS.
Click Source Link
From source file:com.fjn.helper.frameworkex.apache.commons.pool.connectionPool.ConnectionManager.java
/** * * @param maxNum//from ww w . j a v a 2 s. co m * @param maxIdleCount * @param minIdleCount * @param maxWaitTime * */ public void initConnectionPool(int maxNum, int maxIdleCount, int minIdleCount, long maxWaitTime) { int maxActive = maxNum; byte whenExhaustedAction = GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION; long maxWait = maxWaitTime; int maxIdle = maxIdleCount; int minIdle = minIdleCount; boolean testOnBorrow = GenericObjectPool.DEFAULT_TEST_ON_BORROW; boolean testOnReturn = GenericObjectPool.DEFAULT_TEST_ON_RETURN; long timeBetweenEvictionRunsMillis = GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS; int numTestsPerEvictionRun = GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN; long minEvictableIdleTimeMillis = GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS; boolean testWhileIdle = GenericObjectPool.DEFAULT_TEST_WHILE_IDLE; long softMinEvictableIdleTimeMillis = GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS; boolean lifo = GenericObjectPool.DEFAULT_LIFO; connPoolFactory = new ConnectionPoolFactory(connFactory, maxActive, whenExhaustedAction, maxWait, maxIdle, minIdle, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle, softMinEvictableIdleTimeMillis, lifo); }
From source file:org.apache.hadoop.hive.metastore.datasource.DbCPDataSourceProvider.java
@Override public DataSource create(Configuration hdpConfig) throws SQLException { LOG.debug("Creating dbcp connection pool for the MetaStore"); String driverUrl = DataSourceProvider.getMetastoreJdbcDriverUrl(hdpConfig); String user = DataSourceProvider.getMetastoreJdbcUser(hdpConfig); String passwd = DataSourceProvider.getMetastoreJdbcPasswd(hdpConfig); int maxPoolSize = hdpConfig.getInt(MetastoreConf.ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS.getVarname(), ((Long) MetastoreConf.ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS.getDefaultVal()).intValue()); long connectionTimeout = hdpConfig.getLong(CONNECTION_TIMEOUT_PROPERTY, 30000L); int connectionMaxIlde = hdpConfig.getInt(CONNECTION_MAX_IDLE_PROPERTY, GenericObjectPool.DEFAULT_MAX_IDLE); int connectionMinIlde = hdpConfig.getInt(CONNECTION_MIN_IDLE_PROPERTY, GenericObjectPool.DEFAULT_MIN_IDLE); boolean testOnBorrow = hdpConfig.getBoolean(CONNECTION_TEST_BORROW_PROPERTY, GenericObjectPool.DEFAULT_TEST_ON_BORROW); long evictionTimeMillis = hdpConfig.getLong(CONNECTION_MIN_EVICT_MILLIS_PROPERTY, GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS); boolean testWhileIdle = hdpConfig.getBoolean(CONNECTION_TEST_IDLEPROPERTY, GenericObjectPool.DEFAULT_TEST_WHILE_IDLE); long timeBetweenEvictionRuns = hdpConfig.getLong(CONNECTION_TIME_BETWEEN_EVICTION_RUNS_MILLIS, GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS); int numTestsPerEvictionRun = hdpConfig.getInt(CONNECTION_NUM_TESTS_PER_EVICTION_RUN, GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN); boolean testOnReturn = hdpConfig.getBoolean(CONNECTION_TEST_ON_RETURN, GenericObjectPool.DEFAULT_TEST_ON_RETURN); long softMinEvictableIdleTimeMillis = hdpConfig.getLong(CONNECTION_SOFT_MIN_EVICTABLE_IDLE_TIME, GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS); boolean lifo = hdpConfig.getBoolean(CONNECTION_LIFO, GenericObjectPool.DEFAULT_LIFO); GenericObjectPool objectPool = new GenericObjectPool(); objectPool.setMaxActive(maxPoolSize); objectPool.setMaxWait(connectionTimeout); objectPool.setMaxIdle(connectionMaxIlde); objectPool.setMinIdle(connectionMinIlde); objectPool.setTestOnBorrow(testOnBorrow); objectPool.setTestWhileIdle(testWhileIdle); objectPool.setMinEvictableIdleTimeMillis(evictionTimeMillis); objectPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRuns); objectPool.setNumTestsPerEvictionRun(numTestsPerEvictionRun); objectPool.setTestOnReturn(testOnReturn); objectPool.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis); objectPool.setLifo(lifo);/*from w ww .ja v a 2s. c om*/ ConnectionFactory connFactory = new DriverManagerConnectionFactory(driverUrl, user, passwd); // This doesn't get used, but it's still necessary, see // https://git1-us-west.apache.org/repos/asf?p=commons-dbcp.git;a=blob;f=doc/ManualPoolingDataSourceExample.java; // h=f45af2b8481f030b27364e505984c0eef4f35cdb;hb=refs/heads/DBCP_1_5_x_BRANCH new PoolableConnectionFactory(connFactory, objectPool, null, null, false, true); return new PoolingDataSource(objectPool); }
From source file:org.ow2.petals.binding.soap.SoapComponentContext.java
/** * <p>// www . ja v a2 s.c o m * Get a service client associated to an axis service set with the good * operation. It is taken from a pool object. * </p> * <p> * <b>This service client must be returned to the pool after usage using * API: * <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code> * .</b> * </p> * * @param address * the address of the service, mainly used as key to retrieve the * associated SU. * @param operation * the target operation QName. Non null * @param mep * the message exchange pattern used. Non null * @param cdkExtensions * SU extensions used by the service client pool when the * creation of a service client is needed * @param provides * the provides block of the endpoint which is creating the * external WS call * @param ramprtUserName * @return a ServiceClient. Not null. Must be returned to the pool after * usage using API: * <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code> * @throws HandlingException */ public ServiceClient borrowServiceClient(final String address, final QName operation, final String soapAction, final URI mep, final ConfigurationExtensions cdkExtensions, final Provides provides, String rampartUserName) throws MessagingException { try { String resolvedOp; if (operation != null) { resolvedOp = operation.toString(); } else if (soapAction != null) { resolvedOp = soapAction; } else { throw new MessagingException( "Unable to resolve the operation. Set it in the Jbi exchange or SoapAction."); } final ServiceClientKey key = new ServiceClientKey(address, resolvedOp, mep); ObjectPool pool = this.serviceClientPools.get(key); if (pool == null) { // TODO: The pool max size should be limited by the JBI worker // number pool = new GenericObjectPool( // object factory new ServiceClientPoolObjectFactory(address, operation, mep, cdkExtensions, this, provides, this.logger, soapAction, rampartUserName), // max number of borrowed object sized to the number of // JBI message processors this.componentConfiguration.getProcessorPoolSize().getValue(), // getting an object blocks until a new or idle object // is available GenericObjectPool.WHEN_EXHAUSTED_BLOCK, // if getting an object is blocked for at most this // delay, a NoSuchElementException will be thrown. In // case of a synchronous call the delay is sized to the // value of the SU's parameter "synchronous-timeout", // otherwise it sized to 5 minutes. MEPConstants.IN_OUT_PATTERN.equals(mep) || MEPConstants.IN_OPTIONAL_OUT_PATTERN.equals(mep) ? SUPropertiesHelper.retrieveTimeout(cdkExtensions) : 300000l, // max number of idle object in the pool. Sized to the // number of JBI acceptors. this.componentConfiguration.getAcceptorPoolSize().getValue(), // min number of idle object in the pool. Sized to 0 // (ie when no activity no object in pool) GenericObjectPool.DEFAULT_MIN_IDLE, // no validation test of the borrowed object false, // no validation test of the returned object false, // how long the eviction thread should sleep before // "runs" of examining idle objects. Sized to 5min. 300000l, // the number of objects examined in each run of the // idle object evictor. Size to the default value (ie. // 3) GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, // the minimum amount of time that an object may sit // idle in the pool before it is eligible for eviction // due to idle time. Sized to 30min GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, // no validation test of the idle object false, // the minimum amount of time an object may sit idle in // the pool before it is eligible for eviction by the // idle object evictor (if any), with the extra // condition that at least "minIdle" amount of object // remain in the pool. GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS, // the pool returns idle objects in last-in-first-out // order true); this.serviceClientPools.put(key, pool); } return (ServiceClient) pool.borrowObject(); } catch (final Exception e) { throw new MessagingException("Can't create get an Axis service client from the pool", e); } }
From source file:org.ow2.petals.binding.soapproxy.SoapComponentContext.java
/** * <p>//from www. java2s . c om * Get a service client associated to an axis service set with the good * operation. It is taken from a pool object. * </p> * <p> * <b>This service client must be returned to the pool after usage using * API: * <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code> * .</b> * </p> * * @param address * the address of the service, mainly used as key to retrieve the * associated SU. * @param operation * the target operation QName. Non null * @param mep * the message exchange pattern used. Non null * @param cdkExtensions * SU extensions used by the service client pool when the * creation of a service client is needed * @param provides * the provides block of the endpoint which is creating the * external WS call * @param ramprtUserName * @return a ServiceClient. Not null. Must be returned to the pool after * usage using API: * <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code> * @throws HandlingException */ public ServiceClient borrowServiceClient(final String address, final QName operation, final String soapAction, final URI mep) throws MessagingException { try { String resolvedOp; if (operation != null) { resolvedOp = operation.toString(); } else if (soapAction != null) { resolvedOp = soapAction; } else { throw new MessagingException( "Unable to resolve the operation. Set it in the Jbi exchange or SoapAction."); } final ServiceClientKey key = new ServiceClientKey(address, resolvedOp, mep); ObjectPool pool = this.serviceClientPools.get(key); if (pool == null) { // TODO: The pool max size should be limited by the JBI worker // number pool = new GenericObjectPool( // object factory new ServiceClientPoolObjectFactory(address, operation, mep, this, this.logger, soapAction), // max number of borrowed object sized to the number of // JBI message processors this.componentConfiguration.getProcessorPoolSize().getValue(), // getting an object blocks until a new or idle object // is available GenericObjectPool.WHEN_EXHAUSTED_BLOCK, // if getting an object is blocked for at most this // delay, a NoSuchElementException will be thrown. In // case of a synchronous call the delay is sized to the // value of the SU's parameter "synchronous-timeout", // otherwise it sized to 5 minutes. MEPConstants.IN_OUT_PATTERN.equals(mep) || MEPConstants.IN_OPTIONAL_OUT_PATTERN.equals(mep) ? 300000l : 300000l, // max number of idle object in the pool. Sized to the // number of JBI acceptors. this.componentConfiguration.getAcceptorPoolSize().getValue(), // min number of idle object in the pool. Sized to 0 // (ie when no activity no object in pool) GenericObjectPool.DEFAULT_MIN_IDLE, // no validation test of the borrowed object false, // no validation test of the returned object false, // how long the eviction thread should sleep before // "runs" of examining idle objects. Sized to 5min. 300000l, // the number of objects examined in each run of the // idle object evictor. Size to the default value (ie. // 3) GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, // the minimum amount of time that an object may sit // idle in the pool before it is eligible for eviction // due to idle time. Sized to 30min GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, // no validation test of the idle object false, // the minimum amount of time an object may sit idle in // the pool before it is eligible for eviction by the // idle object evictor (if any), with the extra // condition that at least "minIdle" amount of object // remain in the pool. GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS, // the pool returns idle objects in last-in-first-out // order true); this.serviceClientPools.put(key, pool); } return (ServiceClient) pool.borrowObject(); } catch (final Exception e) { throw new MessagingException("Can't create get an Axis service client from the pool", e); } }