| | |
| | | * 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.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | 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 static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | |
| | | public class LDAPStatistics |
| | | extends MonitorProvider |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.protocols.ldap.LDAPStatistics"; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | super("LDAP Statistics Monitor Provider"); |
| | | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(parent)); |
| | | |
| | | this.instanceName = instanceName; |
| | | this.parent = parent; |
| | |
| | | public void initializeMonitorProvider(ConfigEntry configEntry) |
| | | throws ConfigException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "initializeMonitorProvider"); |
| | | |
| | | // Throw an exception, because this monitor is not intended to be |
| | | // dynamically loaded from the configuration. Rather, it should be |
| | |
| | | */ |
| | | public String getMonitorInstanceName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getMonitorInstanceName"); |
| | | |
| | | return instanceName; |
| | | } |
| | |
| | | */ |
| | | public long getUpdateInterval() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getUpdateInterval"); |
| | | |
| | | |
| | | // This monitor should not run periodically. |
| | |
| | | */ |
| | | public void updateMonitorData() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "updateMonitorData"); |
| | | |
| | | // No implementation is required since this does not do periodic updates. |
| | | } |
| | |
| | | */ |
| | | public ArrayList<Attribute> getMonitorData() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getMonitorData"); |
| | | |
| | | ArrayList<Attribute> attrs = new ArrayList<Attribute>(29); |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "getMonitorData", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | return attrs; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "getMonitorData", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | return attrs; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "getMonitorData", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | return attrs; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "getMonitorData", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | return attrs; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "getMonitorData", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | return attrs; |
| | | } |
| | |
| | | */ |
| | | public void clearStatistics() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "clearStatistics"); |
| | | |
| | | |
| | | // Quickly grab the locks and store consistent copies of the information. |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "clearStatistics", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "clearStatistics", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "clearStatistics", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "clearStatistics", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "clearStatistics", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | public void updateConnect() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "updateConnect"); |
| | | |
| | | connectLock.lock(); |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "updateConnect", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | public void updateDisconnect() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "updateDisconnect"); |
| | | |
| | | disconnectLock.lock(); |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "updateDisconnect", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | public void updateBytesRead(int bytesRead) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "updateBytesRead", String.valueOf(bytesRead)); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "updateBytesRead", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | public void updateMessageRead(LDAPMessage message) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "updateMessageRead", String.valueOf(message), |
| | | String.valueOf(bytesRead)); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "updateMessagesRead", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | public void updateMessageWritten(LDAPMessage message, int bytesWritten) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "updateMessageWritten", |
| | | String.valueOf(message), String.valueOf(bytesWritten)); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "updateMessageWritten", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | public void updateAbandonedOperation() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "updateAbandonedOperation"); |
| | | |
| | | abandonLock.lock(); |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "updateAbandonedOperation", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | private Attribute createAttribute(String name, String value) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "createAttribute", String.valueOf(name), |
| | | String.valueOf(value)); |
| | | |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "createAttribute", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | values.add(new AttributeValue(encodedValue, encodedValue)); |
| | | } |
| | |
| | | */ |
| | | public long getConnectionsEstablished() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConnectionsEstablished"); |
| | | |
| | | connectLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getConnectionsClosed() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConnectionsClosed"); |
| | | |
| | | disconnectLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getBytesRead() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getBytesRead"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getBytesWritten() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getBytesWritten"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getMessagesRead() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getMessagesRead"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getMessagesWritten() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getMessagesWritten"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getOperationsInitiated() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getOperationsInitiated"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getOperationsCompleted() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getOperationsCompleted"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getOperationsAbandoned() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getOperationsAbandoned"); |
| | | |
| | | abandonLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getAbandonRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getAbandonRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getAddRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getAddRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getAddResponses() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getAddResponses"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getBindRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getBindRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getBindResponses() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getBindResponses"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getCompareRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getCompareRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getCompareResponses() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getCompareResponses"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getDeleteRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getDeleteRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getDeleteResponses() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getDeleteResponses"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getExtendedRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getExtendedRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getExtendedResponses() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getExtendedResponses"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getModifyRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getModifyRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getModifyResponses() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getModifyResponses"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getModifyDNRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getModifyDNRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getModifyDNResponses() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getModifyDNResponses"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getSearchRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSearchRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getSearchResultEntries() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSearchResultEntries"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getSearchResultReferences() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSearchResultReferences"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getSearchResultsDone() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSearchResultsDone"); |
| | | |
| | | writeLock.lock(); |
| | | |
| | |
| | | */ |
| | | public long getUnbindRequests() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getUnbindRequests"); |
| | | |
| | | readLock.lock(); |
| | | |
| | |
| | | */ |
| | | public LDAPStatistics getParent() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getParent"); |
| | | |
| | | return parent; |
| | | } |