| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | |
| | | extends DirectoryThread |
| | | implements ServerShutdownListener |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.protocols.ldap.LDAPRequestHandler"; |
| | | |
| | | |
| | | |
| | |
| | | super("LDAP Request Handler " + requestHandlerID + |
| | | " for connection handler " + connectionHandler.toString()); |
| | | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(connectionHandler)); |
| | | |
| | | this.connectionHandler = connectionHandler; |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_REQHANDLER_OPEN_SELECTOR_FAILED; |
| | | String message = getMessage(msgID, handlerName, String.valueOf(e)); |
| | |
| | | */ |
| | | public void run() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "run"); |
| | | |
| | | |
| | | // Operate in a loop until the server shuts down. Each time through the |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "run", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | // FIXME -- Should we do something else with this? |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "run", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | // Some other error occurred while we were trying to read data |
| | | // from the client. |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "run", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | // We got some other kind of error. If nothing else, cancel the |
| | | // key, but if the client connection is available then |
| | |
| | | } |
| | | catch (CancelledKeyException cke) |
| | | { |
| | | assert debugException(CLASS_NAME, "run", cke); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, cke); |
| | | } |
| | | |
| | | // This could happen if a connection was closed between the time |
| | | // that select returned and the time that we try to access the |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "run", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | // This should not happen, and it would have caused our reader |
| | | // thread to die. Log a severe error. |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "run", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | c.disconnect(DisconnectReason.SERVER_ERROR, true, |
| | | MSGID_LDAP_REQHANDLER_CANNOT_REGISTER, handlerName, |
| | |
| | | */ |
| | | public boolean registerClient(LDAPClientConnection clientConnection) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "registerClient", |
| | | String.valueOf(clientConnection)); |
| | | |
| | | // FIXME -- Need to check if the maximum client limit has been reached. |
| | | |
| | |
| | | */ |
| | | public void deregisterClient(LDAPClientConnection clientConnection) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "deregisterClient", |
| | | String.valueOf(clientConnection)); |
| | | |
| | | SelectionKey[] keyArray = selector.keys().toArray(new SelectionKey[0]); |
| | | for (SelectionKey key : keyArray) |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "deregisterClient", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | |
| | | try |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "deregisterClient", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public void deregisterAllClients() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "deregisterAllClients"); |
| | | |
| | | SelectionKey[] keyArray = selector.keys().toArray(new SelectionKey[0]); |
| | | for (SelectionKey key : keyArray) |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "deregisterAllClients", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | |
| | | try |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "deregisterAllClients", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public Collection<LDAPClientConnection> getClientConnections() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getClientConnections"); |
| | | |
| | | SelectionKey[] keyArray = selector.keys().toArray(new SelectionKey[0]); |
| | | |
| | |
| | | */ |
| | | public String getShutdownListenerName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getShutdownListenerName"); |
| | | |
| | | return handlerName; |
| | | } |
| | |
| | | */ |
| | | public void registerShutdownListener() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "registerShutdownListener"); |
| | | |
| | | DirectoryServer.registerShutdownListener(this); |
| | | } |
| | |
| | | */ |
| | | public void processServerShutdown(String reason) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processServerShutdown", |
| | | String.valueOf(reason)); |
| | | |
| | | shutdownRequested = true; |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "processServerShutdown", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "processServerShutdown", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | } |