Package org.apache.slider.core.exceptions

Examples of org.apache.slider.core.exceptions.BadCommandArgumentsException


  public ApplicationReport monitorAppToState(
    ApplicationId appId, YarnApplicationState desiredState, Duration duration)
    throws YarnException, IOException {

    if (appId == null) {
      throw new BadCommandArgumentsException("null application ID");
    }
    if (duration.limit <= 0) {
      throw new BadCommandArgumentsException("Invalid monitoring duration");
    }
    log.debug("Waiting {} millis for app to reach state {} ",
              duration.limit,
              desiredState);
    duration.start();
View Full Code Here


  }

  protected void requireArgumentSet(String argname, String argfield)
      throws BadCommandArgumentsException {
    if (isUnset(argfield)) {
      throw new BadCommandArgumentsException("Required argument "
                                             + argname
                                             + " missing");
    }
  }
View Full Code Here

  public void validate() throws BadCommandArgumentsException {
   
    int minArgs = getMinParams();
    int actionArgSize = parameters.size();
    if (minArgs > actionArgSize) {
      throw new BadCommandArgumentsException(
        ErrorStrings.ERROR_NOT_ENOUGH_ARGUMENTS + getActionName());
    }
    int maxArgs = getMaxParams();
    if (maxArgs == -1) {
      maxArgs = minArgs;
    }
    if (actionArgSize > maxArgs) {
      String message = String.format("%s for action %s: limit is %d but saw %d",
                                     ErrorStrings.ERROR_TOO_MANY_ARGUMENTS,
                                     getActionName(), maxArgs,
                                     actionArgSize);
      log.error(message);
      int index = 1;
      for (String actionArg : parameters) {
        log.error("[{}] \"{}\"", index++, actionArg);
      }
      throw new BadCommandArgumentsException(message);
    }
  }
View Full Code Here

    } else if (SliderActions.ACTION_VERSION.equals(action)) {
      bindCoreAction(actionVersionArgs);

    } else if (action == null || action.isEmpty()) {
      throw new BadCommandArgumentsException(ErrorStrings.ERROR_NO_ACTION);

    } else {
      throw new BadCommandArgumentsException(ErrorStrings.ERROR_UNKNOWN_ACTION
                                             + " " + action);
    }
  }
View Full Code Here

    //verify that at most one of the operations is set
    int gets = s(getConf) + s(getFiles);
    int lists = s(list) + s(listConf) + s(listFiles);
    int set = lists + gets;
    if (set > 1) {
      throw new BadCommandArgumentsException(
          ErrorStrings.ERROR_TOO_MANY_ARGUMENTS);
    }
    if (dest != null && (lists > 0 || set == 0)) {
      throw new BadCommandArgumentsException("Argument " + ARG_DEST
           + " is only supported on 'get' operations");
    }
    if (!list && !is(name)) {
      throw new BadCommandArgumentsException("Argument " + ARG_NAME
           +" missing");

    }
  }
View Full Code Here

  public void parse() throws SliderException {
    addActionArguments();
    try {
      commander.parse(getArgs());
    } catch (ParameterException e) {
      throw new BadCommandArgumentsException(e, "%s in %s",
                                             e.toString(),
                                             (getArgs() != null
                                              ? (SliderUtils.join(getArgs(),
                                                 " ", false))
                                              : "[]"));
View Full Code Here

  /**
   * Validate the arguments against the action requested
   */
  public void validate() throws BadCommandArgumentsException {
    if (coreAction == null) {
      throw new BadCommandArgumentsException(ErrorStrings.ERROR_NO_ACTION
                                             + usage());
    }
    log.debug("action={}", getAction());
    //let the action validate itself
    coreAction.validate();
View Full Code Here

    Map<String, String> results = new HashMap<>();
    if (list != null && !list.isEmpty()) {
      int size = list.size();
      if (size % 2 != 0) {
        //odd number of elements, not permitted
        throw new BadCommandArgumentsException(
          ErrorStrings.ERROR_PARSE_FAILURE + description);
      }
      for (int count = 0; count < size; count += 2) {
        String key = list.get(count);
        String val = list.get(count + 1);
        if (results.get(key) != null) {
          throw new BadCommandArgumentsException(
            ErrorStrings.ERROR_DUPLICATE_ENTRY + description
            + ": " + key);
        }
        results.put(key, val);
      }
View Full Code Here

      new HashMap<>();
    if (list != null && !list.isEmpty()) {
      int size = list.size();
      if (size % 3 != 0) {
        //wrong number of elements, not permitted
        throw new BadCommandArgumentsException(
          ErrorStrings.ERROR_PARSE_FAILURE + description);
      }
      for (int count = 0; count < size; count += 3) {
        String role = list.get(count);
        String key = list.get(count + 1);
        String val = list.get(count + 2);
        Map<String, String> roleMap = results.get(role);
        if (roleMap == null) {
          //demand create new role map
          roleMap = new HashMap<>();
          results.put(role, roleMap);
        }
        if (roleMap.get(key) != null) {
          throw new BadCommandArgumentsException(
            ErrorStrings.ERROR_DUPLICATE_ENTRY + description
            + ": for key " + key + " under " + role);
        }
        roleMap.put(key, val);
      }
View Full Code Here

   * @throws BadCommandArgumentsException the exception raised on an invalid config
   */
  public void verifyBindingsDefined() throws BadCommandArgumentsException {
    InetSocketAddress rmAddr = SliderUtils.getRmAddress(getConfig());
    if (!SliderUtils.isAddressDefined(rmAddr)) {
      throw new BadCommandArgumentsException(
        "No valid Resource Manager address provided in the argument "
        + Arguments.ARG_MANAGER
        + " or the configuration property "
        + YarnConfiguration.RM_ADDRESS
        + " value :" + rmAddr);
View Full Code Here

TOP

Related Classes of org.apache.slider.core.exceptions.BadCommandArgumentsException

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.