use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class ListBatchJobSteps method handleJob.
private Map<String, Object> handleJob(StepExecution stepExecution, ColumnFormatter columnFormatter) {
Map<String, Object> jobInfo = new HashMap<>();
int stepMetricsIndex = -1;
StringTokenizer st = new StringTokenizer("", "");
String[] cfData = new String[getOutputHeaders().length];
for (int index = 0; index < getOutputHeaders().length; index++) {
Object data = null;
switch(getOutputHeaders()[index]) {
case NAME:
data = stepExecution.getStepName();
break;
case STEP_ID:
data = stepExecution.getStepExecutionId();
break;
case BATCH_STATUS:
data = stepExecution.getBatchStatus() != null ? stepExecution.getBatchStatus() : "";
break;
case EXIT_STATUS:
data = stepExecution.getExitStatus() != null ? stepExecution.getExitStatus() : "";
break;
case START_TIME:
if (stepExecution.getStartTime() != null) {
data = stepExecution.getStartTime().getTime();
cfData[index] = stepExecution.getStartTime().toString();
} else {
data = "";
}
break;
case END_TIME:
if (stepExecution.getEndTime() != null) {
data = stepExecution.getEndTime().getTime();
cfData[index] = stepExecution.getEndTime().toString();
} else {
data = "";
}
break;
case STEP_METRICS:
stepMetricsIndex = index;
Map<String, Long> metricMap = new HashMap<>();
if (stepExecution.getMetrics() != null) {
ColumnFormatter cf = new ColumnFormatter(new String[] { "METRICNAME", "VALUE" });
for (Metric metric : stepExecution.getMetrics()) {
metricMap.put(metric.getType().name(), metric.getValue());
cf.addRow(new Object[] { metric.getType().name(), metric.getValue() });
}
st = new StringTokenizer(cf.toString(), "\n");
}
data = metricMap;
break;
default:
throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
}
jobInfo.put(getOutputHeaders()[index], data);
cfData[index] = (stepMetricsIndex != index) ? (cfData[index] == null ? data.toString() : cfData[index]) : (st.hasMoreTokens() ? st.nextToken() : "");
}
columnFormatter.addRow(cfData);
cfData = new String[getOutputHeaders().length];
for (int i = 0; i < getOutputHeaders().length; i++) cfData[i] = "";
while (st.hasMoreTokens()) {
cfData[stepMetricsIndex] = st.nextToken();
columnFormatter.addRow(cfData);
}
return jobInfo;
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class ListBatchJobSteps method executeCommand.
@Override
protected void executeCommand(AdminCommandContext context, Properties extraProps) throws Exception {
ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
List<Map<String, Object>> jobExecutions = new ArrayList<>();
extraProps.put(LIST_BATCH_JOBS_STEPS, jobExecutions);
for (StepExecution je : findStepExecutions()) {
try {
jobExecutions.add(handleJob(je, columnFormatter));
} catch (Exception ex) {
logger.log(Level.WARNING, "Exception while getting jobExecution details: " + ex);
logger.log(Level.FINE, "Exception while getting jobExecution details ", ex);
}
}
context.getActionReport().setMessage(columnFormatter.toString());
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class GetDatadogNotifierConfiguration method listConfiguration.
@Override
protected String listConfiguration(DatadogNotifierConfiguration configuration) {
String[] headers = { "Enabled", "Key" };
ColumnFormatter columnFormatter = new ColumnFormatter(headers);
Object[] values = new Object[2];
values[0] = configuration.getEnabled();
values[1] = configuration.getKey();
columnFormatter.addRow(values);
return columnFormatter.toString();
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class GetEmailNotifierConfiguration method listConfiguration.
@Override
protected String listConfiguration(EmailNotifierConfiguration configuration) {
String[] headers = { "Enabled", "JNDI Name", "To" };
ColumnFormatter columnFormatter = new ColumnFormatter(headers);
Object[] values = new Object[3];
values[0] = configuration.getEnabled();
values[1] = configuration.getJndiName();
values[2] = configuration.getTo();
columnFormatter.addRow(values);
return columnFormatter.toString();
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class GetHipchatNotifierConfiguration method listConfiguration.
@Override
protected String listConfiguration(HipchatNotifierConfiguration configuration) {
String[] headers = { "Enabled", "Room Name", "Token" };
ColumnFormatter columnFormatter = new ColumnFormatter(headers);
Object[] values = new Object[3];
values[0] = configuration.getEnabled();
values[1] = configuration.getRoomName();
values[2] = configuration.getToken();
columnFormatter.addRow(values);
return columnFormatter.toString();
}
Aggregations