Package org.springframework.xd.shell.util

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


  @CliCommand(value = LIST_STEP_EXECUTIONS, help = "List all step executions for the provided job execution id")
  public Table listStepExecutions(
      @CliOption(mandatory = true, key = { "", "id" }, help = "the id of the job execution") long jobExecutionId) {

    final List<StepExecutionInfoResource> stepExecutions = jobOperations().listStepExecutions(jobExecutionId);
    final Table table = new Table();
    table.addHeader(1, new TableHeader("Id"))
        .addHeader(2, new TableHeader("Step Name"))
        .addHeader(3, new TableHeader("Job Exec ID"))
        .addHeader(4, new TableHeader("Start Time"))
        .addHeader(5, new TableHeader("End Time"))
        .addHeader(6, new TableHeader("Status"));

    for (StepExecutionInfoResource stepExecutionInfoResource : stepExecutions) {

      final String localStartTime = this.configuration.getLocalTime(stepExecutionInfoResource.getStepExecution().getStartTime());
      final Date endTimeDate = stepExecutionInfoResource.getStepExecution().getEndTime();
      final String localEndTime = (endTimeDate == null) ? "" : this.configuration.getLocalTime(endTimeDate);
      final TableRow row = new TableRow();

      row.addValue(1, String.valueOf(stepExecutionInfoResource.getStepExecution().getId()))
          .addValue(2, stepExecutionInfoResource.getStepExecution().getStepName())
          .addValue(3, String.valueOf(stepExecutionInfoResource.getJobExecutionId()))
          .addValue(4, localStartTime)
          .addValue(5, localEndTime)
          .addValue(6, stepExecutionInfoResource.getStepExecution().getStatus().name());
      table.getRows().add(row);
    }

    return table;
  }
View Full Code Here


  public Table stepExecutionProgress(
      @CliOption(mandatory = true, key = { "", "id" }, help = "the id of the step execution") long stepExecutionId,
      @CliOption(mandatory = true, key = { "jobExecutionId" }, help = "the job execution id") long jobExecutionId) {
    StepExecutionProgressInfoResource progressInfoResource = jobOperations().stepExecutionProgress(jobExecutionId,
        stepExecutionId);
    Table table = new Table();
    table.addHeader(1, new TableHeader("Id"))
        .addHeader(2, new TableHeader("Step Name"))
        .addHeader(3, new TableHeader("Percentage Complete"))
        .addHeader(4, new TableHeader("Duration"));
    final TableRow tableRow = new TableRow();
    tableRow.addValue(1, String.valueOf(progressInfoResource.getStepExecution().getId()))
        .addValue(2, String.valueOf(progressInfoResource.getStepExecution().getStepName()))
        .addValue(3, String.format("%.0f%%", progressInfoResource.getPercentageComplete() * 100))
        .addValue(4, String.format("%.0f ms", progressInfoResource.getDuration()));
    table.getRows().add(tableRow);
    return table;
  }
View Full Code Here

      @CliOption(mandatory = true, key = { "jobExecutionId" }, help = "the job execution id") long jobExecutionId) {
    final StepExecutionInfoResource stepExecutionInfoResource = jobOperations().displayStepExecution(
        jobExecutionId,
        stepExecutionId);

    final Table stepExecutionTable = JobCommandsUtils.prepareStepExecutionTable(stepExecutionInfoResource,
        this.configuration.getClientTimeZone());

    return stepExecutionTable;
  }
View Full Code Here

  public String display(
      @CliOption(mandatory = true, key = { "", "id" }, help = "the id of the job execution") long jobExecutionId) {

    final JobExecutionInfoResource jobExecutionInfoResource = jobOperations().displayJobExecution(jobExecutionId);

    final Table jobExecutionTable = new Table();
    jobExecutionTable.addHeader(1, new TableHeader("Property"))
        .addHeader(2, new TableHeader("Value"));

    final StringBuilder details = new StringBuilder();

    details.append("Job Execution Details:\n");
    details.append(UiUtils.HORIZONTAL_LINE);

    final String localCreateTime = this.configuration.getLocalTime(jobExecutionInfoResource.getJobExecution().getCreateTime());
    final String localStartTime = this.configuration.getLocalTime(jobExecutionInfoResource.getJobExecution().getStartTime());
    final Date endTimeDate = jobExecutionInfoResource.getJobExecution().getEndTime();
    final String localEndTime = (endTimeDate == null) ? "" : this.configuration.getLocalTime(endTimeDate);

    jobExecutionTable.addRow("Job Execution ID", String.valueOf(jobExecutionInfoResource.getExecutionId()))
        .addRow("Job Name", jobExecutionInfoResource.getName())
        .addRow("Create Time", localCreateTime)
        .addRow("Start Time", localStartTime)
        .addRow("End Time", localEndTime)
        .addRow("Running", String.valueOf(jobExecutionInfoResource.getJobExecution().isRunning()))
        .addRow("Stopping", String.valueOf(jobExecutionInfoResource.getJobExecution().isStopping()))
        .addRow("Step Execution Count", String.valueOf(jobExecutionInfoResource.getStepExecutionCount()))
        .addRow("Execution Status", jobExecutionInfoResource.getJobExecution().getStatus().name());

    details.append(jobExecutionTable);

    details.append(UiUtils.HORIZONTAL_LINE);
    details.append("Job Parameters:\n");
    details.append(UiUtils.HORIZONTAL_LINE);

    if (jobExecutionInfoResource.getJobExecution().getJobParameters().isEmpty()) {
      details.append("No Job Parameters are present");
    }
    else {
      final Table jobParameterTable = new Table();
      jobParameterTable.addHeader(1, new TableHeader("Name"))
          .addHeader(2, new TableHeader("Value"))
          .addHeader(3, new TableHeader("Type"))
          .addHeader(4, new TableHeader("Identifying"));

      for (Map.Entry<String, JobParameter> jobParameterEntry : jobExecutionInfoResource.getJobExecution().getJobParameters().getParameters().entrySet()) {

        jobParameterTable.addRow(jobParameterEntry.getKey(),
            jobParameterEntry.getValue().getValue().toString(),
            jobParameterEntry.getValue().getType().name(),
            String.valueOf(jobParameterEntry.getValue().isIdentifying()));
      }
View Full Code Here

      ) {
    JobInstanceInfoResource jobInstance = jobOperations().displayJobInstance(instanceId);
    StringBuilder result = new StringBuilder("Information about instance ");
    result.append(jobInstance.getInstanceId()).append(" of the job '").append(jobInstance.getJobName()).append(
        "':\n");
    Table table = new Table();
    table.addHeader(1, new TableHeader("Name"))
        .addHeader(2, new TableHeader("Execution Id"))
        .addHeader(3, new TableHeader("Start Time"))
        .addHeader(4, new TableHeader("Step Execution Count"))
        .addHeader(5, new TableHeader("Status"))
        .addHeader(6, new TableHeader("Job Parameters"));

    for (JobExecutionInfoResource jobExecutionInfoResource : jobInstance.getJobExecutions()) {
      String startTimeAsString =
          jobExecutionInfoResource.getStartDate() + " " +
              jobExecutionInfoResource.getStartTime() + " " +
              jobExecutionInfoResource.getTimeZone().getID();
      table.addRow(//
          jobInstance.getJobName(), //
          String.valueOf(jobExecutionInfoResource.getExecutionId()), //
          startTimeAsString, //
          String.valueOf(jobExecutionInfoResource.getStepExecutionCount()), //
          jobExecutionInfoResource.getJobExecution().getStatus().name(), //
View Full Code Here

    Assert.notNull(modules);
    this.modules = modules;
  }

  public Table renderByType() {
    Table table = new Table();
    int i = 1;
    Map<String, Integer> currentRowByType = new HashMap<String, Integer>();
    for (String type : typeToColumn.keySet()) {
      table.addHeader(i++, new TableHeader("    " + StringUtils.capitalize(type)));
    }
    for (ModuleDefinitionResource module : modules) {
      TableRow row = rowForType(module.getType(), table, currentRowByType);
      row.addValue(typeToColumn.get(module.getType()), cellValue(module));
    }
View Full Code Here

  private RichGaugeOperations richGaugeOperations() {
    return xdShell.getSpringXDOperations().richGaugeOperations();
  }

  private Table displayRichGauge(RichGaugeResource r, NumberFormat pattern) {
    Table t = new Table();
    t.addHeader(1, new TableHeader(String.format("Name"))).addHeader(2, new TableHeader(r.getName()));
    t.newRow().addValue(1, "value").addValue(2, pattern.format(r.getValue()));
    t.newRow().addValue(1, "alpha").addValue(2, pattern.format(r.getAlpha()));
    t.newRow().addValue(1, "average").addValue(2, pattern.format(r.getAverage()));
    t.newRow().addValue(1, "max").addValue(2, pattern.format(r.getMax()));
    t.newRow().addValue(1, "min").addValue(2, pattern.format(r.getMin()));
    t.newRow().addValue(1, "count").addValue(2, pattern.format(r.getCount()));
    return t;
  }
View Full Code Here

  private Table displayFVCvalue(FieldValueCounterResource fvcResource, NumberFormat pattern, final int size) {
    final Map<String, Double> fieldValueCounts = fvcResource.getFieldValueCounts();
    FieldValueComparator fvc = new FieldValueComparator(fieldValueCounts);
    TreeMap<String, Double> sortedFvc = new TreeMap<String, Double>(fvc);
    sortedFvc.putAll(fieldValueCounts);
    Table t = new Table();
    t.addHeader(1, new TableHeader("FieldValueCounter=" + fvcResource.getName())).addHeader(2, new TableHeader(""))
        .addHeader(3, new TableHeader(""));
    t.newRow().addValue(1, "VALUE").addValue(2, "-").addValue(3, "COUNT");
    int rowSize = 1;
    for (Map.Entry<String, Double> entry : sortedFvc.entrySet()) {
      t.newRow().addValue(1, entry.getKey()).addValue(2, "|").addValue(3, pattern.format(entry.getValue()));
      if (rowSize >= size) {
        break;
      }
      rowSize++;
    }
View Full Code Here

        "':\n\n");
    if (options == null) {
      result.append("Module options metadata is not available");
    }
    else {
      Table table = new Table().addHeader(1, new TableHeader("Option Name")).addHeader(2,
          new TableHeader("Description")).addHeader(
              3, new TableHeader("Default")).addHeader(4, new TableHeader("Type"));
      for (DetailedModuleDefinitionResource.Option o : options) {
        if (!showHidden && o.isHidden()) {
          continue;
        }
        final TableRow row = new TableRow();
        row.addValue(1, o.getName())
            .addValue(2, o.getDescription())
            .addValue(3, o.getDefaultValue() == null ? "<none>" : o.getDefaultValue())
            .addValue(4, o.getType() == null ? "<unknown>" : o.getType());
        table.getRows().add(row);
      }
      result.append(table.toString());
    }
    return result.toString();
  }
View Full Code Here

public class MetricExistsMatcher<T extends AbstractMetricSink> extends BaseMatcher<T> {

  @Override
  public boolean matches(Object item) {
    AbstractMetricSink metric = (AbstractMetricSink) item;
    Table table = (Table) metric.shell.executeCommand(metric.getDslName() + " list").getResult();
    return table.getRows().contains(new TableRow().addValue(1, metric.getName()));
  }
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.