@Override public JmxServerConnectionWrapper connect(JmxConnectors connectorName, InetAddress ipAddress, Map<String, String> properties, RetryCallback retryCallback) throws JmxServerConnectionException { // if null, use dummy implementation if (retryCallback == null) { retryCallback = NULL_CALLBACK; } JmxServerConnectionException lastException = null; final JmxServerConnector connector = getConnector(connectorName); for (int i = 0; i < retries; i++) { LOG.debug("{}/{}: Try connecting to {}", (i+1), retries, ipAddress); retryCallback.onRetry(); try { JmxServerConnectionWrapper connectionWrapper = connector.createConnection(ipAddress, properties); if (connectionWrapper == null) { throw new JmxServerConnectionException("Received null connection"); } return connectionWrapper; } catch (JmxServerConnectionException ex) { LOG.debug("Connection could not be established", ex); lastException = ex; } } if (lastException != null) { throw lastException; } throw new JmxServerConnectionException("Connection could not be established. Reason: No retries left."); }
@Override public JmxServerConnectionWrapper connect(JmxConnectors connectorName, InetAddress ipAddress, Map<String, String> properties, RetryCallback retryCallback) throws JmxServerConnectionException { // if null, use dummy implementation if (retryCallback == null) { retryCallback = NULL_CALLBACK; } JmxServerConnectionException lastException = null; final JmxServerConnector connector = getConnector(connectorName); for (int i = 0; i < retries; i++) { LOG.debug("{}/{}: Try connecting to {}", (i+1), retries, ipAddress); retryCallback.onRetry(); try { JmxServerConnectionWrapper connectionWrapper = connector.createConnection(ipAddress, properties); if (connectionWrapper == null) { throw new JmxServerConnectionException("Received null connection"); } return connectionWrapper; } catch (JmxServerConnectionException ex) { LOG.debug("Connection could not be established", ex); lastException = ex; } } if (lastException != null) { throw lastException; } throw new JmxServerConnectionException("Connection could not be established. Reason: No retries left."); }