Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E01336B71 for ; Tue, 2 Aug 2011 23:31:23 +0000 (UTC) Received: (qmail 71423 invoked by uid 500); 2 Aug 2011 23:31:23 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 71364 invoked by uid 500); 2 Aug 2011 23:31:23 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 71357 invoked by uid 99); 2 Aug 2011 23:31:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Aug 2011 23:31:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Aug 2011 23:31:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6F5B723889B3 for ; Tue, 2 Aug 2011 23:31:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110802233101.6F5B723889B3@eris.apache.org> 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 Apache Directory Project */ -public class ReplicaEventLog +public class ReplicaEventLog implements Comparable { /** 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 Apache Directory Project 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 ) ); } } }