directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1415012 - in /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap: ./ handlers/request/ handlers/response/
Date Thu, 29 Nov 2012 00:35:25 GMT
Author: elecharny
Date: Thu Nov 29 00:35:24 2012
New Revision: 1415012

URL: http://svn.apache.org/viewvc?rev=1415012&view=rev
Log:
o Register each searchRequest into the session, to be handled by the messageSent handlers
o Added some preliminary code to deal with the MessageSent event for SRE and SRD
o Added a Map in LdapSession to store the pending SearchRequests

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultDoneHandler.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultEntryHandler.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java?rev=1415012&r1=1415011&r2=1415012&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
Thu Nov 29 00:35:24 2012
@@ -28,11 +28,15 @@ import java.util.concurrent.ConcurrentHa
 
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.LdapPrincipal;
+import org.apache.directory.server.core.api.SearchRequestContainer;
 import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.ldap.handlers.controls.PagedSearchContext;
+import org.apache.directory.shared.ldap.model.cursor.Cursor;
+import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.message.AbandonableRequest;
 import org.apache.directory.shared.ldap.model.message.BindStatus;
+import org.apache.directory.shared.ldap.model.message.SearchRequest;
 import org.apache.mina.core.session.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -73,6 +77,9 @@ public class LdapSession
     /** A map of all the running requests */
     private Map<Integer, AbandonableRequest> outstandingRequests;
 
+    /** A map of all the pending search requests */
+    private Map<Integer, SearchRequestContainer> searchRequests;
+
     /** The current Bind status */
     private BindStatus bindStatus;
 
@@ -99,6 +106,7 @@ public class LdapSession
         this.ioSession = ioSession;
         outstandingLock = "OutstandingRequestLock: " + ioSession.toString();
         outstandingRequests = new ConcurrentHashMap<Integer, AbandonableRequest>();
+        searchRequests = new ConcurrentHashMap<Integer, SearchRequestContainer>();
         bindStatus = BindStatus.ANONYMOUS;
         saslProperties = new HashMap<String, Object>();
         pagedSearchContexts = new ConcurrentHashMap<Integer, PagedSearchContext>();
@@ -292,8 +300,8 @@ public class LdapSession
             outstandingRequests.remove( request.getMessageId() );
         }
     }
-
-
+    
+    
     /**
      * @return A list of all the abandonable requests for this session.
      */
@@ -305,6 +313,43 @@ public class LdapSession
         }
     }
 
+    
+    /**
+     * Registers a new searchRequest
+     *
+     * @param searchRequest a new searchRequest
+     */
+    public void registerSearchRequest( SearchRequest searchRequest, Cursor<Entry> cursor
)
+    {
+        synchronized ( outstandingLock )
+        {
+            SearchRequestContainer searchRequestContainer = new SearchRequestContainer( searchRequest,
cursor );
+            searchRequests.put( searchRequest.getMessageId(), searchRequestContainer );
+        }
+    }
+
+
+    /**
+     * Unregisters a completed search request.
+     *
+     * @param searchRequest the searchRequest to unregister
+     */
+    public void unregisterSearchRequest( SearchRequest searchRequest )
+    {
+        searchRequests.remove( searchRequest.getMessageId() );
+    }
+
+
+    /**
+     * Find the searchRequestContainer associated with a MessageID
+     *
+     * @param messageId the SearchRequestContainer MessageID we are looking for
+     */
+    public SearchRequestContainer getSearchRequest( int messageId )
+    {
+        return searchRequests.get( messageId );
+    }
+
 
     /**
      * @return the current bind status for this session

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java?rev=1415012&r1=1415011&r2=1415012&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
Thu Nov 29 00:35:24 2012
@@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.ReferralManager;
+import org.apache.directory.server.core.api.SearchRequestContainer;
 import org.apache.directory.server.core.api.entry.ClonedServerEntry;
 import org.apache.directory.server.core.api.event.EventType;
 import org.apache.directory.server.core.api.event.NotificationCriteria;
@@ -806,6 +807,9 @@ public class SearchRequestHandler extend
         // No cursor : do a search.
         EntryFilteringCursor cursor = session.getCoreSession().search( req );
 
+        // register the request in the session
+        session.registerSearchRequest( req, cursor );
+
         // Position the cursor at the beginning
         cursor.beforeFirst();
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultDoneHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultDoneHandler.java?rev=1415012&r1=1415011&r2=1415012&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultDoneHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultDoneHandler.java
Thu Nov 29 00:35:24 2012
@@ -20,6 +20,7 @@
 package org.apache.directory.server.ldap.handlers.response;
 
 
+import org.apache.directory.server.core.api.SearchRequestContainer;
 import org.apache.directory.server.ldap.LdapSession;
 import org.apache.directory.server.ldap.handlers.LdapResponseHandler;
 import org.apache.directory.shared.ldap.model.message.SearchResultDone;
@@ -38,5 +39,18 @@ public class SearchResultDoneHandler ext
     public void handle( LdapSession session, SearchResultDone searchResultDone ) throws Exception
     {
         LOG.debug( "Message Sent : {}", searchResultDone );
+        SearchRequestContainer searchRequestContainer = session.getSearchRequest( searchResultDone.getMessageId()
);
+        
+        if ( searchRequestContainer == null )
+        {
+            // We have had an exception
+            //System.out.println( "SearchResultDone : " + searchResultDone );
+        }
+        else
+        {
+            //System.out.println( "SearchResultDone : " + searchRequestContainer );
+            // Unregister the request from the session
+            session.unregisterSearchRequest( searchRequestContainer.getSearchRequest() );
+        }
     }
 }

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultEntryHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultEntryHandler.java?rev=1415012&r1=1415011&r2=1415012&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultEntryHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/response/SearchResultEntryHandler.java
Thu Nov 29 00:35:24 2012
@@ -20,6 +20,7 @@
 package org.apache.directory.server.ldap.handlers.response;
 
 
+import org.apache.directory.server.core.api.SearchRequestContainer;
 import org.apache.directory.server.ldap.LdapSession;
 import org.apache.directory.server.ldap.handlers.LdapResponseHandler;
 import org.apache.directory.shared.ldap.model.message.SearchResultEntry;
@@ -38,5 +39,13 @@ public class SearchResultEntryHandler ex
     public void handle( LdapSession session, SearchResultEntry searchResultEntry ) throws
Exception
     {
         LOG.debug( "Message Sent : {}", searchResultEntry );
+        SearchRequestContainer searchRequestContainer = session.getSearchRequest( searchResultEntry.getMessageId()
);
+        
+        if ( searchRequestContainer != null )
+        {
+            searchRequestContainer.increment();
+        }
+        
+        //System.out.println( "SearchResultEntry : " + searchRequestContainer );
     }
 }



Mime
View raw message