public AbstractBenchmarkClient addClients(ClientType type, BenchmarkPartConfig partConfig) {

    AbstractBenchmarkClient bc = null;

    switch (type) {
      case CONSUMER:
        bc = new BenchmarkJMSConsumerWrapper(this, partConfig);
        break;
      case PRODUCER:
        bc = new BenchmarkJMSProducerWrapper(this, partConfig);
        break;
      case PROBER:
        bc = new BenchmarkProbeWrapper(this, partConfig.getParent());
        break;
      default:
        // can't happen
        break;
    }

    boolean prepared = bc.prepare();

    if (prepared) {
      synchronized (activeClients) {
        activeClients.put(bc.getClientId().toString(), bc);
      }
      return bc;
    } else {
      log().warn("Error while setting up clients for clientId: " + bc.getClientId());
      return null;
    }
  }
 public AbstractBenchmarkClient addProbeRunner(BenchmarkConfig config) {
   AbstractBenchmarkClient bc = new BenchmarkProbeWrapper(this, config);
   if (bc.prepare()) {
     synchronized (activeClients) {
       activeClients.put(bc.getClientId().toString(), bc);
     }
     return bc;
   } else {
     log().warn("Error while setting up clients for clientId: " + bc.getClientId());
     return null;
   }
 }
 public void endBenchmark(EndBenchmarkCommand endCommand) {
   for (AbstractBenchmarkClient client : getClientsByBenchmarkId(endCommand.getBenchmarkId())) {
     client.release();
     synchronized (activeClients) {
       activeClients.remove(client.getClientId().toString());
     }
   }
 }
  private List<AbstractBenchmarkClient> getClientsByBenchmarkId(String benchmarkId) {

    ArrayList<AbstractBenchmarkClient> result = new ArrayList<AbstractBenchmarkClient>();
    synchronized (activeClients) {
      for (AbstractBenchmarkClient client : activeClients.values()) {
        if (client.getClientId().getBenchmarkId().equals(benchmarkId)) {
          result.add(client);
        }
      }
    }
    return result;
  }
 public void startBenchmark(StartBenchmarkCommand startCommand) {
   for (AbstractBenchmarkClient client : getClientsByBenchmarkId(startCommand.getBenchmarkId())) {
     log().debug("Starting client: " + client.getClientId());
     client.start();
   }
 }