use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class ListBatchJobs method executeCommand.
@Override
protected void executeCommand(AdminCommandContext context, Properties extraProps) throws Exception {
String dataSourceName = batchRuntimeHelper.getDataSourceLookupName();
InitialContext ctx = new InitialContext();
Object object = ctx.lookup(dataSourceName);
// check whether the referenced JNDI entry is a DataSource
if (object instanceof DataSource) {
dataSource = DataSource.class.cast(object);
String prefix = batchRuntimeConfiguration.getTablePrefix();
String suffix = batchRuntimeConfiguration.getTableSuffix();
createTables();
jobInstanceTableKey = prefix + "JOBINSTANCEDATA" + suffix;
if (checkIfTableExists(jobInstanceTableKey)) {
queryToGetUniqueJobNames = "SELECT DISTINCT name FROM " + jobInstanceTableKey;
ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
if (isSimpleMode()) {
setToSimpleMode(extraProps, columnFormatter);
} else {
setToLongMode(extraProps, columnFormatter);
}
context.getActionReport().setMessage(columnFormatter.toString());
} else {
context.getActionReport().failure(logger, jobInstanceTableKey + " table doesn't exists");
}
}
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class ListBatchRuntimeConfiguration method executeCommand.
@Override
protected void executeCommand(AdminCommandContext context, Properties extraProps) {
Config config = targetUtil.getConfig(target);
if (config == null) {
context.getActionReport().setMessage("No such config named: " + target);
context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
BatchRuntimeConfiguration batchRuntimeConfiguration = config.getExtensionByType(BatchRuntimeConfiguration.class);
Map<String, Object> map = new HashMap<>();
map.put(DATA_SOURCE_NAME, batchRuntimeConfiguration.getDataSourceLookupName());
map.put(EXECUTOR_SERVICE_NAME, batchRuntimeConfiguration.getExecutorServiceLookupName());
map.put(SCHEMA_NAME, batchRuntimeConfiguration.getSchemaName());
map.put(TABLE_PREFIX, batchRuntimeConfiguration.getTablePrefix());
map.put(TABLE_SUFFIX, batchRuntimeConfiguration.getTableSuffix());
extraProps.put("listBatchRuntimeConfiguration", map);
ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
Object[] data = new Object[getOutputHeaders().length];
for (int index = 0; index < getOutputHeaders().length; index++) {
switch(getOutputHeaders()[index]) {
case DATA_SOURCE_NAME:
String val = batchRuntimeConfiguration.getDataSourceLookupName();
data[index] = (val == null || val.trim().length() == 0) ? BatchRuntimeHelper.getDefaultDataSourceLookupNameForTarget(target) : val;
break;
case EXECUTOR_SERVICE_NAME:
data[index] = batchRuntimeConfiguration.getExecutorServiceLookupName();
break;
case SCHEMA_NAME:
data[index] = batchRuntimeConfiguration.getSchemaName();
break;
case TABLE_PREFIX:
data[index] = batchRuntimeConfiguration.getTablePrefix();
break;
case TABLE_SUFFIX:
data[index] = batchRuntimeConfiguration.getTableSuffix();
break;
default:
throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
}
}
columnFormatter.addRow(data);
context.getActionReport().setMessage(columnFormatter.toString());
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class GetMPHealthCheckConfiguration method execute.
@Override
public void execute(AdminCommandContext context) {
Config targetConfig = targetUtil.getConfig(target);
if (targetConfig == null) {
context.getActionReport().setMessage("No such config name: " + targetUtil);
context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
MicroprofileHealthCheckConfiguration healthCheckConfiguration = targetConfig.getExtensionByType(MicroprofileHealthCheckConfiguration.class);
ColumnFormatter columnFormatter = new ColumnFormatter(OUTPUT_HEADERS);
Object[] outputValues = { healthCheckConfiguration.getEnabled(), healthCheckConfiguration.getEndpoint(), healthCheckConfiguration.getVirtualServers(), healthCheckConfiguration.getSecurityEnabled(), healthCheckConfiguration.getRoles() };
columnFormatter.addRow(outputValues);
context.getActionReport().appendMessage(columnFormatter.toString());
Map<String, Object> extraPropertiesMap = new HashMap<>();
extraPropertiesMap.put("enabled", healthCheckConfiguration.getEnabled());
extraPropertiesMap.put("endpoint", healthCheckConfiguration.getEndpoint());
extraPropertiesMap.put("virtualServers", healthCheckConfiguration.getVirtualServers());
extraPropertiesMap.put("securityenabled", healthCheckConfiguration.getSecurityEnabled());
extraPropertiesMap.put("roles", healthCheckConfiguration.getRoles());
Properties extraProperties = new Properties();
extraProperties.put("microprofileHealthCheckConfiguration", extraPropertiesMap);
context.getActionReport().setExtraProperties(extraProperties);
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class ListRequestTraces method generateReport.
private void generateReport(ActionReport actionReport) {
RequestTracingExecutionOptions executionOptions = service.getExecutionOptions();
if (first == null) {
first = executionOptions.getTraceStoreSize();
}
RequestTraceStoreInterface eventStore;
if (historicTraces == null || historicTraces) {
eventStore = service.getHistoricRequestTraceStore();
} else {
eventStore = service.getRequestTraceStore();
}
ColumnFormatter columnFormatter = new ColumnFormatter(headers);
Properties extrasProps = new Properties();
List<Map<String, String>> tracesList = new ArrayList<>();
Collection<RequestTrace> traces = eventStore.getTraces(first);
for (RequestTrace requestTrace : traces) {
Map<String, String> messages = new LinkedHashMap<>();
Object[] values = new Object[3];
values[0] = requestTrace.getStartTime();
values[1] = requestTrace.getElapsedTime();
values[2] = requestTrace.toString();
messages.put("occuringTime", values[0].toString());
messages.put("elapsedTime", values[1].toString());
messages.put("message", (String) values[2]);
tracesList.add(messages);
columnFormatter.addRow(values);
}
actionReport.setMessage(columnFormatter.toString());
extrasProps.put("traces", tracesList);
actionReport.setExtraProperties(extrasProps);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class ListHistoricHealthChecks method generateReport.
private void generateReport(ActionReport actionReport) {
if (first == null) {
first = service.getHistoricalTraceStoreSize();
}
HistoricHealthCheckEvent[] traces = eventStore.getTraces(first);
ColumnFormatter columnFormatter = new ColumnFormatter(headers);
Properties extrasProps = new Properties();
List historic = new ArrayList<>();
if (traces != null) {
for (HistoricHealthCheckEvent historicHealthCheckEvent : traces) {
LinkedHashMap<String, String> messages = new LinkedHashMap<String, String>();
Object[] values = new Object[2];
values[0] = new Date(historicHealthCheckEvent.getOccurringTime());
values[1] = constructMessage(historicHealthCheckEvent);
messages.put("dateTime", values[0].toString());
messages.put("message", (String) values[1]);
historic.add(messages);
columnFormatter.addRow(values);
}
}
actionReport.setMessage(columnFormatter.toString());
extrasProps.put("historicmessages", historic);
actionReport.setExtraProperties(extrasProps);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Aggregations