Package com.cloudera.flume.master

Examples of com.cloudera.flume.master.Command


      ArrayList<String> lst = new ArrayList<String>();
      for (int i = 0; i < cmd.getChildCount(); i++) {
        String tok = toString((CommonTree) cmd.getChild(i));
        lst.add(tok);
      }
      return new Command(command, lst.toArray(new String[0]));

    } catch (RecognitionException e) {
      LOG.debug("Failed to parse line, '" + s + "' because of "
          + e.getMessage(), e);
      throw e;
View Full Code Here


    FlumeMasterCommandAvro cmda = csa.cmd;
    List<String> args = new ArrayList<String>();
    for (CharSequence cs : cmda.arguments) {
      args.add(cs.toString());
    }
    Command cmd = new Command(cmda.command.toString(), args
        .toArray(new String[0]));
    CommandStatus cs = new CommandStatus(csa.cmdId, cmd, CommandStatus.State
        .valueOf(csa.state.toString()), csa.message.toString());
    return cs;
  }
View Full Code Here

      CommandStatusThrift cst = masterClient.getCmdStatus(cmdid);
      if (cst == null) {
        throw new IOException("Illegal command id: " + cmdid);
      }
      FlumeMasterCommandThrift cmdt = cst.getCmd();
      Command cmd = new Command(cmdt.getCommand(), cmdt.arguments
          .toArray(new String[0]));
      CommandStatus cs = new CommandStatus(cst.getCmdId(), cmd,
          CommandStatus.State.valueOf(cst.state), cst.getMessage());
      return cs;
    } catch (TException e) {
View Full Code Here

      try {
        List<String> args = new ArrayList<String>();
        if (cmd.getArgs().size() > 1) {
          args = cmd.getArgs().subList(1, cmd.getArgs().size());
        }
        long cmdid = client.submit(new Command(cmd.getArgs().get(0),
            (String[]) args.toArray(new String[args.size()])));
        lastCmdId = cmdid;
        // Do not change this, other programs will likely depend on this.
        System.out.println("[id: " + cmdid + "] Submitted command : "
            + cmd.getArgs().get(0));
        return cmdid;
      } catch (IOException e) {
        disconnect();
        LOG.debug("config failed due to transport error", e);
        return -1;
      }
    }

    /*
     * Wait waits for the specified cmdid to be done (success or error), for a
     * specified amount of time. If no cmdid is specified, it is assumed to be
     * the last command issued by the shell, or the last command in the master's
     * command queue.
     *
     * 0 wait time means forever.
     */
    if (cmd.getCommand().equals("wait")) {
      long millis = CMD_WAIT_TIME_MS;
      long cmdid = lastCmdId;

      // args are time, and then cmdid.
      List<String> args = cmd.getArgs();
      if (args.size() >= 1) {
        long ms = Long.parseLong(args.get(0));
        if (ms < 0) {
          System.out.println("Wait time <0 is illegal");
          return -1;
        }
        // if 0, effectively wait forever.
        millis = (ms == 0) ? Long.MAX_VALUE : ms;
      }

      if (args.size() >= 2) {
        cmdid = Long.parseLong(args.get(1));
      }

      try {
        return pollWait(cmdid, millis);
      } catch (IOException e) {
        disconnect();
        LOG.debug("config failed due to transport error", e);
        return -1;
      } catch (InterruptedException e) {
        System.out.println("Interrupted during command processing");
        LOG.debug("Interrupted!", e);
        return -1;
      }
    }

    /*
     * Exec sends a command to the master and polls for a response. These are
     * the commands which cause the master to do some processing. We wait
     * synchronously for success or failure.
     *
     * There is no schema checking for these commands - so it is possible to
     * send ill-formed commands and receive a failure notification with no idea
     * of what went wrong.
     */
    if (cmd.getCommand().equals("exec")) {
      try {
        List<String> args = new ArrayList<String>();
        if (cmd.getArgs().size() > 1) {
          args = cmd.getArgs().subList(1, cmd.getArgs().size());
        }
        long cmdid = client.submit(new Command(cmd.getArgs().get(0),
            (String[]) args.toArray(new String[args.size()])));
        System.out.println("[id: " + cmdid + "] Execing command : "
            + cmd.getArgs().get(0));
        lastCmdId = cmdid;

View Full Code Here

    FlumeMasterCommandAvro cmda = csa.cmd;
    List<String> args = new ArrayList<String>();
    for (CharSequence cs : cmda.arguments) {
      args.add(cs.toString());
    }
    Command cmd = new Command(cmda.command.toString(), args
        .toArray(new String[0]));
    CommandStatus cs = new CommandStatus(csa.cmdId, cmd, CommandStatus.State
        .valueOf(csa.state.toString()), csa.message.toString());
    return cs;
  }
View Full Code Here

      ArrayList<String> lst = new ArrayList<String>();
      for (int i = 0; i < cmd.getChildCount(); i++) {
        String tok = toString((CommonTree) cmd.getChild(i));
        lst.add(tok);
      }
      return new Command(command, lst.toArray(new String[0]));

    } catch (RecognitionException e) {
      LOG.debug("Failed to parse line, '" + s + "' because of "
          + e.getMessage(), e);
      throw e;
View Full Code Here

  /**
   * Convert this bean into a command.
   */
  public Command toCommand() {
    String[] args = { physicalNode, logicalNode };
    return new Command("spawn", args);
  }
View Full Code Here

TOP

Related Classes of com.cloudera.flume.master.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.