private void createConnections() { for (int i = 0; i < poolConfig.minIdle; i++) { try { pool.addObject(); } catch (Exception e) { LoggerUtil.error("NettyClient init pool create connect Error: url=" + url.getUri(), e); } } }
/** * Check to see if we are below our minimum number of objects * if so enough to bring us back to our minimum. * * @throws Exception when {@link #addObject()} fails. */ private void ensureMinIdle() throws Exception { // this method isn't synchronized so the // calculateDeficit is done at the beginning // as a loop limit and a second time inside the loop // to stop when another thread already returned the // needed objects int objectDeficit = calculateDeficit(false); for ( int j = 0 ; j < objectDeficit && calculateDeficit(true) > 0 ; j++ ) { try { addObject(); } finally { synchronized (this) { _numInternalProcessing--; } allocate(); } } }
/** * Aquire and release a number of rw and ro connection * * @param connectionsToPrepare * Number of connections to prepare and release * @throws BocaException */ public void prepareReleaseRepositoryConnections(int connectionsToPrepare) throws BocaException { if (!started) throw new RuntimeException("ContainerConnectionPool not started"); try { if (roPool.getNumIdle() == 0) { for (int i = 0; i < connectionsToPrepare; i++) { roPool.addObject(); rwPool.addObject(); queryPool.addObject(); } } } catch (Exception e) { log.error(this, e);; } }
@Override protected void doInitialise() throws InitialisationException { logger.debug("Initialising transformer: " + this); try { // Only load the file once at initialize time if (xslFile != null) { this.xslt = IOUtils.getResourceAsString(xslFile, getClass()); } if (uriResolver == null) { this.uriResolver = new LocalURIResolver(xslFile); } transformerPool.addObject(); } catch (Throwable te) { throw new InitialisationException(te, this); } }
/** * Check to see if we are below our minimum number of objects * if so enough to bring us back to our minimum. * * @throws Exception when {@link #addObject()} fails. */ private void ensureMinIdle() throws Exception { // this method isn't synchronized so the // calculateDeficit is done at the beginning // as a loop limit and a second time inside the loop // to stop when another thread already returned the // needed objects int objectDeficit = calculateDeficit(false); for ( int j = 0 ; j < objectDeficit && calculateDeficit(true) > 0 ; j++ ) { try { addObject(); } finally { synchronized (this) { _numInternalProcessing--; allocate(); } } } }
/** * Check to see if we are below our minimum number of objects * if so enough to bring us back to our minimum. * * @throws Exception when {@link #addObject()} fails. */ private void ensureMinIdle() throws Exception { // this method isn't synchronized so the // calculateDeficit is done at the beginning // as a loop limit and a second time inside the loop // to stop when another thread already returned the // needed objects int objectDeficit = calculateDeficit(false); for ( int j = 0 ; j < objectDeficit && calculateDeficit(true) > 0 ; j++ ) { try { addObject(); } finally { synchronized (this) { _numInternalProcessing--; } allocate(); } } }
/** * Check to see if we are below our minimum number of objects * if so enough to bring us back to our minimum. * * @throws Exception when {@link #addObject()} fails. */ private void ensureMinIdle() throws Exception { // this method isn't synchronized so the // calculateDeficit is done at the beginning // as a loop limit and a second time inside the loop // to stop when another thread already returned the // needed objects int objectDeficit = calculateDeficit(false); for ( int j = 0 ; j < objectDeficit && calculateDeficit(true) > 0 ; j++ ) { try { addObject(); } finally { synchronized (this) { _numInternalProcessing--; } allocate(); } } }
/** * Check to see if we are below our minimum number of objects * if so enough to bring us back to our minimum. * * @throws Exception when {@link #addObject()} fails. */ private void ensureMinIdle() throws Exception { // this method isn't synchronized so the // calculateDeficit is done at the beginning // as a loop limit and a second time inside the loop // to stop when another thread already returned the // needed objects int objectDeficit = calculateDeficit(false); for ( int j = 0 ; j < objectDeficit && calculateDeficit(true) > 0 ; j++ ) { try { addObject(); } finally { synchronized (this) { _numInternalProcessing--; allocate(); } } } }
@Override protected void doInitialise() throws InitialisationException { if (xquery != null && xqueryFile != null) { throw new InitialisationException(XmlMessages.canOnlySetFileOrXQuery(), this); } try { if (xqueryFile != null) { xquery = IOUtils.getResourceAsString(xqueryFile, getClass()); } if (configuration == null) { configuration = new Configuration(); } XQDataSource ds = new SaxonXQDataSource(configuration); connection = ds.getConnection(); transformerPool.addObject(); } catch (Throwable te) { throw new InitialisationException(te, this); } }
connectionPool.addObject();
if ( Boolean.parseBoolean( prePopulatePoolStr ) ) { for ( int i = 0; i < maxIdleConnection; ++i ) { pool.addObject();
connectionPool.addObject();
connectionPool.addObject();
private synchronized GenericObjectPool createPool() { if (closed) { throw new RedisException("Data source is closed"); } if (connectionPool == null) { GenericObjectPool 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; createConnectionFactory(); try { for (int i = 0; i < initialSize; i++) { connectionPool.addObject(); } } catch (Exception e) { throw new RedisException("Error preloading the connection pool", e); } } return connectionPool; }