directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r584605 - in /directory/apacheds/branches/bigbang/mitosis/src: main/java/org/apache/directory/mitosis/service/ main/java/org/apache/directory/mitosis/service/protocol/handler/ test/java/org/apache/directory/mitosis/service/
Date Sun, 14 Oct 2007 21:08:16 GMT
Author: akarasulu
Date: Sun Oct 14 14:08:16 2007
New Revision: 584605

URL: http://svn.apache.org/viewvc?rev=584605&view=rev
Log:
adding better logging to mitosis and cleaning up a bit

Modified:
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
    directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java
    directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java?rev=584605&r1=584604&r2=584605&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
(original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
Sun Oct 14 14:08:16 2007
@@ -68,7 +68,7 @@
  */
 class ClientConnectionManager
 {
-    private static final Logger log = LoggerFactory.getLogger( ClientConnectionManager.class
);
+    private static final Logger LOG = LoggerFactory.getLogger( ClientConnectionManager.class
);
 
     private final ReplicationInterceptor interceptor;
     private final IoConnector connector = new SocketConnector();
@@ -98,7 +98,6 @@
     public void start( ReplicationConfiguration cfg ) throws Exception
     {
         this.configuration = cfg;
-
         monitor = new ConnectionMonitor();
         monitor.start();
     }
@@ -117,48 +116,50 @@
         // Remove all status values.
         sessions.clear();
     }
-    
+
+
     public void replicate()
     {
         // FIXME Can get ConcurrentModificationException.
-        for( Iterator i = sessions.values().iterator(); i.hasNext(); )
+        for ( Connection connection : sessions.values() )
         {
-            Connection con = ( Connection ) i.next();
-            synchronized( con )
+            synchronized ( connection )
             {
                 // Begin replication for the connected replicas.
-                if ( con.session != null )
+                if ( connection.session != null )
                 {
-                    ( ( ReplicationProtocolHandler ) con.session.getHandler() ).getContext(
con.session ).replicate();
+                    ( ( ReplicationProtocolHandler ) connection.session.getHandler() )
+                            .getContext( connection.session ).replicate();
                 }
             }
         }
     }
-    
+
+
     /**
      * Interrupt the unconnected connections to make them attempt to connect immediately.
      *
      */
     public void interruptConnectors()
     {
-        for( Iterator i = sessions.values().iterator(); i.hasNext(); )
+        for ( Connection connection : sessions.values() )
         {
-            Connection con = ( Connection ) i.next();
-            synchronized( con )
+            synchronized ( connection )
             {
                 // Wake up the replicas that are sleeping.
-                if ( con.inProgress && con.connector != null )
+                if ( connection.inProgress && connection.connector != null )
                 {
-                    con.connector.interrupt();
+                    connection.connector.interrupt();
                 }
             }
         }
         
     }
 
+
     private class ConnectionMonitor extends Thread
     {
-        private boolean timeToShutdown = false;
+        private boolean timeToShutdown;
 
 
         public ConnectionMonitor()
@@ -166,14 +167,13 @@
             super( "ClientConnectionManager" );
             
             // Initialize the status map.
-            Iterator i = configuration.getPeerReplicas().iterator();
-            while ( i.hasNext() )
+            for ( Replica replica : configuration.getPeerReplicas() )
             {
-                Replica replica = ( Replica ) i.next();
                 Connection con = sessions.get( replica.getId() );
                 if ( con == null )
                 {
                     con = new Connection();
+                    con.replicaId = replica.getId();
                     sessions.put( replica.getId(), con );
                 }
             }
@@ -191,7 +191,7 @@
                 }
                 catch ( InterruptedException e )
                 {
-                    log.warn( "Unexpected exception.", e );
+                    LOG.warn( "[Replica-{}] Unexpected exception.", configuration.getReplicaId(),
e );
                 }
             }
         }
@@ -208,7 +208,7 @@
                 }
                 catch ( InterruptedException e )
                 {
-                    log.warn( "Unexpected exception.", e );
+                    LOG.warn( "[Replica-{}] Unexpected exception.", configuration.getReplicaId(),
e );
                 }
             }
 
@@ -218,16 +218,15 @@
 
         private void connectUnconnected()
         {
-            Iterator i = configuration.getPeerReplicas().iterator();
-            while ( i.hasNext() )
+            for ( Replica replica : configuration.getPeerReplicas() )
             {
                 // Someone might have modified the configuration,
                 // and therefore we try to detect newly added replicas.
-                Replica replica = ( Replica ) i.next();
                 Connection con = sessions.get( replica.getId() );
                 if ( con == null )
                 {
                     con = new Connection();
+                    con.replicaId = replica.getId();
                     sessions.put( replica.getId(), con );
                 }
 
@@ -282,7 +281,7 @@
 
         private void disconnectConnected()
         {
-            log.info( "Closing all connections..." );
+            LOG.info( "[Replica-{}] Closing all connections...", configuration.getReplicaId()
);
             for ( ;; )
             {
                 Iterator i = sessions.values().iterator();
@@ -304,6 +303,8 @@
 
                         if ( con.session != null )
                         {
+                            LOG.info( "[Replica-{}] Closed connection to Replica-{}", configuration.getReplicaId(),
+                                    con.replicaId );
                             con.session.close();
                         }
                     }
@@ -321,12 +322,13 @@
                 }
                 catch ( InterruptedException e )
                 {
-                    log.warn( "Unexpected exception.", e );
+                    LOG.warn( "[Replica-{}] Unexpected exception.", configuration.getReplicaId(),
e );
                 }
             }
         }
     }
 
+
     private class Connector extends Thread
     {
         private final Replica replica;
@@ -345,17 +347,24 @@
         {
             if ( con.delay > 0 )
             {
-                log.info( "[" + replica + "] Waiting for " + con.delay + " seconds to reconnect."
);
+                if ( LOG.isInfoEnabled() )
+                {
+                    LOG.info( "[Replica-{}] Waiting for {} seconds to reconnect to replica-"
+ con.replicaId,
+                            ClientConnectionManager.this.configuration.getReplicaId(), con.delay
);
+                }
+                
                 try
                 {
                     Thread.sleep( con.delay * 1000L );
                 }
                 catch ( InterruptedException e )
                 {
+                    e.printStackTrace();
                 }
             }
 
-            log.info( "[" + replica + "] Connecting..." );
+            LOG.info( "[Replica-{}] Connecting to replica-{}",
+                    ClientConnectionManager.this.configuration.getReplicaId(), replica.getId()
);
 
             IoSession session;
             try
@@ -372,11 +381,13 @@
                     con.session = session;
                     con.delay = -1; // reset delay
                     con.inProgress = false;
+                    con.replicaId = replica.getId();
                 }
             }
             catch ( RuntimeIOException e )
             {
-                log.warn( "[" + replica + "] Failed to connect.", e );
+                LOG.error( "[Replica-{}] Failed to connect to replica-" + replica.getId(),
+                        ClientConnectionManager.this.configuration.getReplicaId(), e );
             }
             finally
             {
@@ -395,6 +406,7 @@
         private int delay = -1;
         private boolean inProgress;
         private Connector connector;
+        private ReplicaId replicaId;
 
 
         public Connection()

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java?rev=584605&r1=584604&r2=584605&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java
(original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/DefaultReplicationContext.java
Sun Oct 14 14:08:16 2007
@@ -141,6 +141,7 @@
         task.cancel();
         return task.message;
     }
+
     
     public boolean replicate()
     {
@@ -187,6 +188,7 @@
         }
         return task;
     }
+
 
     private class ExpirationTask extends TimerTask
     {

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java?rev=584605&r1=584604&r2=584605&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java
(original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java
Sun Oct 14 14:08:16 2007
@@ -61,6 +61,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+
 /**
  * An {@link Interceptor} that intercepts LDAP operations and propagates the
  * changes occurred by the operations into other {@link Replica}s so the DIT
@@ -243,7 +244,8 @@
         }
         catch ( Exception e )
         {
-            LOG.warn( "Failed to stop the client connection manager.", e );
+            LOG.error( "[Replica-{}] Failed to stop the client connection manager.", configuration.getReplicaId()
);
+            LOG.error( "Stop failure exception: ", e );
         }
         registry.unbindAll();
     }
@@ -254,7 +256,7 @@
      */
     public void replicate()
     {
-        LOG.info( "Forcing replication..." );
+        LOG.info( "[Replica-{}] Forcing replication...", configuration.getReplicaId() );
         this.clientConnectionManager.replicate();
     }
 
@@ -263,7 +265,7 @@
      */
     public void interruptConnectors()
     {
-        LOG.info( "Waking sleeping replicas..." );
+        LOG.info( "[Replica-{}] Waking sleeping replicas...", configuration.getReplicaId()
);
         this.clientConnectionManager.interruptConnectors();
     }
 
@@ -319,7 +321,7 @@
             }
 
             contextName.normalize( attrRegistry.getNormalizerMapping() );
-            LOG.info( "Purging aged data under '" + contextName + '"' );
+            LOG.info( "[Replica-{}] Purging aged data under '{}'", configuration.getReplicaId(),
contextName );
             purgeAgedData( contextName, filter );
         }
 
@@ -360,12 +362,12 @@
             {
                 name.normalize( attrRegistry.getNormalizerMapping() );
                 Attributes entry = nexus.lookup( new LookupOperationContext( name ) );
-                LOG.info( "Purge: " + name + " (" + entry + ')' );
+                LOG.info( "[Replica-{}] Purge: " + name + " (" + entry + ')', configuration.getReplicaId()
);
                 nexus.delete( new DeleteOperationContext( name ) );
             }
             catch ( NamingException ex )
             {
-                LOG.warn( "Failed to fetch/delete: " + name, ex );
+                LOG.error( "[Replica-{}] Failed to fetch/delete: " + name, configuration.getReplicaId(),
ex );
             }
         }
     }

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java?rev=584605&r1=584604&r2=584605&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java
(original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java
Sun Oct 14 14:08:16 2007
@@ -20,36 +20,14 @@
 package org.apache.directory.mitosis.service.protocol.handler;
 
 
-import java.net.InetSocketAddress;
-import java.util.Map;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-
-import org.apache.directory.mitosis.common.CSN;
-import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.DefaultCSN;
-import org.apache.directory.mitosis.common.Replica;
-import org.apache.directory.mitosis.common.ReplicaId;
+import org.apache.directory.mitosis.common.*;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.AddEntryOperation;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.service.ReplicationContext;
 import org.apache.directory.mitosis.service.ReplicationContext.State;
 import org.apache.directory.mitosis.service.protocol.Constants;
-import org.apache.directory.mitosis.service.protocol.message.BaseMessage;
-import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesAckMessage;
-import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesMessage;
-import org.apache.directory.mitosis.service.protocol.message.EndLogEntriesAckMessage;
-import org.apache.directory.mitosis.service.protocol.message.EndLogEntriesMessage;
-import org.apache.directory.mitosis.service.protocol.message.LogEntryAckMessage;
-import org.apache.directory.mitosis.service.protocol.message.LogEntryMessage;
-import org.apache.directory.mitosis.service.protocol.message.LoginAckMessage;
-import org.apache.directory.mitosis.service.protocol.message.LoginMessage;
+import org.apache.directory.mitosis.service.protocol.message.*;
 import org.apache.directory.mitosis.store.ReplicationLogIterator;
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
@@ -61,6 +39,15 @@
 import org.apache.mina.common.WriteFuture;
 import org.apache.mina.util.SessionLog;
 
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import java.net.InetSocketAddress;
+import java.util.Map;
+
 
 /**
  * {@link ReplicationContextHandler} that implements client-side replication
@@ -198,7 +185,11 @@
 
     public void exceptionCaught( ReplicationContext ctx, Throwable cause ) throws Exception
     {
-        SessionLog.warn( ctx.getSession(), "Unexpected exception.", cause );
+        if ( SessionLog.isWarnEnabled( ctx.getSession() ) )
+        {
+            SessionLog.warn( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+                    +"] Unexpected exception.", cause );
+        }
         ctx.getSession().close();
     }
 
@@ -213,7 +204,8 @@
     {
         if ( message.getResponseCode() != Constants.OK )
         {
-            SessionLog.warn( ctx.getSession(), "Login attempt failed: " + message.getResponseCode()
);
+            SessionLog.warn( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+
+                    "] Login attempt failed: " + message.getResponseCode() );
             ctx.getSession().close();
             return;
         }
@@ -231,7 +223,8 @@
                 }
                 else
                 {
-                    SessionLog.warn( ctx.getSession(), "Peer address mismatches: "
+                    SessionLog.warn( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+                            + "] Peer address mismatches: "
                             + ctx.getSession().getRemoteAddress() + " (expected: " + replica.getAddress()
);
                     ctx.getSession().close();
                     return;
@@ -239,7 +232,8 @@
             }
         }
 
-        SessionLog.warn( ctx.getSession(), "Unknown peer replica ID: " + message.getReplicaId()
);
+        SessionLog.warn( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+
+                    "] Unknown peer replica ID: " + message.getReplicaId() );
         ctx.getSession().close();
     }
 
@@ -269,7 +263,9 @@
                 SessionLog.debug( ctx.getSession(), "(" +
                     ctx.getConfiguration().getReplicaId().getId() + "->" +
                     (ctx.getPeer() != null ? ctx.getPeer().getId().getId() : "null") +
-                    ") Couldn't begin replication.  State:" + ctx.getState() + ", scheduledExpirations:"
+ ctx.getScheduledExpirations() + ", scheduledWriteRequests:" + ctx.getSession().getScheduledWriteRequests()
);
+                    ") Couldn't begin replication.  State:" + ctx.getState() + ", scheduledExpirations:"
+                        + ctx.getScheduledExpirations() +
+                        ", scheduledWriteRequests:" + ctx.getSession().getScheduledWriteRequests()
);
             }
         	return false;
         }
@@ -280,7 +276,8 @@
     {
         if ( message.getResponseCode() != Constants.OK )
         {
-            SessionLog.warn( ctx.getSession(), "Remote peer failed to execute a log entry."
);
+            SessionLog.warn( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+
+                    "] Remote peer failed to execute a log entry." );
             ctx.getSession().close();
         }
     }
@@ -304,7 +301,8 @@
         }
         catch ( Exception e )
         {
-            SessionLog.warn( ctx.getSession(), "Failed to get update vector.", e );
+            SessionLog.warn( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+
+                    "] Failed to get update vector.", e );
             ctx.getSession().close();
             return;
         }
@@ -314,12 +312,14 @@
         {
             if ( myPV.size() > 0 && yourUV.size() == 0 )
             {
-                SessionLog.warn( ctx.getSession(), "Starting a whole DIT transfer." );
+                SessionLog.warn( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+
+                    "] Starting a whole DIT transfer." );
                 sendAllEntries( ctx );
             }
             else
             {
-                SessionLog.warn( ctx.getSession(), "Starting a partial replication log transfer."
);
+                SessionLog.warn( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+
+                    "] Starting a partial replication log transfer." );
                 sendReplicationLogs( ctx, myPV, yourUV );
             }
         }
@@ -338,7 +338,8 @@
         Attribute namingContextsAttr = rootDSE.get( "namingContexts" );
         if ( namingContextsAttr == null || namingContextsAttr.size() == 0 )
         {
-            SessionLog.warn( ctx.getSession(), "No namingContexts attributes in rootDSE."
);
+            SessionLog.warn( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+
+                    "] No namingContexts attributes in rootDSE." );
             return;
         }
 
@@ -359,7 +360,8 @@
                 contextName = new LdapDN( String.valueOf( value ) );
             }
 
-            SessionLog.info( ctx.getSession(), "Sending entries under '" + contextName +
'\'' );
+            SessionLog.info( ctx.getSession(), "[Replica-"+ ctx.getConfiguration().getReplicaId()
+
+                    "] Sending entries under '" + contextName + '\'' );
 
             Map<String, OidNormalizer> mapping = ctx.getDirectoryService().getRegistries().getAttributeTypeRegistry()
                 .getNormalizerMapping();

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java?rev=584605&r1=584604&r2=584605&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
(original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
Sun Oct 14 14:08:16 2007
@@ -20,26 +20,20 @@
 package org.apache.directory.mitosis.service.protocol.handler;
 
 
-import java.net.InetSocketAddress;
-
+import com.sun.org.apache.bcel.internal.classfile.Unknown;
 import org.apache.directory.mitosis.common.CSNVector;
 import org.apache.directory.mitosis.common.Replica;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.service.ReplicationContext;
 import org.apache.directory.mitosis.service.ReplicationContext.State;
 import org.apache.directory.mitosis.service.protocol.Constants;
-import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesAckMessage;
-import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesMessage;
-import org.apache.directory.mitosis.service.protocol.message.EndLogEntriesAckMessage;
-import org.apache.directory.mitosis.service.protocol.message.EndLogEntriesMessage;
-import org.apache.directory.mitosis.service.protocol.message.LogEntryAckMessage;
-import org.apache.directory.mitosis.service.protocol.message.LogEntryMessage;
-import org.apache.directory.mitosis.service.protocol.message.LoginAckMessage;
-import org.apache.directory.mitosis.service.protocol.message.LoginMessage;
+import org.apache.directory.mitosis.service.protocol.message.*;
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.util.SessionLog;
 
+import java.net.InetSocketAddress;
+
 
 /**
  * {@link ReplicationContextHandler} that implements server-side replication logic
@@ -117,7 +111,8 @@
 
     public void exceptionCaught( ReplicationContext ctx, Throwable cause ) throws Exception
     {
-        SessionLog.warn( ctx.getSession(), "Unexpected exception.", cause );
+        SessionLog.warn( ctx.getSession(), "[Replica-" + ctx.getConfiguration().getReplicaId()
+                + "] Unexpected exception.", cause );
         ctx.getSession().close();
     }
 
@@ -126,7 +121,8 @@
     {
         if ( ctx.getState() == State.INIT )
         {
-            SessionLog.warn( ctx.getSession(), "No login attempt in " + ctx.getConfiguration().getResponseTimeout()
+            SessionLog.warn( ctx.getSession(), "[Replica-" + ctx.getConfiguration().getReplicaId()
+                + "] No login attempt in " + ctx.getConfiguration().getResponseTimeout()
                 + " second(s)." );
             ctx.getSession().close();
         }
@@ -155,7 +151,8 @@
                 }
                 else
                 {
-                    SessionLog.warn( ctx.getSession(), "Peer address mismatches: "
+                    SessionLog.warn( ctx.getSession(), "[Replica-" + ctx.getConfiguration().getReplicaId()
+                            + "] Peer address mismatches: "
                             + ctx.getSession().getRemoteAddress() + " (expected: " + replica.getAddress()
);
                     ctx.getSession().write(
                             new LoginAckMessage( message.getSequence(), Constants.NOT_OK,
ctx.getConfiguration()
@@ -166,7 +163,8 @@
             }
         }
 
-        SessionLog.warn( ctx.getSession(), "Unknown peer replica ID: " + message.getReplicaId()
);
+        SessionLog.warn( ctx.getSession(), "[Replica-" + ctx.getConfiguration().getReplicaId()
+                + "] Unknown peer replica ID: " + message.getReplicaId() );
         ctx.getSession().write(
             new LoginAckMessage( message.getSequence(), Constants.NOT_OK, ctx.getConfiguration().getReplicaId()
) );
         ctx.getSession().close();
@@ -247,7 +245,8 @@
 
     private void onUnexpectedMessage( ReplicationContext ctx, Object message )
     {
-        SessionLog.warn( ctx.getSession(), "Unexpected message: " + message );
+        SessionLog.warn( ctx.getSession(), "[Replica-" + ctx.getConfiguration().getReplicaId()
+                + "] Unexpected message: " + message );
         ctx.getSession().close();
     }
 }

Modified: directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java?rev=584605&r1=584604&r2=584605&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java
(original)
+++ directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java
Sun Oct 14 14:08:16 2007
@@ -54,17 +54,19 @@
     protected Map<String, DirectoryService> services = new HashMap<String, DirectoryService>();
     protected Map<String, ReplicationInterceptor> replicationServices = new HashMap<String,
ReplicationInterceptor>();
 
+
     protected void setUp() throws Exception
     {
         createReplicas( new String[] { "A", "B", "C" } );
     }
 
+
     protected void tearDown() throws Exception
     {
         destroyAllReplicas();
     }
 
-    @SuppressWarnings("unchecked")
+
     protected void createReplicas( String[] names ) throws Exception
     {
         int lastAvailablePort = 1024;
@@ -72,8 +74,7 @@
         Replica[] replicas = new Replica[ names.length ];
         for( int i = 0; i < names.length; i++ )
         {
-            int replicationPort = AvailablePortFinder
-                    .getNextAvailable( lastAvailablePort );
+            int replicationPort = AvailablePortFinder.getNextAvailable( lastAvailablePort
);
             lastAvailablePort = replicationPort + 1;
 
             replicas[ i ] = new Replica( new ReplicaId( names[ i ] ),
@@ -90,10 +91,7 @@
             String replicaId = replica.getId().getId();
             DirectoryService service = new DefaultDirectoryService();
             service.setInstanceId( replicaId );
-
-            File workDir = new File( homeDirectory + File.separator
-                    + service.getInstanceId() );
-
+            File workDir = new File( homeDirectory + File.separator + service.getInstanceId()
);
             service.setShutdownHookEnabled( false );
             service.setWorkingDirectory( workDir );
 
@@ -104,6 +102,7 @@
             // Disable automatic replication to prevent unexpected behavior
             replicationCfg.setReplicationInterval( 0 );
             replicationCfg.setServerPort( replica.getAddress().getPort() );
+
             for ( Replica replica1 : replicas )
             {
                 if ( replica1 != replica )
@@ -125,14 +124,13 @@
 
             service.startup();
             
-            Hashtable env = new Hashtable();
+            Hashtable<String,Object> env = new Hashtable<String,Object>();
             env.put( DirectoryService.JNDI_KEY, service );
             env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
             env.put( Context.SECURITY_CREDENTIALS, "secret" );
             env.put( Context.SECURITY_AUTHENTICATION, "simple" );
             env.put( Context.PROVIDER_URL, "" );
-            env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class
-                    .getName() );
+            env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName()
);
 
             // Initialize the server instance.
             LdapContext context = new InitialLdapContext( env, null );
@@ -149,6 +147,7 @@
         Thread.sleep( 5000 );
     }
 
+
     protected LdapContext getReplicaContext( String name ) throws Exception
     {
         LdapContext context = contexts.get( name );
@@ -159,6 +158,7 @@
 
         return ( LdapContext ) context.lookup( "" );
     }
+
 
     @SuppressWarnings("unchecked")
     protected void destroyAllReplicas() throws Exception

Modified: directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java?rev=584605&r1=584604&r2=584605&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
(original)
+++ directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
Sun Oct 14 14:08:16 2007
@@ -65,7 +65,7 @@
      * NOTE: This test is DISABLED as there is an occasional problem when a message is acknowledged
      * too quickly, meaning no further messages can be sent until it has timed out (DIRSERVER-998).
      *
-     * @throws Exception
+     * @throws Exception on failure
      */
     public void disabled_testTwoWayBind() throws Exception
     {



Mime
View raw message