use of javax.batch.runtime.JobInstance in project wildfly by wildfly.
the class BatchJobExecutionResource method refreshChildren.
/**
* Note the access to the {@link #children} is <strong>not</strong> guarded here and needs to be externally
* guarded.
*/
private void refreshChildren() {
final List<JobExecution> executions = new ArrayList<>();
// Casting to (Supplier<List<JobInstance>>) is done here on purpose as a workaround for a bug in 1.8.0_45
final List<JobInstance> instances = jobOperator.allowMissingJob((Supplier<List<JobInstance>>) () -> jobOperator.getJobInstances(jobName, 0, jobOperator.getJobInstanceCount(jobName)), Collections.emptyList());
for (JobInstance instance : instances) {
executions.addAll(jobOperator.getJobExecutions(instance));
}
for (JobExecution execution : executions) {
final String name = Long.toString(execution.getExecutionId());
if (!children.contains(name)) {
children.add(name);
}
}
}
use of javax.batch.runtime.JobInstance in project wildfly by wildfly.
the class JobOperatorService method stop.
@Override
public void stop(final long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException, JobSecurityException {
checkState(null, "stop");
final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
final JobInstance instance = super.getJobInstance(executionId);
validateJob(instance.getJobName());
super.stop(executionId);
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
}
}
use of javax.batch.runtime.JobInstance in project wildfly by wildfly.
the class JobOperatorService method getParameters.
@Override
public Properties getParameters(final long executionId) throws NoSuchJobExecutionException, JobSecurityException {
checkState();
final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
final JobInstance instance = super.getJobInstance(executionId);
validateJob(instance.getJobName());
return super.getParameters(executionId);
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
}
}
use of javax.batch.runtime.JobInstance in project wildfly by wildfly.
the class JobOperatorService method getJobInstance.
@Override
public JobInstance getJobInstance(final long executionId) throws NoSuchJobExecutionException, JobSecurityException {
checkState();
final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
final JobInstance instance = super.getJobInstance(executionId);
validateJob(instance.getJobName());
return super.getJobInstance(executionId);
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
}
}
use of javax.batch.runtime.JobInstance in project Payara by payara.
the class ListBatchJobExecutions method getJobExecutionForInstance.
private static List<JobExecution> getJobExecutionForInstance(long instId) throws JobSecurityException, NoSuchJobException, NoSuchJobInstanceException, NoSuchJobExecutionException {
JobOperator jobOperator = AbstractListCommand.getJobOperatorFromBatchRuntime();
JobInstance jobInstance = null;
for (String jn : jobOperator.getJobNames()) {
List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1);
if (exe != null) {
for (JobInstance ji : exe) {
if (ji.getInstanceId() == instId) {
jobInstance = ji;
break;
}
}
}
}
List<JobExecution> jeList = new ArrayList<JobExecution>();
if (jobInstance == null)
throw new RuntimeException("No Job Executions found for instanceid = " + instId);
List<JobExecution> lst = AbstractListCommand.getJobOperatorFromBatchRuntime().getJobExecutions(jobInstance);
if (lst != null) {
for (JobExecution je : lst) {
jeList.add(jobOperator.getJobExecution(je.getExecutionId()));
}
}
return jeList;
}
Aggregations