示例#1
0
    @Override
    public Connection<CL> createConnection() {

      try {
        Connection<CL> connection =
            connFactory.createConnection((HostConnectionPool<CL>) pool, null);
        connection.open();
        availableConnections.add(connection);

        monitor.incConnectionCreated(host);
        numActiveConnections.incrementAndGet();

        return connection;
      } catch (DynoConnectException e) {
        if (Logger.isDebugEnabled()) {
          if (monitor.getConnectionCreateFailedCount() % 10000 == 0) {
            Logger.error("Failed to create connection", e);
          }
        }
        monitor.incConnectionCreateFailed(host, e);
        throw e;
      } catch (RuntimeException e) {
        if (Logger.isDebugEnabled()) {
          if (monitor.getConnectionCreateFailedCount() % 10000 == 0) {
            Logger.error("Failed to create connection", e);
          }
        }
        monitor.incConnectionCreateFailed(host, e);
        throw new DynoConnectException(e);
      }
    }
示例#2
0
 @Override
 public boolean closeConnection(Connection<CL> connection) {
   try {
     connection.close();
     return true;
   } catch (Exception e) {
     Logger.warn("Failed to close connection for host: " + host + " " + e.getMessage());
     return false;
   } finally {
     numActiveConnections.decrementAndGet();
     monitor.incConnectionClosed(host, connection.getLastException());
   }
 }