public boolean execute(
        CommandInterpreter interpreter, CommandLine commandLine, boolean batchMode) {
      final String machineName = commandLine.getOptionValue('n');
      final int localJobId = Integer.parseInt(commandLine.getOptionValue('j'));
      final boolean singleOnly = commandLine.hasOption('1');

      String message = "sending " + jobCommand + " to " + machineName + ":" + localJobId;
      if (singleOnly) message = message + " (single)";
      interpreter.showMessage(message, batchMode);

      Response[] responses = null;
      try {
        responses = sendJobCommand(jobCommand, machineName, localJobId, singleOnly);
      } catch (ClusterException e) {
        throw new IllegalStateException(e);
      }

      interpreter.showMessage("Received " + responses.length + " responses:", batchMode);
      for (Response response : responses) {
        String responseMessage = null;
        if (response instanceof BooleanResponse) {
          final BooleanResponse bresponse = (BooleanResponse) response;
          responseMessage = bresponse.getNodeName() + ": " + bresponse.getValue();
        } else {
          responseMessage = response.toString();
        }
        interpreter.showMessage(responseMessage, batchMode);
      }

      return true;
    }
  /**
   * Starts an interactive command loop for sending job commands to the cluster using current active
   * cluster definition.
   */
  public static void main(String[] args) throws IOException {
    // ./run org.sd.cluster.config.JobAdmin

    final PropertiesParser pp = new PropertiesParser(args, true);
    final Properties properties = pp.getProperties();
    final ClusterRunner cr = new ClusterRunner(true /*useActiveCluster*/, properties);
    // final String user = cr.getUser();
    final ClusterDefinition clusterDef = cr.getClusterDefinition();
    final JobAdmin jobAdmin = new JobAdmin(clusterDef, 10000);
    final String cmdFile = properties != null ? properties.getProperty("cmdFile") : null;
    final CommandInterpreter interp = new CommandInterpreter(jobAdmin, cmdFile);

    interp.setVar("prompt", "jobcmd> ");
    interp.setVar("user", clusterDef.getUser());
    interp.setVar("defName", clusterDef.getDefinitionName());
    interp.setVar("machines", concat(clusterDef.getMachines(), ", "));

    jobAdmin.init();
    if (cmdFile != null) {
      interp.init(); // just run commands in command file
    } else {
      interp.init();
      interp.start(); // start interactive interpreter
    }
    jobAdmin.shutdown();
  }
    public boolean execute(
        CommandInterpreter interpreter, CommandLine commandLine, boolean batchMode) {
      final String groupName = commandLine.getOptionValue('g', ClusterDefinition.ALL_NODES_GROUP);

      final String message = "Requesting jobs from group '" + groupName + "'...";
      interpreter.showMessage(message, batchMode);

      Response[] responses = null;
      try {
        responses = console.sendMessageToNodes(new GetJobsMessage(), groupName, 5000, false);
      } catch (ClusterException e) {
        throw new IllegalStateException(e);
      }

      interpreter.showMessage("Received " + responses.length + " responses:", batchMode);
      for (Response response : responses) {
        interpreter.showMessage(response.toString(), batchMode);
      }

      return true;
    }
  /**
   * Starts an interactive command loop for sending job commands to the cluster.
   *
   * <p>arg1: user (i.e. bperry) arg2: defName (i.e. dev-3a) arg3: gateway (i.e. vorta) arg4+
   * machine names (i.e. suliban andorian tholian)
   */
  public static void oldMain(String[] args) throws IOException {
    // java -Xmx640m org.sd.cluster.config.JobAdmin bperry 3m3n.1-2 vorta suliban andorian tholian
    // java -Xmx640m org.sd.cluster.config.JobAdmin bperry 3m10n.2-8 vorta suliban founder shran

    // todo: manage args through cli

    final String user = args[0];
    final String defName = args[1];
    final String gateway = args[2];
    final String[] machines = new String[args.length - 3];
    for (int i = 3; i < args.length; ++i) {
      machines[i - 3] = args[i];
    }
    final ClusterDefinition clusterDef = new ClusterDefinition(user, defName, gateway, machines);
    final JobAdmin jobAdmin = new JobAdmin(clusterDef, 10000);
    final CommandInterpreter interp = new CommandInterpreter(jobAdmin, null);

    interp.setVar("prompt", "jobcmd> ");
    interp.setVar("user", user);
    interp.setVar("defName", defName);
    interp.setVar("gateway", gateway);
    interp.setVar("machines", concat(machines, ", "));

    jobAdmin.init();
    interp.start();
    jobAdmin.shutdown();
  }
    public boolean execute(
        CommandInterpreter interpreter, CommandLine commandLine, boolean batchMode) {
      final String localPathToDataDir = commandLine.getOptionValue('l');
      final String groupName = commandLine.getOptionValue('g');
      final String destDataDirId = commandLine.getOptionValue('d');
      final String jobIdString = commandLine.getOptionValue('j');
      final String partitionPatternString = commandLine.getOptionValue('p');
      final int partitionGroupNum = Integer.parseInt(commandLine.getOptionValue('n'));

      final String message =
          "Sending data to nodes (backgrounded):\n"
              + "\tlocalPathToDataDir="
              + localPathToDataDir
              + "\n"
              + "\tgroupName="
              + groupName
              + "\n"
              + "\tdestDataDirId="
              + destDataDirId
              + "\n"
              + "\tjobIdString="
              + jobIdString
              + "\n"
              + "\tpartitionPatternString="
              + partitionPatternString
              + "\n"
              + "\tpartitionGroupNum="
              + partitionGroupNum
              + "\n";
      interpreter.showMessage(message, batchMode);

      final String jobDirPostfix = DataPusher.getJobDirPostfix(jobIdString, destDataDirId);
      DataPusher.sendDataToNodes(
          console.getClusterDefinition(),
          groupName,
          jobDirPostfix,
          localPathToDataDir,
          Pattern.compile(partitionPatternString),
          partitionGroupNum,
          3,
          1);

      return true;
    }