[hornetq-commits] JBoss hornetq SVN: r11596 - in branches/Branch_2_2_EAP/src/main/org/hornetq: jms/client and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Oct 25 17:50:31 EDT 2011


Author: clebert.suconic
Date: 2011-10-25 17:50:31 -0400 (Tue, 25 Oct 2011)
New Revision: 11596

Modified:
   branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
   branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
   branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQConnectionFactory.java
   branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/recovery/HornetQXAResourceWrapper.java
   branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/recovery/XARecoveryConfig.java
   branches/Branch_2_2_EAP/src/main/org/hornetq/ra/recovery/RecoveryManager.java
Log:
Just adding some logging to debug the resource adapter's recovery

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java	2011-10-25 18:44:58 UTC (rev 11595)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java	2011-10-25 21:50:31 UTC (rev 11596)
@@ -885,9 +885,8 @@
       }
 
       // Should never get here
-      throw new IllegalStateException("Internal Error! ClientSessionFactoryImpl::createSessionInternal " +
-                                      "just reached a condition that was not supposed to happen. " +
-                                      "Please inform this condition to the HornetQ team");
+      throw new IllegalStateException("Internal Error! ClientSessionFactoryImpl::createSessionInternal " + "just reached a condition that was not supposed to happen. "
+                                      + "Please inform this condition to the HornetQ team");
    }
 
    private void callFailureListeners(final HornetQException me, final boolean afterReconnect, final boolean failedOver)
@@ -1293,7 +1292,9 @@
                ClientSessionFactoryImpl.log.trace(this + "::Subscribing Topology");
             }
 
-            channel0.send(new SubscribeClusterTopologyUpdatesMessageV2(serverLocator.isClusterConnection(), VersionLoader.getVersion().getIncrementingVersion()));
+            channel0.send(new SubscribeClusterTopologyUpdatesMessageV2(serverLocator.isClusterConnection(),
+                                                                       VersionLoader.getVersion()
+                                                                                    .getIncrementingVersion()));
 
          }
       }
@@ -1314,13 +1315,16 @@
    /**
     * @param channel0
     */
-   public void sendNodeAnnounce(final long currentEventID, String nodeID, boolean isBackup, TransportConfiguration config, TransportConfiguration backupConfig)
+   public void sendNodeAnnounce(final long currentEventID,
+                                String nodeID,
+                                boolean isBackup,
+                                TransportConfiguration config,
+                                TransportConfiguration backupConfig)
    {
       Channel channel0 = connection.getChannel(0, -1);
       if (ClientSessionFactoryImpl.isDebug)
       {
-         ClientSessionFactoryImpl.log.debug("Announcing node " + serverLocator.getNodeID() +
-                                            ", isBackup=" + isBackup);
+         ClientSessionFactoryImpl.log.debug("Announcing node " + serverLocator.getNodeID() + ", isBackup=" + isBackup);
       }
       channel0.send(new NodeAnnounceMessage(currentEventID, nodeID, isBackup, config, backupConfig));
    }
@@ -1489,7 +1493,10 @@
                                                      " csf created at\nserverLocator=" +
                                                      serverLocator, e);
                }
-               serverLocator.notifyNodeUp(System.currentTimeMillis(), topMessage.getNodeID(), topMessage.getPair(), topMessage.isLast());
+               serverLocator.notifyNodeUp(System.currentTimeMillis(),
+                                          topMessage.getNodeID(),
+                                          topMessage.getPair(),
+                                          topMessage.isLast());
             }
          }
          else if (type == PacketImpl.CLUSTER_TOPOLOGY_V2)
@@ -1516,7 +1523,10 @@
                                                      " csf created at\nserverLocator=" +
                                                      serverLocator, e);
                }
-               serverLocator.notifyNodeUp(topMessage.getUniqueEventID(), topMessage.getNodeID(), topMessage.getPair(), topMessage.isLast());
+               serverLocator.notifyNodeUp(topMessage.getUniqueEventID(),
+                                          topMessage.getNodeID(),
+                                          topMessage.getPair(),
+                                          topMessage.isLast());
             }
          }
       }
@@ -1642,6 +1652,20 @@
    }
 
    /* (non-Javadoc)
+    * @see java.lang.Object#toString()
+    */
+   @Override
+   public String toString()
+   {
+      return "ClientSessionFactoryImpl [serverLocator=" + serverLocator +
+             ", connectorConfig=" +
+             connectorConfig +
+             ", backupConfig=" +
+             backupConfig +
+             "]";
+   }
+
+   /* (non-Javadoc)
     * @see org.hornetq.core.client.impl.ClientSessionFactoryInternal#setReconnectAttempts(int)
     */
    public void setReconnectAttempts(final int attempts)

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java	2011-10-25 18:44:58 UTC (rev 11595)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java	2011-10-25 21:50:31 UTC (rev 11596)
@@ -1687,7 +1687,8 @@
              username +
              ", closed=" +
              closed +
-             " metaData=(" +
+             ", factory = " + this.sessionFactory +
+             ", metaData=(" +
              buffer +
              ")]@" +
              Integer.toHexString(hashCode());

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQConnectionFactory.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQConnectionFactory.java	2011-10-25 18:44:58 UTC (rev 11595)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQConnectionFactory.java	2011-10-25 21:50:31 UTC (rev 11596)
@@ -700,6 +700,24 @@
 
    // Private --------------------------------------------------------------------------------------
 
+   /* (non-Javadoc)
+    * @see java.lang.Object#toString()
+    */
+   @Override
+   public String toString()
+   {
+      return "HornetQConnectionFactory [serverLocator=" + serverLocator +
+             ", clientID=" +
+             clientID +
+             ", dupsOKBatchSize=" +
+             dupsOKBatchSize +
+             ", transactionBatchSize=" +
+             transactionBatchSize +
+             ", readOnly=" +
+             readOnly +
+             "]";
+   }
+
    private void checkWrite()
    {
       if (readOnly)

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/recovery/HornetQXAResourceWrapper.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/recovery/HornetQXAResourceWrapper.java	2011-10-25 18:44:58 UTC (rev 11595)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/recovery/HornetQXAResourceWrapper.java	2011-10-25 21:50:31 UTC (rev 11596)
@@ -13,17 +13,15 @@
 
 package org.hornetq.jms.server.recovery;
 
-import java.util.Map;
+import java.util.Arrays;
 
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
 import org.hornetq.api.core.HornetQException;
-import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.client.ClientSession;
 import org.hornetq.api.core.client.ClientSessionFactory;
-import org.hornetq.api.core.client.HornetQClient;
 import org.hornetq.api.core.client.ServerLocator;
 import org.hornetq.api.core.client.SessionFailureListener;
 import org.hornetq.core.logging.Logger;
@@ -53,19 +51,25 @@
    private static final Object lock = new Object();
 
    private ServerLocator serverLocator;
-   
+
    private ClientSessionFactory csf;
 
    private XAResource delegate;
 
    private XARecoveryConfig[] xaRecoveryConfigs;
 
-   //private TransportConfiguration currentConnection;
+   // private TransportConfiguration currentConnection;
 
    public HornetQXAResourceWrapper(XARecoveryConfig... xaRecoveryConfigs)
    {
+      this.xaRecoveryConfigs = xaRecoveryConfigs;
 
-      this.xaRecoveryConfigs = xaRecoveryConfigs;
+      if (log.isDebugEnabled())
+      {
+         log.debug("Recovery configured with " + Arrays.toString(xaRecoveryConfigs) +
+                   ", instance=" +
+                   System.identityHashCode(this));
+      }
    }
 
    public Xid[] recover(final int flag) throws XAException
@@ -74,10 +78,18 @@
       HornetQXAResourceWrapper.log.debug("Recover " + xaResource);
       try
       {
-         return xaResource.recover(flag);
+         Xid[] xids = xaResource.recover(flag);
+
+         if (log.isDebugEnabled() && xids != null && xids.length > 0)
+         {
+            log.debug("Recovering these following IDs " + Arrays.toString(xids) + " at " + this);
+         }
+
+         return xids;
       }
       catch (XAException e)
       {
+         log.warn(e.getMessage(), e);
          throw check(e);
       }
    }
@@ -214,7 +226,8 @@
 
    public void connectionFailed(final HornetQException me, boolean failedOver)
    {
-      HornetQXAResourceWrapper.log.warn("Notified of connection failure in xa recovery connectionFactory for provider " + csf + " will attempt reconnect on next pass",
+      HornetQXAResourceWrapper.log.warn("Notified of connection failure in xa recovery connectionFactory for provider " + csf +
+                                                 " will attempt reconnect on next pass",
                                         me);
       close();
    }
@@ -244,9 +257,9 @@
 
       if (result == null)
       {
-         //we should always throw a retry for certain methods comit etc, if not the tx is marked as a heuristic and
-         //all chaos is let loose
-         if(retry)
+         // we should always throw a retry for certain methods comit etc, if not the tx is marked as a heuristic and
+         // all chaos is let loose
+         if (retry)
          {
             XAException xae = new XAException("Connection unavailable for xa recovery");
             xae.errorCode = XAException.XA_RETRY;
@@ -294,6 +307,10 @@
       for (XARecoveryConfig xaRecoveryConfig : xaRecoveryConfigs)
       {
 
+         if (log.isDebugEnabled())
+         {
+            log.debug("Trying to connect recovery on " + xaRecoveryConfig + " of " + Arrays.toString(xaRecoveryConfigs));
+         }
 
          ClientSession cs = null;
 
@@ -308,7 +325,13 @@
             }
             else
             {
-               cs = csf.createSession(xaRecoveryConfig.getUsername(), xaRecoveryConfig.getPassword(), true, false, false, false, 1);
+               cs = csf.createSession(xaRecoveryConfig.getUsername(),
+                                      xaRecoveryConfig.getPassword(),
+                                      true,
+                                      false,
+                                      false,
+                                      false,
+                                      1);
             }
          }
          catch (HornetQException e)
@@ -323,10 +346,29 @@
          }
 
          return delegate;
-       }
+      }
+      log.warn("Can't connect to any hornetq server on recovery " + Arrays.toString(xaRecoveryConfigs));
       throw new HornetQException(HornetQException.NOT_CONNECTED);
    }
 
+   /* (non-Javadoc)
+    * @see java.lang.Object#toString()
+    */
+   @Override
+   public String toString()
+   {
+      return "HornetQXAResourceWrapper [serverLocator=" + serverLocator +
+             ", csf=" +
+             csf +
+             ", delegate=" +
+             delegate +
+             ", xaRecoveryConfigs=" +
+             Arrays.toString(xaRecoveryConfigs) +
+             ", instance=" +
+             System.identityHashCode(this) +
+             "]";
+   }
+
    /**
     * Close the connection
     */
@@ -366,6 +408,8 @@
     */
    protected XAException check(final XAException e) throws XAException
    {
+      log.warn(e.getMessage(), e);
+
       if (e.errorCode == XAException.XA_RETRY)
       {
          close();

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/recovery/XARecoveryConfig.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/recovery/XARecoveryConfig.java	2011-10-25 18:44:58 UTC (rev 11595)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/recovery/XARecoveryConfig.java	2011-10-25 21:50:31 UTC (rev 11596)
@@ -65,8 +65,24 @@
 
       return true;
    }
+   
+   
 
+   /* (non-Javadoc)
+    * @see java.lang.Object#toString()
+    */
    @Override
+   public String toString()
+   {
+      return "XARecoveryConfig [hornetQConnectionFactory=" + hornetQConnectionFactory +
+             ", username=" +
+             username +
+             ", password=" +
+             password +
+             "]";
+   }
+
+   @Override
    public int hashCode()
    {
       int result = hornetQConnectionFactory != null ? hornetQConnectionFactory.hashCode() : 0;

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/recovery/RecoveryManager.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/recovery/RecoveryManager.java	2011-10-25 18:44:58 UTC (rev 11595)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/recovery/RecoveryManager.java	2011-10-25 21:50:31 UTC (rev 11596)
@@ -54,6 +54,8 @@
 
    public HornetQResourceRecovery register(HornetQConnectionFactory factory, String userName, String password)
    {
+      log.debug("registering recovery for factory : " + factory);
+      
       if(!isRegistered(factory) && registry != null)
       {
          XARecoveryConfig xaRecoveryConfig = new XARecoveryConfig(factory, userName, password);



More information about the hornetq-commits mailing list