private void shutdownConnectors() {
   log.debug("Shutting down connectors");
   Iterator<Object> it = connectors.keySet().iterator();
   while (it.hasNext()) {
     Object key = it.next();
     final AWSMonAgentConnector conn = connectors.get(key);
     log.debug("Shutting down " + conn.toString());
     // Fix ConcurrentModificationException if more than one host
     // connectors.remove(key);
     it.remove();
     conn.disconnect();
   }
 }
 private void processConnectors() {
   Iterator<Object> it = connectors.keySet().iterator();
   while (it.hasNext()) {
     Object key = it.next();
     AWSMonAgentConnector connector = connectors.get(key);
     try {
       connector.generateSamples(this);
     } catch (IOException e) {
       log.error(e.getMessage());
       connectors.put(key, new UnavailableAgentConnector(e));
     }
   }
 }
  private void initiateConnector(
      String instanceid,
      String credentials_path,
      int index,
      String metricType,
      String statisticType,
      StandardUnit unit,
      long startTime,
      int awsInterval) {
    AWSConnector server = new AWSConnector(instanceid, credentials_path);
    String stringKey = server.toString() + "#" + index; // strange check

    // handle label parameter
    //  MetricParams paramsParsed = MetricParams.createFromString(statisticType);
    String label;
    // if (paramsParsed.getLabel().isEmpty()) {
    label = instanceid + " " + metricType + " " + statisticType;
    /* } /*else {
        label = instanceid + " " + metric + " " + paramsParsed.getLabel();
        // TODO: God, I need to test this case properly or find better way to do this
        params = params.replaceAll(":label=" + paramsParsed.getLabel() + ":", "");
        params = params.replaceAll("label=" + paramsParsed.getLabel() + ":", "");
        params = params.replaceAll(":label=" + paramsParsed.getLabel(), "");
    }*/

    try {
      if (connectors.containsKey(server)) {
        connectors
            .get(server)
            .addMetric(metricType, statisticType, label, unit, startTime, awsInterval);
      } else {
        AWSMonAgentConnector connector = getConnector(instanceid, credentials_path);
        connector.addMetric(metricType, statisticType, label, unit, startTime, awsInterval);

        if (connector instanceof AgentConnector) {
          connectors.put(stringKey, connector);
        } else {
          connectors.put(server, connector);
        }
      }
    } catch (IOException e) {
      log.error("Problems creating connector", e);
      connectors.put(stringKey, new UnavailableAgentConnector(e));
    }
  }