org.apache.commons.pool.impl.GenericObjectPool Java Examples
The following examples show how to use
org.apache.commons.pool.impl.GenericObjectPool.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisClient.java From apollo with GNU General Public License v2.0 | 6 votes |
private GenericObjectPool.Config getPoolConfig() { GenericObjectPool.Config poolConfig = new GenericObjectPool.Config(); // maxIdle为负数时,不对pool size大小做限制,此处做限制,防止保持过多空闲redis连接 if (this.maxIdle >= 0) { poolConfig.maxIdle = this.maxIdle; } poolConfig.maxWait = this.maxWait; if (this.whenExhaustedAction >= 0 && this.whenExhaustedAction < 3) { poolConfig.whenExhaustedAction = this.whenExhaustedAction; } poolConfig.testOnBorrow = this.testOnBorrow; poolConfig.minIdle = this.minIdle; poolConfig.maxActive = this.maxActive; poolConfig.testOnReturn = this.testOnReturn; poolConfig.testWhileIdle = this.testWhileIdle; poolConfig.timeBetweenEvictionRunsMillis = this.timeBetweenEvictionRunsMillis; poolConfig.numTestsPerEvictionRun = this.numTestsPerEvictionRun; poolConfig.minEvictableIdleTimeMillis = this.minEvictableIdleTimeMillis; poolConfig.softMinEvictableIdleTimeMillis = this.softMinEvictableIdleTimeMillis; poolConfig.lifo = this.lifo; return poolConfig; }
Example #2
Source File: NSFFileJdbcDBCPProvider.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
public IJdbcResourceFactory loadConnection(Document doc, String name) throws XMLException, PoolException { // Common parameters String driver = getStringValue(doc, "/jdbc/driver", null); // $NON-NLS-1$ String url = getStringValue(doc, "/jdbc/url", null); // $NON-NLS-1$ String user = getStringValue(doc, "/jdbc/user", null); // $NON-NLS-1$ String password = DOMAccessor.getStringValue(doc, "/jdbc/password"); // $NON-NLS-1$ // dbcp pool parameters int minIdle = getIntValue(doc, "/jdbc/dbcp/minIdle",GenericObjectPool.DEFAULT_MIN_IDLE); // $NON-NLS-1$ int maxIdle = getIntValue(doc, "/jdbc/dbcp/maxIdle",GenericObjectPool.DEFAULT_MAX_IDLE); // $NON-NLS-1$ int maxActive = getIntValue(doc, "/jdbc/dbcp/maxActive",GenericObjectPool.DEFAULT_MAX_ACTIVE); // $NON-NLS-1$ long maxWait = getLongValue(doc, "/jdbc/dbcp/maxWait",GenericObjectPool.DEFAULT_MAX_WAIT); // $NON-NLS-1$ DbcpPoolDataSource dbcpDS = new DbcpPoolDataSource( name, driver, url, user, password, minIdle, maxIdle, maxActive, maxWait ); return dbcpDS; }
Example #3
Source File: GenericSyslogPoolFactory.java From syslog4j with GNU Lesser General Public License v2.1 | 6 votes |
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()); }
Example #4
Source File: GenericSyslogPoolFactory.java From syslog4j-graylog2 with GNU Lesser General Public License v2.1 | 6 votes |
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()); }
Example #5
Source File: KeyedResourcePool.java From JVoiceXML with GNU Lesser General Public License v2.1 | 6 votes |
/** * Adds the given resource factory. * @param resourceFactory The {@link ResourceFactory} to add. * @exception Exception error populating the pool */ public void addResourceFactory( final ResourceFactory<T> resourceFactory) throws Exception { final PoolableObjectFactory<T> factory = new PoolableResourceFactory<T>(resourceFactory); final GenericObjectPool<T> pool = new GenericObjectPool<T>(factory); final int instances = resourceFactory.getInstances(); pool.setMinIdle(instances); pool.setMaxActive(instances); pool.setMaxIdle(instances); pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL); final String type = resourceFactory.getType(); pools.put(type, pool); LOGGER.info("loading " + instances + " instance(s) of type '" + type + "'"); for (int i = 0; i < instances; i++) { pool.addObject(); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("...resources loaded."); } }
Example #6
Source File: PooledConfiguration.java From navi-pbrpc with Apache License 2.0 | 6 votes |
/** * 获取对象池配置 * * @return */ public GenericObjectPool.Config getPoolConfig() { GenericObjectPool.Config poolConfig = new GenericObjectPool.Config(); // maxIdle为负数时,不对pool size大小做限制,此处做限制,防止保持过多空闲redis连接 if (this.maxIdle >= 0) { poolConfig.maxIdle = this.maxIdle; } poolConfig.maxWait = this.maxWait; if (this.whenExhaustedAction >= 0 && this.whenExhaustedAction < 3) { poolConfig.whenExhaustedAction = this.whenExhaustedAction; } poolConfig.testOnBorrow = this.testOnBorrow; poolConfig.minIdle = this.minIdle; poolConfig.maxActive = this.maxActive; poolConfig.testOnReturn = this.testOnReturn; poolConfig.testWhileIdle = this.testWhileIdle; poolConfig.timeBetweenEvictionRunsMillis = this.timeBetweenEvictionRunsMillis; poolConfig.numTestsPerEvictionRun = this.numTestsPerEvictionRun; poolConfig.minEvictableIdleTimeMillis = this.minEvictableIdleTimeMillis; poolConfig.softMinEvictableIdleTimeMillis = this.softMinEvictableIdleTimeMillis; poolConfig.lifo = this.lifo; return poolConfig; }
Example #7
Source File: ResourceQueue.java From datawave with Apache License 2.0 | 6 votes |
/** * Constructor that accepts the type of pool, the connector, and the capacity * * @param capacity * @param cxn * @param type */ public ResourceQueue(int capacity, Connector cxn, byte type) { Preconditions.checkNotNull(cxn); Preconditions.checkArgument(capacity > 0); this.type = type; PoolableObjectFactory<AccumuloResource> factory = new AccumuloResourceFactory(cxn); this.scannerPool = new GenericObjectPool<AccumuloResource>(factory); // set the max capacity this.scannerPool.setMaxActive(capacity); // amount of time to wait for a connection this.scannerPool.setMaxWait(5000); // block this.scannerPool.setWhenExhaustedAction(type); }
Example #8
Source File: SQLBackendImpl.java From fiware-cygnus with GNU Affero General Public License v3.0 | 6 votes |
/** * Closes the Driver releasing resources * @return */ public void close() { int poolCount = 0; int poolsSize = pools.size(); for ( String destination : pools.keySet()){ GenericObjectPool pool = pools.get(destination); try { pool.close(); pools.remove(destination); poolCount ++; LOGGER.debug(sqlInstance.toUpperCase() + " Pool closed: (" + destination + ")"); } catch (Exception e) { LOGGER.error(sqlInstance.toUpperCase() + " Error closing SQL pool " + destination +": " + e.getMessage()); } } LOGGER.debug(sqlInstance.toUpperCase() + " Number of Pools closed: " + poolCount + "/" + poolsSize); }
Example #9
Source File: TestPersistence.java From development with Apache License 2.0 | 6 votes |
private DataSource createManagedDataSource(DataSource ds) { // wrap it with a LocalXAConnectionFactory XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory( transactionManager, new DataSourceConnectionFactory(ds)); GenericObjectPool pool = new GenericObjectPool(); // create the pool object factory PoolableConnectionFactory factory = new PoolableConnectionFactory( xaConnectionFactory, pool, null, "SELECT DUMMY FROM DUAL", false, false); pool.setFactory(factory); ManagedDataSource managedDs = new ManagedDataSource(pool, xaConnectionFactory.getTransactionRegistry()); managedDs.setAccessToUnderlyingConnectionAllowed(true); return managedDs; }
Example #10
Source File: AgentPool.java From emissary with Apache License 2.0 | 6 votes |
/** * Configure the commons pool stuff based on our requirements * * @param name name of the pool in the namespace */ protected void configurePool(String name) { setMaxActive(initialPoolSize); namespaceName = name; // Set blocking policy setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK); // Set maximum wait time when blocking on exhausted pool setMaxWait(1000 * 60 * 50); // 50 min logger.debug("Configuring AgentPool to use " + initialPoolSize + " agents"); // start them all setMinIdle(initialPoolSize); setMaxIdle(initialPoolSize); bindPool(); fillPool(); }
Example #11
Source File: DataSourceProviderDbcpImpl.java From ralasafe with MIT License | 5 votes |
public void setup( Properties prop ) { this.prop=prop; GenericObjectPool.Config conPoolCfg = new GenericObjectPool.Config(); conPoolCfg.maxActive = Integer.parseInt( prop.getProperty( "connectionPoolMaxSize", "15" ) ); conPoolCfg.maxIdle = Integer.parseInt( prop.getProperty( "connectionPoolMaxIdle", "8" ) ); conPoolCfg.maxWait = Integer.parseInt( prop.getProperty( "connectionPoolMaxWait", "60000" ) ); conPoolCfg.minIdle = Integer.parseInt( prop.getProperty( "connectionPoolMinSize", "2" ) ); ObjectPool connectionPool = new GenericObjectPool( null, conPoolCfg ); try { Class.forName( prop.getProperty( "jdbcDriver" ) ); } catch( ClassNotFoundException e ) { e.printStackTrace(); throw new RuntimeException(); } ConnectionFactory connectionFactory = new DriverManagerConnectionFactory( prop.getProperty( "jdbcUrl" ), prop.getProperty( "jdbcUser" ), prop.getProperty( "jdbcPassword" ) ); new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true); PoolingDataSource dataSource = new PoolingDataSource(connectionPool); ds = dataSource; }
Example #12
Source File: ConnectionPoolingIT.java From snowflake-jdbc with Apache License 2.0 | 5 votes |
private PoolingDataSource setUpPoolingDataSource() throws Exception { Class.forName(BaseJDBCTest.DRIVER_CLASS); connectionPool = new GenericObjectPool(); connectionPool.setMaxActive(20); return new PoolingDataSource(connectionPool); }
Example #13
Source File: SQLBackendImpl.java From fiware-cygnus with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns the Maximum number of connections * @return */ protected int maxPoolConnections() { int connectionCount = 0; for ( String destination : pools.keySet()){ GenericObjectPool pool = pools.get(destination); connectionCount += pool.getMaxActive(); LOGGER.debug(sqlInstance.toUpperCase() + " Pool status (" + destination + ") Max.: " + pool.getMaxActive() + "; Active: " + pool.getNumActive() + "; Idle: " + pool.getNumIdle()); } LOGGER.debug(sqlInstance.toUpperCase() + " Max pool connections: " + connectionCount); return connectionCount; }
Example #14
Source File: SQLBackendImpl.java From fiware-cygnus with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns the actual number of active connections * @return */ protected int activePoolConnections() { int connectionCount = 0; for ( String destination : pools.keySet()){ GenericObjectPool pool = pools.get(destination); connectionCount += pool.getNumActive(); LOGGER.debug(sqlInstance.toUpperCase() + " Pool status (" + destination + ") Max.: " + pool.getMaxActive() + "; Active: " + pool.getNumActive() + "; Idle: " + pool.getNumIdle()); } LOGGER.debug(sqlInstance.toUpperCase() + " Total pool's active connections: " + connectionCount); return connectionCount; }
Example #15
Source File: DirectCodecFactory.java From parquet-mr with Apache License 2.0 | 5 votes |
/** * Borrow an object from a pool. * * @param pool - the pull to borrow from, must not be null * @return - an object from the pool */ @SuppressWarnings("unchecked") public <T> T borrow(GenericObjectPool pool) { try { return (T) pool.borrowObject(); } catch (Exception e) { throw new ParquetCompressionCodecException(e); } }
Example #16
Source File: HttpClientFactory.java From monasca-common with Apache License 2.0 | 5 votes |
HttpClientFactory(String host, int port, boolean useHttps, int timeout, boolean clientAuth, String keyStore, String keyPass, String trustStore, String trustPass, String adminToken, int maxActive, long timeBetweenEvictionRunsMillis, long minEvictableIdleTimeMillis) { clientPool = new HttpClientPoolFactory(host, port, useHttps, timeout, clientAuth, keyStore, keyPass, trustStore, trustPass, adminToken, maxActive, timeBetweenEvictionRunsMillis, minEvictableIdleTimeMillis); pool = new GenericObjectPool(clientPool); }
Example #17
Source File: DirectCodecFactory.java From parquet-mr with Apache License 2.0 | 5 votes |
private void returnToPool(Object obj, Map<Class<?>, GenericObjectPool> pools) { try { GenericObjectPool pool = pools.get(obj.getClass()); if (pool == null) { throw new IllegalStateException("Received unexpected compressor or decompressor, " + "cannot be returned to any available pool: " + obj.getClass().getSimpleName()); } pool.returnObject(obj); } catch (Exception e) { throw new ParquetCompressionCodecException(e); } }
Example #18
Source File: DBUtils.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public final static void initConnection(String address, String user, String password) throws ClassNotFoundException { Class.forName("com.mysql.jdbc.Driver"); GenericObjectPool connectionPool = new GenericObjectPool(null); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(address, user, password); KeyedObjectPoolFactory keyed_factory = new StackKeyedObjectPoolFactory(); new PoolableConnectionFactory(connectionFactory, connectionPool, keyed_factory, null, false, true); ds = new PoolingDataSource(connectionPool); }
Example #19
Source File: CommonsPoolTargetSource.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #20
Source File: DatabaseConnectionBuilder.java From oodt with Apache License 2.0 | 5 votes |
public static DataSource buildDataSource(String user, String pass, String driver, String url) { DataSource ds; try { Class.forName(driver); } catch (ClassNotFoundException ignore) { } GenericObjectPool connectionPool = new GenericObjectPool(null); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory( url, user, pass); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory( connectionFactory, connectionPool, null, null, false, true); return new PoolingDataSource(connectionPool); }
Example #21
Source File: DataSourceWorkflowRepositoryFactory.java From oodt with Apache License 2.0 | 5 votes |
/** * <p> * Default Constructor * </p>. */ public DataSourceWorkflowRepositoryFactory() throws WorkflowException { String jdbcUrl, user, pass, driver; jdbcUrl = System .getProperty("org.apache.oodt.cas.workflow.repo.datasource.jdbc.url"); user = System .getProperty("org.apache.oodt.cas.workflow.repo.datasource.jdbc.user"); pass = System .getProperty("org.apache.oodt.cas.workflow.repo.datasource.jdbc.pass"); driver = System .getProperty("org.apache.oodt.cas.workflow.repo.datasource.jdbc.driver"); try { Class.forName(driver); } catch (ClassNotFoundException e) { throw new WorkflowException("Cannot load driver: " + driver); } GenericObjectPool connectionPool = new GenericObjectPool(null); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory( jdbcUrl, user, pass); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory( connectionFactory, connectionPool, null, null, false, true); dataSource = new PoolingDataSource(connectionPool); }
Example #22
Source File: IvaratorReloadTest.java From datawave with Apache License 2.0 | 5 votes |
public static GenericObjectPool.Config createIvaratorSourcePoolConfig(int maxIvaratorSources) { GenericObjectPool.Config poolConfig = new GenericObjectPool.Config(); poolConfig.maxActive = maxIvaratorSources; poolConfig.maxIdle = maxIvaratorSources; poolConfig.minIdle = 0; poolConfig.whenExhaustedAction = WHEN_EXHAUSTED_BLOCK; return poolConfig; }
Example #23
Source File: DataSourceWorkflowInstanceRepositoryFactory.java From oodt with Apache License 2.0 | 5 votes |
/** * <p> * Default constructor * </p> */ public DataSourceWorkflowInstanceRepositoryFactory() throws WorkflowException { String jdbcUrl, user, pass, driver; jdbcUrl = PathUtils .replaceEnvVariables(System .getProperty("org.apache.oodt.cas.workflow.instanceRep.datasource.jdbc.url")); user = PathUtils .replaceEnvVariables(System .getProperty("org.apache.oodt.cas.workflow.instanceRep.datasource.jdbc.user")); pass = PathUtils .replaceEnvVariables(System .getProperty("org.apache.oodt.cas.workflow.instanceRep.datasource.jdbc.pass")); driver = PathUtils .replaceEnvVariables(System .getProperty("org.apache.oodt.cas.workflow.instanceRep.datasource.jdbc.driver")); try { Class.forName(driver); } catch (ClassNotFoundException e) { throw new WorkflowException("Cannot load driver: " + driver); } GenericObjectPool connectionPool = new GenericObjectPool(null); dataSource = new PoolingDataSource(connectionPool); quoteFields = Boolean .getBoolean("org.apache.oodt.cas.workflow.instanceRep.datasource.quoteFields"); pageSize = Integer.getInteger( "org.apache.oodt.cas.workflow.instanceRep.pageSize", VAL); }
Example #24
Source File: ResourceQueue.java From datawave with Apache License 2.0 | 5 votes |
public AccumuloResource getScannerResource() throws Exception { // let's grab an object from the pool, AccumuloResource resource = null; while (resource == null) { try { resource = scannerPool.borrowObject(); } catch (NoSuchElementException nse) { if (type == GenericObjectPool.WHEN_EXHAUSTED_FAIL) { throw nse; } } } return resource; }
Example #25
Source File: JDBCConnectionFactory.java From amforeas with GNU General Public License v3.0 | 5 votes |
/** * Instantiates a new JDBCConnectionFactory if required and creates a connections pool for every database. * @return the instance of the singleton. */ public void load () { for (DatabaseConfiguration db : configuration.getDatabases()) { l.debug("Registering Connection Pool for {}", db.getDatabase()); GenericObjectPool pool = new GenericObjectPool(null, db.getMaxConnections()); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(db.toJdbcURL(), db.getUsername(), db.getPassword()); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, pool, null, null, db.isReadOnly(), true); poolableConnectionFactory.hashCode(); this.connectionPool.put(db.getDatabase(), pool); } }
Example #26
Source File: QueryIterator.java From datawave with Apache License 2.0 | 5 votes |
private GenericObjectPool.Config createIvaratorSourcePoolConfig(int maxIvaratorSources) { GenericObjectPool.Config poolConfig = new GenericObjectPool.Config(); poolConfig.maxActive = maxIvaratorSources; poolConfig.maxIdle = maxIvaratorSources; poolConfig.minIdle = 0; poolConfig.whenExhaustedAction = WHEN_EXHAUSTED_BLOCK; return poolConfig; }
Example #27
Source File: ElexisPoolingDataSource.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private ObjectPool<Connection> createConnectionPool(DBConnection dbConnection) throws InstantiationException, IllegalAccessException, ClassNotFoundException{ String driverName = StringUtils.defaultString(dbConnection.rdbmsType.driverName); String username = StringUtils.defaultString(dbConnection.username); String password = StringUtils.defaultString(dbConnection.password); String jdbcString = StringUtils.defaultString(dbConnection.connectionString); Driver driver = (Driver) Class.forName(driverName).newInstance(); Properties properties = new Properties(); properties.put("user", username); properties.put("password", password); log.info("db connection pool [" + driver + ", " + jdbcString + ", " + username + "] initialization"); ConnectionFactory connectionFactory = new DriverConnectionFactory(driver, jdbcString, properties); GenericObjectPool<Connection> connectionPool = new GenericObjectPool<>(null); connectionPool.setMaxActive(32); connectionPool.setMinIdle(8); connectionPool.setMaxWait(10000); connectionPool.setTestOnBorrow(true); new PoolableConnectionFactory(connectionFactory, connectionPool, null, "SELECT 1;", false, true); return connectionPool; }
Example #28
Source File: DBase.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public DataSource newDataSource (String driver, String connect, String login, String password) { ObjectPool <Object> connectionPool = new GenericObjectPool<>(null, dsPoolsize, (dsPoolgrow ? GenericObjectPool.WHEN_EXHAUSTED_GROW : GenericObjectPool.WHEN_EXHAUSTED_BLOCK), 0); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory (connect, login, password); // THIS IS REQUIRED DUE TO INTERNAL SIDE EFFECTS, DO NOT REMOVE THIS (AGAIN)! @SuppressWarnings("unused") PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory (connectionFactory, connectionPool, null, null, false, true); log.out (Log.INFO, "nds", "New data source for " + driver + " using " + connect + " with " + login + " created (poolsize " + dsPoolsize + ", grow is " + dsPoolgrow + ")"); return new PoolingDataSource (connectionPool); }
Example #29
Source File: IteratorBuildingVisitor.java From datawave with Apache License 2.0 | 4 votes |
public IteratorBuildingVisitor setIvaratorSourcePool(GenericObjectPool<SortedKeyValueIterator<Key,Value>> ivaratorSourcePool) { this.ivaratorSourcePool = ivaratorSourcePool; return this; }
Example #30
Source File: GMConnectionPoolConfig.java From gm4java with Apache License 2.0 | 4 votes |
GenericObjectPool.Config getConfig() { return config; }