@Override public Transition getNextTransition(ExecutionElement currentExecutionElem, ExecutionStatus currentStatus) throws IllegalTransitionException { if (logger.isLoggable(Level.FINE)) { logger.fine("Getting next transition in job, currentExecutionElem = " + currentExecutionElem); } Transition nextTransition = getNextTransition(currentExecutionElem, job.getExecutionElements(), currentStatus); logger.fine("Got next transition in job = " + nextTransition); return nextTransition; }
public String toString() { return "JobNavigatorImpl for job id = " + job.getId(); }
/** * Create an instance of {@link JSLJob } * */ public JSLJob createJSLJob() { return new JSLJob(); }
public static boolean equals(JSLJob job1, JSLJob job2) { if(job1 == null && job2 == null) return true; if(job1 == null || job2 == null) return false; boolean stillEqual = true; //for each attribute, stillEqual && equal(that attribute) stillEqual = stillEqual && equals(job1.getListeners(), job2.getListeners()) && equals(job1.getProperties(), job2.getProperties()) && true; return stillEqual; }
job.setId(this.replaceAllProperties(job.getId(), submittedProps, parentProps)); job.setRestartable(this.replaceAllProperties(job.getRestartable(), submittedProps, parentProps)); if (job.getProperties() != null) { currentProps = this.resolveElementProperties(job.getProperties().getPropertyList(), submittedProps, parentProps); if (job.getListeners() != null) { for (final Listener listener : job.getListeners().getListenerList()) { PropertyResolverFactory.createListenerPropertyResolver(this.isPartitionedStep).substituteProperties(listener, submittedProps, currentProps); for (final ExecutionElement next : job.getExecutionElements()) { if (next instanceof Step) { PropertyResolverFactory.createStepPropertyResolver(this.isPartitionedStep).substituteProperties((Step)next, submittedProps, currentProps);
JSLJob jslJob = new JSLJob(); jslJob.setRestartable("true"); jslJob.setId(jobName); jslJob.setVersion("1.0"); jslJob.setProperties(JobDefinitionBuildUtils.buildJobProperties(scopeId, jobId, jobStartOptions)); jslJob.setListeners(JobDefinitionBuildUtils.buildListener()); jslJob.getExecutionElements().addAll(jslExecutionElements);
public static JSLJob buildFlowInSplitSubJob(long topLevelJobInstanceId, JobContext jobContext, Split split, Flow flow) { ObjectFactory jslFactory = new ObjectFactory(); JSLJob subJob = jslFactory.createJSLJob(); // Uses the true top-level job instance id, not an internal "subjob" id. String subJobId = generateSubJobId(topLevelJobInstanceId, split.getId(), flow.getId()); subJob.setId(subJobId); //Copy all properties from parent JobContext to flow threads subJob.setProperties(CloneUtility.javaPropsTojslProperties(jobContext.getProperties())); //We don't need to do a deep copy here since each flow is already independent of all others, unlike in a partition //where one step instance can be executed with different properties on multiple threads. subJob.getExecutionElements().add(flow); return subJob; }
public static JSLJob buildFlowInSplitSubJob(JobContextImpl jobContext, Split split, Flow flow) { ObjectFactory jslFactory = new ObjectFactory(); JSLJob subJob = jslFactory.createJSLJob(); // Uses the true top-level job instance id, not an internal "subjob" id. String subJobId = generateSubJobId(jobContext.getInstanceId(), split.getId(), flow.getId()); subJob.setId(subJobId); //Copy all properties from parent JobContext to flow threads subJob.setProperties(CloneUtility.javaPropsTojslProperties(jobContext.getProperties())); //We don't need to do a deep copy here since each flow is already independent of all others, unlike in a partition //where one step instance can be executed with different properties on multiple threads. subJob.getExecutionElements().add(flow); jobContext.addTopLevelContextProperties(subJob.getProperties()); return subJob; }
@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()); }
private Properties initTopLevelJobProperties() { // Should this be in the spec (that Properties is never null)? Or is it already? Properties jobProperties = new Properties(); JSLProperties jslProperties = new JSLProperties(); if (jobNavigator.getRootModelElement() != null) { jslProperties = jobNavigator.getRootModelElement().getProperties(); } if (jslProperties != null) { // null if not job properties defined. for (Property property : jslProperties.getPropertyList()) { jobProperties.setProperty(property.getName(), property.getValue()); } } return jobProperties; }
private void initJobLevelListeners(JSLJob jobModel, InjectionReferences injectionRefs) { jobLevelListenerInfo = new ArrayList<ListenerInfo>(); Listeners jobLevelListeners = jobModel.getListeners(); if (jobLevelListeners != null) { for (Listener listener : jobLevelListeners.getListenerList()) { ListenerInfo info = buildListenerInfo(listener, injectionRefs); jobLevelListenerInfo.add(info); } } }
private static void validateRestartableFalseJobsDoNotRestart(JSLJob jobModel) throws JobRestartException { if (jobModel.getRestartable() != null && jobModel.getRestartable().equalsIgnoreCase("false")) { throw new JobRestartException("Job Restartable attribute is false, Job cannot be restarted."); } }
job.setId(this.replaceAllProperties(job.getId(), submittedProps, parentProps)); job.setRestartable(this.replaceAllProperties(job.getRestartable(), submittedProps, parentProps)); if (job.getProperties() != null) { currentProps = this.resolveElementProperties(job.getProperties().getPropertyList(), submittedProps, parentProps); if (job.getListeners() != null) { for (final Listener listener : job.getListeners().getListenerList()) { PropertyResolverFactory.createListenerPropertyResolver(this.isPartitionedStep).substituteProperties(listener, submittedProps, currentProps); for (final ExecutionElement next : job.getExecutionElements()) { if (next instanceof Step) { PropertyResolverFactory.createStepPropertyResolver(this.isPartitionedStep).substituteProperties((Step)next, submittedProps, currentProps);
JSLJob jslJob = new JSLJob(); jslJob.setRestartable("true"); jslJob.setId(jobName); jslJob.setVersion("1.0"); jslJob.setProperties(JobDefinitionBuildUtils.buildJobProperties(scopeId, jobId, jobStartOptions)); jslJob.setListeners(JobDefinitionBuildUtils.buildListener()); jslJob.getExecutionElements().addAll(jslExecutionElements);
public static JSLJob buildFlowInSplitSubJob(Long parentJobExecutionId, JobContext jobContext, Split split, Flow flow) { ObjectFactory jslFactory = new ObjectFactory(); JSLJob subJob = jslFactory.createJSLJob(); // Set the generated subjob id String subJobId = generateSubJobId(parentJobExecutionId, split.getId(), flow.getId()); subJob.setId(subJobId); //Copy all properties from parent JobContext to flow threads subJob.setProperties(CloneUtility.javaPropsTojslProperties(jobContext.getProperties())); //We don't need to do a deep copy here since each flow is already independent of all others, unlike in a partition //where one step instance can be executed with different properties on multiple threads. subJob.getExecutionElements().add(flow); return subJob; }
subJob.setId(subJobId); subJob.setProperties(CloneUtility.javaPropsTojslProperties(jobContext.getProperties())); subJob.getExecutionElements().add(newStep); jobContext.addTopLevelContextProperties(subJob.getProperties());
@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 boolean equals(JSLJob job1, JSLJob job2) { if(job1 == null && job2 == null) return true; if(job1 == null || job2 == null) return false; boolean stillEqual = true; //for each attribute, stillEqual && equal(that attribute) stillEqual = stillEqual && equals(job1.getListeners(), job2.getListeners()) && equals(job1.getProperties(), job2.getProperties()) && true; return stillEqual; }
private static JobContextImpl getJobContext(ModelNavigator<JSLJob> jobNavigator) { JSLProperties jslProperties = new JSLProperties(); if(jobNavigator.getRootModelElement() != null) { jslProperties = jobNavigator.getRootModelElement().getProperties(); } return new JobContextImpl(jobNavigator, jslProperties); }
private void initJobLevelListeners(JSLJob jobModel, InjectionReferences injectionRefs) { jobLevelListenerInfo = new ArrayList<ListenerInfo>(); Listeners jobLevelListeners = jobModel.getListeners(); if (jobLevelListeners != null) { for (Listener listener : jobLevelListeners.getListenerList()) { ListenerInfo info = buildListenerInfo(listener, injectionRefs); jobLevelListenerInfo.add(info); } } }