/** * Performs any necessary cleanup to ensure that this connection is properly * closed before it is garbage collected. * * @throws Throwable If the superclass finalizer throws an exception. */ @Override() protected void finalize() throws Throwable { super.finalize(); setDisconnectInfo(DisconnectType.CLOSED_BY_FINALIZER, null, null); setClosed(); }
/** * Performs any necessary cleanup to ensure that this connection is properly * closed before it is garbage collected. * * @throws Throwable If the superclass finalizer throws an exception. */ @Override() protected void finalize() throws Throwable { super.finalize(); setDisconnectInfo(DisconnectType.CLOSED_BY_FINALIZER, null, null); setClosed(); }
/** * {@inheritDoc} */ @Override() protected void doHealthCheck() { final Iterator<Map.Entry<Thread,LDAPConnection>> iterator = connections.entrySet().iterator(); while (iterator.hasNext()) { final Map.Entry<Thread,LDAPConnection> e = iterator.next(); final Thread t = e.getKey(); final LDAPConnection c = e.getValue(); if (! t.isAlive()) { c.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_UNNEEDED, null, null); c.terminate(null); iterator.remove(); } } }
/** * Performs the real work of terminating a defunct connection and replacing it * with a new connection if possible. * * @param connection The defunct connection to be replaced. */ private void handleDefunctConnection(final LDAPConnection connection) { final Thread t = Thread.currentThread(); connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, null, null); connection.terminate(null); connections.remove(t); if (closed) { return; } try { final LDAPConnection conn = createConnection(); connections.put(t, conn); } catch (LDAPException le) { debugException(le); } }
/** * Unbinds from the server and closes the connection, optionally including * the provided set of controls in the unbind request. * <BR><BR> * If this method is invoked while any operations are in progress on this * connection, then the directory server may or may not abort processing for * those operations, depending on the type of operation and how far along the * server has already gotten while processing that operation. It is * recommended that all active operations be abandoned, canceled, or allowed * to complete before attempting to close an active connection. * * @param controls The set of controls to include in the unbind request. It * may be {@code null} if there are not to be any controls * sent in the unbind request. */ public void close(final Control[] controls) { closeRequested = true; setDisconnectInfo(DisconnectType.UNBIND, null, null); if (connectionPool == null) { terminate(controls); } else { connectionPool.releaseDefunctConnection(this); } }
/** * Indicates that the provided connection should be removed from the pool, * and that no new connection should be created to take its place. This may * be used to shrink the pool if such functionality is desired. * * @param connection The connection to be discarded. */ public void discardConnection(final LDAPConnection connection) { if (connection == null) { return; } connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_UNNEEDED, null, null); connection.terminate(null); poolStatistics.incrementNumConnectionsClosedUnneeded(); if (availableConnections.remainingCapacity() > 0) { final int newReplaceCount = failedReplaceCount.incrementAndGet(); if (newReplaceCount > numConnections) { failedReplaceCount.set(numConnections); } } }
/** * Indicates that the provided connection should be removed from the pool, * and that no new connection should be created to take its place. This may * be used to shrink the pool if such functionality is desired. * * @param connection The connection to be discarded. */ public void discardConnection(final LDAPConnection connection) { if (connection == null) { return; } connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_UNNEEDED, null, null); connection.terminate(null); poolStatistics.incrementNumConnectionsClosedUnneeded(); if (availableConnections.remainingCapacity() > 0) { final int newReplaceCount = failedReplaceCount.incrementAndGet(); if (newReplaceCount > numConnections) { failedReplaceCount.set(numConnections); } } }
/** * {@inheritDoc} */ @Override() public LDAPConnection replaceDefunctConnection( final LDAPConnection connection) throws LDAPException { poolStatistics.incrementNumConnectionsClosedDefunct(); connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, null, null); connection.terminate(null); connections.remove(Thread.currentThread(), connection); if (closed) { throw new LDAPException(ResultCode.CONNECT_ERROR, ERR_POOL_CLOSED.get()); } final LDAPConnection newConnection = createConnection(); connections.put(Thread.currentThread(), newConnection); return newConnection; }
/** * Unbinds from the server and closes the connection, optionally including * the provided set of controls in the unbind request. * <BR><BR> * If this method is invoked while any operations are in progress on this * connection, then the directory server may or may not abort processing for * those operations, depending on the type of operation and how far along the * server has already gotten while processing that operation. It is * recommended that all active operations be abandoned, canceled, or allowed * to complete before attempting to close an active connection. * * @param controls The set of controls to include in the unbind request. It * may be {@code null} if there are not to be any controls * sent in the unbind request. */ @ThreadSafety(level=ThreadSafetyLevel.METHOD_NOT_THREADSAFE) public void close(final Control[] controls) { closeRequested = true; setDisconnectInfo(DisconnectType.UNBIND, null, null); if (connectionPool == null) { terminate(controls); } else { connectionPool.releaseDefunctConnection(this); } }
conn.setDisconnectInfo(DisconnectType.POOL_CLOSED, null, null); if (unbind)
/** * {@inheritDoc} */ @Override() public LDAPConnection replaceDefunctConnection( final LDAPConnection connection) throws LDAPException { poolStatistics.incrementNumConnectionsClosedDefunct(); connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, null, null); connection.terminate(null); if (closed) { throw new LDAPException(ResultCode.CONNECT_ERROR, ERR_POOL_CLOSED.get()); } return createConnection(); }
/** * {@inheritDoc} */ @Override() public LDAPConnection replaceDefunctConnection( final LDAPConnection connection) throws LDAPException { poolStatistics.incrementNumConnectionsClosedDefunct(); connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, null, null); connection.terminate(null); if (closed) { throw new LDAPException(ResultCode.CONNECT_ERROR, ERR_POOL_CLOSED.get()); } return createConnection(); }
/** * Closes the connection. */ public void run() { final AbstractConnectionPool pool = connection.getConnectionPool(); if (pool != null) { final LDAPConnectionPoolStatistics stats = pool.getConnectionPoolStatistics(); if (stats != null) { stats.incrementNumConnectionsClosedUnneeded(); } } connection.setDisconnectInfo(DisconnectType.POOL_CLOSED, null, null); if (unbind) { connection.terminate(null); } else { connection.setClosed(); } } }
setDisconnectInfo(DisconnectType.BIND_FAILED, null, le); close(); throw le;
setDisconnectInfo(DisconnectType.BIND_FAILED, null, le); close(); throw le;
/** * Closes the connection. */ public void run() { final AbstractConnectionPool pool = connection.getConnectionPool(); if (pool != null) { final LDAPConnectionPoolStatistics stats = pool.getConnectionPoolStatistics(); if (stats != null) { stats.incrementNumConnectionsClosedUnneeded(); } } connection.setDisconnectInfo(DisconnectType.POOL_CLOSED, null, null); if (unbind) { connection.terminate(null); } else { connection.setClosed(); } } }
connections.put(Thread.currentThread(), newConnection); connection.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_EXPIRED, null, null); connection.terminate(null);
getExceptionMessage(e)); conn.setDisconnectInfo(DisconnectType.POOLED_CONNECTION_DEFUNCT, msg, e); throw new LDAPException(ResultCode.SERVER_DOWN, msg, e);
setDisconnectInfo(DisconnectType.UNBIND, null, null); if (debugEnabled(DebugType.LDAP))
setDisconnectInfo(DisconnectType.UNBIND, null, null); if (debugEnabled(DebugType.LDAP))