smiklosovic commented on code in PR #2577:
URL: https://github.com/apache/cassandra/pull/2577#discussion_r1300330415


##########
test/distributed/org/apache/cassandra/distributed/impl/IsolatedJmx.java:
##########
@@ -127,45 +131,26 @@ public void startJmx()
 
             registry.setRemoteServerStub(jmxRmiServer.toStub());
             JMXServerUtils.logJmxServiceUrl(addr, jmxPort);
-            waitForJmxAvailability(hostname, jmxPort, env);
+            waitForJmxAvailability(env);
         }
-        catch (Throwable e)
+        catch (Throwable t)
         {
-            throw new RuntimeException("Feature.JMX was enabled but could not 
be started.", e);
+            throw new RuntimeException("Feature.JMX was enabled but could not 
be started.", t);
         }
     }
 
-
-    private void waitForJmxAvailability(String hostname, int rmiPort, 
Map<String, Object> env) throws InterruptedException, MalformedURLException
+    private void waitForJmxAvailability(Map<String, ?> env)
     {
-        String url = 
String.format("service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi", hostname, rmiPort);
-        JMXServiceURL serviceURL = new JMXServiceURL(url);
-        int attempts = 0;
-        Throwable lastThrown = null;
-        while (attempts < 20)
-        {
-            attempts++;
-            try (JMXConnector ignored = 
JMXConnectorFactory.connect(serviceURL, env))
-            {
-                inInstancelogger.info("Connected to JMX server at {} after {} 
attempt(s)",
-                                      url, attempts);
-                return;
-            }
-            catch (MalformedURLException e)
-            {
-                throw new RuntimeException(e);
-            }
-            catch (Throwable thrown)
-            {
-                lastThrown = thrown;
-            }
-            inInstancelogger.info("Could not connect to JMX on {} after {} 
attempts. Will retry.", url, attempts);
-            Thread.sleep(1000);
+        try (JMXConnector ignored = JMXUtil.getJmxConnector(config, 20, env)) {
+            // Do nothing - JMXUtil now retries
+        } catch (IOException iex) {

Review Comment:
   @JeetKunDoug here too



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to