Search in sources :

Example 6 with JobInstance

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);
        }
    }
}
Also used : JobExecution(javax.batch.runtime.JobExecution) JobInstance(javax.batch.runtime.JobInstance) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with JobInstance

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);
    }
}
Also used : JobInstance(javax.batch.runtime.JobInstance)

Example 8 with JobInstance

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);
    }
}
Also used : JobInstance(javax.batch.runtime.JobInstance)

Example 9 with JobInstance

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);
    }
}
Also used : JobInstance(javax.batch.runtime.JobInstance)

Example 10 with JobInstance

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;
}
Also used : JobExecution(javax.batch.runtime.JobExecution) TaggedJobExecution(com.ibm.jbatch.spi.TaggedJobExecution) JobInstance(javax.batch.runtime.JobInstance)

Aggregations

JobInstance (javax.batch.runtime.JobInstance)12 JobExecution (javax.batch.runtime.JobExecution)5 TaggedJobExecution (com.ibm.jbatch.spi.TaggedJobExecution)3 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Properties (java.util.Properties)1 TreeSet (java.util.TreeSet)1 JobOperator (javax.batch.operations.JobOperator)1 NoSuchJobException (javax.batch.operations.NoSuchJobException)1