directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r733530 - in /directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service: ClientConnectionManager.java DefaultReplicationContext.java ReplicationContext.java protocol/handler/ReplicationProtocolHandler.java
Date Sun, 11 Jan 2009 22:44:32 GMT
Author: elecharny
Date: Sun Jan 11 14:44:31 2009
New Revision: 733530

URL: http://svn.apache.org/viewvc?rev=733530&view=rev
Log:
o Removed the ReplicationContext interface
o Renamed the DefaultReplicationContext to ReplicationContext

Added:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java
      - copied, changed from r732113, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java
Removed:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java
Modified:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationProtocolHandler.java

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java?rev=733530&r1=733529&r2=733530&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
(original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
Sun Jan 11 14:44:31 2009
@@ -366,6 +366,7 @@
                     ClientConnectionManager.this.configuration.getReplicaId(), replica.getId()
);
 
             IoSession session;
+            
             try
             {
                 connector.setConnectTimeoutMillis( configuration.getResponseTimeout() );

Copied: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java
(from r732113, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java?p2=directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java&p1=directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java&r1=732113&r2=733530&rev=733530&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java
(original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java
Sun Jan 11 14:44:31 2009
@@ -40,9 +40,10 @@
 /**
  * The default implementation of {@link ReplicationContext}
  * 
- * @author The Apache Directory Project Team
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev: $, $Date:  $
  */
-public class DefaultReplicationContext implements ReplicationContext
+public class ReplicationContext
 {
     /** A logger for this class */
     private final Logger logger = LoggerFactory.getLogger(getClass());
@@ -59,7 +60,27 @@
     private State state = State.INIT;
 
 
-    public DefaultReplicationContext( ReplicationInterceptor interceptor, DirectoryService
directoryService,
+    /**
+     * Represents the state of the connection between two {@link Replica}s.
+     * 
+     * @author The Apache Directory Project Team
+     */
+    public enum State
+    {
+        /**
+         * Connection is established.
+         */
+        INIT,
+
+        /**
+         * Client has logged in and is ready to exchange information.
+         */
+        READY,
+        ;
+    }
+
+    
+    public ReplicationContext( ReplicationInterceptor interceptor, DirectoryService directoryService,
         ReplicationConfiguration configuration, IoSession session )
     {
         this.interceptor = interceptor;
@@ -69,42 +90,72 @@
     }
 
 
+    /**
+     * Returns the {@link ReplicationInterceptor} which is managing this
+     * context.
+     */
     public ReplicationInterceptor getService()
     {
         return interceptor;
     }
 
 
+    /**
+     * Returns the current {@link ReplicationConfiguration} of the
+     * {@link Replica} which is managing this context.
+     */
     public ReplicationConfiguration getConfiguration()
     {
         return configuration;
     }
 
 
+    /**
+     * Returns the {@link DirectoryService} which owns the {@link ReplicationInterceptor}
+     * which is managing this context.
+     */
     public DirectoryService getDirectoryService()
     {
         return directoryService;
     }
 
 
+    /**
+     * Returns <a href="http://mina.apache.org/">MINA</a> {@link IoSession}
+     * instance that is associated with the current connection to
+     * the remote {@link Replica}.
+     */
     public IoSession getSession()
     {
         return session;
     }
 
 
+    /**
+     * Generates a new and unique sequence number of protocol message.
+     * @return the new sequence number.
+     */
     public int getNextSequence()
     {
         return nextSequence++;
     }
 
 
+    /**
+     * Returns the remote peer {@link Replica} that this context is connected
+     * to. 
+     */
     public Replica getPeer()
     {
         return peer;
     }
 
 
+    /**
+     * Sets the remote peer {@link Replica} that this context is connected
+     * to.  A user has authenticate the remote peer first and call this method
+     * manually to prevent unauthorized access.
+     */
     public void setPeer( Replica peer )
     {
         assert peer != null;
@@ -112,18 +163,33 @@
     }
 
 
+    /**
+     * Returns the current state of the {@link Replica} this context is
+     * managing.
+     */
     public State getState()
     {
         return state;
     }
 
 
+    /**
+     * Sets the current state of the {@link Replica} this context is
+     * managing.
+     */
     public void setState( State state )
     {
         this.state = state;
     }
 
 
+    /**
+     * Schedules an expiration of the specified <tt>message</tt>.  A user of
+     * this context could call this method with the message it has written out
+     * to the remote peer.  If {@link #cancelExpiration(int)} method is not
+     * invoked within a certain timeout, an exception will be raised to
+     * {@link ReplicationContextHandler#exceptionCaught(ReplicationContext, Throwable)}.
+     */
     public void scheduleExpiration( Object message )
     {
         BaseMessage bm = ( BaseMessage ) message;
@@ -137,6 +203,15 @@
     }
 
 
+    /**
+     * Cancels the expiration scheduled by calling
+     * {@link #scheduleExpiration(Object)}.  A user of this context could
+     * call this method when the response message has been received to
+     * stop the expiration for the message with the specified
+     * <tt>sequence</tt> number.
+     * 
+     * @return the request message with the specified <tt>sequence</tt> number
+     */
     public Object cancelExpiration( int sequence )
     {
         ExpirationTask task = removeTask( sequence );
@@ -150,6 +225,14 @@
     }
 
     
+    /**
+     * Forces this context to send replication data to the peer replica immediately.
+     * 
+     * @return <tt>true</tt> if the replication has been started,
+     *         <tt>false</tt> if the replication didn't start because
+     *         the replication process is already in progress or
+     *         the client is currently logging in to the server yet.
+     */
     public boolean replicate()
     {
         ReplicationProtocolHandler handler =
@@ -165,6 +248,10 @@
     }
 
 
+    /**
+     * Cancels all scheduled expirations.  A user of this context could
+     * call this method when the current connection is closed.
+     */
     public void cancelAllExpirations()
     {
         synchronized ( expirableMessages )
@@ -177,6 +264,12 @@
     }
 
 
+    /**
+     * Returns the number of the scheduled experations.  A user of this
+     * contexst could check this value before sending a new message to the
+     * remote peer to prevent {@link OutOfMemoryError} by limiting the number
+     * of the messages which didn't get their responses.
+     */
     public int getScheduledExpirations()
     {
         synchronized ( expirableMessages )

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationProtocolHandler.java?rev=733530&r1=733529&r2=733530&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationProtocolHandler.java
(original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationProtocolHandler.java
Sun Jan 11 14:44:31 2009
@@ -21,7 +21,7 @@
 
 
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
-import org.apache.directory.mitosis.service.DefaultReplicationContext;
+import org.apache.directory.mitosis.service.ReplicationContext;
 import org.apache.directory.mitosis.service.ReplicationContext;
 import org.apache.directory.mitosis.service.ReplicationInterceptor;
 import org.apache.directory.server.core.DirectoryService;
@@ -71,7 +71,7 @@
     public void sessionCreated( IoSession session ) throws Exception
     {
         session.setAttribute( CONTEXT,
-                new DefaultReplicationContext( interceptor, directoryService, configuration,
session ) );
+                new ReplicationContext( interceptor, directoryService, configuration, session
) );
     }
 
 



Mime
View raw message