qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject svn commit: r886974 - in /qpid/trunk/qpid/java/management: common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
Date Thu, 03 Dec 2009 23:06:38 GMT
Author: robbie
Date: Thu Dec  3 23:06:36 2009
New Revision: 886974

URL: http://svn.apache.org/viewvc?rev=886974&view=rev
Log:
QPID-2152: Update the timeout process so as not to return a null, and close any orphaned connections.
Increase default timeout to 15sec.

Modified:
    qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java
    qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java

Modified: qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java?rev=886974&r1=886973&r2=886974&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java
(original)
+++ qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java
Thu Dec  3 23:06:36 2009
@@ -199,25 +199,32 @@
         Thread connectorThread = new Thread(connector);
         connectorThread.start();
         connectorThread.join(timeout);
-
-        if (connector.getConnectionException() != null)
+        
+        if(connector.getJmxc() == null)
         {
-            throw connector.getConnectionException();
+            if (connector.getConnectionException() != null)
+            {
+                throw connector.getConnectionException();
+            }
+            else
+            {
+                throw new IOException("Timed out connecting to " + host + ":" + port);
+            }
         }
+        
         return connector.getJmxc();
     }
 	
-    public static class ConnectWaiter implements Runnable
+    private static class ConnectWaiter implements Runnable
     {
-        private boolean _connected;
         private Exception _connectionException;
         private JMXConnector _jmxc;
         private JMXServiceURL _jmxUrl;
         private Map<String, ?> _env;
+        private boolean _connectionRetrieved;
         
         public ConnectWaiter(JMXServiceURL url, Map<String, ?> env)
         {
-            super();
             _jmxUrl = url;
             _env = env;
         }
@@ -226,46 +233,52 @@
         {
             try
             {
-                setConnected(false);
-                setConnectionException(null);
-                setJmxc(JMXConnectorFactory.connect(_jmxUrl, _env));
-
-                setConnected(true);
+                _jmxc = null;
+                _connectionRetrieved = false;
+                _connectionException = null;
+                
+                JMXConnector conn = JMXConnectorFactory.connect(_jmxUrl, _env);
+                
+                synchronized (this)
+                {
+                    if(_connectionRetrieved)
+                    {
+                        //The app thread already timed out the attempt and retrieved the

+                        //null connection, so just close this orphaned connection
+                        try
+                        {
+                            conn.close();
+                        }
+                        catch (IOException e)
+                        {
+                            //ignore
+                        }
+                    }
+                    else
+                    {
+                        _jmxc = conn;
+                    }
+                }
             }
             catch (Exception ex)
             {
-                setConnectionException(ex);
+                _connectionException = ex;
             }
         }
 
-        public void setConnected(boolean _connected)
-        {
-            this._connected = _connected;
-        }
-
-        public boolean getConnected()
-        {
-            return _connected;
-        }
-
-        public void setConnectionException(Exception _connectionException)
-        {
-            this._connectionException = _connectionException;
-        }
-
         public Exception getConnectionException()
         {
             return _connectionException;
         }
 
-        public void setJmxc(JMXConnector _jmxc)
-        {
-            this._jmxc = _jmxc;
-        }
-
         public JMXConnector getJmxc()
         {
-            return _jmxc;
+            synchronized (this)
+            {
+                _connectionRetrieved = true;
+                
+                return _jmxc;
+            }
         }
     }
 }

Modified: qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java?rev=886974&r1=886973&r2=886974&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
(original)
+++ qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
Thu Dec  3 23:06:36 2009
@@ -43,7 +43,7 @@
     private static ImageRegistry imageRegistry = new ImageRegistry();
     private static FontRegistry fontRegistry = new FontRegistry();
     public static final boolean debug = Boolean.getBoolean("eclipse.consoleLog");
-    public static final long timeout = Long.parseLong(System.getProperty("timeout", "5000"));
+    public static final long timeout = Long.parseLong(System.getProperty("timeout", "15000"));
 
     //max supported broker management interface supported by this release of the management
console
     public static final int SUPPORTED_QPID_JMX_API_MAJOR_VERSION = 1;



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message