Пример #1
0
  private void startPerfTest() {
    int num_puts = 1000;
    int size = 1000;
    short repl_count = 1;
    long timeout = 0;
    String key_prefix = "key";

    String tmp = perf_key_prefix.getText();
    if (tmp != null) key_prefix = tmp;
    tmp = perf_num_keys.getText();
    if (tmp != null) num_puts = Integer.valueOf(tmp);
    tmp = perf_size.getText();
    if (tmp != null) size = Integer.valueOf(tmp);
    tmp = perf_repl_count_field.getText();
    if (tmp != null) repl_count = Short.valueOf(tmp);
    tmp = perf_timeout_field.getText();
    if (tmp != null) timeout = Long.valueOf(tmp);

    long start = System.currentTimeMillis();
    for (int i = 0; i < num_puts; i++) {
      String key = key_prefix + "-" + i;
      String value = "val-" + i;
      cache.put(key, value, repl_count, timeout);
    }
    long diff = System.currentTimeMillis() - start;
    status.setText("It took " + diff + " ms to insert " + num_puts + " elements");
  }
Пример #2
0
  public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();

    if (command.equals("Put")) {
      String key = key_field.getText();
      String value = value_field.getText();
      String repl_count = repl_count_field.getText();
      String timeout = timeout_field.getText();

      if (key == null || value == null) return;

      if (repl_count == null) repl_count = "1";
      if (timeout == null) timeout = "0";

      cache.put(key, value, Short.valueOf(repl_count), Long.valueOf(timeout));
    } else if (command.equals("Remove")) {
      int[] rows = table.getSelectedRows();
      if (rows != null) {
        for (int row : rows) {
          String key = (String) model.getValueAt(row, 0);
          if (key != null) cache.remove(key);
        }
      }
    } else if (command.equals("Clear")) {
      clear();
    } else if (command.equals("Rebalance")) {
      cache.mcastEntries();
    } else if (command.equals("Reset")) {
      status.setText("");
    } else if (command.equals("Start")) {
      startPerfTest();
    } else if (command.equals("Stop")) {

    } else if (command.equals("Exit")) {
      if (cache != null) cache.stop();
      frame.dispose();
      System.exit(1); // or can we break out of mainLoop() somehow else ?
    }
  }