[jboss-cvs] JBoss Messaging SVN: r8224 - in branches/JBM1842/src/main/org/jboss: messaging/core/impl/postoffice and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 15 10:00:55 EST 2011


Author: gaohoward
Date: 2011-02-15 10:00:55 -0500 (Tue, 15 Feb 2011)
New Revision: 8224

Modified:
   branches/JBM1842/src/main/org/jboss/jms/server/MessagingClusterHealthMBean.java
   branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java
Log:
fix second restart issue, and added retry on failure of restarting po


Modified: branches/JBM1842/src/main/org/jboss/jms/server/MessagingClusterHealthMBean.java
===================================================================
--- branches/JBM1842/src/main/org/jboss/jms/server/MessagingClusterHealthMBean.java	2011-02-15 14:49:20 UTC (rev 8223)
+++ branches/JBM1842/src/main/org/jboss/jms/server/MessagingClusterHealthMBean.java	2011-02-15 15:00:55 UTC (rev 8224)
@@ -68,7 +68,6 @@
       connectionFactories = new ArrayList<ObjectName>();
       destinations = new ArrayList<ObjectName>();
       
-      nodeRecovery = new NodeRecovery();
       log.info(this + " started.");
    }
    
@@ -80,8 +79,11 @@
       connectionFactories.clear();
       destinations.clear();
       
-      nodeRecovery.abandon();
-      nodeRecovery = null;
+      if (nodeRecovery != null)
+      {
+         nodeRecovery.abandon();
+         nodeRecovery = null;
+      }
       log.info(this + " stopped.");
    }
    
@@ -113,6 +115,8 @@
       
       nodeStopped = true;
       
+      nodeRecovery = new NodeRecovery();
+      
       nodeRecovery.start();
       
       log.info("JBM node is stopped.");
@@ -223,7 +227,14 @@
       
       //wait for jgroups back
       MessagingPostOffice pm = (MessagingPostOffice)JMXAccessor.getJMXAttributeOverSecurity(server, poName, "Instance");
-      pm.waitForJGroups();
+      while (!pm.waitForJGroups())
+      {
+         log.info("Failed to start post office due to JGroups failure, retrying...");
+         this.stopService(poName);
+         makeSureDelay();
+         this.startService(poName);
+         pm = (MessagingPostOffice)JMXAccessor.getJMXAttributeOverSecurity(server, poName, "Instance");
+      }
       
       List<ObjectName> copy = new ArrayList<ObjectName>(connectionFactories);
       connectionFactories.clear();

Modified: branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java
===================================================================
--- branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java	2011-02-15 14:49:20 UTC (rev 8223)
+++ branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java	2011-02-15 15:00:55 UTC (rev 8224)
@@ -4337,7 +4337,7 @@
       groupMember.unregisterChannelInJmx(server, channelPartitionName);
    }
 
-   public void waitForJGroups()
+   public boolean waitForJGroups()
    {
       log.info("Waiting for JGroups...");
       synchronized (jgroupsLock)
@@ -4379,19 +4379,27 @@
             {
                PostOfficeAddressInfo info = new PostOfficeAddressInfo(groupMember.getControlChannelAddress(),
                                                                       groupMember.getDataChannelAddress());
+               boolean stateGot = groupMember.requestState();
+               
                // requestState
-               if (!groupMember.requestState())
+               if (!stateGot)
                {
                   log.info("couldn't get state, we are the first  (coordinator).");
                   for (Address addr : newNodes)
                   {
                      if (!addr.equals(info.getControlChannelAddress()))
                      {
-                        groupMember.requestState(addr);
-                        break;
+                        stateGot = groupMember.requestState(addr);
+                        if (stateGot) break;
                      }
                   }
                }
+               
+               if (!stateGot)
+               {
+                  log.info("We cannot get state from JGroups.");
+                  return false;
+               }
 
                nodeIDAddressMap.put(new Integer(thisNodeID), info);
 
@@ -4411,9 +4419,11 @@
             catch (Exception e)
             {
                log.error("Error initializing state", e);
+               return false;
             }
          }
          log.info("Now node is ready for work.");
+         return true;
       }
    }
    



More information about the jboss-cvs-commits mailing list