Exemple #1
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 ?
    }
  }