From 86a13a070a5adbc1d52dbf0943318dc01a3ee62e Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 18 Dec 2006 22:01:00 +0000
Subject: [PATCH] Update the LDAP connection handler and LDAP client connection to properly update the abandon operation count when appropriate. Also, update a number of test cases to verify that the LDAPStatistics information is properly updated.
---
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java | 7
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java | 6
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java | 14
opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java | 684 ++++++++++++++++++++++++++++++++++++++++++
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java | 18 +
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/OperationTestCase.java | 30 +
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AbandonOperationTestCase.java | 77 ++++
opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java | 16 +
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AddOperationTestCase.java | 18 +
opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java | 32 +
10 files changed, 899 insertions(+), 3 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
index c8c22af..147535a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
@@ -1312,7 +1312,15 @@
{
if (ps.getSearchOperation().getMessageID() == messageID)
{
- return ps.getSearchOperation().cancel(cancelRequest);
+ CancelResult cancelResult =
+ ps.getSearchOperation().cancel(cancelRequest);
+
+ if (keepStats && (cancelResult == CancelResult.CANCELED))
+ {
+ statTracker.updateAbandonedOperation();
+ }
+
+ return cancelResult;
}
}
@@ -1320,6 +1328,12 @@
}
else
{
+ CancelResult cancelResult = op.cancel(cancelRequest);
+ if (keepStats && (cancelResult == CancelResult.CANCELED))
+ {
+ statTracker.updateAbandonedOperation();
+ }
+
return op.cancel(cancelRequest);
}
}
@@ -1347,7 +1361,11 @@
{
try
{
- o.cancel(cancelRequest);
+ CancelResult cancelResult = o.cancel(cancelRequest);
+ if (keepStats && (cancelResult == CancelResult.CANCELED))
+ {
+ statTracker.updateAbandonedOperation();
+ }
}
catch (Exception e)
{
@@ -1408,7 +1426,11 @@
{
try
{
- o.cancel(cancelRequest);
+ CancelResult cancelResult = o.cancel(cancelRequest);
+ if (keepStats && (cancelResult == CancelResult.CANCELED))
+ {
+ statTracker.updateAbandonedOperation();
+ }
}
catch (Exception e)
{
@@ -1848,6 +1870,10 @@
protocolOp.getIDToAbandon());
abandonOp.run();
+ if (keepStats && (abandonOp.getResultCode() == ResultCode.CANCELED))
+ {
+ statTracker.updateAbandonedOperation();
+ }
return connectionValid;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
index adb2099..1a20f51 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
@@ -1605,6 +1605,22 @@
/**
+ * Indicates whether this connection handler should use SSL to communicate
+ * with clients.
+ *
+ * @return {@code true} if this connection handler should use SSL to
+ * communicate with clients, or {@code false} if not.
+ */
+ public boolean useSSL()
+ {
+ assert debugEnter(CLASS_NAME, "useSSL");
+
+ return useSSL;
+ }
+
+
+
+ /**
* Retrieves the SSL client authentication policy for this connection handler.
*
* @return The SSL client authentication policy for this connection handler.
diff --git a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
index 7629007..ca75988 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
@@ -918,5 +918,689 @@
return new Attribute(attrType, name, values);
}
+
+
+
+ /**
+ * Retrieves the number of client connections that have been established.
+ *
+ * @return The number of client connections that have been established.
+ */
+ public long getConnectionsEstablished()
+ {
+ assert debugEnter(CLASS_NAME, "getConnectionsEstablished");
+
+ connectLock.lock();
+
+ try
+ {
+ return connectionsEstablished;
+ }
+ finally
+ {
+ connectLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of client connections that have been closed.
+ *
+ * @return The number of client connections that have been closed.
+ */
+ public long getConnectionsClosed()
+ {
+ assert debugEnter(CLASS_NAME, "getConnectionsClosed");
+
+ disconnectLock.lock();
+
+ try
+ {
+ return connectionsClosed;
+ }
+ finally
+ {
+ disconnectLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of bytes that have been received from clients.
+ *
+ * @return The number of bytes that have been received from clients.
+ */
+ public long getBytesRead()
+ {
+ assert debugEnter(CLASS_NAME, "getBytesRead");
+
+ readLock.lock();
+
+ try
+ {
+ return bytesRead;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of bytes that have been written to clients.
+ *
+ * @return The number of bytes that have been written to clients.
+ */
+ public long getBytesWritten()
+ {
+ assert debugEnter(CLASS_NAME, "getBytesWritten");
+
+ writeLock.lock();
+
+ try
+ {
+ return bytesWritten;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of LDAP messages that have been received from clients.
+ *
+ * @return The number of LDAP messages that have been received from clients.
+ */
+ public long getMessagesRead()
+ {
+ assert debugEnter(CLASS_NAME, "getMessagesRead");
+
+ readLock.lock();
+
+ try
+ {
+ return messagesRead;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of LDAP messages that have been written to clients.
+ *
+ * @return The number of LDAP messages that have been written to clients.
+ */
+ public long getMessagesWritten()
+ {
+ assert debugEnter(CLASS_NAME, "getMessagesWritten");
+
+ writeLock.lock();
+
+ try
+ {
+ return messagesWritten;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of operations that have been initiated by clients.
+ *
+ * @return The number of operations that have been initiated by clients.
+ */
+ public long getOperationsInitiated()
+ {
+ assert debugEnter(CLASS_NAME, "getOperationsInitiated");
+
+ readLock.lock();
+
+ try
+ {
+ return operationsInitiated;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of operations for which the server has completed
+ * processing.
+ *
+ * @return The number of operations for which the server has completed
+ * processing.
+ */
+ public long getOperationsCompleted()
+ {
+ assert debugEnter(CLASS_NAME, "getOperationsCompleted");
+
+ writeLock.lock();
+
+ try
+ {
+ return operationsCompleted;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of operations that have been abandoned by clients.
+ *
+ * @return The number of operations that have been abandoned by clients.
+ */
+ public long getOperationsAbandoned()
+ {
+ assert debugEnter(CLASS_NAME, "getOperationsAbandoned");
+
+ abandonLock.lock();
+
+ try
+ {
+ return operationsAbandoned;
+ }
+ finally
+ {
+ abandonLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of abandon requests that have been received.
+ *
+ * @return The number of abandon requests that have been received.
+ */
+ public long getAbandonRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getAbandonRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return abandonRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of add requests that have been received.
+ *
+ * @return The number of add requests that have been received.
+ */
+ public long getAddRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getAddRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return addRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of add responses that have been sent.
+ *
+ * @return The number of add responses that have been sent.
+ */
+ public long getAddResponses()
+ {
+ assert debugEnter(CLASS_NAME, "getAddResponses");
+
+ writeLock.lock();
+
+ try
+ {
+ return addResponses;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of bind requests that have been received.
+ *
+ * @return The number of bind requests that have been received.
+ */
+ public long getBindRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getBindRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return bindRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of bind responses that have been sent.
+ *
+ * @return The number of bind responses that have been sent.
+ */
+ public long getBindResponses()
+ {
+ assert debugEnter(CLASS_NAME, "getBindResponses");
+
+ writeLock.lock();
+
+ try
+ {
+ return bindResponses;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of compare requests that have been received.
+ *
+ * @return The number of compare requests that have been received.
+ */
+ public long getCompareRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getCompareRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return compareRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of compare responses that have been sent.
+ *
+ * @return The number of compare responses that have been sent.
+ */
+ public long getCompareResponses()
+ {
+ assert debugEnter(CLASS_NAME, "getCompareResponses");
+
+ writeLock.lock();
+
+ try
+ {
+ return compareResponses;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of delete requests that have been received.
+ *
+ * @return The number of delete requests that have been received.
+ */
+ public long getDeleteRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getDeleteRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return deleteRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of delete responses that have been sent.
+ *
+ * @return The number of delete responses that have been sent.
+ */
+ public long getDeleteResponses()
+ {
+ assert debugEnter(CLASS_NAME, "getDeleteResponses");
+
+ writeLock.lock();
+
+ try
+ {
+ return deleteResponses;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of extended requests that have been received.
+ *
+ * @return The number of extended requests that have been received.
+ */
+ public long getExtendedRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getExtendedRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return extendedRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of extended responses that have been sent.
+ *
+ * @return The number of extended responses that have been sent.
+ */
+ public long getExtendedResponses()
+ {
+ assert debugEnter(CLASS_NAME, "getExtendedResponses");
+
+ writeLock.lock();
+
+ try
+ {
+ return extendedResponses;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of modify requests that have been received.
+ *
+ * @return The number of modify requests that have been received.
+ */
+ public long getModifyRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getModifyRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return modifyRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of modify responses that have been sent.
+ *
+ * @return The number of modify responses that have been sent.
+ */
+ public long getModifyResponses()
+ {
+ assert debugEnter(CLASS_NAME, "getModifyResponses");
+
+ writeLock.lock();
+
+ try
+ {
+ return modifyResponses;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of modify DN requests that have been received.
+ *
+ * @return The number of modify DN requests that have been received.
+ */
+ public long getModifyDNRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getModifyDNRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return modifyDNRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of modify DN responses that have been sent.
+ *
+ * @return The number of modify DN responses that have been sent.
+ */
+ public long getModifyDNResponses()
+ {
+ assert debugEnter(CLASS_NAME, "getModifyDNResponses");
+
+ writeLock.lock();
+
+ try
+ {
+ return modifyDNResponses;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of search requests that have been received.
+ *
+ * @return The number of search requests that have been received.
+ */
+ public long getSearchRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getSearchRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return searchRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of search result entries that have been sent.
+ *
+ * @return The number of search result entries that have been sent.
+ */
+ public long getSearchResultEntries()
+ {
+ assert debugEnter(CLASS_NAME, "getSearchResultEntries");
+
+ writeLock.lock();
+
+ try
+ {
+ return searchResultEntries;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of search result references that have been sent.
+ *
+ * @return The number of search result references that have been sent.
+ */
+ public long getSearchResultReferences()
+ {
+ assert debugEnter(CLASS_NAME, "getSearchResultReferences");
+
+ writeLock.lock();
+
+ try
+ {
+ return searchResultReferences;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of search result done messages that have been sent.
+ *
+ * @return The number of search result done messages that have been sent.
+ */
+ public long getSearchResultsDone()
+ {
+ assert debugEnter(CLASS_NAME, "getSearchResultsDone");
+
+ writeLock.lock();
+
+ try
+ {
+ return searchResultsDone;
+ }
+ finally
+ {
+ writeLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the number of unbind requests that have been received.
+ *
+ * @return The number of unbind requests that have been received.
+ */
+ public long getUnbindRequests()
+ {
+ assert debugEnter(CLASS_NAME, "getUnbindRequests");
+
+ readLock.lock();
+
+ try
+ {
+ return unbindRequests;
+ }
+ finally
+ {
+ readLock.unlock();
+ }
+ }
+
+
+
+ /**
+ * Retrieves the parent statistics tracker that will also be updated whenever
+ * this tracker is updated.
+ *
+ * @return The parent statistics tracker, or {@code null} if there is none.
+ */
+ public LDAPStatistics getParent()
+ {
+ assert debugEnter(CLASS_NAME, "getParent");
+
+ return parent;
+ }
}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AbandonOperationTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AbandonOperationTestCase.java
index 5bbb1c6..93c36f7 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AbandonOperationTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AbandonOperationTestCase.java
@@ -311,6 +311,10 @@
assertEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS);
+ long abandonRequests = ldapStatistics.getAbandonRequests();
+ long abandonsCompleted = ldapStatistics.getOperationsAbandoned();
+
+
// Create an add request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
@@ -346,6 +350,9 @@
AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp();
assertEquals(addResponse.getResultCode(), LDAPResultCode.CANCELED);
+ assertEquals(ldapStatistics.getAbandonRequests(), abandonRequests+1);
+ waitForAbandon(abandonsCompleted+1);
+
s.close();
assertTrue(InvocationCounterPlugin.getPostConnectCount() > 0);
@@ -384,6 +391,10 @@
assertEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS);
+ long abandonRequests = ldapStatistics.getAbandonRequests();
+ long abandonsCompleted = ldapStatistics.getOperationsAbandoned();
+
+
// Create a compare request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
@@ -410,6 +421,9 @@
message.getCompareResponseProtocolOp();
assertEquals(compareResponse.getResultCode(), LDAPResultCode.CANCELED);
+ assertEquals(ldapStatistics.getAbandonRequests(), abandonRequests+1);
+ waitForAbandon(abandonsCompleted+1);
+
s.close();
assertTrue(InvocationCounterPlugin.getPostConnectCount() > 0);
@@ -462,6 +476,10 @@
assertEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS);
+ long abandonRequests = ldapStatistics.getAbandonRequests();
+ long abandonsCompleted = ldapStatistics.getOperationsAbandoned();
+
+
// Create a delete request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
@@ -487,6 +505,9 @@
message.getDeleteResponseProtocolOp();
assertEquals(deleteResponse.getResultCode(), LDAPResultCode.CANCELED);
+ assertEquals(ldapStatistics.getAbandonRequests(), abandonRequests+1);
+ waitForAbandon(abandonsCompleted+1);
+
s.close();
assertTrue(InvocationCounterPlugin.getPostConnectCount() > 0);
@@ -525,6 +546,10 @@
assertEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS);
+ long abandonRequests = ldapStatistics.getAbandonRequests();
+ long abandonsCompleted = ldapStatistics.getOperationsAbandoned();
+
+
// Create a "Who Am I?" extended oepration and send it to the server. Make
// sure to include the delay request control so it won't complete before we
// can send the abandon request.
@@ -550,6 +575,9 @@
message.getExtendedResponseProtocolOp();
assertEquals(extendedResponse.getResultCode(), LDAPResultCode.CANCELED);
+ assertEquals(ldapStatistics.getAbandonRequests(), abandonRequests+1);
+ waitForAbandon(abandonsCompleted+1);
+
s.close();
assertTrue(InvocationCounterPlugin.getPostConnectCount() > 0);
@@ -588,6 +616,10 @@
assertEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS);
+ long abandonRequests = ldapStatistics.getAbandonRequests();
+ long abandonsCompleted = ldapStatistics.getOperationsAbandoned();
+
+
// Create a modify request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
@@ -620,6 +652,9 @@
message.getModifyResponseProtocolOp();
assertEquals(modifyResponse.getResultCode(), LDAPResultCode.CANCELED);
+ assertEquals(ldapStatistics.getAbandonRequests(), abandonRequests+1);
+ waitForAbandon(abandonsCompleted+1);
+
s.close();
assertTrue(InvocationCounterPlugin.getPostConnectCount() > 0);
@@ -672,6 +707,10 @@
assertEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS);
+ long abandonRequests = ldapStatistics.getAbandonRequests();
+ long abandonsCompleted = ldapStatistics.getOperationsAbandoned();
+
+
// Create a modify DN request and send it to the server. Make sure to
// include the delay request control so it won't complete before we can send
// the abandon request.
@@ -698,6 +737,9 @@
message.getModifyDNResponseProtocolOp();
assertEquals(modifyDNResponse.getResultCode(), LDAPResultCode.CANCELED);
+ assertEquals(ldapStatistics.getAbandonRequests(), abandonRequests+1);
+ waitForAbandon(abandonsCompleted+1);
+
s.close();
assertTrue(InvocationCounterPlugin.getPostConnectCount() > 0);
@@ -736,6 +778,10 @@
assertEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS);
+ long abandonRequests = ldapStatistics.getAbandonRequests();
+ long abandonsCompleted = ldapStatistics.getOperationsAbandoned();
+
+
// Create a search request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
@@ -766,10 +812,41 @@
message.getSearchResultDoneProtocolOp();
assertEquals(searchDone.getResultCode(), LDAPResultCode.CANCELED);
+ assertEquals(ldapStatistics.getAbandonRequests(), abandonRequests+1);
+ waitForAbandon(abandonsCompleted+1);
+
s.close();
assertTrue(InvocationCounterPlugin.getPostConnectCount() > 0);
assertTrue(InvocationCounterPlugin.getPreParseCount() > 0);
}
+
+
+
+ /**
+ * Waits up to ten seconds for the abandoned operation count to reach the
+ * expected value.
+ *
+ * @param expectedCount The abandon count the server is expected to reach.
+ *
+ * @throws Exception If an unexpected problem occurs.
+ */
+ private void waitForAbandon(long expectedCount)
+ throws Exception
+ {
+ long stopTime = System.currentTimeMillis() + 10000;
+ while (System.currentTimeMillis() < stopTime)
+ {
+ if (ldapStatistics.getOperationsAbandoned() == expectedCount)
+ {
+ return;
+ }
+
+ Thread.sleep(10);
+ }
+
+ throw new AssertionError("Expected abandon count of " + expectedCount +
+ " but got " + ldapStatistics.getOperationsAbandoned());
+ }
}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AddOperationTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AddOperationTestCase.java
index a523cf8..ccda84b 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AddOperationTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/AddOperationTestCase.java
@@ -855,6 +855,9 @@
values.add(new ASN1OctetString("20060101000000Z"));
attrs.add(new LDAPAttribute("createTimestamp", values));
+ long addRequests = ldapStatistics.getAddRequests();
+ long addResponses = ldapStatistics.getAddResponses();
+
AddRequestProtocolOp addRequest =
new AddRequestProtocolOp(new ASN1OctetString("ou=People,o=test"),
attrs);
@@ -866,6 +869,9 @@
message.getAddResponseProtocolOp();
assertFalse(addResponse.getResultCode() == 0);
+ assertEquals(ldapStatistics.getAddRequests(), addRequests+1);
+ assertEquals(ldapStatistics.getAddResponses(), addResponses+1);
+
try
{
s.close();
@@ -1650,6 +1656,9 @@
DirectoryServer.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
+ long addRequests = ldapStatistics.getAddRequests();
+ long addResponses = ldapStatistics.getAddResponses();
+
AddRequestProtocolOp addRequest =
new AddRequestProtocolOp(new ASN1OctetString("ou=People,o=test"),
attrs);
@@ -1661,6 +1670,9 @@
message.getAddResponseProtocolOp();
assertFalse(addResponse.getResultCode() == 0);
+ assertEquals(ldapStatistics.getAddRequests(), addRequests+1);
+ assertEquals(ldapStatistics.getAddResponses(), addResponses+1);
+
try
{
s.close();
@@ -1796,6 +1808,9 @@
Backend b = DirectoryServer.getBackend(DN.decode("o=test"));
b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
+ long addRequests = ldapStatistics.getAddRequests();
+ long addResponses = ldapStatistics.getAddResponses();
+
AddRequestProtocolOp addRequest =
new AddRequestProtocolOp(new ASN1OctetString("ou=People,o=test"),
attrs);
@@ -1807,6 +1822,9 @@
message.getAddResponseProtocolOp();
assertFalse(addResponse.getResultCode() == 0);
+ assertEquals(ldapStatistics.getAddRequests(), addRequests+1);
+ assertEquals(ldapStatistics.getAddResponses(), addResponses+1);
+
try
{
s.close();
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java
index 2051d57..347acd8 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java
@@ -635,6 +635,9 @@
{
InvocationCounterPlugin.resetAllCounters();
+ long compareRequests = ldapStatistics.getCompareRequests();
+ long compareResponses = ldapStatistics.getCompareResponses();
+
CompareRequestProtocolOp compareRequest =
new CompareRequestProtocolOp(
new ASN1OctetString(entry.getDN().toString()),
@@ -654,6 +657,9 @@
assertEquals(InvocationCounterPlugin.getPostOperationCount(), 0);
// The post response might not have been called yet.
assertEquals(InvocationCounterPlugin.waitForPostResponse(), 1);
+
+ assertEquals(ldapStatistics.getCompareRequests(), compareRequests+1);
+ assertEquals(ldapStatistics.getCompareResponses(), compareResponses+1);
} finally
{
LockManager.unlock(entry.getDN(), writeLock);
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java
index 4650f5f..87560ff 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java
@@ -3549,6 +3549,9 @@
ArrayList<LDAPModification> mods = new ArrayList<LDAPModification>();
mods.add(new LDAPModification(ModificationType.REPLACE, attr));
+ long modifyRequests = ldapStatistics.getModifyRequests();
+ long modifyResponses = ldapStatistics.getModifyResponses();
+
ModifyRequestProtocolOp modifyRequest =
new ModifyRequestProtocolOp(
new ASN1OctetString("uid=test.user," + baseDN), mods);
@@ -3559,6 +3562,9 @@
ModifyResponseProtocolOp modifyResponse =
message.getModifyResponseProtocolOp();
assertFalse(modifyResponse.getResultCode() == 0);
+
+ assertEquals(ldapStatistics.getModifyRequests(), modifyRequests+1);
+ assertEquals(ldapStatistics.getModifyResponses(), modifyResponses+1);
}
@@ -3737,6 +3743,9 @@
ArrayList<LDAPModification> mods = new ArrayList<LDAPModification>();
mods.add(new LDAPModification(ModificationType.ADD, attr));
+ long modifyRequests = ldapStatistics.getModifyRequests();
+ long modifyResponses = ldapStatistics.getModifyResponses();
+
ModifyRequestProtocolOp modifyRequest =
new ModifyRequestProtocolOp(
new ASN1OctetString("uid=test.user," + baseDN), mods);
@@ -3748,6 +3757,9 @@
message.getModifyResponseProtocolOp();
assertFalse(modifyResponse.getResultCode() == 0);
+ assertEquals(ldapStatistics.getModifyRequests(), modifyRequests+1);
+ assertEquals(ldapStatistics.getModifyResponses(), modifyResponses+1);
+
DirectoryServer.setWritabilityMode(WritabilityMode.ENABLED);
}
@@ -3930,6 +3942,9 @@
ArrayList<LDAPModification> mods = new ArrayList<LDAPModification>();
mods.add(new LDAPModification(ModificationType.ADD, attr));
+ long modifyRequests = ldapStatistics.getModifyRequests();
+ long modifyResponses = ldapStatistics.getModifyResponses();
+
ModifyRequestProtocolOp modifyRequest =
new ModifyRequestProtocolOp(
new ASN1OctetString("uid=test.user," + baseDN), mods);
@@ -3941,6 +3956,9 @@
message.getModifyResponseProtocolOp();
assertFalse(modifyResponse.getResultCode() == 0);
+ assertEquals(ldapStatistics.getModifyRequests(), modifyRequests+1);
+ assertEquals(ldapStatistics.getModifyResponses(), modifyResponses+1);
+
b.setWritabilityMode(WritabilityMode.ENABLED);
}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/OperationTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/OperationTestCase.java
index f99cd0b..dbf1ec6 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/OperationTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/OperationTestCase.java
@@ -33,6 +33,9 @@
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
+import org.opends.server.api.ConnectionHandler;
+import org.opends.server.protocols.ldap.LDAPConnectionHandler;
+import org.opends.server.protocols.ldap.LDAPStatistics;
import org.opends.server.types.Control;
import org.opends.server.types.ResultCode;
@@ -46,6 +49,14 @@
public abstract class OperationTestCase
extends CoreTestCase
{
+ // The LDAPStatistics object associated with the LDAP connection handler.
+ protected LDAPStatistics ldapStatistics;
+
+ // The LDAPStatistics object associated with the LDAPS connection handler.
+ protected LDAPStatistics ldapsStatistics;
+
+
+
/**
* Ensures that the Directory Server is running.
*
@@ -56,6 +67,25 @@
throws Exception
{
TestCaseUtils.startServer();
+
+ for (ConnectionHandler ch : DirectoryServer.getConnectionHandlers())
+ {
+ if (ch instanceof LDAPConnectionHandler)
+ {
+ LDAPConnectionHandler lch = (LDAPConnectionHandler) ch;
+ if (lch.useSSL())
+ {
+ ldapsStatistics = lch.getStatTracker();
+ }
+ else
+ {
+ ldapStatistics = lch.getStatTracker();
+ }
+ }
+ }
+
+ assertNotNull(ldapStatistics);
+ assertNotNull(ldapsStatistics);
}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
index 3af728e..abfd9bc 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
@@ -255,6 +255,11 @@
InvocationCounterPlugin.resetAllCounters();
+ long searchRequests = ldapStatistics.getSearchRequests();
+ long searchEntries = ldapStatistics.getSearchResultEntries();
+ long searchReferences = ldapStatistics.getSearchResultReferences();
+ long searchesDone = ldapStatistics.getSearchResultsDone();
+
LDAPMessage message;
message = new LDAPMessage(2, searchRequest, controls);
w.writeElement(message.encode());
@@ -269,9 +274,11 @@
{
case LDAPConstants.OP_TYPE_SEARCH_RESULT_ENTRY:
searchResultEntry = message.getSearchResultEntryProtocolOp();
+ searchEntries++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_REFERENCE:
+ searchReferences++;
break;
case LDAPConstants.OP_TYPE_SEARCH_RESULT_DONE:
@@ -279,10 +286,17 @@
assertEquals(searchResultDone.getResultCode(),
LDAPResultCode.SUCCESS);
assertEquals(InvocationCounterPlugin.waitForPostResponse(), 1);
+ searchesDone++;
break;
}
}
+ assertEquals(ldapStatistics.getSearchRequests(), searchRequests+1);
+ assertEquals(ldapStatistics.getSearchResultEntries(), searchEntries);
+ assertEquals(ldapStatistics.getSearchResultReferences(),
+ searchReferences);
+ assertEquals(ldapStatistics.getSearchResultsDone(), searchesDone);
+
return searchResultEntry;
}
finally
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java
index ab7671f..5b731e9 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java
@@ -1172,6 +1172,9 @@
{
InvocationCounterPlugin.resetAllCounters();
+ long modifyDNRequests = ldapStatistics.getModifyDNRequests();
+ long modifyDNResponses = ldapStatistics.getModifyDNResponses();
+
ModifyDNRequestProtocolOp modifyRequest =
new ModifyDNRequestProtocolOp(
new ASN1OctetString(entry.getDN().toString()),
@@ -1191,6 +1194,10 @@
assertEquals(InvocationCounterPlugin.getPostOperationCount(), 0);
// The post response might not have been called yet.
assertEquals(InvocationCounterPlugin.waitForPostResponse(), 1);
+
+ assertEquals(ldapStatistics.getModifyDNRequests(), modifyDNRequests+1);
+ assertEquals(ldapStatistics.getModifyDNResponses(),
+ modifyDNResponses+1);
} finally
{
LockManager.unlock(entry.getDN(), writeLock);
--
Gitblit v1.10.0