Exemplo n.º 1
0
  @Override
  @SuppressWarnings("deprecation")
  public void perform(Arguments arguments, PrintStream output) throws Exception {
    String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
    String appId = programIdParts[0];

    int instances;
    switch (elementType) {
      case FLOWLET:
        if (programIdParts.length < 3) {
          throw new CommandInputError(this);
        }
        String flowId = programIdParts[1];
        String flowletId = programIdParts[2];
        instances = programClient.getFlowletInstances(appId, flowId, flowletId);
        break;
      case WORKER:
        if (programIdParts.length < 2) {
          throw new CommandInputError(this);
        }
        String workerId = programIdParts[1];
        instances = programClient.getWorkerInstances(appId, workerId);
        break;
      case SERVICE:
        if (programIdParts.length < 2) {
          throw new CommandInputError(this);
        }
        String service = programIdParts[1];
        instances = programClient.getServiceInstances(appId, service);
        break;
      default:
        // TODO: remove this
        throw new IllegalArgumentException(
            "Unrecognized program element type for scaling: " + elementType);
    }

    output.println(instances);
  }
Exemplo n.º 2
0
 @Override
 public String getPattern() {
   return String.format(
       "get %s instances <%s>", elementType.getName(), elementType.getArgumentName());
 }