Package javax.batch.runtime

Examples of javax.batch.runtime.JobExecution


    @Override
    public JobExecutionImpl createJobExecution(final JobInstanceImpl jobInstance, final Properties jobParameters) {
        final JobExecutionImpl jobExecution = new JobExecutionImpl(jobInstance, jobParameters);
        insertJobExecution(jobExecution);
        final JobExecution jobExecutionExisting = jobExecutions.putIfAbsent(jobExecution.getExecutionId(), jobExecution);
        if (jobExecutionExisting != null) {
            throw BatchLogger.LOGGER.jobExecutionAlreadyExists(jobExecutionExisting.getExecutionId());
        }
        jobInstance.addJobExecution(jobExecution);
        return jobExecution;
    }
View Full Code Here


                preparedStatement.setLong(1, jobInstanceId);
            }
            rs = preparedStatement.executeQuery();
            while (rs.next()) {
                final long i = rs.getLong(TableColumns.JOBEXECUTIONID);
                JobExecution jobExecution1 = jobExecutions.get(i);
                if (jobExecution1 == null) {
                    if (jobInstanceId == 0) {
                        jobInstanceId = rs.getLong(TableColumns.JOBINSTANCEID);
                    }
                    final Properties jobParameters1 = BatchUtil.stringToProperties(rs.getString(TableColumns.JOBPARAMETERS));
View Full Code Here

        cursor = cursor.sort(new BasicDBObject(TableColumns.JOBEXECUTIONID, 1));
        final List<JobExecution> result = new ArrayList<JobExecution>();
        while (cursor.hasNext()) {
            final DBObject next = cursor.next();
            final Long i = (Long) next.get(TableColumns.JOBEXECUTIONID);
            JobExecution jobExecution1 = jobExecutions.get(i);
            if (jobExecution1 == null) {
                if (jobInstanceId == 0) {
                    jobInstanceId = (Long) next.get(TableColumns.JOBINSTANCEID);
                }
                final Properties jobParameters1 = BatchUtil.stringToProperties((String) next.get(TableColumns.JOBPARAMETERS));
View Full Code Here

            throw MESSAGES.jobRestartException(executionId, previousStatus);
        }
        if (previousStatus == BatchStatus.FAILED || previousStatus == BatchStatus.STOPPED) {
            final JobInstanceImpl jobInstance = (JobInstanceImpl) getJobInstance(executionId);
            final List<JobExecution> executions = getJobExecutions(jobInstance);
            final JobExecution mostRecentExecution = executions.get(executions.size() - 1);
            if (executionId != mostRecentExecution.getExecutionId()) {
                throw MESSAGES.jobExecutionNotMostRecentException(executionId, jobInstance.getInstanceId());
            }

            // the job may not have been loaded, e.g., when the restart is performed in a new JVM
            final String jobName = originalToRestart.getJobName();
View Full Code Here

        }
        if (previousStatus == BatchStatus.FAILED ||
                previousStatus == BatchStatus.STOPPED) {
            final JobInstanceImpl jobInstance = (JobInstanceImpl) getJobInstance(executionId);
            final List<JobExecution> executions = jobInstance.getJobExecutions();
            final JobExecution mostRecentExecution = executions.get(executions.size() - 1);
            if (executionId != mostRecentExecution.getExecutionId()) {
                throw LOGGER.jobExecutionNotMostRecentException(executionId, jobInstance.getInstanceId());
            }
            try {
                newExecutionId = startJobExecution(jobInstance, restartParameters, originalToRestart);
            } catch (Exception e) {
View Full Code Here

        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.valueOf(executionId));
            if (instanceId != null) {
                JobInstance ji = jobOperator.getJobInstance(Long.valueOf(executionId));
                if (ji.getInstanceId() != Long.valueOf(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.valueOf(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);
                                }
                            }
View Full Code Here

    }

    private List<StepExecution> findStepExecutions()
        throws JobSecurityException, NoSuchJobExecutionException {
        JobOperator jobOperator = AbstractListCommand.getJobOperatorFromBatchRuntime();
        JobExecution je = jobOperator.getJobExecution(Long.valueOf(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.valueOf(executionId));
        if (stepExecutions == null || stepExecutions.size() == 0)
View Full Code Here

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        List<Map<String, Object>> jobExecutions = new ArrayList<>();
        extraProps.put("listBatchJobExecutions", jobExecutions);
        if (executionId != null) {
            JobOperator jobOperator = BatchRuntime.getJobOperator();
            JobExecution je = jobOperator.getJobExecution(Long.valueOf(executionId));
            if (instanceId != null) {
                JobInstance ji = jobOperator.getJobInstance(Long.valueOf(executionId));
                if (ji.getInstanceId() != Long.valueOf(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.valueOf(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 = BatchRuntime.getJobOperator();
            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);
                                }
                            }
View Full Code Here

    }
    private List<JobExecution> findJobExecutions() {
        List<JobExecution> jobExecutions = new ArrayList<JobExecution>();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        if (executionId != null) {
            JobExecution jobExecution = jobOperator.getJobExecution(Long.valueOf(executionId));
            if (jobExecution != null)
                jobExecutions.add(jobExecution);
        } else if (instanceId != null) {
            jobExecutions.addAll(getJobExecutionForInstance(Long.valueOf(instanceId)));
        } else if (jobName != null) {
View Full Code Here

        final List<JobExecution> jobExecutions = jobOperator.getJobExecutions(jobInstance);
        //the job was executed 2 times during Batchlet1Test for the latest job instance
        Assert.assertEquals(2, jobExecutions.size());

        final JobExecution jobExecution = jobExecutions.get(1);
        System.out.printf("JobInstance id: %s%n", jobInstance.getInstanceId());

        final BatchStatus batchStatus = jobExecution.getBatchStatus();
        final String exitStatus = jobExecution.getExitStatus();
        final Date createTime = jobExecution.getCreateTime();
        final Date endTime = jobExecution.getEndTime();
        final Date lastUpdatedTime = jobExecution.getLastUpdatedTime();
        final Date startTime = jobExecution.getStartTime();
        final Properties jobParameters = jobExecution.getJobParameters();
        Assert.assertEquals(Batchlet1Test.jobName, jobExecution.getJobName());
        Assert.assertNotEquals(0, jobExecution.getExecutionId());
        Assert.assertEquals(BatchStatus.STOPPED, batchStatus);
        Assert.assertEquals(Batchlet1.ACTION_STOP, exitStatus);
        Assert.assertNotNull(createTime);
        Assert.assertNotNull(lastUpdatedTime);
        Assert.assertNotNull(endTime);
        Assert.assertNotNull(startTime);
        Assert.assertNotNull(jobParameters);
        System.out.printf("JobExecution id: %s, batchStatus: %s, exitStatus: %s, createTime: %s, endTime: %s, lastUpdatedTime: %s, startTime: %s, jobParameters: %s%n",
                jobExecution.getExecutionId(), batchStatus, exitStatus, createTime, endTime, lastUpdatedTime, startTime, jobParameters);

        final List<StepExecution> stepExecutions = jobOperator.getStepExecutions(jobExecution.getExecutionId());
        Assert.assertEquals(1, stepExecutions.size());
        final StepExecution stepExecution = stepExecutions.get(0);
        final String stepName1 = stepExecution.getStepName();
        final BatchStatus batchStatus1 = stepExecution.getBatchStatus();
        final String exitStatus1 = stepExecution.getExitStatus();
        final Date startTime1 = stepExecution.getStartTime();
        final Date endTime1 = stepExecution.getEndTime();
        final Serializable persistentUserData = stepExecution.getPersistentUserData();
        final Metric[] metrics = stepExecution.getMetrics();

        Assert.assertNotNull(stepExecution.getStepExecutionId());
        Assert.assertEquals(stepName, stepName1);
        Assert.assertEquals(BatchStatus.COMPLETED, batchStatus1);
        Assert.assertEquals(Batchlet1.ACTION_STOP, exitStatus1);
        Assert.assertNotNull(startTime1);
        Assert.assertNotNull(endTime1);
        //Assert.assertEquals(new Integer(1), persistentUserData);
        Assert.assertEquals("Persistent User Data", persistentUserData);
        Assert.assertNotNull(metrics);
        System.out.printf("StepExecution id: %s, stepName: %s, batchStatus: %s, exitStatus: %s, startTime: %s, endTime: %s, persistentUserData: %s, metrics: %s%n",
                stepExecution.getStepExecutionId(), stepName1, batchStatus1, exitStatus1, startTime1, endTime1, persistentUserData,
                Arrays.toString(metrics));

        restartJobMatchOther(jobExecution.getExecutionId());
    }
View Full Code Here

TOP

Related Classes of javax.batch.runtime.JobExecution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.