directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r471331 - /directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/
Date Sun, 05 Nov 2006 02:19:15 GMT
Author: akarasulu
Date: Sat Nov  4 18:19:13 2006
New Revision: 471331

URL: http://svn.apache.org/viewvc?view=rev&rev=471331
Log:
source formatting

Modified:
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationServiceException.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/SimpleReplicationContext.java

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java?view=diff&rev=471331&r1=471330&r2=471331
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
Sat Nov  4 18:19:13 2006
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.mitosis.service;
 
+
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -45,6 +46,7 @@
 import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
 
+
 /**
  * Manages all outgoing connections to remote replicas.
  *
@@ -54,256 +56,262 @@
 class ClientConnectionManager
 {
     private static final Logger log = LoggerFactory.getLogger( ClientConnectionManager.class
);
-    
+
     private final ReplicationService service;
     private final IoConnector connector = new SocketConnector();
     private final IoConnectorConfig connectorConfig = new SocketConnectorConfig();
     private final Map sessions = new HashMap();
     private ReplicationConfiguration configuration;
     private ConnectionMonitor monitor;
-    
+
+
     ClientConnectionManager( ReplicationService service )
     {
         this.service = service;
-        
-        ExecutorThreadModel threadModel = ExecutorThreadModel.getInstance("mitosis");
-        threadModel.setExecutor(
-                new ThreadPoolExecutor(16, 16, 60, TimeUnit.SECONDS, new LinkedBlockingQueue()
));
-        connectorConfig.setThreadModel(threadModel);
+
+        ExecutorThreadModel threadModel = ExecutorThreadModel.getInstance( "mitosis" );
+        threadModel.setExecutor( new ThreadPoolExecutor( 16, 16, 60, TimeUnit.SECONDS, new
LinkedBlockingQueue() ) );
+        connectorConfig.setThreadModel( threadModel );
 
         //// add codec
         connectorConfig.getFilterChain().addLast( "protocol",
-                new ProtocolCodecFilter( new ReplicationClientProtocolCodecFactory() ) );
+            new ProtocolCodecFilter( new ReplicationClientProtocolCodecFactory() ) );
 
         //// add logger
         connectorConfig.getFilterChain().addLast( "logger", new LoggingFilter() );
     }
 
+
     public void start( ReplicationConfiguration cfg ) throws Exception
     {
         this.configuration = cfg;
-        
+
         monitor = new ConnectionMonitor();
         monitor.start();
     }
-    
+
+
     public void stop() throws Exception
     {
         // close all connections
         monitor.shutdown();
-        
+
         // remove all filters
         connector.getFilterChain().clear();
-        
-        ( ( ExecutorService ) ( ( ExecutorThreadModel ) connectorConfig.getThreadModel()
).
-                getExecutor() ).shutdown();
+
+        ( ( ExecutorService ) ( ( ExecutorThreadModel ) connectorConfig.getThreadModel()
).getExecutor() ).shutdown();
     }
-    
+
     private class ConnectionMonitor extends Thread
     {
         private boolean timeToShutdown = false;
 
+
         public ConnectionMonitor()
         {
             super( "ClientConnectionManager" );
         }
-        
+
+
         public void shutdown()
         {
             timeToShutdown = true;
-            while( isAlive() )
+            while ( isAlive() )
             {
                 try
                 {
                     join();
                 }
-                catch( InterruptedException e )
+                catch ( InterruptedException e )
                 {
                     log.warn( "Unexpected exception.", e );
                 }
             }
         }
-        
+
+
         public void run()
         {
-            while( !timeToShutdown )
+            while ( !timeToShutdown )
             {
                 connectUnconnected();
                 try
                 {
                     Thread.sleep( 1000 );
                 }
-                catch( InterruptedException e )
+                catch ( InterruptedException e )
                 {
                     log.warn( "Unexpected exception.", e );
                 }
             }
-            
+
             disconnectConnected();
         }
 
+
         private void connectUnconnected()
         {
             Iterator i = configuration.getPeerReplicas().iterator();
-            while( i.hasNext() )
+            while ( i.hasNext() )
             {
                 Replica replica = ( Replica ) i.next();
                 Connection con = ( Connection ) sessions.get( replica.getId() );
-                if( con == null )
+                if ( con == null )
                 {
                     con = new Connection();
                     sessions.put( replica.getId(), con );
                 }
-                
-                synchronized( con )
+
+                synchronized ( con )
                 {
-                    if( con.inProgress )
+                    if ( con.inProgress )
                     {
                         // connection is in progress
                         continue;
                     }
-                        
-                    if( con.session != null )
+
+                    if ( con.session != null )
                     {
-                        if( con.session.isConnected() )
+                        if ( con.session.isConnected() )
                         {
                             continue;
                         }
                         con.session = null;
                     }
-                    
+
                     // put to connectingSession with dummy value to mark
                     // that connection is in progress
                     con.inProgress = true;
 
-                    if( con.delay < 0 )
+                    if ( con.delay < 0 )
                     {
                         con.delay = 0;
                     }
-                    else if( con.delay == 0 )
+                    else if ( con.delay == 0 )
                     {
                         con.delay = 2;
                     }
                     else
                     {
                         con.delay *= 2;
-                        if( con.delay > 60 )
+                        if ( con.delay > 60 )
                         {
                             con.delay = 60;
                         }
                     }
                 }
-                
+
                 Connector connector = new Connector( replica, con );
-                synchronized( con ) 
+                synchronized ( con )
                 {
                     con.connector = connector;
                 }
                 connector.start();
             }
         }
-        
+
+
         private void disconnectConnected()
         {
             log.info( "Closing all connections..." );
-            for( ;; )
+            for ( ;; )
             {
                 Iterator i = sessions.values().iterator();
-                while( i.hasNext() )
+                while ( i.hasNext() )
                 {
                     Connection con = ( Connection ) i.next();
-                    synchronized( con )
+                    synchronized ( con )
                     {
-                        if( con.inProgress )
+                        if ( con.inProgress )
                         {
-                            if( con.connector != null )
+                            if ( con.connector != null )
                             {
                                 con.connector.interrupt();
                             }
                             continue;
                         }
-                        
+
                         i.remove();
 
-                        if( con.session != null )
+                        if ( con.session != null )
                         {
                             con.session.close();
                         }
                     }
                 }
-                
-                if( sessions.isEmpty() )
+
+                if ( sessions.isEmpty() )
                 {
                     break;
                 }
-                
+
                 // Sleep 1 second and try again waiting for Connector threads.
                 try
                 {
                     Thread.sleep( 1000 );
                 }
-                catch( InterruptedException e )
+                catch ( InterruptedException e )
                 {
                     log.warn( "Unexpected exception.", e );
                 }
             }
         }
     }
-    
+
     private class Connector extends Thread
     {
         private final Replica replica;
         private final Connection con;
-        
+
+
         public Connector( Replica replica, Connection con )
         {
             super( "ClientConnectionManager-" + replica );
             this.replica = replica;
             this.con = con;
         }
-        
+
+
         public void run()
         {
-            if( con.delay > 0 )
+            if ( con.delay > 0 )
             {
                 log.info( "[" + replica + "] Waiting for " + con.delay + " seconds to reconnect."
);
                 try
                 {
                     Thread.sleep( con.delay * 1000L );
                 }
-                catch( InterruptedException e )
+                catch ( InterruptedException e )
                 {
                 }
             }
-            
+
             log.info( "[" + replica + "] Connecting..." );
 
             IoSession session;
             try
             {
                 connectorConfig.setConnectTimeout( configuration.getResponseTimeout() );
-                ConnectFuture future = connector.connect(
-                        replica.getAddress(),
-                        new ReplicationClientProtocolHandler( service ),
-                        connectorConfig );
-                
+                ConnectFuture future = connector.connect( replica.getAddress(), new ReplicationClientProtocolHandler(
+                    service ), connectorConfig );
+
                 future.join();
                 session = future.getSession();
 
-                synchronized( con )
+                synchronized ( con )
                 {
                     con.session = session;
                     con.delay = -1; // reset delay
                     con.inProgress = false;
                 }
             }
-            catch( RuntimeIOException e )
+            catch ( RuntimeIOException e )
             {
-                log.warn("[" + replica + "] Failed to connect.", e );
+                log.warn( "[" + replica + "] Failed to connect.", e );
             }
             finally
             {
-                synchronized( con )
+                synchronized ( con )
                 {
                     con.inProgress = false;
                     con.connector = null;
@@ -311,14 +319,15 @@
             }
         }
     }
-    
+
     private static class Connection
     {
         private IoSession session;
         private int delay = -1;
         private boolean inProgress;
         private Connector connector;
-        
+
+
         public Connection()
         {
         }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java?view=diff&rev=471331&r1=471330&r2=471331
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationContext.java
Sat Nov  4 18:19:13 2006
@@ -19,48 +19,74 @@
  */
 package org.apache.directory.mitosis.service;
 
+
 import org.apache.directory.server.core.DirectoryServiceConfiguration;
 import org.apache.mina.common.IoSession;
 import org.apache.directory.mitosis.common.Replica;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 
-public interface ReplicationContext {
+
+public interface ReplicationContext
+{
     IoSession getSession();
+
+
     ReplicationConfiguration getConfiguration();
+
+
     ReplicationService getService();
+
+
     DirectoryServiceConfiguration getServiceConfiguration();
+
+
     int getNextSequence();
 
+
     Replica getPeer();
+
+
     void setPeer( Replica peer );
-    
+
+
     State getState();
+
+
     void setState( State state );
-    
+
+
     void scheduleExpiration( Object message );
+
+
     Object cancelExpiration( int sequence );
+
+
     void cancelAllExpirations();
+
+
     int getScheduledExpirations();
-    
+
     public static class State
     {
         /**
          * Connection is established.
          */
         public static final State INIT = new State( "INIT" );
-        
+
         /**
          * Client has logged in and is ready to exchange information.
          */
         public static final State READY = new State( "READY" );
-        
+
         private final String value;
-        
+
+
         private State( String value )
         {
             this.value = value;
         }
-        
+
+
         public String toString()
         {
             return value;

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java?view=diff&rev=471331&r1=471330&r2=471331
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationLogCleanJob.java
Sat Nov  4 18:19:13 2006
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.mitosis.service;
 
+
 import java.util.Iterator;
 
 import javax.naming.NamingException;
@@ -29,22 +30,25 @@
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 
+
 public class ReplicationLogCleanJob implements Job
 {
     public static final String INSTANCE_ID = "instanceId";
-    
+
+
     public ReplicationLogCleanJob()
     {
     }
 
+
     public void execute( JobExecutionContext ctx ) throws JobExecutionException
     {
         String instanceId = ctx.getJobDetail().getJobDataMap().getString( INSTANCE_ID );
-        if( instanceId == null )
+        if ( instanceId == null )
         {
             // Execute for all instances in the VM if instanceId is not specified.
             Iterator it = DirectoryService.getAllInstances().iterator();
-            while( it.hasNext() )
+            while ( it.hasNext() )
             {
                 DirectoryService service = ( DirectoryService ) it.next();
                 execute0( service.getConfiguration().getInstanceId() );
@@ -57,21 +61,22 @@
             execute0( instanceId );
         }
     }
-    
+
+
     private void execute0( String instanceId ) throws JobExecutionException
     {
         DirectoryService service = DirectoryService.getInstance( instanceId );
         Iterator it = service.getConfiguration().getInterceptorChain().getAll().iterator();
-        while( it.hasNext() )
+        while ( it.hasNext() )
         {
-            Interceptor interceptor = (Interceptor) it.next();
-            if( interceptor instanceof ReplicationService )
+            Interceptor interceptor = ( Interceptor ) it.next();
+            if ( interceptor instanceof ReplicationService )
             {
                 try
                 {
                     ( ( ReplicationService ) interceptor ).purgeAgedData();
                 }
-                catch( NamingException e )
+                catch ( NamingException e )
                 {
                     throw new JobExecutionException( e );
                 }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java?view=diff&rev=471331&r1=471330&r2=471331
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
Sat Nov  4 18:19:13 2006
@@ -74,11 +74,11 @@
 public class ReplicationService extends BaseInterceptor
 {
     private static final Logger log = LoggerFactory.getLogger( ReplicationService.class );
-    
+
     /** TODO these OID's need to be switched from safehaus to apache enterprise numbers */
     private static final String ENTRY_CSN_OID = "1.2.6.1.4.1.18060.1.1.1.3.30";
     private static final String ENTRY_DELETED_OID = "1.2.6.1.4.1.18060.1.1.1.3.31";
-    
+
     private DirectoryServiceConfiguration directoryServiceConfiguration;
     private ReplicationConfiguration configuration;
     private PartitionNexus nexus;
@@ -87,32 +87,32 @@
     private IoAcceptor registry;
     private final ClientConnectionManager clientConnectionManager = new ClientConnectionManager(
this );
     private AttributeTypeRegistry attrRegistry;
-    
-    
+
+
     public ReplicationService()
     {
     }
-    
-    
+
+
     public ReplicationConfiguration getConfiguration()
     {
         return configuration;
     }
-    
-    
+
+
     public void setConfiguration( ReplicationConfiguration cfg )
     {
         cfg.validate();
         this.configuration = cfg;
     }
-    
-    
+
+
     public DirectoryServiceConfiguration getFactoryConfiguration()
     {
         return directoryServiceConfiguration;
     }
 
-    
+
     public void init( DirectoryServiceConfiguration serviceCfg, InterceptorConfiguration
cfg ) throws NamingException
     {
         configuration.validate();
@@ -122,7 +122,7 @@
         store = configuration.getStore();
         operationFactory = new OperationFactory( serviceCfg, configuration );
         attrRegistry = serviceCfg.getGlobalRegistries().getAttributeTypeRegistry();
-        
+
         // Initialize store and service
         store.open( serviceCfg, configuration );
         boolean serviceStarted = false;
@@ -131,53 +131,48 @@
             startNetworking();
             serviceStarted = true;
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
             throw new ReplicationServiceException( "Failed to initialize MINA ServiceRegistry.",
e );
         }
         finally
         {
-            if( !serviceStarted )
+            if ( !serviceStarted )
             {
                 // roll back
                 store.close();
             }
         }
-        
+
         purgeAgedData();
     }
 
-    
+
     private void startNetworking() throws Exception
     {
         registry = new SocketAcceptor();
         IoServiceConfig config = new SocketAcceptorConfig();
 
-        config.getFilterChain().addLast(
-                "protocol",
-                new ProtocolCodecFilter( new ReplicationServerProtocolCodecFactory() ) );
-        
-        config.getFilterChain().addLast(
-                "logger",
-                new LoggingFilter());
+        config.getFilterChain().addLast( "protocol",
+            new ProtocolCodecFilter( new ReplicationServerProtocolCodecFactory() ) );
+
+        config.getFilterChain().addLast( "logger", new LoggingFilter() );
 
         // bind server protocol provider
-        registry.bind(
-                new InetSocketAddress( configuration.getServerPort() ),
-                new ReplicationServerProtocolHandler(this),
-                config );
-        
+        registry.bind( new InetSocketAddress( configuration.getServerPort() ), new ReplicationServerProtocolHandler(
+            this ), config );
+
         clientConnectionManager.start( configuration );
     }
 
-    
+
     public void destroy()
     {
         stopNetworking();
         store.close();
     }
 
-    
+
     private void stopNetworking()
     {
         // close all open connections, deactivate all filters and service registry
@@ -185,53 +180,51 @@
         {
             clientConnectionManager.stop();
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
             log.warn( "Failed to stop the client connection manager.", e );
         }
         registry.unbindAll();
     }
-    
+
 
     public void purgeAgedData() throws NamingException
     {
         Attributes rootDSE = nexus.getRootDSE();
         Attribute namingContextsAttr = rootDSE.get( "namingContexts" );
-        if( namingContextsAttr == null || namingContextsAttr.size() == 0 )
+        if ( namingContextsAttr == null || namingContextsAttr.size() == 0 )
         {
             throw new NamingException( "No namingContexts attributes in rootDSE." );
         }
-        
-        CSN purgeCSN = new SimpleCSN(
-                System.currentTimeMillis() -
-                configuration.getLogMaxAge() * 1000L * 60L * 60L * 24L, // convert days to
millis
-                new ReplicaId( "ZZZZZZZZZZZZZZZZ" ),
-                Integer.MAX_VALUE );
+
+        CSN purgeCSN = new SimpleCSN( System.currentTimeMillis() - configuration.getLogMaxAge()
* 1000L * 60L * 60L
+            * 24L, // convert days to millis
+            new ReplicaId( "ZZZZZZZZZZZZZZZZ" ), Integer.MAX_VALUE );
         FilterParser parser = new FilterParserImpl();
         ExprNode filter;
-        
+
         try
         {
-            filter = parser.parse( "(& (" + ENTRY_CSN_OID +"=<" 
-                + purgeCSN.toOctetString() + ") (" + ENTRY_DELETED_OID + "=true))" );
+            filter = parser.parse( "(& (" + ENTRY_CSN_OID + "=<" + purgeCSN.toOctetString()
+ ") (" + ENTRY_DELETED_OID
+                + "=true))" );
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             throw ( NamingException ) new NamingException().initCause( e );
         }
-        catch( ParseException e )
+        catch ( ParseException e )
         {
             throw ( NamingException ) new NamingException().initCause( e );
         }
-        
+
         // Iterate all context partitions to send all entries of them.
         NamingEnumeration e = namingContextsAttr.getAll();
-        while( e.hasMore() )
+        while ( e.hasMore() )
         {
             Object value = e.next();
             // Convert attribute value to JNDI name.
             LdapDN contextName;
-            if( value instanceof LdapDN )
+            if ( value instanceof LdapDN )
             {
                 contextName = ( LdapDN ) value;
             }
@@ -239,35 +232,33 @@
             {
                 contextName = new LdapDN( String.valueOf( value ) );
             }
-            
+
             contextName.normalize( attrRegistry.getNormalizerMapping() );
-            log.info( "Purging aged data under '" + contextName + '"');
+            log.info( "Purging aged data under '" + contextName + '"' );
             purgeAgedData( contextName, filter );
         }
-        
+
         store.removeLogs( purgeCSN, false );
     }
-    
-    
+
+
     private void purgeAgedData( LdapDN contextName, ExprNode filter ) throws NamingException
     {
         SearchControls ctrl = new SearchControls();
-        ctrl.setSearchScope( SearchControls.SUBTREE_SCOPE ); 
+        ctrl.setSearchScope( SearchControls.SUBTREE_SCOPE );
         ctrl.setReturningAttributes( new String[]
-        { "entryCSN", "entryDeleted" } );
+            { "entryCSN", "entryDeleted" } );
 
-        NamingEnumeration e = nexus.search( contextName,
-                directoryServiceConfiguration.getEnvironment(),
-                filter, ctrl );
+        NamingEnumeration e = nexus.search( contextName, directoryServiceConfiguration.getEnvironment(),
filter, ctrl );
 
         List names = new ArrayList();
         try
         {
-            while( e.hasMore() )
+            while ( e.hasMore() )
             {
                 SearchResult sr = ( SearchResult ) e.next();
                 LdapDN name = new LdapDN( sr.getName() );
-                if( name.size() > contextName.size() )
+                if ( name.size() > contextName.size() )
                 {
                     names.add( new LdapDN( sr.getName() ) );
                 }
@@ -277,9 +268,9 @@
         {
             e.close();
         }
-        
+
         Iterator it = names.iterator();
-        while( it.hasNext() )
+        while ( it.hasNext() )
         {
             LdapDN name = ( LdapDN ) it.next();
             try
@@ -288,83 +279,93 @@
                 log.info( "Purge: " + name + " (" + entry + ')' );
                 nexus.delete( ( LdapDN ) name );
             }
-            catch( NamingException ex )
+            catch ( NamingException ex )
             {
                 log.warn( "Failed to fetch/delete: " + name, ex );
             }
         }
     }
-    
-    
+
+
     public void add( NextInterceptor nextInterceptor, LdapDN normalizedName, Attributes entry
) throws NamingException
     {
         Operation op = operationFactory.newAdd( normalizedName, entry );
         op.execute( nexus, store );
     }
 
+
     public void delete( NextInterceptor nextInterceptor, LdapDN name ) throws NamingException
     {
         Operation op = operationFactory.newDelete( name );
         op.execute( nexus, store );
     }
 
+
     public void modify( NextInterceptor next, LdapDN name, int modOp, Attributes attrs )
throws NamingException
     {
         Operation op = operationFactory.newModify( name, modOp, attrs );
         op.execute( nexus, store );
     }
 
+
     public void modify( NextInterceptor next, LdapDN name, ModificationItem[] items ) throws
NamingException
     {
         Operation op = operationFactory.newModify( name, items );
         op.execute( nexus, store );
     }
 
-    public void modifyRn( NextInterceptor next, LdapDN oldName, String newRDN, boolean deleteOldRDN
) throws NamingException
+
+    public void modifyRn( NextInterceptor next, LdapDN oldName, String newRDN, boolean deleteOldRDN
)
+        throws NamingException
     {
         Operation op = operationFactory.newModifyRn( oldName, newRDN, deleteOldRDN );
         op.execute( nexus, store );
     }
 
-    public void move( NextInterceptor next, LdapDN oldName, LdapDN newParentName, String
newRDN, boolean deleteOldRDN ) throws NamingException
+
+    public void move( NextInterceptor next, LdapDN oldName, LdapDN newParentName, String
newRDN, boolean deleteOldRDN )
+        throws NamingException
     {
         Operation op = operationFactory.newMove( oldName, newParentName, newRDN, deleteOldRDN
);
         op.execute( nexus, store );
     }
 
+
     public void move( NextInterceptor next, LdapDN oldName, LdapDN newParentName ) throws
NamingException
     {
         Operation op = operationFactory.newMove( oldName, newParentName );
         op.execute( nexus, store );
     }
 
+
     public boolean hasEntry( NextInterceptor nextInterceptor, Name name ) throws NamingException
     {
         // Ask others first.
-        boolean hasEntry = nextInterceptor.hasEntry( (LdapDN)name );
-        
+        boolean hasEntry = nextInterceptor.hasEntry( ( LdapDN ) name );
+
         // If the entry exists,
-        if( hasEntry )
+        if ( hasEntry )
         {
             // Check DELETED attribute.
             try
             {
-                Attributes entry = nextInterceptor.lookup( (LdapDN)name );
+                Attributes entry = nextInterceptor.lookup( ( LdapDN ) name );
                 hasEntry = !isDeleted( entry );
             }
-            catch( NameNotFoundException e )
+            catch ( NameNotFoundException e )
             {
                 System.out.println( e.toString( true ) );
                 hasEntry = false;
             }
         }
-        
+
         return hasEntry;
     }
 
+
     public Attributes lookup( NextInterceptor nextInterceptor, Name name ) throws NamingException
     {
-        Attributes result = nextInterceptor.lookup( (LdapDN)name );
+        Attributes result = nextInterceptor.lookup( ( LdapDN ) name );
         ensureNotDeleted( name, result );
         return result;
     }
@@ -374,25 +375,25 @@
     {
         boolean found = false;
         // Look for 'entryDeleted' attribute is in attrIds.
-        for( int i = 0; i < attrIds.length; i ++ )
+        for ( int i = 0; i < attrIds.length; i++ )
         {
-            if( Constants.ENTRY_DELETED.equals( attrIds[i] ) )
+            if ( Constants.ENTRY_DELETED.equals( attrIds[i] ) )
             {
                 found = true;
                 break;
             }
         }
-        
+
         // If not exists, add one.
-        if( !found )
+        if ( !found )
         {
-            String[] newAttrIds = new String[ attrIds.length + 1 ];
+            String[] newAttrIds = new String[attrIds.length + 1];
             System.arraycopy( attrIds, 0, newAttrIds, 0, attrIds.length );
-            newAttrIds[ attrIds.length ] = Constants.ENTRY_DELETED;
+            newAttrIds[attrIds.length] = Constants.ENTRY_DELETED;
             attrIds = newAttrIds;
         }
-        
-        Attributes result = nextInterceptor.lookup( (LdapDN)name, attrIds );
+
+        Attributes result = nextInterceptor.lookup( ( LdapDN ) name, attrIds );
         ensureNotDeleted( name, result );
         return result;
     }
@@ -400,38 +401,40 @@
 
     public NamingEnumeration list( NextInterceptor nextInterceptor, Name baseName ) throws
NamingException
     {
-        NamingEnumeration e = nextInterceptor.list( (LdapDN)baseName );
-        return new SearchResultFilteringEnumeration( e, new SearchControls(), InvocationStack.getInstance().peek(),
Constants.DELETED_ENTRIES_FILTER );
+        NamingEnumeration e = nextInterceptor.list( ( LdapDN ) baseName );
+        return new SearchResultFilteringEnumeration( e, new SearchControls(), InvocationStack.getInstance().peek(),
+            Constants.DELETED_ENTRIES_FILTER );
     }
 
 
-    public NamingEnumeration search( NextInterceptor nextInterceptor, Name baseName, Map
environment, ExprNode filter, SearchControls searchControls ) throws NamingException
+    public NamingEnumeration search( NextInterceptor nextInterceptor, Name baseName, Map
environment, ExprNode filter,
+        SearchControls searchControls ) throws NamingException
     {
-        NamingEnumeration e = nextInterceptor.search( (LdapDN)baseName, environment, filter,
searchControls );
+        NamingEnumeration e = nextInterceptor.search( ( LdapDN ) baseName, environment, filter,
searchControls );
         if ( searchControls.getReturningAttributes() != null )
         {
             return e;
         }
 
-        return new SearchResultFilteringEnumeration( e, searchControls, InvocationStack.getInstance().peek(),
Constants.DELETED_ENTRIES_FILTER );
+        return new SearchResultFilteringEnumeration( e, searchControls, InvocationStack.getInstance().peek(),
+            Constants.DELETED_ENTRIES_FILTER );
     }
 
-    
+
     private void ensureNotDeleted( Name name, Attributes entry ) throws NamingException,
LdapNameNotFoundException
     {
-        if( isDeleted( entry ) )
+        if ( isDeleted( entry ) )
         {
-            LdapNameNotFoundException e = 
-                    new LdapNameNotFoundException( "Deleted entry: " + name );
-            e.setResolvedName( nexus.getMatchedName( (LdapDN)name ) );
+            LdapNameNotFoundException e = new LdapNameNotFoundException( "Deleted entry:
" + name );
+            e.setResolvedName( nexus.getMatchedName( ( LdapDN ) name ) );
             throw e;
         }
-    }    
+    }
+
 
-    
     private boolean isDeleted( Attributes entry ) throws NamingException
     {
-        if( entry == null )
+        if ( entry == null )
         {
             return true;
         }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationServiceException.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationServiceException.java?view=diff&rev=471331&r1=471330&r2=471331
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationServiceException.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationServiceException.java
Sat Nov  4 18:19:13 2006
@@ -19,26 +19,32 @@
  */
 package org.apache.directory.mitosis.service;
 
+
 import org.apache.directory.mitosis.common.ReplicationException;
 
+
 public class ReplicationServiceException extends ReplicationException
 {
     private static final long serialVersionUID = 3906090070204430386L;
 
+
     public ReplicationServiceException()
     {
         super();
     }
 
+
     public ReplicationServiceException( String message, Throwable cause )
     {
         super( message, cause );
     }
 
+
     public ReplicationServiceException( String message )
     {
         super( message );
     }
+
 
     public ReplicationServiceException( Throwable cause )
     {

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/SimpleReplicationContext.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/SimpleReplicationContext.java?view=diff&rev=471331&r1=471330&r2=471331
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/SimpleReplicationContext.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/SimpleReplicationContext.java
Sat Nov  4 18:19:13 2006
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.mitosis.service;
 
+
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -32,6 +33,7 @@
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.service.protocol.message.BaseMessage;
 
+
 public class SimpleReplicationContext implements ReplicationContext
 {
     private static final Timer expirationTimer = new Timer( "ReplicationMessageExpirer" );
@@ -44,8 +46,10 @@
     private int nextSequence;
     private Replica peer;
     private State state = State.INIT;
-    
-    public SimpleReplicationContext( ReplicationService service, DirectoryServiceConfiguration
serviceCfg, ReplicationConfiguration configuration, IoSession session )
+
+
+    public SimpleReplicationContext( ReplicationService service, DirectoryServiceConfiguration
serviceCfg,
+        ReplicationConfiguration configuration, IoSession session )
     {
         this.service = service;
         this.configuration = configuration;
@@ -53,70 +57,79 @@
         this.session = session;
     }
 
+
     public ReplicationService getService()
     {
         return service;
     }
-    
+
+
     public ReplicationConfiguration getConfiguration()
     {
         return configuration;
     }
-    
+
+
     public DirectoryServiceConfiguration getServiceConfiguration()
     {
         return serviceConfiguration;
     }
-    
+
+
     public IoSession getSession()
     {
         return session;
     }
 
+
     public int getNextSequence()
     {
-        return nextSequence ++;
+        return nextSequence++;
     }
 
+
     public Replica getPeer()
     {
         return peer;
     }
-    
+
+
     public void setPeer( Replica peer )
     {
         assert peer != null;
         this.peer = peer;
     }
-    
+
+
     public State getState()
     {
         return state;
     }
-    
+
+
     public void setState( State state )
     {
         this.state = state;
     }
-    
+
+
     public void scheduleExpiration( Object message )
     {
         BaseMessage bm = ( BaseMessage ) message;
         ExpirationTask task = new ExpirationTask( bm );
-        synchronized( expirableMessages )
+        synchronized ( expirableMessages )
         {
-            expirableMessages.put(
-                    new Integer( bm.getSequence() ),
-                    task );
+            expirableMessages.put( new Integer( bm.getSequence() ), task );
         }
-        
+
         expirationTimer.schedule( task, configuration.getResponseTimeout() * 1000L );
     }
-    
+
+
     public Object cancelExpiration( int sequence )
     {
         ExpirationTask task = removeTask( sequence );
-        if( task == null )
+        if ( task == null )
         {
             return null;
         }
@@ -124,31 +137,34 @@
         task.cancel();
         return task.message;
     }
-    
+
+
     public void cancelAllExpirations()
     {
-        synchronized( expirableMessages )
+        synchronized ( expirableMessages )
         {
             Iterator i = expirableMessages.values().iterator();
-            while( i.hasNext() )
+            while ( i.hasNext() )
             {
                 ( ( ExpirationTask ) i.next() ).cancel();
             }
         }
     }
-    
+
+
     public int getScheduledExpirations()
     {
-        synchronized( expirableMessages )
+        synchronized ( expirableMessages )
         {
             return expirableMessages.size();
         }
     }
 
+
     private ExpirationTask removeTask( int sequence )
     {
         ExpirationTask task;
-        synchronized( expirableMessages )
+        synchronized ( expirableMessages )
         {
             task = ( ExpirationTask ) expirableMessages.remove( new Integer( sequence ) );
         }
@@ -158,19 +174,20 @@
     private class ExpirationTask extends TimerTask
     {
         private final BaseMessage message;
-        
+
+
         private ExpirationTask( Object message )
         {
             this.message = ( BaseMessage ) message;
         }
 
+
         public void run()
         {
-            if( removeTask( message.getSequence() ) == this )
+            if ( removeTask( message.getSequence() ) == this )
             {
-                SessionLog.warn(
-                        getSession(),
-                        "No response within " + configuration.getResponseTimeout() + " second(s)
for message #" + message.getSequence() );
+                SessionLog.warn( getSession(), "No response within " + configuration.getResponseTimeout()
+                    + " second(s) for message #" + message.getSequence() );
                 getSession().close();
             }
         }



Mime
View raw message