private static CounterSet doCountersQuery(final HttpClient cm,final String hostname,final String baseRequestURI,final int uniqueId) throws Exception {
  final String uriStr=baseRequestURI + "/counters";
  final ConnectOptions o=new ConnectOptions(uriStr);
  o.setAcceptHeader(ConnectOptions.MIME_APPLICATION_XML);
  o.method="GET";
  o.addRequestParam("path","/" + hostname + "/");
  o.addRequestParam("depth","3");
  o.addRequestParam("uniqueId",Integer.toString(uniqueId));
  boolean didDrainEntity=false;
  JettyResponseListener response=null;
  try {
    response=doConnect(cm,o);
    RemoteRepository.checkResponseCode(response);
    final String contentType=response.getContentType();
    if (!contentType.startsWith(IMimeTypes.MIME_APPLICATION_XML)) {
      throw new IOException("Expecting " + IMimeTypes.MIME_APPLICATION_XML + ", not Content-Type="+ contentType);
    }
    final CounterSet counterSet=new CounterSet();
    final InputStream is=response.getInputStream();
    try {
      counterSet.readXML(is,DefaultInstrumentFactory.NO_OVERWRITE_60M,null);
      didDrainEntity=true;
      if (log.isDebugEnabled())       log.debug("hostname=" + hostname + ": counters="+ counterSet);
      return counterSet;
    }
  finally {
      try {
        is.close();
      }
 catch (      IOException ex) {
        log.warn(ex);
      }
    }
  }
  finally {
    if (response != null && !didDrainEntity) {
      response.abort();
    }
  }
}

private static CounterSet doCountersQuery ( final HttpClient cm , final String hostname , final String baseRequestURI , final int uniqueId ) throws Exception { final String uriStr = baseRequestURI + "/counters" ; final ConnectOptions o = new ConnectOptions ( uriStr ) ; o . setAcceptHeader ( ConnectOptions . MIME_APPLICATION_XML ) ; o . method = "GET" ; o . addRequestParam ( "path" , "/" + hostname + "/" ) ; o . addRequestParam ( "depth" , "3" ) ; o . addRequestParam ( "uniqueId" , Integer . toString ( uniqueId ) ) ; boolean didDrainEntity = false ; JettyResponseListener response = null ; try { response = doConnect ( cm , o ) ; RemoteRepository . checkResponseCode ( response ) ; final String contentType = response . getContentType ( ) ; if ( ! contentType . startsWith ( IMimeTypes . MIME_APPLICATION_XML ) ) { throw new IOException ( "Expecting " + IMimeTypes . MIME_APPLICATION_XML + ", not Content-Type=" + contentType ) ; } final CounterSet counterSet = new CounterSet ( ) ; final InputStream is = response . getInputStream ( ) ; try { counterSet . readXML ( is , DefaultInstrumentFactory . NO_OVERWRITE_60M , null ) ; didDrainEntity = true ; if ( log . isDebugEnabled ( ) ) log . debug ( "hostname=" + hostname + ": counters=" + counterSet ) ; return counterSet ; } finally { try { is . close ( ) ; } catch ( IOException ex ) { log . warn ( ex ) ; } } } finally { if ( response != null && ! didDrainEntity ) { response . abort ( ) ; } } }
do an http get to the remote service and return the platform performance metrics for that service .
