List of usage examples for org.apache.commons.pool.impl GenericObjectPool WHEN_EXHAUSTED_GROW
byte WHEN_EXHAUSTED_GROW
To view the source code for org.apache.commons.pool.impl GenericObjectPool WHEN_EXHAUSTED_GROW.
Click Source Link
From source file:org.onexus.website.api.widgets.tags.tagstore.TagStoreManager.java
public void init() { LOGGER.debug("Connecting to '{}' as '{}'.", database, username); Driver.load();//from w w w . j a v a 2s. c o m // Initialize the DataSource with a connection pool ConnectionFactory connectionFactory = new H2ConnectionFactory(); ObjectPool connectionPool = new GenericObjectPool(null, GenericObjectPool.DEFAULT_MAX_ACTIVE, GenericObjectPool.WHEN_EXHAUSTED_GROW, GenericObjectPool.DEFAULT_MAX_WAIT); @SuppressWarnings("unused") PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true); dataSource = new PoolingDataSource(connectionPool); this.tagStores = Collections.synchronizedMap(new HashMap<String, TagStore>()); }
From source file:org.openbravo.database.ConnectionProviderImpl.java
public void addNewPool(String dbDriver, String dbServer, String dbLogin, String dbPassword, int minConns, int maxConns, double maxConnTime, String dbSessionConfig, String rdbms, String name) throws Exception { log4j.debug("Loading underlying JDBC driver."); try {/*from www.j a v a2 s .c o m*/ Class.forName(dbDriver); } catch (ClassNotFoundException e) { throw new Exception(e); } log4j.debug("Done."); GenericObjectPool connectionPool = new GenericObjectPool(null); connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW); connectionPool.setMaxActive(maxConns); connectionPool.setTestOnBorrow(false); connectionPool.setTestOnReturn(false); connectionPool.setTestWhileIdle(false); KeyedObjectPoolFactory keyedObject = new StackKeyedObjectPoolFactory(); ConnectionFactory connectionFactory = new OpenbravoDriverManagerConnectionFactory(dbServer, dbLogin, dbPassword, dbSessionConfig, rdbms); @SuppressWarnings("unused") // required by dbcp PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, keyedObject, null, false, true); Class.forName("org.apache.commons.dbcp.PoolingDriver"); PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:"); driver.registerPool(contextName + "_" + name, connectionPool); if (this.defaultPoolName == null || this.defaultPoolName.equals("")) { this.defaultPoolName = name; this.bbdd = dbServer; this.rdbms = rdbms; } }
From source file:org.opencms.db.CmsDbPool.java
/** * Creates a JDBC DriverManager based DBCP connection pool.<p> * // w w w . j av a 2s .c om * @param config the configuration (opencms.properties) * @param key the key of the database pool in the configuration * @return String the URL to access the created DBCP pool * @throws Exception if the pool could not be initialized */ public static PoolingDriver createDriverManagerConnectionPool(CmsParameterConfiguration config, String key) throws Exception { // read the values of the pool configuration specified by the given key String jdbcDriver = config.get(KEY_DATABASE_POOL + '.' + key + '.' + KEY_JDBC_DRIVER); String jdbcUrl = config.get(KEY_DATABASE_POOL + '.' + key + '.' + KEY_JDBC_URL); String jdbcUrlParams = config.get(KEY_DATABASE_POOL + '.' + key + '.' + KEY_JDBC_URL_PARAMS); int maxActive = config.getInteger(KEY_DATABASE_POOL + '.' + key + '.' + KEY_MAX_ACTIVE, 10); int maxWait = config.getInteger(KEY_DATABASE_POOL + '.' + key + '.' + KEY_MAX_WAIT, 2000); int maxIdle = config.getInteger(KEY_DATABASE_POOL + '.' + key + '.' + KEY_MAX_IDLE, 5); int minEvictableIdleTime = config .getInteger(KEY_DATABASE_POOL + '.' + key + '.' + KEY_MIN_EVICTABLE_IDLE_TIME, 1800000); int minIdle = config.getInteger(KEY_DATABASE_POOL + '.' + key + '.' + KEY_MIN_IDLE, 0); int numTestsPerEvictionRun = config .getInteger(KEY_DATABASE_POOL + '.' + key + '.' + KEY_NUM_TESTS_PER_EVICTION_RUN, 3); int timeBetweenEvictionRuns = config .getInteger(KEY_DATABASE_POOL + '.' + key + '.' + KEY_TIME_BETWEEN_EVICTION_RUNS, 3600000); String testQuery = config.get(KEY_DATABASE_POOL + '.' + key + '.' + KEY_TEST_QUERY); String username = config.get(KEY_DATABASE_POOL + '.' + key + '.' + KEY_USERNAME); String password = config.get(KEY_DATABASE_POOL + '.' + key + '.' + KEY_PASSWORD); String poolUrl = config.get(KEY_DATABASE_POOL + '.' + key + '.' + KEY_POOL_URL); String whenExhaustedActionValue = config .get(KEY_DATABASE_POOL + '.' + key + '.' + KEY_WHEN_EXHAUSTED_ACTION).trim(); byte whenExhaustedAction = 0; boolean testOnBorrow = Boolean .valueOf(config.getString(KEY_DATABASE_POOL + '.' + key + '.' + KEY_TEST_ON_BORROW, "false").trim()) .booleanValue(); boolean testWhileIdle = Boolean .valueOf( config.getString(KEY_DATABASE_POOL + '.' + key + '.' + KEY_TEST_WHILE_IDLE, "false").trim()) .booleanValue(); if ("block".equalsIgnoreCase(whenExhaustedActionValue)) { whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK; } else if ("fail".equalsIgnoreCase(whenExhaustedActionValue)) { whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_FAIL; } else if ("grow".equalsIgnoreCase(whenExhaustedActionValue)) { whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW; } else { whenExhaustedAction = GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION; } if ("".equals(testQuery)) { testQuery = null; } if (username == null) { username = ""; } if (password == null) { password = ""; } // read the values of the statement pool configuration specified by the given key boolean poolingStmts = Boolean.valueOf(config .getString(KEY_DATABASE_STATEMENTS + '.' + key + '.' + KEY_POOLING, CmsStringUtil.TRUE).trim()) .booleanValue(); int maxActiveStmts = config.getInteger(KEY_DATABASE_STATEMENTS + '.' + key + '.' + KEY_MAX_ACTIVE, 25); int maxWaitStmts = config.getInteger(KEY_DATABASE_STATEMENTS + '.' + key + '.' + KEY_MAX_WAIT, 250); int maxIdleStmts = config.getInteger(KEY_DATABASE_STATEMENTS + '.' + key + '.' + KEY_MAX_IDLE, 15); String whenStmtsExhaustedActionValue = config .get(KEY_DATABASE_STATEMENTS + '.' + key + '.' + KEY_WHEN_EXHAUSTED_ACTION); byte whenStmtsExhaustedAction = GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW; if (whenStmtsExhaustedActionValue != null) { whenStmtsExhaustedActionValue = whenStmtsExhaustedActionValue.trim(); whenStmtsExhaustedAction = ("block".equalsIgnoreCase(whenStmtsExhaustedActionValue)) ? GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK : ("fail".equalsIgnoreCase(whenStmtsExhaustedActionValue)) ? GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL : GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW; } int connectionAttempts = config.getInteger(KEY_DATABASE_POOL + '.' + key + '.' + KEY_CONNECT_ATTEMTS, 10); int connetionsWait = config.getInteger(KEY_DATABASE_POOL + '.' + key + '.' + KEY_CONNECT_WAITS, 5000); // create an instance of the JDBC driver Class.forName(jdbcDriver).newInstance(); // initialize a keyed object pool to store connections GenericObjectPool connectionPool = new GenericObjectPool(null); /* Abandoned pool configuration: * * In case the systems encounters "pool exhaustion" (runs out of connections), * comment the above line with "new GenericObjectPool(null)" and uncomment the * 5 lines below. This will generate an "abandoned pool" configuration that logs * abandoned connections to the System.out. Unfortunatly this code is deprecated, * so to avoid code warnings it's also disabled here. * Tested with commons-pool v 1.2. */ // AbandonedConfig abandonedConfig = new AbandonedConfig(); // abandonedConfig.setLogAbandoned(true); // abandonedConfig.setRemoveAbandoned(true); // abandonedConfig.setRemoveAbandonedTimeout(5); // GenericObjectPool connectionPool = new AbandonedObjectPool(null, abandonedConfig); // initialize an object pool to store connections connectionPool.setMaxActive(maxActive); connectionPool.setMaxIdle(maxIdle); connectionPool.setMinIdle(minIdle); connectionPool.setMaxWait(maxWait); connectionPool.setWhenExhaustedAction(whenExhaustedAction); if (testQuery != null) { connectionPool.setTestOnBorrow(testOnBorrow); connectionPool.setTestWhileIdle(testWhileIdle); connectionPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRuns); connectionPool.setNumTestsPerEvictionRun(numTestsPerEvictionRun); connectionPool.setMinEvictableIdleTimeMillis(minEvictableIdleTime); } // initialize a connection factory to make the DriverManager taking connections from the pool if (jdbcUrlParams != null) { jdbcUrl += jdbcUrlParams; } ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(jdbcUrl, username, password); // Set up statement pool, if desired GenericKeyedObjectPoolFactory statementFactory = null; if (poolingStmts) { statementFactory = new GenericKeyedObjectPoolFactory(null, maxActiveStmts, whenStmtsExhaustedAction, maxWaitStmts, maxIdleStmts); } // initialize a factory to obtain pooled connections and prepared statements new PoolableConnectionFactory(connectionFactory, connectionPool, statementFactory, testQuery, false, true); // initialize a new pooling driver using the pool PoolingDriver driver = new PoolingDriver(); driver.registerPool(poolUrl, connectionPool); Connection con = null; boolean connect = false; int connectionTests = 0; // try to connect once to the database to ensure it can be connected to at all // if the conection cannot be established, multiple attempts will be done to connect // just in cast the database was not fast enough to start before OpenCms was started do { try { // try to connect con = connectionFactory.createConnection(); connect = true; } catch (Exception e) { // connection failed, increase attempts, sleept for some seconds and log a message connectionTests++; if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WAIT_FOR_DB_4, new Object[] { poolUrl, jdbcUrl, new Integer(connectionTests), new Integer(connetionsWait) })); } Thread.sleep(connetionsWait); } finally { if (con != null) { con.close(); } } } while (!connect && (connectionTests < connectionAttempts)); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_JDBC_POOL_2, poolUrl, jdbcUrl)); } return driver; }
From source file:org.openconcerto.sql.model.SQLDataSource.java
public synchronized void setBlockWhenExhausted(boolean block) { this.blockWhenExhausted = block; if (this.connectionPool != null) { this.connectionPool.setWhenExhaustedAction( block ? GenericObjectPool.WHEN_EXHAUSTED_BLOCK : GenericObjectPool.WHEN_EXHAUSTED_GROW); }// w ww . java 2s. c o m }
From source file:org.opensubsystems.core.persist.jdbc.connectionpool.dbcp.DBCPDatabaseConnectionFactoryImpl.java
/** * {@inheritDoc}/* w w w . j av a2 s . c o m*/ */ @Override protected Object createConnectionPool(String strConnectionPoolName, Database database, String strDriverName, String strUrl, String strUser, String strPassword, int iTransactionIsolation) throws OSSException { // I am using here the PoolingDriver instead of PoolingDataSource because // in DBCP version 1.1 the PoolingDriver has clear way how to shutdown // the pool and PoolingDataSource doesn't. // This code was inspired by method setupDriver from // ManualPoolingDriverExample.java in commons-dbcp package v 1.6 ObjectPool connectionPool; ConnectionFactory connectionFactory; PoolableConnectionFactory poolableConnectionFactory; PooledDatabaseConnectionFactorySetupReader setupReader = new PooledDatabaseConnectionFactorySetupReader( strConnectionPoolName, database.getDatabaseTypeIdentifier()); int iInitialPoolSize = setupReader .getIntegerParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_INITIAL_SIZE) .intValue(); int iMinimalPoolSize = setupReader .getIntegerParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_MIN_SIZE).intValue(); int iMaximalPoolSize = setupReader .getIntegerParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_MAX_SIZE).intValue(); boolean bCanGrow = setupReader .getBooleanParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_CAN_GROW) .booleanValue(); long lMaxWaitTimeForConnection = setupReader .getLongParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_WAIT_PERIOD).longValue(); boolean bValidateOnBorrow = setupReader .getBooleanParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_VALIDATE_BORROW) .booleanValue(); boolean bValidateOnReturn = setupReader .getBooleanParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_VALIDATE_RETURN) .booleanValue(); boolean bValidateOnIdle = setupReader .getBooleanParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_VALIDATE_IDLE) .booleanValue(); long lTimeBetweenEvictionRunsMillis = setupReader .getLongParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_IDLE_CHECK_PERIOD) .longValue(); int iNumTestsPerEvictionRun = setupReader .getIntegerParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_IDLE_CHECK_SIZE) .intValue(); long lMinEvictableIdleTimeMillis = setupReader .getLongParameterValue(PooledDatabaseConnectionFactorySetupReader.DBPOOL_IDLE_PERIOD).longValue(); int iPreparedStatementCacheSize = setupReader.getIntegerParameterValue( PooledDatabaseConnectionFactorySetupReader.DBPOOL_PREPSTATEMENT_CACHE_SIZE).intValue(); // First, we'll need a ObjectPool that serves as the actual pool of // connections. We'll use a GenericObjectPool instance, although // any ObjectPool implementation will suffice. connectionPool = new GenericObjectPool(null, // factory will be specified below iMaximalPoolSize, bCanGrow ? GenericObjectPool.WHEN_EXHAUSTED_GROW : GenericObjectPool.WHEN_EXHAUSTED_BLOCK, lMaxWaitTimeForConnection, iMaximalPoolSize, // max idle - if no connections are used // the pool should not fall under this size iMinimalPoolSize, // min idle - if connection count falls // under this limit (e.g. closed connections) // new connections will be created bValidateOnBorrow, bValidateOnReturn, lTimeBetweenEvictionRunsMillis, iNumTestsPerEvictionRun, lMinEvictableIdleTimeMillis, bValidateOnIdle); // Next, we'll create a ConnectionFactory that the pool will use to // create Connections. I am using DriverManagerConnectionFactory instead // of DriverConnectionFactory because it allows me to specify user name // and password directly connectionFactory = new DriverManagerConnectionFactory(strUrl, strUser, strPassword); // This configuration of prepared statement caching is inspired by // Commons-DBCP Wiki available at http://wiki.apache.org/jakarta-commons/DBCP // null can be used as parameter because this parameter is set in // PoolableConnectionFactory when creating a new PoolableConnection // 0 according to documentation should mean no limit KeyedObjectPoolFactory statementPool = null; if (iPreparedStatementCacheSize >= 0) { statementPool = new GenericKeyedObjectPoolFactory(null, iPreparedStatementCacheSize); } // Now we'll create the PoolableConnectionFactory, which wraps // the "real" Connections created by the ConnectionFactory with // the classes that implement the pooling functionality. poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, statementPool, DatabaseImpl.getInstance().getConnectionTestStatement(), false, // not read-only connection false, // Default auto commit is false iTransactionIsolation); // PoolableConnectionFactory doesn't support the initialSize attribute of // DBCP so I have replicated the code from BasicDataSource v1.37 here try { for (int iIndex = 0; iIndex < iInitialPoolSize; iIndex++) { connectionPool.addObject(); } } catch (Exception e) { throw new OSSDatabaseAccessException("Error preloading the connection pool", e); } if (GlobalConstants.ERROR_CHECKING) { // Put this check here to trick checkstyle assert poolableConnectionFactory != null : "Poolable connection factory cannot be null."; } return connectionPool; }
From source file:org.pentaho.di.core.database.ConnectionPoolUtil.java
private static void createPool(LogChannelInterface log, DatabaseMeta databaseMeta, String partitionId, int initialSize, int maximumSize) throws KettleDatabaseException { log.logBasic(BaseMessages.getString(PKG, "Database.CreatingConnectionPool", databaseMeta.getName())); GenericObjectPool gpool = new GenericObjectPool(); gpool.setMaxIdle(-1);/*ww w. ja v a 2 s .c o m*/ gpool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW); gpool.setMaxActive(maximumSize); String clazz = databaseMeta.getDriverClass(); try { Class.forName(clazz).newInstance(); } catch (Exception e) { throw new KettleDatabaseException(BaseMessages.getString(PKG, "Database.UnableToLoadConnectionPoolDriver.Exception", databaseMeta.getName(), clazz), e); } String url; String userName; String password; try { url = databaseMeta.environmentSubstitute(databaseMeta.getURL(partitionId)); userName = databaseMeta.environmentSubstitute(databaseMeta.getUsername()); password = databaseMeta.environmentSubstitute(databaseMeta.getPassword()); } catch (RuntimeException e) { url = databaseMeta.getURL(partitionId); userName = databaseMeta.getUsername(); password = databaseMeta.getPassword(); } password = Encr.decryptPasswordOptionallyEncrypted(password); // Get the list of pool properties Properties originalProperties = databaseMeta.getConnectionPoolingProperties(); // Add user/pass originalProperties.setProperty("user", Const.NVL(userName, "")); originalProperties.setProperty("password", Const.NVL(password, "")); // Now, replace the environment variables in there... Properties properties = new Properties(); Iterator<Object> iterator = originalProperties.keySet().iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); String value = originalProperties.getProperty(key); properties.put(key, databaseMeta.environmentSubstitute(value)); } // Create factory using these properties. // ConnectionFactory cf = new DriverManagerConnectionFactory(url, properties); new PoolableConnectionFactory(cf, gpool, null, null, false, false); for (int i = 0; i < initialSize; i++) { try { gpool.addObject(); } catch (Exception e) { throw new KettleDatabaseException( BaseMessages.getString(PKG, "Database.UnableToPreLoadConnectionToConnectionPool.Exception"), e); } } pd.registerPool(databaseMeta.getName(), gpool); log.logBasic(BaseMessages.getString(PKG, "Database.CreatedConnectionPool", databaseMeta.getName())); }
From source file:org.sakaiproject.nakamura.lite.storage.AbstractClientConnectionPool.java
@Activate public void activate(Map<String, Object> properties) throws ClassNotFoundException { // for testing purposes if (configuration == null) { configuration = (Configuration) properties.get(Configuration.class.getName()); }// ww w . jav a2 s. c om indexColums = ImmutableSet.of(configuration.getIndexColumnNames()); int maxActive = StorageClientUtils.getSetting(properties.get(MAX_ACTIVE), 200); byte whenExhaustedAction = GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION; String whenExhausted = (String) properties.get(WHEN_EHAUSTED); if ("fail".equals(whenExhausted)) { whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_FAIL; } else if ("grow".equals(whenExhausted)) { whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW; } else if ("block".equals(whenExhausted)) { whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK; } long maxWait = StorageClientUtils.getSetting(properties.get(MAX_WAIT), 10L); int maxIdle = StorageClientUtils.getSetting(properties.get(MAX_IDLE), 5); boolean testOnBorrow = StorageClientUtils.getSetting(properties.get(TEST_ON_BORROW), true); boolean testOnReturn = StorageClientUtils.getSetting(properties.get(TEST_ON_RETURN), true); long timeBetweenEvictionRunsMillis = StorageClientUtils .getSetting(properties.get(TIME_BETWEEN_EVICTION_RUNS_MILLIS), 60000L); int numTestsPerEvictionRun = StorageClientUtils.getSetting(properties.get(NUM_TESTS_PER_EVICTION_RUN), 1000); long minEvictableIdleTimeMillis = StorageClientUtils .getSetting(properties.get(MIN_EVICTABLE_IDLE_TIME_MILLIS), 10000L); boolean testWhileIdle = StorageClientUtils.getSetting(properties.get(TEST_WHILE_IDLE), false); pool = new GenericObjectPool(getConnectionPoolFactory(), maxActive, whenExhaustedAction, maxWait, maxIdle, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle); // set the maximum size of a string, if this is not 0, strings over this size will become files. StringType.setLengthLimit(StorageClientUtils.getSetting(properties.get(LONG_STRING_SIZE), 0)); }
From source file:org.sakaiproject.nakamura.lite.storage.spi.AbstractClientConnectionPool.java
@Activate public void activate(Map<String, Object> properties) throws ClassNotFoundException { // for testing purposes if (configuration == null) { configuration = (Configuration) properties.get(Configuration.class.getName()); }/*from w w w.j a va 2s.co m*/ indexColumns = ImmutableSet.copyOf(configuration.getIndexColumnNames()); indexColumnsTypes = ImmutableSet.copyOf(configuration.getIndexColumnTypes()); int maxActive = StorageClientUtils.getSetting(properties.get(MAX_ACTIVE), 200); byte whenExhaustedAction = GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION; String whenExhausted = (String) properties.get(WHEN_EHAUSTED); if ("fail".equals(whenExhausted)) { whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_FAIL; } else if ("grow".equals(whenExhausted)) { whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW; } else if ("block".equals(whenExhausted)) { whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK; } long maxWait = StorageClientUtils.getSetting(properties.get(MAX_WAIT), 10L); int maxIdle = StorageClientUtils.getSetting(properties.get(MAX_IDLE), 5); boolean testOnBorrow = StorageClientUtils.getSetting(properties.get(TEST_ON_BORROW), true); boolean testOnReturn = StorageClientUtils.getSetting(properties.get(TEST_ON_RETURN), true); long timeBetweenEvictionRunsMillis = StorageClientUtils .getSetting(properties.get(TIME_BETWEEN_EVICTION_RUNS_MILLIS), 60000L); int numTestsPerEvictionRun = StorageClientUtils.getSetting(properties.get(NUM_TESTS_PER_EVICTION_RUN), 1000); long minEvictableIdleTimeMillis = StorageClientUtils .getSetting(properties.get(MIN_EVICTABLE_IDLE_TIME_MILLIS), 10000L); boolean testWhileIdle = StorageClientUtils.getSetting(properties.get(TEST_WHILE_IDLE), false); pool = new GenericObjectPool(getConnectionPoolFactory(), maxActive, whenExhaustedAction, maxWait, maxIdle, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle); // set the maximum size of a string, if this is not 0, strings over this size will become files. StringType.setLengthLimit( StorageClientUtils.getSetting(properties.get(LONG_STRING_SIZE), DEFAULT_LONG_STRING_SIZE)); // location of the long string store. LongString.setBase(StorageClientUtils.getSetting(properties.get(LONG_STRING_STORE_BASE), StorageClientUtils.getSetting(properties.get(FS_STORE_BASE_DIR), DEFAULT_FILE_STORE))); }
From source file:org.xlcloud.ssh.SshPoolableSessionFactory.java
@PostConstruct public void init() { GenericObjectPool genericPool = new GenericObjectPool(new SshSessionPoolableObjectFactory()); genericPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW); genericPool.setTestOnBorrow(true);/*w ww . ja va 2 s . co m*/ genericPool.setMaxActive(maxActive); this.sessionPool = genericPool; }
From source file:org.yosemite.jcsadra.impl.SimpleCassandraClientPool.java
public static byte getObjectPoolExhaustedAction(ExhaustedAction exhaustedAction) { switch (exhaustedAction) { case WHEN_EXHAUSTED_FAIL: return GenericObjectPool.WHEN_EXHAUSTED_FAIL; case WHEN_EXHAUSTED_BLOCK: return GenericObjectPool.WHEN_EXHAUSTED_BLOCK; case WHEN_EXHAUSTED_GROW: return GenericObjectPool.WHEN_EXHAUSTED_GROW; default:/*from w ww .ja v a 2s . co m*/ return GenericObjectPool.WHEN_EXHAUSTED_BLOCK; } }