private JMXConnector connect(String host,int port){
  try {
    if (!isNodeAvailable(host)) {
      log.info("Node({}) is unavailable",host);
      throw new IllegalStateException("Node is unavailable");
    }
    log.debug("Connecting to JMX Server {}:{}",host,port);
    String connectorAddress=String.format(serviceUrl,host,port);
    JMXServiceURL jmxUrl=new JMXServiceURL(connectorAddress);
    return JMXConnectorFactory.connect(jmxUrl);
  }
 catch (  MalformedURLException e) {
    log.error(String.format("Failed to construct jmx url for %s:%d",host,port),e);
    throw new IllegalStateException("Failed to construct jmx url");
  }
catch (  IOException e) {
    log.error(String.format("Failed to connect %s:%d",host,port),e);
    throw new IllegalStateException("Failed to connect " + host);
  }
}

private JMXConnector connect ( String host , int port ) { try { if ( ! isNodeAvailable ( host ) ) { log . info ( "Node({}) is unavailable" , host ) ; throw new IllegalStateException ( "Node is unavailable" ) ; } log . debug ( "Connecting to JMX Server {}:{}" , host , port ) ; String connectorAddress = String . format ( serviceUrl , host , port ) ; JMXServiceURL jmxUrl = new JMXServiceURL ( connectorAddress ) ; return JMXConnectorFactory . connect ( jmxUrl ) ; } catch ( MalformedURLException e ) { log . error ( String . format ( "Failed to construct jmx url for %s:%d" , host , port ) , e ) ; throw new IllegalStateException ( "Failed to construct jmx url" ) ; } catch ( IOException e ) { log . error ( String . format ( "Failed to connect %s:%d" , host , port ) , e ) ; throw new IllegalStateException ( "Failed to connect " + host ) ; } }
create a connection to the jmx agent
