public static void main(String[] args) {
    final String barrierName = args.length == 0 ? "barrierName" : args[0];
    final int numberOfParties = Integer.parseInt(args.length == 0 ? "2" : args[0]);

    // Start the Terracotta client
    ClusteringToolkit toolkit = new TerracottaClient("localhost:9510").getToolkit();

    // Get an instance of a barrier by name
    Barrier barrier = toolkit.getBarrier(barrierName, numberOfParties);
    try {
      System.out.println("Waiting ...");
      int index = barrier.await();
      System.out.println("... finished " + index);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public EhCachePerfTest(final Configuration configuration) {
    SpringFactory.getApplicationContext(configuration);
    ehcacheBean = SpringFactory.getControllerBean(configuration, TcEhCacheManagerFactoryBean.class);
    if (ehcacheBean == null) {
      log.warn("Cant find TcEhCacheManagerFactoryBean. Load incoherently WON'T work.");
    }

    this.test = configuration.getTestCase().getTest();
    if (test == null) throw new RuntimeException("Test case is null.");
    log.info("XXXXX running test: " + this.test.getClass().getSimpleName());
    test.setDriver(this);
    this.configuration = configuration;
    if (configuration.isStandalone()) {
      ClusteringToolkit toolkit =
          new TerracottaClient(configuration.getExpressTerracottaUrl()).getToolkit();
      this.barrier = toolkit.getBarrier(BARRIER_ROOT, configuration.getNodesNum());
      clusterTestCount = toolkit.getAtomicLong("ehcacheperf-clusterTestCount");
      clusterLatency = toolkit.getAtomicLong("ehcacheperf-clusterLatency");
      clusterWarmup = toolkit.getAtomicLong("ehcacheperf-warmup");
      clusterReads = toolkit.getAtomicLong("ehcacheperf-clusterReads");
      clusterWrites = toolkit.getAtomicLong("ehcacheperf-clusterWrites");
      clusterCacheWarmup = toolkit.getAtomicLong("ehcacheperf-clusterCacheWarmup");

      // Counter for increasing keys over time
      ClusteredAtomicLong atomicLong = toolkit.getAtomicLong("ehcacheperf-currKeyCount");
      atomicLong.set(configuration.getElementNum());
      test.setCurrKeyCount(atomicLong);
    } else {
      this.barrier = new DefaultBarrierImpl(configuration.getNodesNum());
      clusterTestCount = new DefaultAtomicLongImpl();
      clusterLatency = new DefaultAtomicLongImpl();
      clusterWarmup = new DefaultAtomicLongImpl();
      clusterReads = new DefaultAtomicLongImpl();
      clusterWrites = new DefaultAtomicLongImpl();
      clusterCacheWarmup = new DefaultAtomicLongImpl();
    }
    this.nodeId = await();
    test.setNodeId(nodeId);
    test.setNumberOfNodes(configuration.getNodesNum());
  }