Package org.apache.ivory.client

Examples of org.apache.ivory.client.IvoryClient


        String entity;

        Services.get().register(ConfigurationStore.get());
        ConfigurationStore.get().init();
        CurrentUser.authenticate("testuser");
        IvoryClient client = new IvoryClient(ivoryUrl);
        for (int index = 2; index < args.length; index++) {
            entity = args[index];
            String[] deps = client.getDependency(type, entity).split("\n");
            for (String line : deps) {
                String[] fields = line.replace("(", "").replace(")", "").split(" ");
                EntityType eType = EntityType.valueOf(fields[0].toUpperCase());
                if (ConfigurationStore.get().get(eType, fields[1]) != null) continue;
                String xml = client.getDefinition(eType.name().toLowerCase(), fields[1]);
                System.out.println(xml);
                store(eType, xml);
            }
            String xml = client.getDefinition(type.toLowerCase(), entity);
            System.out.println(xml);
            store(EntityType.valueOf(type.toUpperCase()), xml);
        }

        entity = args[2];
View Full Code Here


  }

  private void instanceCommand(CommandLine commandLine)
      throws IvoryCLIException, IOException {
    String ivoryUrl = getIvoryEndpoint(commandLine);
    IvoryClient client = new IvoryClient(ivoryUrl);

    Set<String> optionsList = new HashSet<String>();
    for (Option option : commandLine.getOptions()) {
      optionsList.add(option.getOpt());
    }

    String result = null;
    String type = commandLine.getOptionValue(ENTITY_TYPE_OPT);
    String entity = commandLine.getOptionValue(ENTITY_NAME_OPT);
    String start = commandLine.getOptionValue(START_OPT);
    String end = commandLine.getOptionValue(END_OPT);
    String filePath = commandLine.getOptionValue(FILE_PATH_OPT);
    String runid = commandLine.getOptionValue(RUNID_OPT);
    String colo = commandLine.getOptionValue(COLO_OPT);
    String clusters = commandLine.getOptionValue(CLUSTERS_OPT);
    String sourceClusters = commandLine.getOptionValue(SOURCECLUSTER_OPT);
   
    colo = getColo(colo);
   
    validateInstanceCommands(optionsList, entity, type, start, end,
        filePath, colo, clusters, sourceClusters);
   
    if (optionsList.contains(RUNNING_OPT)) {
      result = client.getRunningInstances(type, entity, colo);
    } else if (optionsList.contains(STATUS_OPT)) {
      result = client.getStatusOfInstances(type, entity, start, end,
          runid, colo);
    } else if (optionsList.contains(KILL_OPT)) {
      result = client.killInstances(type, entity, start, end, colo, clusters, sourceClusters);
    } else if (optionsList.contains(SUSPEND_OPT)) {
      result = client.suspendInstances(type, entity, start, end, colo, clusters, sourceClusters);
    } else if (optionsList.contains(RESUME_OPT)) {
      result = client.resumeInstances(type, entity, start, end, colo, clusters, sourceClusters);
    } else if (optionsList.contains(RERUN_OPT)) {
      result = client.rerunInstances(type, entity, start, end, filePath, colo, clusters, sourceClusters);
    else if (optionsList.contains(CONTINUE_OPT)) {
      result = client.rerunInstances(type, entity, start, end, colo, clusters, sourceClusters);
    } else if(optionsList.contains(LOG_OPT)){
      result = client.getLogsOfInstances(type, entity, start, end, colo, runid);
    } else {
      throw new IvoryCLIException("Invalid command");
    }
    OUT_STREAM.println(result);
View Full Code Here

  }

  private void entityCommand(CommandLine commandLine)
      throws IvoryCLIException, IOException {
    String ivoryUrl = getIvoryEndpoint(commandLine);
    IvoryClient client = new IvoryClient(ivoryUrl);

    Set<String> optionsList = new HashSet<String>();
    for (Option option : commandLine.getOptions()) {
      optionsList.add(option.getOpt());
    }

    String result = null;
    String entityType = commandLine.getOptionValue(ENTITY_TYPE_OPT);
    String entityName = commandLine.getOptionValue(ENTITY_NAME_OPT);
    String filePath = commandLine.getOptionValue(FILE_PATH_OPT);
    String colo = commandLine.getOptionValue(COLO_OPT);
   
   
    validateEntityType(optionsList, entityType);

    if (optionsList.contains(SUBMIT_OPT)) {
      validateFilePath(optionsList, filePath);
      validateColo(optionsList);
      result = client.submit(entityType, filePath);
    } else if (optionsList.contains(UPDATE_OPT)) {
      validateFilePath(optionsList, filePath);
      validateColo(optionsList);
      validateEntityName(optionsList, entityName);
      result = client.update(entityType, entityName, filePath);
    } else if (optionsList.contains(SUBMIT_AND_SCHEDULE_OPT)) {
      validateFilePath(optionsList, filePath);
      validateColo(optionsList);
      result = client.submitAndSchedule(entityType, filePath);
    } else if (optionsList.contains(VALIDATE_OPT)) {
      validateFilePath(optionsList, filePath);
      validateColo(optionsList);
      result = client.validate(entityType, filePath);
    } else if (optionsList.contains(SCHEDULE_OPT)) {
      validateEntityName(optionsList, entityName);
      colo = getColo(colo);
      result = client.schedule(entityType, entityName, colo);
    } else if (optionsList.contains(SUSPEND_OPT)) {
      validateEntityName(optionsList, entityName);
      colo = getColo(colo);
      result = client.suspend(entityType, entityName, colo);
    } else if (optionsList.contains(RESUME_OPT)) {
      validateEntityName(optionsList, entityName);
      colo = getColo(colo);
      result = client.resume(entityType, entityName, colo);
    } else if (optionsList.contains(DELETE_OPT)) {
      validateColo(optionsList);
      validateEntityName(optionsList, entityName);
      result = client.delete(entityType, entityName);
    } else if (optionsList.contains(STATUS_OPT)) {
      validateEntityName(optionsList, entityName);
      colo = getColo(colo);
      result = client.getStatus(entityType, entityName, colo);
    } else if (optionsList.contains(DEFINITION_OPT)) {
      validateColo(optionsList);
      validateEntityName(optionsList, entityName);
      result = client.getDefinition(entityType, entityName);
    } else if (optionsList.contains(DEPENDENCY_OPT)) {
      validateColo(optionsList);
      validateEntityName(optionsList, entityName);
      result = client.getDependency(entityType, entityName);
    } else if (optionsList.contains(LIST_OPT)) {
      validateColo(optionsList);
      result = client.getEntityList(entityType);
    } else if (optionsList.contains(HELP_CMD)) {
      OUT_STREAM.println("Ivory Help");
    } else {
      throw new IvoryCLIException("Invalid command");
    }
View Full Code Here

  }

  private void adminCommand(CommandLine commandLine) throws IvoryCLIException, IOException {
    String result;
    String ivoryUrl = getIvoryEndpoint(commandLine);
    IvoryClient client = new IvoryClient(ivoryUrl);
   
    Set<String> optionsList = new HashSet<String>();
    for (Option option : commandLine.getOptions()) {
      optionsList.add(option.getOpt());
    }
   
    if(optionsList.contains(STACK_OPTION)){
      result = client.getThreadDump();
      OUT_STREAM.println(result);
    }
    if (optionsList.contains(VERSION_OPTION)) {
      result = client.getVersion();
      OUT_STREAM.println("Ivory server build version: " + result);
    }

    else if (optionsList.contains(HELP_CMD)) {
      OUT_STREAM.println("Ivory Help");
View Full Code Here

TOP

Related Classes of org.apache.ivory.client.IvoryClient

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.