/** * Access-Method for the {@link #connectorMap}. * * @param connectorName * @return * @throws JmxServerConnectionException */ public JmxServerConnector getConnector(JmxConnectors connectorName) throws JmxServerConnectionException { if (!connectorMap.containsKey(connectorName)) { throw new JmxServerConnectionException("No Connector available for connection name '" + connectorName + "'"); } final JmxServerConnector connector = connectorMap.get(connectorName); return connector; } }
/** * Access-Method for the {@link #connectorMap}. * * @param connectorName * @return * @throws JmxServerConnectionException */ public JmxServerConnector getConnector(JmxConnectors connectorName) throws JmxServerConnectionException { if (!connectorMap.containsKey(connectorName)) { throw new JmxServerConnectionException("No Connector available for connection name '" + connectorName + "'"); } final JmxServerConnector connector = connectorMap.get(connectorName); return connector; } }
@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."); }
connector.connect(env); } catch (SecurityException x) { throw new JmxServerConnectionException("Security exception: bad credentials", x); return connectionWrapper; } catch (MalformedURLException e) { throw new JmxServerConnectionException(e); } catch (IOException e) { throw new JmxServerConnectionException(e);
connector.connect(env); } catch (SecurityException x) { throw new JmxServerConnectionException("Security exception: bad credentials", x); return connectionWrapper; } catch (MalformedURLException e) { throw new JmxServerConnectionException(e); } catch (IOException e) { throw new JmxServerConnectionException(e);