directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1153306 - in /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication: ReplicaEventLog.java SyncReplConsumer.java SyncReplSearchListener.java
Date Tue, 02 Aug 2011 23:31:01 GMT
Author: elecharny
Date: Tue Aug  2 23:31:00 2011
New Revision: 1153306

URL: http://svn.apache.org/viewvc?rev=1153306&view=rev
Log:
o Added Javadoc
o Removed a useless method

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java?rev=1153306&r1=1153305&r2=1153306&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java
Tue Aug  2 23:31:00 2011
@@ -30,7 +30,6 @@ import org.apache.activemq.command.Activ
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.directory.server.core.event.EventType;
 import org.apache.directory.server.core.event.NotificationCriteria;
-import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,7 +49,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ReplicaEventLog
+public class ReplicaEventLog implements Comparable<ReplicaEventLog>
 {
     /** The logger */
     private static final Logger LOG = LoggerFactory.getLogger( ReplicaEventLog.class );
@@ -92,9 +91,14 @@ public class ReplicaEventLog
     /** ActiveMQ's BrokerService */
     private BrokerService brokerService;
 
+    /** A flag used to indicate that the consumer is not up to date */
     private volatile boolean dirty;
 
 
+    /**
+     * Create a new instance of EventLog for a replica
+     * @param replicaId The replica ID
+     */
     public ReplicaEventLog( int replicaId )
     {
         this.replicaId = replicaId;
@@ -104,7 +108,7 @@ public class ReplicaEventLog
 
 
     /**
-     * instantiates a message queue and corresponding producer for storing DIT changes  
+     * Instantiates a message queue and corresponding producer for storing DIT changes  
      *
      * @param amqConnection ActiveMQ connection
      * @param brokerService ActiveMQ's broker service
@@ -124,17 +128,10 @@ public class ReplicaEventLog
 
 
     /**
-     * Stores the given EventType and Entry in the queue 
+     * Stores the given message in the queue 
      *
-     * @param event the EventType
-     * @param entry the modified Entry
+     * @param message The message to store
      */
-    public void log( EventType event, Entry entry )
-    {
-        log( new ReplicaEventMessage( event, entry ) );
-    }
-
-
     public void log( ReplicaEventMessage message )
     {
         try
@@ -153,7 +150,7 @@ public class ReplicaEventLog
 
 
     /**
-     * deletes the queue (to remove the log) and recreates a new queue instance
+     * Deletes the queue (to remove the log) and recreates a new queue instance
      * with the same queue name. Also creates the corresponding message producer
      *
      * @throws Exception
@@ -169,6 +166,10 @@ public class ReplicaEventLog
     }
 
 
+    /**
+     * Re-create the queue
+     * @throws Exception If the creation has failed
+     */
     public void recreate() throws Exception
     {
         LOG.debug( "recreating the queue for the replica id {}", replicaId );
@@ -177,6 +178,11 @@ public class ReplicaEventLog
     }
 
 
+    /**
+     * Stop the EventLog
+     * 
+     * @throws Exception If the stop failed
+     */
     public void stop() throws Exception
     {
         // then close the producer and session, DO NOT close connection 
@@ -185,6 +191,9 @@ public class ReplicaEventLog
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public boolean equals( Object obj )
     {
@@ -204,17 +213,23 @@ public class ReplicaEventLog
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public int hashCode()
     {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + searchFilter.hashCode();
-        result = prime * result + hostName.hashCode();
+        int result = 17;
+        result = 31 * result + searchFilter.hashCode();
+        result = 31 * result + hostName.hashCode();
+        
         return result;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public int compareTo( ReplicaEventLog o )
     {
         if ( this.equals( o ) )
@@ -226,54 +241,86 @@ public class ReplicaEventLog
     }
 
 
+    /**
+     * @return The listener
+     */
     public SyncReplSearchListener getPersistentListener()
     {
         return persistentListener;
     }
 
 
+    /**
+     * Set the listener
+     * @param persistentListener The listener
+     */
     public void setPersistentListener( SyncReplSearchListener persistentListener )
     {
         this.persistentListener = persistentListener;
     }
 
 
+    /**
+     * @return The search criteria
+     */
     public NotificationCriteria getSearchCriteria()
     {
         return searchCriteria;
     }
 
 
+    /**
+     * Stores the search criteria
+     * @param searchCriteria The search criteria
+     */
     public void setSearchCriteria( NotificationCriteria searchCriteria )
     {
         this.searchCriteria = searchCriteria;
     }
 
 
+    /**
+     * @return true if the consumer is in Refresh And Persist mode
+     */
     public boolean isRefreshNPersist()
     {
         return refreshNPersist;
     }
 
 
+    /**
+     * @param refreshNPersist if true, set the EventLog in Refresh and Persist mode
+     */
     public void setRefreshNPersist( boolean refreshNPersist )
     {
         this.refreshNPersist = refreshNPersist;
     }
 
 
+    /**
+     * @return The replica ID
+     */
     public int getId()
     {
         return replicaId;
     }
 
 
+    /**
+     * @return The last CSN sent by the consumer
+     */
     public String getLastSentCsn()
     {
         return lastSentCsn;
     }
 
 
+    /**
+     * Update the last Sent CSN. If it's different from the present one, we
+     * will set the dirty flag to true, and a replication will follow.
+     *  
+     * @param lastSentCsn The new Sent CSN
+     */
     public void setLastSentCsn( String lastSentCsn )
     {
         // set only if there is a change in cookie value
@@ -287,48 +334,76 @@ public class ReplicaEventLog
     }
 
 
+    /**
+     * @return The consumer Hostname
+     */
     public String getHostName()
     {
         return hostName;
     }
 
 
+    /**
+     * Set the consumer hostname
+     * @param hostName The consumer hostname
+     */
     public void setHostName( String hostName )
     {
         this.hostName = hostName;
     }
 
 
+    /**
+     * @return The searchFilter
+     */
     public String getSearchFilter()
     {
         return searchFilter;
     }
 
 
+    /**
+     * Set the searchFilter
+     * @param searchFilter The searchFilter
+     */
     public void setSearchFilter( String searchFilter )
     {
         this.searchFilter = searchFilter;
     }
 
 
+    /**
+     * @return True if the consumer is not up to date
+     */
     public boolean isDirty()
     {
         return dirty;
     }
 
 
+    /**
+     * Set the dirty flag
+     * @param dirty The current consumer status
+     */
     public void setDirty( boolean dirty )
     {
         this.dirty = dirty;
     }
 
 
+    /**
+     * @return The queue name
+     */
     public String getQueueName()
     {
         return "replicaId=" + replicaId;
     }
 
 
+    /**
+     * @return A cursor on top of the queue
+     * @throws Exception If the cursor can't be created
+     */
     public ReplicaEventLogCursor getCursor() throws Exception
     {
         Queue regionQueue = ( Queue ) brokerService.getRegionBroker().getDestinationMap().get(
queue );
@@ -337,6 +412,9 @@ public class ReplicaEventLog
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public String toString()
     {

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java?rev=1153306&r1=1153305&r2=1153306&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
Tue Aug  2 23:31:00 2011
@@ -84,7 +84,6 @@ import org.slf4j.LoggerFactory;
 
 
 /**
- *
  * Implementation of syncrepl slave a.k.a consumer.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java?rev=1153306&r1=1153305&r2=1153306&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java
Tue Aug  2 23:31:00 2011
@@ -220,7 +220,7 @@ public class SyncReplSearchListener impl
             else
             {
                 // We are not connected, store the entry into the consumer's queue
-                consumerMsgLog.log( EventType.ADD, addContext.getEntry() );
+                consumerMsgLog.log( new ReplicaEventMessage( EventType.ADD, addContext.getEntry()
) );
             }
         }
         catch ( LdapInvalidAttributeValueException e )
@@ -265,7 +265,7 @@ public class SyncReplSearchListener impl
             }
             else
             {
-                consumerMsgLog.log( EventType.DELETE, entry );
+                consumerMsgLog.log( new ReplicaEventMessage( EventType.DELETE, entry ) );
             }
         }
         catch ( LdapInvalidAttributeValueException e )
@@ -303,7 +303,7 @@ public class SyncReplSearchListener impl
             }
             else
             {
-                consumerMsgLog.log( EventType.MODIFY, modifyContext.getAlteredEntry() );
+                consumerMsgLog.log( new ReplicaEventMessage( EventType.MODIFY, modifyContext.getAlteredEntry()
) );
             }
         }
         catch ( Exception e )
@@ -515,7 +515,7 @@ public class SyncReplSearchListener impl
             }
             else
             {
-                consumerMsgLog.log( event, entry );
+                consumerMsgLog.log( new ReplicaEventMessage( event, entry ) );
             }
         }
     }



Mime
View raw message