- Common ways to obtain GenericObjectPool
private void myMethod () {GenericObjectPool g =
new GenericObjectPool()
new GenericObjectPool(null)
PoolableObjectFactory factory;new GenericObjectPool(factory)
- Smart code suggestions by Codota
}
protected void invalidateObject(Channel nettyChannel) { if (nettyChannel == null) { return; } try { pool.invalidateObject(nettyChannel); } catch (Exception ie) { LoggerUtil.error(this.getClass().getSimpleName() + " invalidate client Error: url=" + url.getUri(), ie); } }
private void closeSocket(Socket s) { // All sockets come from the pool. // This socket is no longer usable, so delete it from the // pool. try { _socketPool.invalidateObject(s); } catch (Exception e) { } }
private void closeSocket(Socket s) { // All sockets come from the pool. // This socket is no longer usable, so delete it from the // pool. try { _socketPool.invalidateObject(s); } catch (Exception e) { } }
private void closeSocket(Socket s) { // All sockets come from the pool. // This socket is no longer usable, so delete it from the // pool. try { _socketPool.invalidateObject(s); } catch (Exception e) { } }
private void closeSocket(Socket s) { // All sockets come from the pool. // This socket is no longer usable, so delete it from the // pool. try { _socketPool.invalidateObject(s); } catch (Exception e) { } }
private void closeSocket(Socket s) { // All sockets come from the pool. // This socket is no longer usable, so delete it from the // pool. try { _socketPool.invalidateObject(s); } catch (Exception e) { } }
public void returnBrokenJedis(Jedis jedis) { if (jedis == null) { return; } ((JedisValid)jedis).valid = false; try { goPool.invalidateObject(jedis); } catch (Exception e) { LOGGER.warning("REDISCONN: BROKEN: " + e); } //pool.returnBrokenResource(jedis); }
public void returnBrokenJedis(Jedis jedis) { if (jedis == null) { return; } ((JedisValid)jedis).valid = false; try { goPool.invalidateObject(jedis); } catch (Exception e) { LOGGER.warning("REDISCONN: BROKEN: " + e); } //pool.returnBrokenResource(jedis); }
/** * 返回一个调用失败的对象到池中 * * @param resource */ protected void returnBrokenResourceObject(final Object resource) { try { internalPool.invalidateObject(resource); } catch (Exception e) { throw new PbrpcException("Could not return the resource to the pool", e); } }
public void invalidate( DelegatingConnection conn ) throws Exception { conn.getDelegate().close(); pool.invalidateObject( conn ); } }
/** * 返回一个调用失败的对象到池中 * * @param resource */ protected void returnBrokenResourceObject(final Object resource) { try { internalPool.invalidateObject(resource); } catch (Exception e) { throw new PbrpcException("Could not return the resource to the pool", e); } }
/** * Call this if the client is unusable (i.e., exception). * * @param client Client to discard. */ public void discard(AuthClient client) { try { pool.invalidateObject(client); } catch (Exception e) { System.out.println("AuthConnection problem destorying"); throw new AuthConnectionException("Failed to destroy client", e); } }
/** * {@inheritDoc} */ @Override public void invalidateComponent(Object component) throws ComponentPoolException { try { pool.invalidateObject(component); } catch (Exception exception) { throw new ComponentPoolException("Cannot invalidate component in pool", exception); } }
/** * Invalidates an object from the pool. * * @param obj object to be returned * @throws Exception if an exception occurs invalidating the object */ public void invalidateObject(Object obj) throws Exception { if (config != null && config.getRemoveAbandoned()) { synchronized (trace) { boolean foundObject = trace.remove(obj); if (!foundObject) { return; // This connection has already been invalidated. Stop now. } } } super.invalidateObject(obj); }
/** * Invalidates an object from the pool. * * @param obj object to be returned * @throws Exception if an exception occurs invalidating the object */ public void invalidateObject(Object obj) throws Exception { if (config != null && config.getRemoveAbandoned()) { synchronized (trace) { boolean foundObject = trace.remove(obj); if (!foundObject) { return; // This connection has already been invalidated. Stop now. } } } super.invalidateObject(obj); }
/** * Invalidates an object from the pool. * * @param obj object to be returned * @throws Exception if an exception occurs invalidating the object */ public void invalidateObject(Object obj) throws Exception { if (config != null && config.getRemoveAbandoned()) { synchronized (trace) { boolean foundObject = trace.remove(obj); if (!foundObject) { return; // This connection has already been invalidated. Stop now. } } } super.invalidateObject(obj); }
public void invalidateTargetChannel(TargetChannel targetChannel) throws Exception { this.connGlobalPool.get(targetChannel.getHttpRoute().toString()).invalidateObject(targetChannel); }
@Override public void destroyObject(Object o) throws Exception { if (((TargetChannel) o).getChannel().isActive()) { if (log.isDebugEnabled()) { log.debug("Original Channel " + ((TargetChannel) o).getChannel().id() + " is returned to the pool. "); } this.genericObjectPool.returnObject(o); } else { if (log.isDebugEnabled()) { log.debug("Original Channel is destroyed. "); } this.genericObjectPool.invalidateObject(o); } }
public void invalidateTargetChannel(TargetChannel targetChannel) throws Exception { targetChannel.setRequestWritten(false); if (targetChannel.getCorrelatedSource() != null) { Map<String, GenericObjectPool> objectPoolMap = targetChannel.getCorrelatedSource().getTargetChannelPool(); try { // Need a null check because SourceHandler side could timeout before TargetHandler side. if (objectPoolMap.get(targetChannel.getHttpRoute().toString()) != null) { objectPoolMap.get(targetChannel.getHttpRoute().toString()).invalidateObject(targetChannel); } } catch (Exception e) { throw new Exception("Cannot invalidate channel from pool", e); } } }
private InvocationHandler makeProxyHandler() throws Exception{ ThriftServiceClient2Proxy handler = null; TServiceClient client = pool.borrowObject(); try { handler = new ThriftServiceClient2Proxy(client); pool.returnObject(client); }catch (Exception e){ pool.invalidateObject(client); throw new ThriftException("获取代理对象失败"); } return handler; }