public synchronized void reconnect() throws IOException { disconnect(); try { connect(); failedReconnecting = false; } catch (Exception e) { if (failedReconnecting) { if (LOG.isDebugEnabled()) LOG.debug("unable to re-connect to JMX url (repeated failure): {}: {}", url, e); } else { LOG.debug("unable to re-connect to JMX url {} (rethrowing): {}", url, e); failedReconnecting = true; } failedReconnectingTime = System.currentTimeMillis(); throw Throwables.propagate(e); } }
@AfterMethod(alwaysRun=true) public void tearDown() throws Exception { if (jmxHelper != null) jmxHelper.disconnect(); if (jmxService != null) jmxService.shutdown(); jmxHelper = null; jmxService = null; }
@AfterMethod(alwaysRun=true) public void tearDown() throws Exception { try { if (jmxHelper != null) jmxHelper.disconnect(); if (jmxService != null) jmxService.shutdown(); } finally { super.tearDown(); } }
@AfterMethod(alwaysRun=true) public void tearDown() throws Exception { try { if (feed != null) feed.stop(); if (jmxHelper != null) jmxHelper.disconnect(); if (jmxService != null) jmxService.shutdown(); feed = null; } finally { super.tearDown(); } }
@Test public void testMBeanNotFoundLoggedOnlyOncePerUrl() throws Exception { ObjectName wrongObjectName = new ObjectName("DoesNotExist:type=DoesNotExist"); // Expect just one log message about: // JMX object DoesNotExist:type=DoesNotExist not found at service:jmx:rmi://localhost:1099/jndi/rmi://localhost:9001/jmxrmi" for (int i = 0; i < 10; i++) { jmxHelper.findMBean(wrongObjectName); } jmxService.shutdown(); jmxHelper.disconnect(); jmxService = newJmxServiceRetrying(LOCALHOST_NAME, 5); jmxHelper = new JmxHelper(jmxService.getUrl()); jmxHelper.connect(); // Expect just one log message about: // JMX object DoesNotExist:type=DoesNotExist not found at service:jmx:rmi://localhost:1099/jndi/rmi://localhost:9001/jmxrmi" for (int i = 0; i < 10; i++) { jmxHelper.findMBean(wrongObjectName); } }