Package org.springframework.xd.shell.util

Examples of org.springframework.xd.shell.util.Table


    assertEquals(prefix + jobName + "'", cr.getResult());
    waitForJobCompletion(jobName);
  }

  protected void checkForJobInList(String jobName, String jobDescriptor, boolean shouldBeDeployed) {
    Table t = listJobs();
    assertTrue(t.getRows().contains(
        new TableRow().addValue(1, jobName).addValue(2, jobDescriptor).addValue(3,
            shouldBeDeployed ? "deployed" : "undeployed")));
  }
View Full Code Here


    checkForSuccess(cr);
  }

  private Table listJobs() {
    Object result = getShell().executeCommand("job list").getResult();
    return (result instanceof Table) ? (Table) result : new Table();
  }
View Full Code Here

    throw new AssertionError();
  }

  public static Table prepareStepExecutionTable(final StepExecutionInfoResource stepExecutionInfoResource,
      final TimeZone timeZone) {
    final Table stepExecutionTable = new Table();
    stepExecutionTable.addHeader(1, new TableHeader("Property"))
    .addHeader(2, new TableHeader("Value"));

    String stepId = CommonUtils.NOT_AVAILABLE;
    String jobExecutionIdFromData = CommonUtils.NOT_AVAILABLE;
    String stepName = CommonUtils.NOT_AVAILABLE;
    String startTimeAsString = CommonUtils.NOT_AVAILABLE;
    String endTimeAsString = CommonUtils.NOT_AVAILABLE;
    String durationAsString = CommonUtils.NOT_AVAILABLE;
    String lastUpdatedTimeAsString = CommonUtils.NOT_AVAILABLE;
    String exitStatus = CommonUtils.NOT_AVAILABLE;
    String commitCount = CommonUtils.NOT_AVAILABLE;
    String filterCount = CommonUtils.NOT_AVAILABLE;
    String processSkipCount = CommonUtils.NOT_AVAILABLE;
    String readCount = CommonUtils.NOT_AVAILABLE;
    String readSkipCount = CommonUtils.NOT_AVAILABLE;
    String rollbackCount = CommonUtils.NOT_AVAILABLE;
    String writeCount = CommonUtils.NOT_AVAILABLE;
    String writeSkipCount = CommonUtils.NOT_AVAILABLE;
    String exitDescription = CommonUtils.NOT_AVAILABLE;
    String batchStatus = CommonUtils.NOT_AVAILABLE;

    if (stepExecutionInfoResource.getJobExecutionId() != null) {
      jobExecutionIdFromData = String.valueOf(stepExecutionInfoResource.getJobExecutionId());
    }

    if (stepExecutionInfoResource.getStepExecution() != null) {
      final StepExecution stepExecution = stepExecutionInfoResource.getStepExecution();

      if (stepExecution.getId() != null) {
        stepId = String.valueOf(stepExecution.getId());
      }
      if (stepExecution.getStepName() != null) {
        stepName = stepExecution.getStepName();
      }
      if (stepExecution.getStartTime() != null) {
        startTimeAsString = CommonUtils.getLocalTime(stepExecution.getStartTime(), timeZone);
      }
      if (stepExecution.getEndTime() != null) {
        endTimeAsString = CommonUtils.getLocalTime(stepExecution.getEndTime(), timeZone);
      }
      if (stepExecution.getStartTime() != null && stepExecution.getEndTime() != null) {
        durationAsString = String.format("%s ms",
            stepExecution.getEndTime().getTime() - stepExecution.getStartTime().getTime());
      }

      if (stepExecution.getLastUpdated() != null) {
        lastUpdatedTimeAsString = CommonUtils.getLocalTime(stepExecution.getLastUpdated(), timeZone);
      }
      if (stepExecution.getExitStatus() != null) {
        exitStatus = stepExecution.getExitStatus().getExitCode();
      }

      if (stepExecution.getExitStatus() != null
          && StringUtils.hasText(stepExecution.getExitStatus().getExitDescription())) {
        exitDescription = stepExecution.getExitStatus().getExitDescription();
      }

      if (stepExecution.getStatus() != null) {
        batchStatus = stepExecution.getStatus().name();
      }

      commitCount = String.valueOf(stepExecution.getCommitCount());
      filterCount = String.valueOf(stepExecution.getFilterCount());
      processSkipCount = String.valueOf(stepExecution.getProcessSkipCount());
      readCount = String.valueOf(stepExecution.getReadCount());
      readSkipCount = String.valueOf(stepExecution.getReadSkipCount());
      rollbackCount = String.valueOf(stepExecution.getRollbackCount());
      writeCount = String.valueOf(stepExecution.getWriteCount());
      writeSkipCount = String.valueOf(stepExecution.getWriteSkipCount());
    }

    stepExecutionTable
    .addRow("Step Execution Id", stepId)
    .addRow("Job Execution Id", jobExecutionIdFromData)
    .addRow("Step Name", stepName)
    .addRow("Start Time", startTimeAsString)
    .addRow("End Time", endTimeAsString)
View Full Code Here

    return xdShell.getSpringXDOperations().aggrCounterOperations();
  }

  private Table displayAggrCounter(AggregateCountsResource aggResource, NumberFormat pattern) {
    final SortedMap<Date, Long> values = aggResource.getValues();
    Table t = new Table();
    t.addHeader(1, new TableHeader("AggregateCounter=" + aggResource.getName())).addHeader(2, new TableHeader(""))
        .addHeader(3, new TableHeader(""));
    t.newRow().addValue(1, "TIME").addValue(2, "-").addValue(3, "COUNT");
    for (Map.Entry<Date, Long> entry : values.entrySet()) {
      t.newRow().addValue(1, entry.getKey().toString()).addValue(2, "|")
          .addValue(3, pattern.format(entry.getValue()));
    }
    return t;
  }
View Full Code Here

  @CliCommand(value = LIST_STREAM, help = "List created streams")
  public Table listStreams() {

    final PagedResources<StreamDefinitionResource> streams = streamOperations().list();

    final Table table = new Table()
        .addHeader(1, new TableHeader("Stream Name"))
        .addHeader(2, new TableHeader("Stream Definition"))
        .addHeader(3, new TableHeader("Status"));

    for (StreamDefinitionResource stream : streams) {
      table.newRow()
          .addValue(1, stream.getName())
          .addValue(2, stream.getDefinition())
          .addValue(3, stream.getStatus());
    }
    return table;
View Full Code Here

  /**
   * Render a table with information about a list of metrics
   */
  protected Table displayMetrics(PagedResources<MetricResource> list) {
    Table table = new Table();
    table.addHeader(1, new TableHeader(String.format("%s name", kind)));
    for (MetricResource r : list) {
      table.newRow().addValue(1, r.getName());
    }
    return table;
  }
View Full Code Here

  }

  @CliCommand(value = LIST_CONTAINERS, help = "List runtime containers")
  public Table listContainers() {
    final PagedResources<DetailedContainerResource> containers = runtimeOperations().listContainers();
    final Table table = new Table();
    table.addHeader(1, new TableHeader("Container Id"))
        .addHeader(2, new TableHeader("Host"))
        .addHeader(3, new TableHeader("IP Address"))
        .addHeader(4, new TableHeader("PID"))
        .addHeader(5, new TableHeader("Groups"))
        .addHeader(6, new TableHeader("Custom Attributes"));
    for (DetailedContainerResource container : containers) {
      Map<String, String> copy = new HashMap<String, String>(container.getAttributes());
      final TableRow row = table.newRow();
      row.addValue(1, copy.remove("id"))
          .addValue(2, copy.remove("host"))
          .addValue(3, copy.remove("ip"))
          .addValue(4, copy.remove("pid"));
      String groups = copy.remove("groups");
View Full Code Here

      runtimeModules = runtimeOperations().listDeployedModulesByModuleId(moduleId);
    }
    else {
      runtimeModules = runtimeOperations().listDeployedModules();
    }
    final Table table = new Table();
    table.addHeader(1, new TableHeader("Module Id")).addHeader(2,
        new TableHeader("Container Id")).addHeader(3, new TableHeader("Options")).addHeader(4,
        new TableHeader("Deployment Properties")).addHeader(5, new TableHeader("Unit status"));
    for (ModuleMetadataResource module : runtimeModules) {
      final TableRow row = table.newRow();
      String unitStatus = (module.getDeploymentStatus() != null) ? module.getDeploymentStatus().name() : "";
      row.addValue(1, String.format("%s.%s.%s", module.getUnitName(), module.getModuleType(), module.getName()))
          .addValue(2, module.getContainerId()).addValue(3, module.getModuleOptions().toString()).addValue(4,
              module.getDeploymentProperties().toString()).addValue(5, unitStatus);
    }
View Full Code Here

  @CliCommand(value = LIST_JOBS, help = "List all jobs")
  public Table listJobs() {

    final PagedResources<JobDefinitionResource> jobs = jobOperations().list();
    final Table table = new Table()
        .addHeader(1, new TableHeader("Job Name"))
        .addHeader(2, new TableHeader("Job Definition"))
        .addHeader(3, new TableHeader("Status"));

    for (JobDefinitionResource jobDefinitionResource : jobs) {
      table.newRow()
          .addValue(1, jobDefinitionResource.getName())
          .addValue(2, jobDefinitionResource.getDefinition())
          .addValue(3, jobDefinitionResource.getStatus());
    }
    return table;
View Full Code Here

  @CliCommand(value = LIST_JOB_EXECUTIONS, help = "List all job executions")
  public Table listJobExecutions() {

    final PagedResources<JobExecutionInfoResource> jobExecutions = jobOperations().listJobExecutions();
    final Table table = new Table();
    table.addHeader(1, new TableHeader("Id"))
        .addHeader(2, new TableHeader("Job Name"))
        .addHeader(3, new TableHeader("Start Time"))
        .addHeader(4, new TableHeader("Step Execution Count"))
        .addHeader(5, new TableHeader("Execution Status"))
        .addHeader(6, new TableHeader("Deployment Status"))
        .addHeader(7, new TableHeader("Definition Status"));

    for (JobExecutionInfoResource jobExecutionInfoResource : jobExecutions) {
      final TableRow row = new TableRow();
      final String startTimeAsString = this.configuration.getLocalTime(jobExecutionInfoResource.getJobExecution().getStartTime());

      row.addValue(1, String.valueOf(jobExecutionInfoResource.getExecutionId()))
          .addValue(2, jobExecutionInfoResource.getName())
          .addValue(3, startTimeAsString)
          .addValue(4, String.valueOf(jobExecutionInfoResource.getStepExecutionCount()))
          .addValue(5, jobExecutionInfoResource.getJobExecution().getStatus().name())
          .addValue(6, (jobExecutionInfoResource.isDeployed()) ? "Deployed" : "Undeployed")
          .addValue(7, (jobExecutionInfoResource.isDeleted()) ? "Destroyed" : "Exists");
      table.getRows().add(row);
    }

    return table;
  }
View Full Code Here

TOP

Related Classes of org.springframework.xd.shell.util.Table

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.