give jmx service a much longer retry period (3m instead of 1s)

we keep getting errors in a test on jenkins machines, and can't fathom why as 
we test beforehand and close:

java.rmi.server.ExportException: Port already in use: 40123; nested exception 
is:
        java.net.BindException: Address already in use
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at 
java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
        at java.net.ServerSocket.bind(ServerSocket.java:376)
        at java.net.ServerSocket.<init>(ServerSocket.java:237)
        at java.net.ServerSocket.<init>(ServerSocket.java:128)
        at 
sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMIDirectSocketFactory.java:45)
        at 
sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMIMasterSocketFactory.java:344)
        at 
sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:666)
        at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:329)
        at 
sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:248)
        at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:411)
        at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
        at 
sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:207)
        at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:122)
        at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:108)
        at 
java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:203)
        at mx4j.tools.naming.NamingService.start(NamingService.java:67)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
        at 
com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:112)
        at 
com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:46)
        at 
com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237)
        at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
        at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
        at 
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
        at 
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
        at 
javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:292)
        at com.sun.proxy.$Proxy657.start(Unknown Source)
        at 
org.apache.brooklyn.entity.software.base.test.jmx.JmxService.<init>(JmxService.java:107)
        at 
org.apache.brooklyn.entity.software.base.test.jmx.JmxService.<init>(JmxService.java:80)
        at 
org.apache.brooklyn.feed.jmx.RebindJmxFeedTest.runJmxFeedIsPersisted(RebindJmxFeedTest.java:99)
        at 
org.apache.brooklyn.feed.jmx.RebindJmxFeedTest.testJmxFeedIsPersisted(RebindJmxFeedTest.java:86)


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/e3dd4095
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/e3dd4095
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/e3dd4095

Branch: refs/heads/master
Commit: e3dd40957867d8083e3e1b2d6d278125009048f6
Parents: 98c342c
Author: Alex Heneveld <alex.henev...@cloudsoftcorp.com>
Authored: Thu Sep 22 21:36:26 2016 +0100
Committer: Alex Heneveld <alex.henev...@cloudsoftcorp.com>
Committed: Thu Sep 22 21:36:26 2016 +0100

----------------------------------------------------------------------
 .../software/base/test/jmx/JmxService.java      | 22 +++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e3dd4095/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/jmx/JmxService.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/jmx/JmxService.java
 
b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/jmx/JmxService.java
index 397aff3..9b88307 100644
--- 
a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/jmx/JmxService.java
+++ 
b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/jmx/JmxService.java
@@ -98,13 +98,21 @@ public class JmxService {
             server.registerMBean(new NamingService(jmxPort), naming);
             Object proxy = 
MBeanServerInvocationHandler.newProxyInstance(server, naming, 
NamingServiceMBean.class, false);
             namingServiceMBean = (NamingServiceMBean) proxy;
-            try {
-                namingServiceMBean.start();
-            } catch (Exception e) {
-                // may take a bit of time for port to be available, if it had 
just been used
-                logger.warn("JmxService couldn't start test mbean ("+e+"); 
will delay then retry once");
-                Thread.sleep(1000);
-                namingServiceMBean.start();
+            for (int i=0; ; i++) {
+                try {
+                    namingServiceMBean.start();
+                    break;
+                } catch (Exception e) {
+                    // may take a bit of time for port to be available, if it 
had just been used
+                    if (i==0) logger.warn("JmxService couldn't start test 
mbean ("+e+"); will delay and retry");
+                    else if (i>=180) {
+                        logger.warn("JmxService couldn't start test mbean 
("+e+"); definitive; throwing "+e);
+                        throw e;
+                    } else {
+                        logger.debug("JmxService couldn't start test mbean on 
retry attempt "+i+" ("+e+"); will continue retrying");
+                    }
+                    Thread.sleep(1000);
+                }
             }
     
             connectorServer.start();

Reply via email to