geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r396773 - in /geronimo/gbuild/trunk: gbuild-agent-application/src/conf/ gbuild-agent-web/src/main/java/org/apache/geronimo/gbuild/agent/web/ gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/
Date Tue, 25 Apr 2006 05:35:54 GMT
Author: dblevins
Date: Mon Apr 24 22:35:52 2006
New Revision: 396773

URL: http://svn.apache.org/viewcvs?rev=396773&view=rev
Log:
Fix for GBUILD-16 "Improve GBuild agent JMS reconnect logic"
The strategy is now:
1. Use ActiveMQ failover with exponential delay maxed at 30min
2. Retry every two hours there after up to four days

Modified:
    geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml
    geronimo/gbuild/trunk/gbuild-agent-web/src/main/java/org/apache/geronimo/gbuild/agent/web/BuildQueueBrowser.java
    geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/Client.java
    geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/ClientManager.java

Modified: geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml
URL: http://svn.apache.org/viewcvs/geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml?rev=396773&r1=396772&r2=396773&view=diff
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml (original)
+++ geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml Mon Apr 24 22:35:52
2006
@@ -65,10 +65,11 @@
       <role>org.apache.geronimo.gbuild.agent.ClientManager</role>
       <implementation>org.apache.geronimo.gbuild.agent.ClientManager</implementation>
       <configuration>
-        <broker-url>tcp://ci.gbuild.org:16161</broker-url>
+        <broker-url>failover:(tcp://ci.gbuild.org:16161)?maxReconnectDelay=1800000</broker-url>
         <ping-interval>300000</ping-interval>
-        <reconnect-attempts>10</reconnect-attempts>
-        <reconnect-delay>600000</reconnect-delay>
+        <reconnect-attempts>48</reconnect-attempts>
+        <reconnect-delay>2</reconnect-delay>
+        <reconnect-delay-unit>hours</reconnect-delay-unit>
       </configuration>
     </component>
 

Modified: geronimo/gbuild/trunk/gbuild-agent-web/src/main/java/org/apache/geronimo/gbuild/agent/web/BuildQueueBrowser.java
URL: http://svn.apache.org/viewcvs/geronimo/gbuild/trunk/gbuild-agent-web/src/main/java/org/apache/geronimo/gbuild/agent/web/BuildQueueBrowser.java?rev=396773&r1=396772&r2=396773&view=diff
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent-web/src/main/java/org/apache/geronimo/gbuild/agent/web/BuildQueueBrowser.java
(original)
+++ geronimo/gbuild/trunk/gbuild-agent-web/src/main/java/org/apache/geronimo/gbuild/agent/web/BuildQueueBrowser.java
Mon Apr 24 22:35:52 2006
@@ -18,6 +18,7 @@
 
 import org.apache.geronimo.gbuild.agent.Client;
 import org.apache.geronimo.gbuild.agent.ClientManager;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 import javax.jms.Message;
 import javax.jms.ObjectMessage;
@@ -33,7 +34,7 @@
 /**
  * @version $Rev$ $Date$
  */
-public class BuildQueueBrowser implements WebComponent {
+public class BuildQueueBrowser extends AbstractLogEnabled implements WebComponent{
 
     /**
      * @plexus.requirement
@@ -56,15 +57,17 @@
     private int maxWidth;
 
     public void service(HttpServletRequest request, HttpServletResponse response) throws
Exception {
+        getLogger().info("Browsing: "+buildTaskQueue);
 
         Client client = clientManager.getClient();
-
         Session session = client.getSession();
         Queue queue = session.createQueue(buildTaskQueue);
         QueueBrowser browser = session.createBrowser(queue);
+        getLogger().info("Browser: "+browser);
 
         Enumeration enumeration = browser.getEnumeration();
-
+        getLogger().info("Enum: "+enumeration);
+    
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
         out.println("<html><body><h1>Browsing "+buildTaskQueue+"</h1>");
@@ -81,8 +84,10 @@
         }
         out.println("</tr>");
 
+        getLogger().info("Has elements: "+enumeration.hasMoreElements());
         while (enumeration.hasMoreElements()) {
             Message message = (Message) enumeration.nextElement();
+            getLogger().info("Message: "+message);
             if (message instanceof ObjectMessage) {
                 ObjectMessage objectMessage = (ObjectMessage) message;
                 Object object = objectMessage.getObject();
@@ -106,7 +111,9 @@
                 }
             }
         }
+        browser.close();
         out.println("</table>");
         out.println("</body></html>");
+        out.close();
     }
 }

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/Client.java
URL: http://svn.apache.org/viewcvs/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/Client.java?rev=396773&r1=396772&r2=396773&view=diff
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/Client.java
(original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/Client.java
Mon Apr 24 22:35:52 2006
@@ -132,7 +132,7 @@
     }
 
     private Connection connect() throws JMSException {
-        return connect(10);
+        return connect(maxTries);
     }
 
     private Connection connect(int tries) throws JMSException {
@@ -149,7 +149,6 @@
                 throw e;
             } else {
                 try {
-                    int delay = 5000;
                     getLogger().info("Client reconnect failed.  Trying again in "+delay+"
milliseconds. ("+ e.getMessage()+")");
                     Thread.sleep(delay);
                 } catch (InterruptedException dontCare) {

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/ClientManager.java
URL: http://svn.apache.org/viewcvs/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/ClientManager.java?rev=396773&r1=396772&r2=396773&view=diff
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/ClientManager.java
(original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/ClientManager.java
Mon Apr 24 22:35:52 2006
@@ -23,6 +23,8 @@
 
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
  * @version $Rev$ $Date$
@@ -49,11 +51,39 @@
      */
     private int reconnectDelay;
 
+    /**
+     * @plexus.configuration
+     */
+    private String reconnectDelayUnit = "seconds";
+
+    private Map timeUnits = new HashMap();
+
     private Client client;
 
-    public ClientManager() {}
+    public ClientManager() {
+        int unit = 1000;
+        timeUnits.put("seconds", new Integer(unit));
+        timeUnits.put("sec", new Integer(unit));
+        timeUnits.put("s", new Integer(unit));
+
+        unit *= 60;
+        timeUnits.put("minutes", new Integer(unit));
+        timeUnits.put("min", new Integer(unit));
+        timeUnits.put("m", new Integer(unit));
+
+        unit *= 60;
+        timeUnits.put("hours", new Integer(unit));
+        timeUnits.put("hour", new Integer(unit));
+        timeUnits.put("h", new Integer(unit));
+
+        unit *= 24;
+        timeUnits.put("days", new Integer(unit));
+        timeUnits.put("day", new Integer(unit));
+        timeUnits.put("d", new Integer(unit));
+    }
 
     public ClientManager(String brokerUrl, int pingInterval, int reconnectAttempts, int reconnectDelay)
{
+        this();
         this.brokerUrl = brokerUrl;
         this.pingInterval = pingInterval;
         this.reconnectAttempts = reconnectAttempts;
@@ -65,8 +95,12 @@
     }
 
     public synchronized void start() throws StartingException {
+        Integer unit = (Integer) timeUnits.get(reconnectDelayUnit);
+        if (unit == null){
+            unit = new Integer(1000); //seconds
+        }
         try {
-            setClient(new Client(brokerUrl, this, getLogger(), reconnectDelay, reconnectAttempts,
pingInterval));
+            setClient(new Client(brokerUrl, this, getLogger(), reconnectDelay * unit.intValue(),
reconnectAttempts, pingInterval));
         } catch (Throwable e) {
             getLogger().error("Could not create connection to: " + brokerUrl, e);
             throw new StartingException("Could not create connection to: " + brokerUrl);



Mime
View raw message