@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;
 }
Ejemplo n.º 4
0
 protected void closeInternalPool() {
   try {
     internalPool.close();
   } catch (Exception e) {
     throw new com.hm.RedssionPoolException("Could not destroy the pool", e);
   }
 }
Ejemplo n.º 5
0
 public Redisson getResource() {
   try {
     return internalPool.borrowObject();
   } catch (Exception e) {
     throw new RedisConnectionException("Could not get a resource from the pool", e);
   }
 }
Ejemplo n.º 6
0
 protected void closeInternalPool() {
   try {
     internalPool.close();
   } catch (Exception e) {
     throw new JedisException("Could not destroy the pool", e);
   }
 }
Ejemplo n.º 7
0
 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);
   }
 }
Ejemplo n.º 8
0
 public synchronized void destory() {
   if (status != 1) {
     throw new RuntimeException("client is not init or aready destory");
   } else {
     status = 2;
   }
   pool.close();
 }
Ejemplo n.º 9
0
  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);
    }
  }
Ejemplo n.º 10
0
 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);
   }
 }
Ejemplo n.º 11
0
 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);
   }
 }