public String toString() { return "JobNavigatorImpl for job id = " + ((job != null) ? job.getId() : "null"); }
public String toString() { return "JobNavigatorImpl for job id = " + job.getId(); }
public String toString() { return "JobNavigatorImpl for job id = " + job.getId(); }
private long getMostRecentExecutionId(JSLJob jobModel) { //There can only be one instance associated with a subjob's id since it is generated from an unique //job instance id. So there should be no way to directly start a subjob with particular List<Long> instanceIds = persistenceService.jobOperatorGetJobInstanceIds(jobModel.getId(), 0, 2); // Maybe we should blow up on '0' too? if (instanceIds.size() > 1) { String errorMsg = "Found " + instanceIds.size() + " entries for instance id = " + jobModel.getId() + ", which should not have happened. Blowing up."; logger.severe(errorMsg); throw new IllegalStateException(errorMsg); } List<IJobExecution> partitionExecs = persistenceService.jobOperatorGetJobExecutions(instanceIds.get(0)); Long execId = Long.MIN_VALUE; for (IJobExecution partitionExec : partitionExecs ) { if (partitionExec.getExecutionId() > execId ) { execId = partitionExec.getExecutionId(); } } return execId; }
private long getMostRecentSubJobExecutionId(JSLJob jobModel) { // Pick off the first. There are some subtle cases we're ignoring probably. List<Long> instanceIds = persistenceService.jobOperatorGetJobInstanceIds(jobModel.getId(), 0, 1); if (instanceIds.size() == 0) { String errorMsg = "Did not find an entry for job name = " + jobModel.getId(); logger.severe(errorMsg); throw new IllegalStateException(errorMsg); } List<IJobExecution> subJobExecs = persistenceService.jobOperatorGetJobExecutions(instanceIds.get(0)); Long execId = Long.MIN_VALUE; for (IJobExecution subJobExec : subJobExecs ) { if (subJobExec.getExecutionId() > execId ) { execId = subJobExec.getExecutionId(); } } return execId; }
public JobContextImpl(ModelNavigator<JSLJob> navigator, JSLProperties jslProperties) { this.navigator = navigator; this.id = navigator.getRootModelElement().getId(); this.batchStatus = BatchStatus.STARTING; this.properties = convertJSProperties(jslProperties); }
public JobContextImpl(ModelNavigator<JSLJob> navigator, JSLProperties jslProperties) { this.navigator = navigator; this.id = navigator.getRootModelElement().getId(); this.batchStatus = BatchStatus.STARTING; this.properties = convertJSProperties(jslProperties); }
logger.fine("This execution already completed: " + parallelJob.getId());
/** * Note we restart all flows. There is no concept of "the flow completed". It is only steps * within the flows that may have already completed and so may not have needed to be rerun. * */ private void buildSubJobBatchWorkUnits() { List<Flow> flows = this.split.getFlows(); parallelBatchWorkUnits = new ArrayList<BatchFlowInSplitWorkUnit>(); // Build all sub jobs from flows in split synchronized (subJobs) { for (Flow flow : flows) { subJobs.add(PartitionedStepBuilder.buildFlowInSplitSubJob(jobContext, this.split, flow)); } // Go back to earlier idea that we may have seen this id before, and need a special "always restart" behavior // for split-flows. for (JSLJob job : subJobs) { int count = batchKernel.getJobInstanceCount(job.getId()); FlowInSplitBuilderConfig config = new FlowInSplitBuilderConfig(job, completedWorkQueue, rootJobExecutionId); if (count == 0) { parallelBatchWorkUnits.add(batchKernel.buildNewFlowInSplitWorkUnit(config)); } else if (count == 1) { parallelBatchWorkUnits.add(batchKernel.buildOnRestartFlowInSplitWorkUnit(config)); } else { throw new IllegalStateException("There is an inconsistency somewhere in the internal subjob creation"); } } } }
/** * Note we restart all flows. There is no concept of "the flow completed". It is only steps * within the flows that may have already completed and so may not have needed to be rerun. * */ private void buildSubJobBatchWorkUnits() { List<Flow> flows = this.split.getFlows(); parallelBatchWorkUnits = new ArrayList<BatchFlowInSplitWorkUnit>(); // Build all sub jobs from flows in split synchronized (subJobs) { for (Flow flow : flows) { subJobs.add(PartitionedStepBuilder.buildFlowInSplitSubJob(jobExecution.getExecutionId(), jobContext, this.split, flow)); } for (JSLJob job : subJobs) { int count = batchKernel.getJobInstanceCount(job.getId()); FlowInSplitBuilderConfig config = new FlowInSplitBuilderConfig(job, completedWorkQueue, rootJobExecutionId); if (count == 0) { parallelBatchWorkUnits.add(batchKernel.buildNewFlowInSplitWorkUnit(config)); } else if (count == 1) { parallelBatchWorkUnits.add(batchKernel.buildOnRestartFlowInSplitWorkUnit(config)); } else { throw new IllegalStateException("There is an inconsistency somewhere in the internal subjob creation"); } } } }
public ModelNavigator<JSLJob> createFirstExecution(JobInstanceEntity jobInstance, IJobXMLSource jslSource, Properties jobParameters) { StreamSource jslStream = null; if (!StringUtils.isEmpty(jobInstance.getJobXml())) { jslStream = new StreamSource(new StringReader(jobInstance.getJobXml())); } else { jslStream = jslSource.getJSLStreamSource(); } JSLJob jobModel = ModelResolverFactory.createJobResolver().resolveModel(jslStream); ModelNavigator<JSLJob> navigator = getResolvedJobNavigator(jobModel, jobParameters, false); String jobName = navigator.getRootModelElement().getId(); String jobXmlString = jslSource.getJSLString(); jobInstance.setJobName(jobName); jobInstance.setJobXml(jobXmlString); getPersistenceManagerService().updateJobInstanceWithJobNameAndJSL(jobInstance.getInstanceId(), jobName, jobXmlString); return navigator; }
@Test public void testModelNoValidate() throws Exception { JAXBContext ctx = JAXBContext.newInstance("com.ibm.jbatch.jsl.model"); Unmarshaller u = ctx.createUnmarshaller(); FileInputStream fis = new FileInputStream(new File("test/files/valid.job1.xml")); // Use this for anonymous type //Job job = (Job)u.unmarshal(url.openStream()); // Use this for named complex type, which is what the spec uses. Object elem = u.unmarshal(fis); JSLJob job = (JSLJob)((JAXBElement)elem).getValue(); assertEquals("job1", job.getId()); assertEquals(1, job.getExecutionElements().size()); Step step = (Step)job.getExecutionElements().get(0); assertEquals("step1", step.getId()); Batchlet b = step.getBatchlet(); assertEquals("step1Ref", b.getRef()); }
@Test public void testModelValidate() throws Exception { JAXBContext ctx = JAXBContext.newInstance("com.ibm.jbatch.jsl.model"); Unmarshaller u = ctx.createUnmarshaller(); u.setSchema(ValidatorHelper.getXJCLSchema()); JSLValidationEventHandler handler = new JSLValidationEventHandler(); u.setEventHandler(handler); FileInputStream fis = new FileInputStream(new File("test/files/valid.job1.xml")); // Use this for anonymous type //Job job = (Job)u.unmarshal(url.openStream()); // Use this for named complex type, which is what the spec uses. Object elem = u.unmarshal(fis); assertFalse("XSD invalid, see sysout", handler.eventOccurred()); JSLJob job = (JSLJob)((JAXBElement)elem).getValue(); assertEquals("job1", job.getId()); assertEquals(1, job.getExecutionElements().size()); Step step = (Step)job.getExecutionElements().get(0); assertEquals("step1", step.getId()); Batchlet b = step.getBatchlet(); assertEquals("step1Ref", b.getRef()); }
public static RuntimeFlowInSplitExecution startFlowInSplit(JSLJob jobModel) throws JobStartException{ logger.entering(CLASSNAME, "startFlowInSplit", jobModel); ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, null, true); JobContextImpl jobContext = getJobContext(jobNavigator); JobInstance jobInstance = getNewSubJobInstance(jobNavigator.getRootModelElement().getId()); RuntimeFlowInSplitExecution executionHelper = _persistenceManagementService.createFlowInSplitExecution(jobInstance, jobContext.getBatchStatus()); executionHelper.prepareForExecution(jobContext); JobStatus jobStatus = createNewJobStatus(jobInstance); _jobStatusManagerService.updateJobStatus(jobStatus); logger.exiting(CLASSNAME, "startFlowInSplit", executionHelper); return executionHelper; }
public static RuntimeJobExecution startPartition(JSLJob jobModel, Properties jobParameters) throws JobStartException{ logger.entering(CLASSNAME, "startPartition", new Object[]{jobModel, jobParameters ==null ? "<null>" :jobParameters}); ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, jobParameters, true); JobContextImpl jobContext = getJobContext(jobNavigator); JobInstance jobInstance = getNewSubJobInstance(jobNavigator.getRootModelElement().getId()); RuntimeJobExecution executionHelper = _persistenceManagementService.createJobExecution(jobInstance, jobParameters, jobContext.getBatchStatus()); executionHelper.prepareForExecution(jobContext); JobStatus jobStatus = createNewJobStatus(jobInstance); _jobStatusManagerService.updateJobStatus(jobStatus); logger.exiting(CLASSNAME, "startPartition", executionHelper); return executionHelper; }
public static RuntimeFlowInSplitExecution startFlowInSplit(JSLJob jobModel) throws JobStartException{ logger.entering(CLASSNAME, "startFlowInSplit", jobModel); ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, null, false); JobContextImpl jobContext = getJobContext(jobNavigator); JobInstance jobInstance = getNewSubJobInstance(jobNavigator.getRootModelElement().getId()); RuntimeFlowInSplitExecution executionHelper = _persistenceManagementService.createFlowInSplitExecution(jobInstance, jobContext.getBatchStatus()); executionHelper.prepareForExecution(jobContext); JobStatus jobStatus = createNewJobStatus(jobInstance); _jobStatusManagerService.updateJobStatus(jobStatus); logger.exiting(CLASSNAME, "startFlowInSplit", executionHelper); return executionHelper; }
public static RuntimeJobExecution startPartition(JSLJob jobModel, Properties jobParameters) throws JobStartException{ logger.entering(CLASSNAME, "startPartition", new Object[]{jobModel, jobParameters ==null ? "<null>" :jobParameters}); ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, jobParameters, true); JobContextImpl jobContext = getJobContext(jobNavigator); JobInstance jobInstance = getNewSubJobInstance(jobNavigator.getRootModelElement().getId()); RuntimeJobExecution executionHelper = _persistenceManagementService.createJobExecution(jobInstance, jobParameters, jobContext.getBatchStatus()); executionHelper.prepareForExecution(jobContext); JobStatus jobStatus = createNewJobStatus(jobInstance); _jobStatusManagerService.updateJobStatus(jobStatus); logger.exiting(CLASSNAME, "startPartition", executionHelper); return executionHelper; }
public static RuntimeJobExecution startJob(String jobXML, Properties jobParameters) throws JobStartException { logger.entering(CLASSNAME, "startJob", new Object[]{jobXML, jobParameters==null ? "<null>" : jobParameters}); JSLJob jobModel = ModelResolverFactory.createJobResolver().resolveModel(jobXML); ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, jobParameters, false); JobContextImpl jobContext = getJobContext(jobNavigator); JobInstance jobInstance = getNewJobInstance(jobNavigator.getRootModelElement().getId(), jobXML); RuntimeJobExecution executionHelper = _persistenceManagementService.createJobExecution(jobInstance, jobParameters, jobContext.getBatchStatus()); executionHelper.prepareForExecution(jobContext); JobStatus jobStatus = createNewJobStatus(jobInstance); _jobStatusManagerService.updateJobStatus(jobStatus); logger.exiting(CLASSNAME, "startJob", executionHelper); return executionHelper; }
public static RuntimeJobExecution startJob(String jobXML, Properties jobParameters) throws JobStartException { logger.entering(CLASSNAME, "startJob", new Object[]{jobXML, jobParameters==null ? "<null>" : jobParameters}); JSLJob jobModel = ModelResolverFactory.createJobResolver().resolveModel(jobXML); ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, jobParameters, false); JobContextImpl jobContext = getJobContext(jobNavigator); JobInstance jobInstance = getNewJobInstance(jobNavigator.getRootModelElement().getId(), jobXML); RuntimeJobExecution executionHelper = _persistenceManagementService.createJobExecution(jobInstance, jobParameters, jobContext.getBatchStatus()); executionHelper.prepareForExecution(jobContext); JobStatus jobStatus = createNewJobStatus(jobInstance); _jobStatusManagerService.updateJobStatus(jobStatus); logger.exiting(CLASSNAME, "startJob", executionHelper); return executionHelper; }
job.setId(this.replaceAllProperties(job.getId(), submittedProps, parentProps)); job.setRestartable(this.replaceAllProperties(job.getRestartable(), submittedProps, parentProps));