[hornetq-commits] JBoss hornetq SVN: r9401 - in branches/2_2_0_HA_Improvements: src/main/org/hornetq/ra and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jul 15 06:21:14 EDT 2010


Author: ataylor
Date: 2010-07-15 06:21:14 -0400 (Thu, 15 Jul 2010)
New Revision: 9401

Modified:
   branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
   branches/2_2_0_HA_Improvements/src/main/org/hornetq/ra/ConnectionFactoryProperties.java
   branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
Log:
tweaked ra ha setting, fixed test and added NoSharedstore activation for the server

Modified: branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java	2010-07-14 07:50:45 UTC (rev 9400)
+++ branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java	2010-07-15 10:21:14 UTC (rev 9401)
@@ -289,6 +289,101 @@
       return new LockFileImpl(fileName, directory);
    }
 
+   private class NoSharedStoreLiveActivation implements Activation
+   {
+      LockFile liveLock;
+
+      public void run()
+      {
+         try
+         {
+            File journalDir = new File(configuration.getJournalDirectory());
+
+            if (!journalDir.exists())
+            {
+               if (configuration.isCreateJournalDir())
+               {
+                  journalDir.mkdirs();
+               }
+               else
+               {
+                  throw new IllegalArgumentException("Directory " + journalDir +
+                                                     " does not exist and will not create it");
+               }
+            }
+
+
+            // We now load the node id file, creating it, if it doesn't exist yet
+            File nodeIDFile = new File(configuration.getJournalDirectory(), "node.id");
+
+            if (!nodeIDFile.exists())
+            {
+               // We use another file lock to prevent a backup reading it before it is complete
+
+               LockFile nodeIDLockFile = createLockFile("nodeid.lock", configuration.getJournalDirectory());
+
+               nodeIDLockFile.lock();
+
+               OutputStream os = null;
+
+               try
+               {
+                  os = new BufferedOutputStream(new FileOutputStream(nodeIDFile));
+
+                  uuid = UUIDGenerator.getInstance().generateUUID();
+
+                  nodeID = new SimpleString(uuid.toString());
+
+                  os.write(uuid.asBytes());
+
+                  log.info("Wrote node id, it is " + nodeID);
+               }
+               finally
+               {
+                  if (os != null)
+                  {
+                     os.close();
+                  }
+               }
+
+               nodeIDLockFile.unlock();
+            }
+            else
+            {
+               // Read it
+
+               readNodeID(nodeIDFile);
+            }
+
+            initialisePart1();
+
+            initialisePart2();
+
+            log.info("Server is now live");
+         }
+         catch (Exception e)
+         {
+            log.error("Failure in initialisation", e);
+         }
+      }
+
+      public void close() throws Exception
+      {
+         if (liveLock != null)
+         {
+            // We need to delete the file too, otherwise the backup will failover when we shutdown or if the backup is
+            // started before the live
+
+            File liveFile = new File(configuration.getJournalDirectory(), "live.lock");
+
+            liveFile.delete();
+
+            liveLock.unlock();
+
+         }
+      }
+   }
+
    private class SharedStoreLiveActivation implements Activation
    {
       LockFile liveLock;
@@ -631,6 +726,12 @@
 
             activation.run();
          }
+         else
+         {
+            activation = new NoSharedStoreLiveActivation();
+
+            activation.run();
+         }
       }
 
       started = true;

Modified: branches/2_2_0_HA_Improvements/src/main/org/hornetq/ra/ConnectionFactoryProperties.java
===================================================================
--- branches/2_2_0_HA_Improvements/src/main/org/hornetq/ra/ConnectionFactoryProperties.java	2010-07-14 07:50:45 UTC (rev 9400)
+++ branches/2_2_0_HA_Improvements/src/main/org/hornetq/ra/ConnectionFactoryProperties.java	2010-07-15 10:21:14 UTC (rev 9401)
@@ -31,6 +31,8 @@
     */
    private static boolean trace = ConnectionFactoryProperties.log.isTraceEnabled();
 
+   private final static Boolean IS_HA = false;
+
    private boolean hasBeenUpdated = false;
 
    /**
@@ -43,7 +45,7 @@
     */
    private Map<String, Object> connectionParameters;
    
-   private Boolean ha;
+   private Boolean ha = IS_HA;
 
    private String connectionLoadBalancingPolicyClassName;
 

Modified: branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
===================================================================
--- branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java	2010-07-14 07:50:45 UTC (rev 9400)
+++ branches/2_2_0_HA_Improvements/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java	2010-07-15 10:21:14 UTC (rev 9401)
@@ -84,7 +84,7 @@
       Assert.assertEquals(factory.getDiscoveryAddress(), null);
       Assert.assertEquals(factory.getDiscoveryInitialWaitTimeout(),
                           HornetQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT);
-      Assert.assertEquals(factory.getDiscoveryPort(), 0);
+      Assert.assertEquals(factory.getDiscoveryPort(), -1);
       Assert.assertEquals(factory.getDiscoveryRefreshTimeout(),
                           HornetQClient.DEFAULT_DISCOVERY_REFRESH_TIMEOUT);
       Assert.assertEquals(factory.getDupsOKBatchSize(), HornetQClient.DEFAULT_ACK_BATCH_SIZE);
@@ -138,7 +138,7 @@
       Assert.assertEquals(factory.getDiscoveryAddress(), null);
       Assert.assertEquals(factory.getDiscoveryInitialWaitTimeout(),
                           HornetQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT);
-      Assert.assertEquals(factory.getDiscoveryPort(), 0);
+      Assert.assertEquals(factory.getDiscoveryPort(), -1);
       Assert.assertEquals(factory.getDiscoveryRefreshTimeout(),
                           HornetQClient.DEFAULT_DISCOVERY_REFRESH_TIMEOUT);
       Assert.assertEquals(factory.getDupsOKBatchSize(), HornetQClient.DEFAULT_ACK_BATCH_SIZE);
@@ -206,7 +206,7 @@
       Assert.assertEquals(factory.getConsumerWindowSize(), 5);
       Assert.assertEquals(factory.getDiscoveryAddress(), null);
       Assert.assertEquals(factory.getDiscoveryInitialWaitTimeout(), 6);
-      Assert.assertEquals(factory.getDiscoveryPort(), 0);
+      Assert.assertEquals(factory.getDiscoveryPort(), -1);
       Assert.assertEquals(factory.getDiscoveryRefreshTimeout(), 7);
       Assert.assertEquals(factory.getDupsOKBatchSize(), 8);
       Assert.assertEquals(factory.getMinLargeMessageSize(), 10);
@@ -270,7 +270,7 @@
       Assert.assertEquals(factory.getConsumerWindowSize(), 5);
       Assert.assertEquals(factory.getDiscoveryAddress(), null);
       Assert.assertEquals(factory.getDiscoveryInitialWaitTimeout(), 6);
-      Assert.assertEquals(factory.getDiscoveryPort(), 0);
+      Assert.assertEquals(factory.getDiscoveryPort(), -1);
       Assert.assertEquals(factory.getDiscoveryRefreshTimeout(), 7);
       Assert.assertEquals(factory.getDupsOKBatchSize(), 8);
       Assert.assertEquals(factory.getMinLargeMessageSize(), 10);



More information about the hornetq-commits mailing list