use of com.ibm.jbatch.spi.TaggedJobExecution in project Payara by payara.
the class ListBatchJobSteps method findStepExecutions.
private List<StepExecution> findStepExecutions() throws JobSecurityException, NoSuchJobExecutionException {
JobOperator jobOperator = AbstractListCommand.getJobOperatorFromBatchRuntime();
JobExecution je = jobOperator.getJobExecution(Long.parseLong(executionId));
if (!glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
throw new NoSuchJobExecutionException("No job execution exists for job execution id: " + executionId);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(Long.parseLong(executionId));
if (stepExecutions == null || stepExecutions.size() == 0)
throw new NoSuchJobExecutionException("No job execution exists for job execution id: " + executionId);
return stepExecutions;
}
use of com.ibm.jbatch.spi.TaggedJobExecution in project Payara by payara.
the class ListBatchJobExecutions 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("listBatchJobExecutions", jobExecutions);
if (executionId != null) {
JobOperator jobOperator = getJobOperatorFromBatchRuntime();
JobExecution je = jobOperator.getJobExecution(Long.parseLong(executionId));
if (instanceId != null) {
JobInstance ji = jobOperator.getJobInstance(Long.parseLong(executionId));
if (ji.getInstanceId() != Long.parseLong(instanceId)) {
throw new RuntimeException("executionid " + executionId + " is not associated with the specified instanceid (" + instanceId + ")" + "; did you mean " + ji.getInstanceId() + " ?");
}
}
try {
if (glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
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);
}
} else if (instanceId != null) {
for (JobExecution je : getJobExecutionForInstance(Long.parseLong(instanceId))) {
try {
if (glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
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);
}
}
} else {
JobOperator jobOperator = getJobOperatorFromBatchRuntime();
Set<String> jobNames = jobOperator.getJobNames();
if (jobNames != null) {
for (String jn : jobOperator.getJobNames()) {
List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1);
if (exe != null) {
for (JobInstance ji : exe) {
for (JobExecution je : jobOperator.getJobExecutions(ji)) {
try {
if (glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
jobExecutions.add(handleJob(jobOperator.getJobExecution(je.getExecutionId()), columnFormatter));
} catch (Exception ex) {
logger.log(Level.WARNING, "Exception while getting jobExecution details: " + ex);
logger.log(Level.FINE, "Exception while getting jobExecution details: ", ex);
}
}
}
}
}
}
}
if (jobExecutions.size() > 0) {
context.getActionReport().setMessage(columnFormatter.toString());
} else {
throw new RuntimeException("No Job Executions found");
}
}
use of com.ibm.jbatch.spi.TaggedJobExecution in project Payara by payara.
the class ListBatchJobs method findSimpleJobInfo.
private Map<String, Integer> findSimpleJobInfo(ColumnFormatter columnFormatter) throws JobSecurityException, NoSuchJobException {
Map<String, Integer> jobToInstanceCountMap = new HashMap<>();
List<JobExecution> jobExecutions = findJobExecutions();
for (JobExecution je : jobExecutions) {
if (glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName())) {
String jobName = je.getJobName();
int count = 0;
if (jobToInstanceCountMap.containsKey(jobName)) {
count = jobToInstanceCountMap.get(jobName);
}
jobToInstanceCountMap.put(jobName, count + 1);
}
}
for (Map.Entry<String, Integer> e : jobToInstanceCountMap.entrySet()) columnFormatter.addRow(new Object[] { e.getKey(), e.getValue() });
return jobToInstanceCountMap;
}
use of com.ibm.jbatch.spi.TaggedJobExecution in project Payara by payara.
the class ListBatchJobs method executeCommand.
@Override
protected void executeCommand(AdminCommandContext context, Properties extraProps) throws Exception {
ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
if (isSimpleMode()) {
extraProps.put("simpleMode", true);
extraProps.put("listBatchJobs", findSimpleJobInfo(columnFormatter));
} else {
extraProps.put("simpleMode", false);
List<Map<String, Object>> jobExecutions = new ArrayList<>();
extraProps.put("listBatchJobs", jobExecutions);
for (JobExecution je : findJobExecutions()) {
try {
if (glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
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());
}
Aggregations