[hornetq-commits] JBoss hornetq SVN: r11083 - in branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster: util and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Aug 1 08:49:46 EDT 2011


Author: borges
Date: 2011-08-01 08:49:46 -0400 (Mon, 01 Aug 2011)
New Revision: 11083

Modified:
   branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
   branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java
Log:
HORNETQ-720 "waitForBackup(..)" to wait for synchronization to finish.

Modified: branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
--- branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java	2011-08-01 10:31:50 UTC (rev 11082)
+++ branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java	2011-08-01 12:49:46 UTC (rev 11083)
@@ -41,6 +41,7 @@
 import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
 import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
 import org.hornetq.core.server.NodeManager;
+import org.hornetq.core.server.impl.HornetQServerImpl;
 import org.hornetq.core.server.impl.InVMNodeManager;
 import org.hornetq.tests.integration.cluster.util.SameProcessHornetQServer;
 import org.hornetq.tests.integration.cluster.util.TestableServer;
@@ -230,12 +231,29 @@
       return sf;
    }
 
-   protected static void waitForBackup(ClientSessionFactoryInternal sessionFactory, long seconds) throws Exception
+   /**
+    * This method will Waits for backup to be in the "started" state and to finish synchronization
+    * with the live.
+    * @param sessionFactory
+    * @param seconds
+    * @throws Exception
+    */
+   protected void waitForBackup(ClientSessionFactoryInternal sessionFactory, long seconds) throws Exception
    {
       final long toWait = seconds * 1000;
       final long time = System.currentTimeMillis();
-      while (sessionFactory.getBackupConnector() == null)
+      final HornetQServerImpl actualServer = (HornetQServerImpl)backupServer.getServer();
+      while (true)
       {
+         if (sessionFactory.getBackupConnector() != null && actualServer.isRemoteBackupUpToDate())
+         {
+            break;
+         }
+         if (System.currentTimeMillis() > (time + toWait))
+         {
+            fail("backup server never started (" + backupServer.isStarted() + "), or never finished synchronizing (" +
+                     actualServer.isRemoteBackupUpToDate() + ")");
+         }
          try
          {
             Thread.sleep(100);
@@ -244,16 +262,10 @@
          {
             //ignore
          }
-         if (sessionFactory.getBackupConnector() != null)
-         {
-            break;
-         }
-         else if (System.currentTimeMillis() > (time + toWait))
-         {
-            fail("backup server never started");
-         }
       }
-      System.out.println("sf.getBackupConnector() = " + sessionFactory.getBackupConnector());
+
+      System.out.println("Backup server state: [started=" + actualServer.isStarted() + ", upToDate=" +
+               actualServer.isRemoteBackupUpToDate() + "]");
    }
 
    protected TransportConfiguration getNettyAcceptorTransportConfiguration(final boolean live)

Modified: branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java
===================================================================
--- branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java	2011-08-01 10:31:50 UTC (rev 11082)
+++ branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java	2011-08-01 12:49:46 UTC (rev 11083)
@@ -34,7 +34,7 @@
 public class RemoteProcessHornetQServer implements TestableServer
 {
 
-   private String configurationClassName;
+   private final String configurationClassName;
    private Process serverProcess;
    private boolean initialised = false;
    private CountDownLatch initLatch;
@@ -44,7 +44,7 @@
    {
       this.configurationClassName = configurationClassName;
    }
-   
+
    public boolean isInitialised()
    {
       if (serverProcess == null)
@@ -53,7 +53,7 @@
       }
       try
       {
-         initLatch = new CountDownLatch(1);         
+         initLatch = new CountDownLatch(1);
          RemoteProcessHornetQServerSupport.isInitialised(serverProcess);
          boolean ok = initLatch.await(10, TimeUnit.SECONDS);
          if (ok)
@@ -139,7 +139,7 @@
          RemoteProcessHornetQServerSupport.crash(serverProcess);
          serverProcess = null;
       }
-      
+
       // Wait to be informed of failure
       boolean ok = latch.await(10000, TimeUnit.MILLISECONDS);
 



More information about the hornetq-commits mailing list