Author: elecharny
Date: Mon May 6 23:46:46 2013
New Revision: 1479726
URL: http://svn.apache.org/r1479726
Log:
o Fixed the testModDn test by waiting for the consumer thread to be initialized before accepting
incoming requests
o Initialized the handlers, partitions and replication before opening the server
Modified:
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java?rev=1479726&r1=1479725&r2=1479726&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
Mon May 6 23:46:46 2013
@@ -33,6 +33,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import javax.net.ssl.KeyManagerFactory;
@@ -256,13 +258,13 @@ public class LdapServer extends Director
private KeyManagerFactory keyManagerFactory;
- /** the time interval between subsequent pings to each replication provider */
+ /** the time interval between subsequent pings to each replication provider */
private int pingerSleepTime;
/** the list of cipher suites to be used in LDAPS and StartTLS */
private List<String> enabledCipherSuites = new ArrayList<String>();
-
-
+
+
/**
* Creates an LDAP protocol provider.
*/
@@ -471,6 +473,30 @@ public class LdapServer extends Director
loadKeyStore();
+ /*
+ * The server is now initialized, we can
+ * install the default requests handlers, which need
+ * access to the DirectoryServer instance.
+ */
+ installDefaultHandlers();
+
+ PartitionNexus nexus = getDirectoryService().getPartitionNexus();
+
+ for ( ExtendedOperationHandler h : extendedOperationHandlers )
+ {
+ LOG.info( "Added Extended Request Handler: " + h.getOid() );
+ h.setLdapServer( this );
+ nexus.registerSupportedExtensions( h.getExtensionOids() );
+ }
+
+ nexus.registerSupportedSaslMechanisms( saslMechanismHandlers.keySet() );
+
+ // Install the replication handler if we have one
+ startReplicationProducer();
+
+ // And start the replication consumers on this server
+ startReplicationConsumers();
+
for ( Transport transport : transports )
{
if ( !( transport instanceof TcpTransport ) )
@@ -522,30 +548,6 @@ public class LdapServer extends Director
startNetwork( transport, chain );
}
- /*
- * The server is now initialized, we can
- * install the default requests handlers, which need
- * access to the DirectoryServer instance.
- */
- installDefaultHandlers();
-
- PartitionNexus nexus = getDirectoryService().getPartitionNexus();
-
- for ( ExtendedOperationHandler h : extendedOperationHandlers )
- {
- LOG.info( "Added Extended Request Handler: " + h.getOid() );
- h.setLdapServer( this );
- nexus.registerSupportedExtensions( h.getExtensionOids() );
- }
-
- nexus.registerSupportedSaslMechanisms( saslMechanismHandlers.keySet() );
-
- // Install the replication handler if we have one
- startReplicationProducer();
-
- // And start the replication consumers on this server
- startReplicationConsumers();
-
started = true;
LOG.info( "Ldap service started." );
@@ -709,6 +711,9 @@ public class LdapServer extends Director
{
consumer.init( getDirectoryService() );
+ // A counter to be decremented when the consumer thread is started
+ final CountDownLatch counter = new CountDownLatch( 1 );
+
Runnable consumerTask = new Runnable()
{
public void run()
@@ -728,6 +733,8 @@ public class LdapServer extends Director
if ( isConnected )
{
+ // Ok, we are connected, we can signal the parent that
all is ok
+ counter.countDown();
pingerThread.addConsumer( consumer );
// We are now connected, start the replication
@@ -759,6 +766,9 @@ public class LdapServer extends Director
Thread consumerThread = new Thread( consumerTask );
consumerThread.setDaemon( true );
consumerThread.start();
+
+ // Wait for the consumer thread to be started
+ counter.await( 60, TimeUnit.SECONDS );
}
}
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java?rev=1479726&r1=1479725&r2=1479726&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
Mon May 6 23:46:46 2013
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTru
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
@@ -93,8 +94,13 @@ public class ClientServerReplicationIT
public static void setUp() throws Exception
{
Class.forName( FrameworkRunner.class.getName() );
- startProvider();
- startConsumer();
+ CountDownLatch counter = new CountDownLatch( 2 );
+
+ startProvider( counter );
+ startConsumer( counter );
+
+ // Wait for the two servers to be up and running
+ counter.await();
}
@@ -187,6 +193,7 @@ public class ClientServerReplicationIT
Entry consumerEntry = consumerSession.lookup( entryDn, "*", "+" );
Csn providerCSN = new Csn( providerEntry.get( SchemaConstants.ENTRY_CSN_AT
).getString() );
Csn consumerCSN = new Csn( consumerEntry.get( SchemaConstants.ENTRY_CSN_AT
).getString() );
+
if ( consumerCSN.compareTo( providerCSN ) >= 0 )
{
if ( print )
@@ -277,7 +284,6 @@ public class ClientServerReplicationIT
@Test
- @Ignore
public void testModDn() throws Exception
{
Entry provUser = createEntry();
@@ -287,7 +293,7 @@ public class ClientServerReplicationIT
// Add entry "cn=entryN,dc=example,dc=com" and check it is replicated
providerSession.add( provUser );
-
+
assertTrue( checkEntryReplicated( userDn ) );
// Add container for users "ou=users,dc=example,dc=com" and check it is replicated
@@ -333,7 +339,7 @@ public class ClientServerReplicationIT
assertTrue( checkEntryReplicated( movedAndRenamedEntryDn ) );
compareEntries( movedAndRenamedEntryDn );
-
+
// cleanup
providerSession.delete( usersContainerDn );
}
@@ -490,7 +496,7 @@ public class ClientServerReplicationIT
private void compareEntries( Dn dn ) throws Exception
{
String[] searchAttributes = new String[]
- {
+ {
SchemaConstants.ALL_USER_ATTRIBUTES,
SchemaConstants.ENTRY_UUID_AT
};
@@ -539,7 +545,7 @@ public class ClientServerReplicationIT
})
@CreateLdapServer(transports =
{ @CreateTransport(port = 16000, protocol = "LDAP") })
- public static void startProvider() throws Exception
+ public static void startProvider( final CountDownLatch counter ) throws Exception
{
DirectoryService provDirService = DSAnnotationProcessor.getDirectoryService();
@@ -556,6 +562,7 @@ public class ClientServerReplicationIT
{
schemaManager = providerServer.getDirectoryService().getSchemaManager();
providerSession = providerServer.getDirectoryService().getAdminSession();
+ counter.countDown();
}
catch ( Exception e )
{
@@ -604,7 +611,7 @@ public class ClientServerReplicationIT
refreshInterval = 1000,
replicaId = 1
)
- public static void startConsumer() throws Exception
+ public static void startConsumer( final CountDownLatch counter ) throws Exception
{
DirectoryService provDirService = DSAnnotationProcessor.getDirectoryService();
consumerServer = ServerAnnotationProcessor.getLdapServer( provDirService );
@@ -649,6 +656,7 @@ public class ClientServerReplicationIT
consumerSession = consumerServer.getDirectoryService().getAdminSession();
consumerSession.add( provConfigEntry );
+ counter.countDown();
}
catch ( Exception e )
{
|