@Override public GMLUnmarshaller acquireUnmarshaller() throws Exception { DefaultGMLUnmarshaller unmarshaller = gmlUnmarshallerPool.borrowObject(); gmlUnmarshallerPool.returnObject(unmarshaller); return unmarshaller; }
public TcpClientPool(String host, int port, int timeout) { this.host = host; this.port = port; this.timeout = timeout; pool = new GenericObjectPool<TcpClient>(this); int coreCount = Runtime.getRuntime().availableProcessors() * 2; pool.setMaxTotal(coreCount * 2); pool.setMaxIdle(coreCount); }
public TcpClient getTcpClient() throws Exception { TcpClient client = pool.borrowObject(); if (!client.isConnected()) { client.connect(); } return client; }
protected void closeInternalPool() { try { internalPool.close(); } catch (Exception e) { throw new com.hm.RedssionPoolException("Could not destroy the pool", e); } }
public Redisson getResource() { try { return internalPool.borrowObject(); } catch (Exception e) { throw new RedisConnectionException("Could not get a resource from the pool", e); } }
protected void closeInternalPool() { try { internalPool.close(); } catch (Exception e) { throw new JedisException("Could not destroy the pool", e); } }
protected void returnBrokenResourceObject(final T resource) { try { internalPool.invalidateObject(resource); } catch (Exception e) { throw new JedisException("Could not return the resource to the pool", e); } }
public synchronized void destory() { if (status != 1) { throw new RuntimeException("client is not init or aready destory"); } else { status = 2; } pool.close(); }
protected void returnBrokenResourceObject(final Redisson resource) { try { internalPool.invalidateObject(resource); } catch (Exception e) { throw new com.hm.RedssionPoolException("Could not return the resource to the pool", e); } }
public void returnResourceObject(final T resource) { if (resource == null) { return; } try { internalPool.returnObject(resource); } catch (Exception e) { throw new JedisException("Could not return the resource to the pool", e); } }
public Response call(Request request) throws Exception { if (request == null || request.getServiceName() == null) { throw new RuntimeException("request or request servciename cannot be null"); } if (status != 1) { throw new RuntimeException("client is not init or aready destory"); } Connection connection = null; try { connection = pool.borrowObject(); return connection.call(request); } catch (SocketException e) { connection.close(); throw e; } finally { if (connection != null) { pool.returnObject(connection); } } }
public void recycle(TcpClient client) { if (client != null) { pool.returnObject(client); } }