directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r755337 - in /directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl: ConsumerCallback.java LdapConnectionImpl.java SyncreplConsumer.java
Date Tue, 17 Mar 2009 18:08:56 GMT
Author: kayyagari
Date: Tue Mar 17 18:08:55 2009
New Revision: 755337

URL: http://svn.apache.org/viewvc?rev=755337&view=rev
Log:
o implemented a new method to handle the sessionclosed event with a connected master server
o removed a unused(now) variable

Modified:
    directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/ConsumerCallback.java
    directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java
    directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/ConsumerCallback.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/ConsumerCallback.java?rev=755337&r1=755336&r2=755337&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/ConsumerCallback.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/ConsumerCallback.java
Tue Mar 17 18:08:55 2009
@@ -70,4 +70,11 @@
      * @param searchRef the SearchResultReference message
      */
     void handleSearchReference( SearchResultReference searchRef );
+    
+    
+    /**
+     * tries to reconnect and resume sync operation with the configured master server
+     * when an existing session is closed.
+     */
+    void handleSessionClosed();
 }

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java?rev=755337&r1=755336&r2=755337&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java
Tue Mar 17 18:08:55 2009
@@ -699,6 +699,7 @@
     public void sessionClosed(IoSession session) throws Exception 
     {
         LOG.debug( "-------> Session Closed <-------" );
+        consumer.handleSessionClosed();
     }
 
     

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java?rev=755337&r1=755336&r2=755337&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java
Tue Mar 17 18:08:55 2009
@@ -487,32 +487,60 @@
 
 
     /**
+     * {@inheritDoc}
+     */
+    public void handleSessionClosed()
+    {
+        boolean connected = false;
+        
+        while( !connected )
+        {
+            try
+            {
+                Thread.sleep( config.getConsumerInterval() );
+            }
+            catch( InterruptedException e )
+            {
+                LOG.error( "Interrupted while sleeping before trying to reconnect", e );
+            }
+
+            LOG.debug( "Trying to reconnect" );
+            connected = connect();
+        }
+        
+        bind();
+        startSync();
+    }
+
+
+    /**
      * starts the syn operation
      */
     public void startSync()
     {
-        if ( searchRequest == null )
+        if( config.isRefreshPersist() )
         {
+            try
+            {
+                LOG.debug( "==================== Refresh And Persist ==========" );
+                doSyncSearch();    
+            }
+            catch( Exception e )
+            {
+                LOG.error( "Failed to sync with refreshAndPersist mode", e );
+            }
+            
             return;
         }
-
-        int pass = 1;
-
+        
         // continue till refreshAndPersist mode is not set
         while( !config.isRefreshPersist() )
         {
             
+            LOG.debug( "==================== Refresh Only ==========" );
+            
             try
             {
-                if ( config.isRefreshPersist() )
-                {
-                    LOG.debug( "==================== Refresh And Persist ==========" );
-                }
-                else
-                {
-                    LOG.debug( "==================== Initial Content ==========" );
-                }
-                
                 if ( ( syncReq.getCookie() == null ) || ( syncReq.getCookie().length == 0
) )
                 {
                     LOG.debug( "First search (no cookie)" );



Mime
View raw message