private Multimap<String, String> computeUserParameters() {
    Multimap<String, String> result = LinkedHashMultimap.create();
    for (String key : suite.parameterNames()) {

      // first check if the user has specified values
      Collection<String> userValues = userParameterArguments.get(key);
      if (!userValues.isEmpty()) {
        result.putAll(key, userValues);
        // TODO: type convert 'em to validate?

      } else { // otherwise use the default values from the suite
        Set<String> values = suite.parameterValues(key);
        if (values.isEmpty()) {
          throw new ConfigurationException(
              key
                  + " has no values. "
                  + "Did you forget a -D"
                  + key
                  + "=<value> command line argument?");
        }
        result.putAll(key, values);
      }
    }
    return result;
  }
  @Override
  public void run() {
    for (int i = 0; i < warmupCycles; ++i) {
      task.run();
    }

    long[] results = new long[benchmarkCycles];
    for (int i = 0; i < benchmarkCycles; ++i) {
      task.run();
      results[i] = task.getResult();
    }

    result = average(results);
  }
  private static void test(Validator val, String[] dataset)
      throws IOException, ClassNotFoundException {
    Benchmark mbm = new Benchmark();
    mbm.start();

    int truecount = 0;
    for (int i = 0; i < REPEATS; i++) {
      truecount = 0;
      for (String s : dataset) {
        if (val.checkInteger(s)) truecount++;
      }
    }

    mbm.stop();
    System.out.printf("%d\t%s", truecount, mbm);
  }
  public F24RotatedHybridComposition4(int dimension, double bias, String file_data, String file_m)
      throws JMetalException {
    super(dimension, bias, FUNCTION_NAME);

    // Note: dimension starts from 0
    m_o = new double[NUM_FUNC][mDimension];
    m_M = new double[NUM_FUNC][mDimension][mDimension];

    m_testPoint = new double[mDimension];
    m_testPointM = new double[mDimension];
    m_fmax = new double[NUM_FUNC];

    m_w = new double[NUM_FUNC];
    m_z = new double[NUM_FUNC][mDimension];
    m_zM = new double[NUM_FUNC][mDimension];

    // Load the shifted global optimum
    Benchmark.loadMatrixFromFile(file_data, NUM_FUNC, mDimension, m_o);
    // Load the matrix
    Benchmark.loadNMatrixFromFile(file_m, NUM_FUNC, mDimension, mDimension, m_M);

    // Initialize the hybrid composition job object
    theJob.numberOfBasicFunctions = NUM_FUNC;
    theJob.numberOfDimensions = mDimension;
    theJob.C = 2000.0;
    theJob.sigma = m_sigma;
    theJob.biases = m_func_biases;
    theJob.lambda = m_lambda;
    theJob.shiftGlobalOptimum = m_o;
    theJob.linearTransformationMatrix = m_M;
    theJob.w = m_w;
    theJob.z = m_z;
    theJob.zM = m_zM;
    // Calculate/estimate the fmax for all the functions involved
    for (int i = 0; i < NUM_FUNC; i++) {
      for (int j = 0; j < mDimension; j++) {
        m_testPoint[j] = (5.0 / m_lambda[i]);
      }
      Benchmark.rotate(m_testPointM, m_testPoint, m_M[i]);
      m_fmax[i] = Math.abs(theJob.basicFunc(i, m_testPointM));
    }
    theJob.fmax = m_fmax;
  }
  // Function body
  public double f(double[] x) throws JMetalException {

    double result = 0.0;

    result = Benchmark.hybrid_composition(x, theJob);

    result += mBias;

    return (result);
  }
  public void testMillionChanges() throws Exception {
    String text = "";
    String name = NAME1;
    int maxver = 2000; // Save 2000 versions.
    Benchmark mark = new Benchmark();

    mark.start();
    for (int i = 0; i < maxver; i++) {
      text = text + ".";
      engine.saveText(name, text);
    }

    mark.stop();

    System.out.println("Benchmark: " + mark.toString(2000) + " pages/second");
    WikiPage pageinfo = engine.getPage(NAME1);

    assertEquals("wrong version", maxver, pageinfo.getVersion());

    // +2 comes from \r\n.
    assertEquals("wrong text", maxver + 2, engine.getText(NAME1).length());
  }
 public double basicFunc(int func_no, double[] x) throws JMetalException {
   double result = 0.0;
   // This part is according to Matlab reference code
   switch (func_no) {
     case 0:
       result = Benchmark.weierstrass(x);
       break;
     case 1:
       result = Benchmark.EScafferF6(x);
       break;
     case 2:
       result = Benchmark.F8F2(x);
       break;
     case 3:
       result = Benchmark.ackley(x);
       break;
     case 4:
       result = Benchmark.rastrigin(x);
       break;
     case 5:
       result = Benchmark.griewank(x);
       break;
     case 6:
       result = Benchmark.EScafferF6NonCont(x);
       break;
     case 7:
       result = Benchmark.rastriginNonCont(x);
       break;
     case 8:
       result = Benchmark.elliptic(x);
       break;
     case 9:
       result = Benchmark.sphere_noise(x);
       break;
     default:
       throw new JMetalException("func_no is out of range.");
   }
   return (result);
 }
Example #8
0
  /**
   * Sleeps for the cycle delay.
   *
   * @throws InterruptedException
   */
  private void sleep() {
    try {
      long sleepTime = cycleRate - cycleTimer.elapsed();
      boolean sleep = sleepTime > 0 && sleepTime <= 600;
      for (int i = 0; i < PacketManager.SIZE; i++) {
        Benchmark b = PacketManager.packetBenchmarks[i];
        if (!sleep && b.getTime() > 0)
          System.out.println(
              "Packet "
                  + i
                  + "["
                  + PacketManager.packets[i].getClass().getSimpleName()
                  + "] took "
                  + b.getTime()
                  + " ms.");
        b.reset();
      }
      if (sleep) {
        Benchmarks.resetAll();
        // System.out.println("[ENGINE]: Sleeping for " + sleepTime + "ms");
        Thread.sleep(sleepTime);
      } else {
        // The server has reached maximum load, players may now lag.
        cycle = (100 + Math.abs(sleepTime) / (cycleRate / 100));
        /*if (cycle > 999) {
        	initiateRestart();
        }*/
        System.out.println("[WARNING]: Server load: " + cycle + "%!");
        Benchmarks.printAll();
        Benchmarks.resetAll();
        for (int i = 0; i < 5; i++) System.out.println("");
      }
    } catch (Exception ex) {
      ex.printStackTrace();

    } finally {
      cycleTimer.reset();
    }
  }
 public BenchmarkWrapper createBenchmark(Scenario scenario) {
   return suite.createBenchmark(scenario.getVariables(getUserParameterNames()));
 }
 public ConfiguredBenchmark createBenchmark(Scenario scenario) {
   return suite.createBenchmark(scenario.getVariables(getUserParameterNames()));
 }
Example #11
0
  /**
   * Queries the command line options for an action to perform.
   *
   * <pre>
   * <code>
   * > java -jar scalaris.jar --help
   * usage: scalaris [Options]
   *  -h,--help                                   print this message
   *  -v,--verbose                                print verbose information,
   *                                              e.g. the properties read
   *  -lh,--localhost                             gets the local host's name as
   *                                              known to Java (for debugging
   *                                              purposes)
   *  -b,--minibench <[ops]> <[tpn]> <[benchs]>   run selected mini
   *                                              benchmark(s) [1|...|18|all]
   *                                              (default: all benchmarks, 500
   *                                              operations, 10 threads per
   *                                              Scalaris node)
   *  -m,--monitor <node>                         print monitoring information
   *  -r,--read <key>                             read an item
   *  -w,--write <key> <value>                    write an item
   *     --test-and-set <key> <old> <new>         atomic test and set, i.e.
   *                                              write <key> to <new> if the
   *                                              current value is <old>
   *  -d,--delete <key> <[timeout]>               delete an item (default
   *                                              timeout: 2000ms)
   *                                              WARNING: This function can
   *                                              lead to inconsistent data
   *                                              (e.g. deleted items can
   *                                              re-appear). Also when
   *                                              re-creating an item the
   *                                              version before the delete can
   *                                              re-appear.
   *  -jmx,--jmxservice <node>                    starts a service exposing
   *                                              Scalaris monitoring values
   *                                              via JMX
   * </code>
   * </pre>
   *
   * In order to override node and cookie to use for a connection, specify the
   * <tt>scalaris.node</tt> or <tt>scalaris.cookie</tt> system properties. Their values will be used
   * instead of the values defined in the config file!
   *
   * @param args command line arguments
   */
  public static void main(final String[] args) {
    boolean verbose = false;
    final CommandLineParser parser = new GnuParser();
    CommandLine line = null;
    final Options options = getOptions();
    try {
      line = parser.parse(options, args);
    } catch (final ParseException e) {
      printException("Parsing failed", e, false);
      return; // will not be reached since printException exits
    }

    if (line.hasOption("verbose")) {
      verbose = true;
      ConnectionFactory.getInstance().printProperties();
    }

    if (line.hasOption("minibench")) {
      final String[] optionValues = line.getOptionValues("minibench");
      int nrOperations = 500;
      int threadsPerNode = 10;
      final HashSet<Integer> benchmarks = new HashSet<Integer>(10);
      boolean all = false;
      if (optionValues != null) {
        checkArguments(optionValues, 0, options, "b");
        if (optionValues.length >= 1) {
          nrOperations = Integer.parseInt(optionValues[0]);
        }
        if (optionValues.length >= 2) {
          threadsPerNode = Integer.parseInt(optionValues[1]);
        }
        if (optionValues.length >= 3) {
          for (int i = 2; i < Math.min(20, optionValues.length); ++i) {
            final String benchmarks_str = optionValues[i];
            if (benchmarks_str.equals("all")) {
              all = true;
            } else {
              benchmarks.add(Integer.parseInt(benchmarks_str));
            }
          }
        }
      } else {
        all = true;
      }
      if (all) {
        for (int i = 1; i <= 18; ++i) {
          benchmarks.add(i);
        }
      }
      Benchmark.minibench(nrOperations, threadsPerNode, benchmarks);
    } else if (line.hasOption("r")) { // read
      final String key = line.getOptionValue("read");
      checkArguments(key, options, "r");
      try {
        final TransactionSingleOp sc = new TransactionSingleOp();
        final String value = sc.read(key).value().toString();
        System.out.println("read(" + key + ") == " + value);
      } catch (final ConnectionException e) {
        printException("read failed with connection error", e, verbose);
      } catch (final NotFoundException e) {
        printException("read failed with not found", e, verbose);
      } catch (final UnknownException e) {
        printException("read failed with unknown", e, verbose);
      }
    } else if (line.hasOption("w")) { // write
      final String[] optionValues = line.getOptionValues("write");
      checkArguments(optionValues, 2, options, "w");
      final String key = optionValues[0];
      final String value = optionValues[1];
      try {
        final TransactionSingleOp sc = new TransactionSingleOp();
        sc.write(key, value);
        System.out.println("write(" + key + ", " + value + "): ok");
      } catch (final ConnectionException e) {
        printException("write failed with connection error", e, verbose);
      } catch (final AbortException e) {
        printException("write failed with abort", e, verbose);
      } catch (final UnknownException e) {
        printException("write failed with unknown", e, verbose);
      }
    } else if (line.hasOption("test-and-set")) { // test_and_set
      final String[] optionValues = line.getOptionValues("test-and-set");
      checkArguments(optionValues, 3, options, "test-and-set");
      final String key = optionValues[0];
      final String oldValue = optionValues[1];
      final String newValue = optionValues[2];
      try {
        final TransactionSingleOp sc = new TransactionSingleOp();
        sc.testAndSet(key, oldValue, newValue);
        System.out.println("testAndSet(" + key + ", " + oldValue + ", " + newValue + "): ok");
      } catch (final ConnectionException e) {
        printException("testAndSet failed with connection error", e, verbose);
      } catch (final AbortException e) {
        printException("testAndSet failed with abort", e, verbose);
      } catch (final UnknownException e) {
        printException("testAndSet failed with unknown", e, verbose);
      } catch (final NotFoundException e) {
        printException("testAndSet failed with not found", e, verbose);
      } catch (final KeyChangedException e) {
        printException(
            "testAndSet failed with key changed (current value: "
                + e.getOldValue().toString()
                + ")",
            e,
            verbose);
      }
    } else if (line.hasOption("d")) { // delete
      final String[] optionValues = line.getOptionValues("delete");
      checkArguments(optionValues, 1, options, "d");
      final String key = optionValues[0];
      int timeout = 2000;
      if (optionValues.length >= 2) {
        try {
          timeout = Integer.parseInt(optionValues[1]);
        } catch (final Exception e) {
          printException(
              "Parsing failed",
              new ParseException(
                  "wrong type for timeout parameter of option d"
                      + " (parameters: <"
                      + options.getOption("d").getArgName()
                      + ">)"),
              verbose);
        }
      }
      try {
        final ReplicatedDHT sc = new ReplicatedDHT();
        final DeleteResult deleteResult = sc.delete(key, timeout);
        System.out.println(
            "delete("
                + key
                + ", "
                + timeout
                + "): "
                + deleteResult.ok
                + " ok, "
                + deleteResult.locks_set
                + " locks_set, "
                + deleteResult.undef
                + " undef");
      } catch (final ConnectionException e) {
        printException("delete failed with connection error", e, verbose);
      } catch (final TimeoutException e) {
        printException("delete failed with timeout", e, verbose);
      } catch (final UnknownException e) {
        printException("delete failed with unknown error", e, verbose);
      }
    } else if (line.hasOption("lh")) { // get local host name
      System.out.println(ConnectionFactory.getLocalhostName());
    } else if (line.hasOption("monitor")) { // print monitoring data
      final String node = line.getOptionValue("monitor");
      checkArguments(node, options, "monitor");
      try {
        final Monitor monitor = new Monitor(node);
        final GetNodeInfoResult nodeInfo = monitor.getNodeInfo();
        final GetNodePerformanceResult nodePerf = monitor.getNodePerformance();
        final GetServiceInfoResult srvInfo = monitor.getServiceInfo();
        final GetServicePerformanceResult srvPerf = monitor.getServicePerformance();

        final Double nodePerfCurLatAvg = Monitor.getCurrentPerfValue(nodePerf.latencyAvg);
        final Double nodePerfCurLatStddev = Monitor.getCurrentPerfValue(nodePerf.latencyStddev);
        final Double srvPerfCurLatAvg = Monitor.getCurrentPerfValue(srvPerf.latencyAvg);
        final Double srcPerfCurLatStddev = Monitor.getCurrentPerfValue(srvPerf.latencyStddev);

        final DecimalFormat df = new DecimalFormat("0.##");
        System.out.println("== Node Info ==");
        System.out.println("Scalaris version: " + nodeInfo.scalarisVersion);
        System.out.println("Erlang   version: " + nodeInfo.erlangVersion);
        System.out.println("# of DHT nodes  : " + nodeInfo.dhtNodes);
        System.out.println("== Service Info (from mgmt_server) ==");
        System.out.println("Total # of nodes: " + srvInfo.nodes);
        System.out.println("Total load      : " + srvInfo.totalLoad);
        System.out.println("== Node Performance ==");
        System.out.println(
            "Current latency : "
                + (nodePerfCurLatAvg == null ? "n/a" : df.format(nodePerfCurLatAvg)));
        System.out.println(
            "Current stddev  : "
                + (nodePerfCurLatStddev == null ? "n/a" : df.format(nodePerfCurLatStddev)));
        System.out.println("== Service Performance ==");
        System.out.println(
            "Current latency : "
                + (srvPerfCurLatAvg == null ? "n/a" : df.format(srvPerfCurLatAvg)));
        System.out.println(
            "Current stddev  : "
                + (srcPerfCurLatStddev == null ? "n/a" : df.format(srcPerfCurLatStddev)));
      } catch (final ConnectionException e) {
        printException("monitor failed with connection error", e, verbose);
      } catch (final UnknownException e) {
        printException("monitor failed with unknown error", e, verbose);
      }
    } else if (line.hasOption("jmx")) { // start JMX monitoring service
      final String node = line.getOptionValue("jmx");
      checkArguments(node, options, "jmx");
      startJmxService(node, verbose);
    } else {
      // print help if no other option was given
      //        if (line.hasOption("help")) {
      final HelpFormatter formatter = new HelpFormatter();
      formatter.setOptionComparator(
          new Comparator<Option>() {
            private int optionToInt(final Option option) {
              if (option.getLongOpt().equals("help")) {
                return 1;
              } else if (option.getLongOpt().equals("verbose")) {
                return 2;
              } else if (option.getLongOpt().equals("localhost")) {
                return 3;
              } else if (option.getLongOpt().equals("minibench")) {
                return 4;
              } else if (option.getLongOpt().equals("monitor")) {
                return 5;
              } else if (option.getLongOpt().equals("read")) {
                return 6;
              } else if (option.getLongOpt().equals("write")) {
                return 7;
              } else if (option.getLongOpt().equals("test-and-set")) {
                return 8;
              } else if (option.getLongOpt().equals("add-del-on-list")) {
                return 9;
              } else if (option.getLongOpt().equals("add-on-nr")) {
                return 10;
              } else if (option.getLongOpt().equals("delete")) {
                return 11;
              } else if (option.getLongOpt().equals("jmxservice")) {
                return 12;
              } else {
                return 13;
              }
            }

            public int compare(final Option arg0, final Option arg1) {
              final int arg0_i = optionToInt(arg0);
              final int arg1_i = optionToInt(arg1);
              if (arg0_i < arg1_i) {
                return -1;
              } else if (arg0_i == arg1_i) {
                return 0;
              } else {
                return 1;
              }
            }
          });
      formatter.printHelp("scalaris [Options]", getOptions());
      if (!line.hasOption("help")) {
        System.exit(1);
      }
    }
  }
 @BindEvent({"OnChanged"})
 public void myMethod(Event e) {
   Benchmark.count(ImplEmitter.this);
 }
 @BindEvent
 public void OnChanged(Event e) {
   Benchmark.count(ImplEmitter.this);
 }
Example #14
0
  /** Performs a server cycle. */
  private void cycle() {
    int loggedIn = 0;
    Benchmark b = Benchmarks.getBenchmark("loginQueue");
    b.start();
    while (!loginQueue.isEmpty() && loggedIn++ < 50) {
      Player player = loginQueue.poll();
      try {
        player.finishLogin();
        player.setLoginStage(LoginStages.LOGGED_IN);
      } catch (Exception ex) {
        // ex.printStackTrace();
        System.out.println("Error, infinite DC loop for this player");
        player.disconnect();
      }
    }
    b.stop();

    b = Benchmarks.getBenchmark("handleNetworkPackets");
    b.start();
    // Handle all network events.
    try {
      selector.selectNow();
      for (SelectionKey selectionKey : selector.selectedKeys()) {
        if (selectionKey.isValid()) {
          if (selectionKey.isReadable()) {
            // Tell the client to handle the packet.
            PacketManager.handleIncomingData((Player) selectionKey.attachment());
          }
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    b.stop();

    // Next, perform game processing.
    try {
      PluginManager.tick();
      World.process();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    b = Benchmarks.getBenchmark("disconnectingPlayers");
    b.start();
    synchronized (disconnectedPlayers) {
      for (Iterator<Player> players = disconnectedPlayers.iterator(); players.hasNext(); ) {
        Player player = players.next();
        if (player.logoutDisabled()) continue;
        player.logout();
        players.remove();
      }
    }
    b.stop();
    if (infoDisplayCounter == 0) {
      System.out.println(
          "[ENGINE]: Server load: " + cycle + "% with " + World.playerAmount() + " players");
      infoDisplayCounter = 300;
    } else {
      infoDisplayCounter--;
    }
  }
  private void runMassiveFileTest(int maxpages) throws Exception {
    String text = "Testing, 1, 2, 3: ";
    String name = NAME1;
    Benchmark mark = new Benchmark();

    System.out.println("Building a massive repository of " + maxpages + " pages...");

    mark.start();
    for (int i = 0; i < maxpages; i++) {
      engine.saveText(name + i, text + i);
    }
    mark.stop();

    System.out.println("Total time to save " + maxpages + " pages was " + mark.toString());
    System.out.println("Saved " + mark.toString(maxpages) + " pages/second");

    mark.reset();

    mark.start();
    Collection pages = engine.getPageManager().getAllPages();
    mark.stop();

    System.out.println("Got a list of all pages in " + mark);

    mark.reset();
    mark.start();

    for (Iterator i = pages.iterator(); i.hasNext(); ) {
      String foo = engine.getPureText((WikiPage) i.next());

      assertNotNull(foo);
    }
    mark.stop();

    System.out.println("Read through all of the pages in " + mark);
    System.out.println("which is " + mark.toString(maxpages) + " pages/second");
  }
 /**
  * Returns a normalized version of {@code scenario}, with information from {@code suite} assisting
  * in correcting problems.
  */
 public Scenario normalizeScenario(Scenario scenario) {
   suite.normalizeScenario(scenario);
   return scenario;
 }
Example #17
0
  /**
   * Queries the command line options for an action to perform.
   *
   * <pre>
   * <code>
   * > java -jar scalaris.jar -help
   * usage: scalaris [Options]
   *  -b,--minibench                   run mini benchmark
   *  -d,--delete <key> <[timeout]>    delete an item (default timeout: 2000ms)
   *                                   WARNING: This function can lead to
   *                                   inconsistent data (e.g. deleted items
   *                                   can re-appear). Also when re-creating an
   *                                   item the version before the delete can
   *                                   re-appear.
   *  -g,--getsubscribers <topic>      get subscribers of a topic
   *  -h,--help                        print this message
   *  -lh,--localhost                  gets the local host's name as known to
   *                                   Java (for debugging purposes)
   *  -p,--publish <topic> <message>   publish a new message for the given
   *                                   topic
   *  -r,--read <key>                  read an item
   *  -s,--subscribe <topic> <url>     subscribe to a topic
   *  -u,--unsubscribe <topic> <url>   unsubscribe from a topic
   *  -v,--verbose                     print verbose information, e.g. the
   *                                   properties read
   *  -w,--write <key> <value>         write an item
   * </code>
   * </pre>
   *
   * @param args command line arguments
   */
  public static void main(String[] args) {
    boolean verbose = false;
    CommandLineParser parser = new GnuParser();
    CommandLine line = null;
    Options options = getOptions();
    try {
      line = parser.parse(options, args);
    } catch (ParseException e) {
      printException("Parsing failed", e, false);
    }

    if (line.hasOption("verbose")) {
      verbose = true;
      ConnectionFactory.getInstance().printProperties();
    }

    if (line.hasOption("minibench")) {
      Benchmark.minibench();
    } else if (line.hasOption("r")) { // read
      String key = line.getOptionValue("read");
      checkArguments(key, options, "r");
      try {
        Scalaris sc = new Scalaris();
        String value = sc.read(key);
        System.out.println("read(" + key + ") == " + value);
      } catch (ConnectionException e) {
        printException("read failed with connection error", e, verbose);
      } catch (TimeoutException e) {
        printException("read failed with timeout", e, verbose);
      } catch (NotFoundException e) {
        printException("read failed with not found", e, verbose);
      } catch (UnknownException e) {
        printException("read failed with unknown", e, verbose);
      }
    } else if (line.hasOption("w")) { // write
      String[] optionValues = line.getOptionValues("write");
      checkArguments(optionValues, 2, options, "w");
      String key = optionValues[0];
      String value = optionValues[1];
      try {
        Scalaris sc = new Scalaris();
        sc.write(key, value);
        System.out.println("write(" + key + ", " + value + ")");
      } catch (ConnectionException e) {
        printException("write failed with connection error", e, verbose);
      } catch (TimeoutException e) {
        printException("write failed with timeout", e, verbose);
      } catch (UnknownException e) {
        printException("write failed with unknown", e, verbose);
      }
    } else if (line.hasOption("p")) { // publish
      String[] optionValues = line.getOptionValues("publish");
      checkArguments(optionValues, 2, options, "p");
      String topic = optionValues[0];
      String content = optionValues[1];
      if (content == null) {
        // parsing methods of commons.cli only checks the first argument :(
        printException(
            "Parsing failed", new ParseException("missing content for option p"), verbose);
      }
      try {
        Scalaris sc = new Scalaris();
        sc.publish(topic, content);
        System.out.println("publish(" + topic + ", " + content + ")");
      } catch (ConnectionException e) {
        printException("publish failed with connection error", e, verbose);
      }
    } else if (line.hasOption("s")) { // subscribe
      String[] optionValues = line.getOptionValues("subscribe");
      checkArguments(optionValues, 2, options, "s");
      String topic = optionValues[0];
      String url = optionValues[1];
      try {
        Scalaris sc = new Scalaris();
        sc.subscribe(topic, url);
        System.out.println("subscribe(" + topic + ", " + url + ")");
      } catch (ConnectionException e) {
        printException("subscribe failed with connection error", e, verbose);
      } catch (TimeoutException e) {
        printException("subscribe failed with timeout", e, verbose);
      } catch (UnknownException e) {
        printException("subscribe failed with unknown", e, verbose);
      }
    } else if (line.hasOption("u")) { // unsubscribe
      String[] optionValues = line.getOptionValues("unsubscribe");
      checkArguments(optionValues, 2, options, "u");
      String topic = optionValues[0];
      String url = optionValues[1];
      try {
        Scalaris sc = new Scalaris();
        sc.unsubscribe(topic, url);
        System.out.println("unsubscribe(" + topic + ", " + url + ")");
      } catch (ConnectionException e) {
        printException("unsubscribe failed with connection error", e, verbose);
      } catch (TimeoutException e) {
        printException("unsubscribe failed with timeout", e, verbose);
      } catch (NotFoundException e) {
        printException("unsubscribe failed with not found", e, verbose);
      } catch (UnknownException e) {
        printException("unsubscribe failed with unknown", e, verbose);
      }
    } else if (line.hasOption("g")) { // getsubscribers
      String topic = line.getOptionValue("getsubscribers");
      checkArguments(topic, options, "g");
      try {
        Scalaris sc = new Scalaris();
        ArrayList<String> subscribers = sc.getSubscribers(topic);
        System.out.println("getSubscribers(" + topic + ") == " + subscribers);
      } catch (ConnectionException e) {
        printException("getSubscribers failed with connection error", e, verbose);
      } catch (UnknownException e) {
        printException("getSubscribers failed with unknown error", e, verbose);
      }
    } else if (line.hasOption("d")) { // delete
      String[] optionValues = line.getOptionValues("delete");
      checkArguments(optionValues, 1, options, "d");
      String key = optionValues[0];
      int timeout = 2000;
      if (optionValues.length >= 2) {
        try {
          timeout = Integer.parseInt(optionValues[1]);
        } catch (Exception e) {
          printException(
              "Parsing failed",
              new ParseException(
                  "wrong type for timeout parameter of option d"
                      + " (parameters: <"
                      + options.getOption("d").getArgName()
                      + ">)"),
              verbose);
        }
      }
      try {
        Scalaris sc = new Scalaris();
        sc.delete(key, timeout);
        DeleteResult deleteResult = sc.getLastDeleteResult();
        System.out.println(
            "delete("
                + key
                + ", "
                + timeout
                + "): "
                + deleteResult.ok
                + " ok, "
                + deleteResult.locks_set
                + " locks_set, "
                + deleteResult.undef
                + " undef");
      } catch (ConnectionException e) {
        printException("delete failed with connection error", e, verbose);
      } catch (TimeoutException e) {
        printException("delete failed with timeout", e, verbose);
      } catch (NodeNotFoundException e) {
        printException("delete failed with node not found", e, verbose);
      } catch (UnknownException e) {
        printException("delete failed with unknown error", e, verbose);
      }
    } else if (line.hasOption("lh")) { // get local host name
      System.out.println(ConnectionFactory.getLocalhostName());
    } else {
      // print help if no other option was given
      //		if (line.hasOption("help")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("scalaris [Options]", getOptions());
    }
  }
 @Override
 public void begin(Benchmark benchmark, int benchmarkIndex, int benchmarkCount) {
   System.out.println(
       "Benchmark " + benchmarkIndex + " / " + benchmarkCount + ": " + benchmark.getTitle());
 }