step.setId(this.replaceAllProperties(step.getId(), submittedProps, parentProps)); step.setAllowStartIfComplete(this.replaceAllProperties(step.getAllowStartIfComplete(), submittedProps, parentProps)); step.setNextFromAttribute(this.replaceAllProperties(step.getNextFromAttribute(), submittedProps, parentProps)); step.setStartLimit(this.replaceAllProperties(step.getStartLimit(), submittedProps, parentProps)); if (step.getProperties() != null) { currentProps = this.resolveElementProperties(step.getProperties().getPropertyList(), submittedProps, parentProps); if (step.getPartition() != null) { PropertyResolverFactory.createPartitionPropertyResolver(this.isPartitionedStep).substituteProperties(step.getPartition(), submittedProps, currentProps); if (step.getListeners() != null) { for (final Listener listener : step.getListeners().getListenerList()) { PropertyResolverFactory.createListenerPropertyResolver(this.isPartitionedStep).substituteProperties(listener, submittedProps, currentProps); if (step.getTransitionElements() != null) { for (final TransitionElement controlElement : step.getTransitionElements()) { PropertyResolverFactory.createTransitionElementPropertyResolver(this.isPartitionedStep).substituteProperties(controlElement, submittedProps, currentProps); if (step.getBatchlet() != null) { PropertyResolverFactory.createBatchletPropertyResolver(this.isPartitionedStep).substituteProperties(step.getBatchlet(), submittedProps, currentProps); if (step.getChunk() != null) { PropertyResolverFactory.createChunkPropertyResolver(this.isPartitionedStep).substituteProperties(step.getChunk(), submittedProps, currentProps);
/** * Create an instance of {@link Step } * */ public Step createStep() { return new Step(); }
public static boolean equals(Step step1, Step step2) { if(step1 == null && step2 == null) return true; if(step1 == null || step2 == null) return false; //TODO: finish with remaining fields return equals(step1.getChunk(), step2.getChunk()) && equals(step1.getListeners(), step2.getListeners()) && equals(step1.getProperties(), step2.getProperties()) && nullSafeEquals(step1.getAllowStartIfComplete(), step2.getAllowStartIfComplete()) && nullSafeEquals(step1.getNextFromAttribute(), step2.getNextFromAttribute()); }
private synchronized List<ListenerInfo> getStepListenerInfo(Step step, InjectionReferences injectionRefs) { if (!stepLevelListenerInfo.containsKey(step.getId())) { List<ListenerInfo> stepListenerInfoList = new ArrayList<ListenerInfo>(); stepLevelListenerInfo.put(step.getId(), stepListenerInfoList); Listeners stepLevelListeners = step.getListeners(); if (stepLevelListeners != null) { for (Listener listener : stepLevelListeners.getListenerList()) { ListenerInfo info = buildListenerInfo(listener, injectionRefs); stepListenerInfoList.add(info); } } return stepListenerInfoList; } else { return stepLevelListenerInfo.get(step.getId()); } }
@Override protected void invokeCoreStep() throws BatchContainerServiceException { //TODO If this step is partitioned create partition artifacts Partition partition = step.getPartition(); if (partition != null) { //partition.getConcurrencyElements(); } try { invokeBatchlet(step.getBatchlet()); } finally { invokeCollectorIfPresent(); } }
String subJobId = generateSubJobId(parentJobInstanceId, step.getId(), partitionInstance); subJob.setId(subJobId); newStep.setId(step.getId()); newStep.setAllowStartIfComplete(step.getAllowStartIfComplete()); if (step.getBatchlet() != null){ newStep.setBatchlet(CloneUtility.cloneBatchlet(step.getBatchlet())); if (step.getChunk() != null) { newStep.setChunk(CloneUtility.cloneChunk(step.getChunk())); Partition partition = step.getPartition(); if (partition != null) { if (partition.getCollector() != null) { newStep.setPartition(basePartition); newStep.setStartLimit(step.getStartLimit()); newStep.setProperties(CloneUtility.cloneJSLProperties(step.getProperties())); newStep.setListeners(CloneUtility.cloneListeners(step.getListeners()));
String subJobId = generateSubJobId(topLevelJobExecutionId, step.getId(), partitionInstance); subJob.setId(subJobId); newStep.setId(step.getId()); if (step.getBatchlet() != null){ newStep.setBatchlet(CloneUtility.cloneBatchlet(step.getBatchlet())); if (step.getChunk() != null) { newStep.setChunk(CloneUtility.cloneChunk(step.getChunk())); Partition partition = step.getPartition(); if (partition != null) { if (partition.getCollector() != null) { newStep.setPartition(basePartition); newStep.setProperties(CloneUtility.cloneJSLProperties(step.getProperties())); newStep.setListeners(CloneUtility.cloneListeners(step.getListeners()));
JobStep jobStep = jobStepIterator.next(); Step jslStep = new Step(); JobStepDefinition jobStepDefinition = STEP_DEFINITION_SERVICE.find(jobStep.getScopeId(), jobStep.getJobStepDefinitionId()); switch (jobStepDefinition.getStepType()) { case GENERIC: jslStep.setBatchlet(JobDefinitionBuildUtils.buildGenericStep(jobStepDefinition)); break; case TARGET: jslStep.setChunk(JobDefinitionBuildUtils.buildChunkStep(jobStepDefinition)); break; default: jslStep.setId("step-" + jobStep.getStepIndex()); jslStep.setNextFromAttribute("step-" + (jobStep.getStepIndex() + 1)); jslStep.setProperties(JobDefinitionBuildUtils.buildStepProperties(jobStepDefinition, jobStep, jobStepIterator.hasNext()));
if(logger.isLoggable(Level.FINER)) { logger.logp (Level.FINER, CLASSNAME, methodName, "Get StepController for", step.getId());} if (step.getPartition() != null) { if (isTruePartitionOfTopLevelStep(step)) { return new PartitionedStepControllerImpl(jobExecutionImpl, step); Batchlet batchlet = step.getBatchlet(); if (batchlet != null) { if(logger.isLoggable(Level.FINER)) { logger.finer("Found batchlet: " + batchlet + ", with ref= " + batchlet.getRef()); if (step.getChunk() != null) { throw new IllegalArgumentException("Step contains both a batchlet and a chunk. Aborting."); Chunk chunk = step.getChunk(); if(logger.isLoggable(Level.FINER)) { logger.finer("Found chunk: " + chunk);
public String toString() { return "BaseStepControllerImpl for step = " + step.getId(); } }
if (!Boolean.parseBoolean(step.getAllowStartIfComplete())) { logger.fine("Step: " + step.getId() + " already has batch status of COMPLETED, so won't be run again since it does not allow start if complete."); return false; } else { logger.fine("Step: " + step.getId() + " already has batch status of COMPLETED, and allow-start-if-complete is set to 'true'"); restartAfterCompletion = true; String startLimitString = step.getStartLimit(); if (startLimitString != null) { try { } catch (NumberFormatException e) { throw new IllegalArgumentException("Could not parse start limit value. Received NumberFormatException for start-limit value: " + startLimitString + " for stepId: " + step.getId() + ", with start-limit=" + step.getStartLimit()); throw new IllegalArgumentException("Found negative start-limit of " + startLimit + "for stepId: " + step.getId()); int newStepStartCount = stepStatus.getStartCount() + 1; if (newStepStartCount > startLimit) { throw new IllegalStateException("For stepId: " + step.getId() + ", tried to start step for the " + newStepStartCount + " time, but startLimit = " + startLimit); } else { logger.fine("Starting (possibly restarting) step: " + step.getId() + ", since newStepStartCount = " + newStepStartCount + " and startLimit=" + startLimit);
@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()); }
final PartitionMapper partitionMapper = step.getPartition().getMapper(); } else if (step.getPartition().getPlan() != null) { //from static partition element in jsl String partitionsAttr = step.getPartition().getPlan().getPartitions(); String threadsAttr = null; numPartitions = Integer.parseInt(partitionsAttr); } catch (final NumberFormatException e) { throw new IllegalArgumentException("Could not parse partition instances value in stepId: " + step.getId() + ", with instances=" + partitionsAttr, e); throw new IllegalArgumentException("Partition instances value must be 1 or greater in stepId: " + step.getId() + ", with instances=" + partitionsAttr); threadsAttr = step.getPartition().getPlan().getThreads(); if (threadsAttr != null) { try { throw new IllegalArgumentException("Could not parse partition threads value in stepId: " + step.getId() + ", with threads=" + threadsAttr, e); throw new IllegalArgumentException("Threads value must be 0 or greater in stepId: " + step.getId() + ", with threads=" + threadsAttr); if (step.getPartition().getPlan().getProperties() != null) { List<JSLProperties> jslProperties = step.getPartition().getPlan().getProperties(); for (JSLProperties props : jslProperties) {
/** * @return true if this is a partitioned step */ protected boolean isPartitionedStep() { return (getStep().getPartition() != null); }
protected void invokeCoreStep() throws BatchContainerServiceException { this.chunk = step.getChunk(); initializeChunkArtifacts(); invokeChunk(); }
private void setContextProperties() { JSLProperties jslProps = step.getProperties(); if (jslProps != null) { for (Property property : jslProps.getPropertyList()) { Properties contextProps = runtimeStepExecution.getJSLProperties(); contextProps.setProperty(property.getName(), property.getValue()); } } // set up metrics runtimeStepExecution.addMetric(MetricImpl.MetricType.READ_COUNT, 0); runtimeStepExecution.addMetric(MetricImpl.MetricType.WRITE_COUNT, 0); runtimeStepExecution.addMetric(MetricImpl.MetricType.READ_SKIP_COUNT, 0); runtimeStepExecution.addMetric(MetricImpl.MetricType.PROCESS_SKIP_COUNT, 0); runtimeStepExecution.addMetric(MetricImpl.MetricType.WRITE_SKIP_COUNT, 0); runtimeStepExecution.addMetric(MetricImpl.MetricType.FILTER_COUNT, 0); runtimeStepExecution.addMetric(MetricImpl.MetricType.COMMIT_COUNT, 0); runtimeStepExecution.addMetric(MetricImpl.MetricType.ROLLBACK_COUNT, 0); transactionManager = getTransactionManagementService().getTransactionManager(runtimeStepExecution); }
private ExecutionElement getNextExecutionElemFromAttribute(List<ExecutionElement> peerExecutionElements, ExecutionElement currentElem) throws IllegalTransitionException { ExecutionElement nextExecutionElement = null; String nextAttrId = null; if (currentElem instanceof Step) { nextAttrId = ((Step) currentElem).getNextFromAttribute(); nextExecutionElement = getExecutionElementFromId(peerExecutionElements, nextAttrId); } else if (currentElem instanceof Split) { nextAttrId = ((Split) currentElem).getNextFromAttribute(); nextExecutionElement = getExecutionElementFromId(peerExecutionElements, nextAttrId); } else if (currentElem instanceof Flow) { nextAttrId = ((Flow) currentElem).getNextFromAttribute(); nextExecutionElement = getExecutionElementFromId(peerExecutionElements, nextAttrId); } else if (currentElem instanceof Decision) { // Nothing special to do in this case. } validateElementType(nextExecutionElement); logger.fine("From currentElem = " + currentElem + " , return @next attribute execution element: " + nextExecutionElement); return nextExecutionElement; }
@Override protected void invokeCoreStep() throws BatchContainerServiceException { try { invokeBatchlet(getStep().getBatchlet()); } finally { invokeCollectorIfPresent(); } }
@Override public StepThreadExecutionEntity setupStepThreadExecutionForRestartIfNecessary(boolean isRemoteDispatch) throws DoNotRestartStepThreadException { TopLevelStepInstanceEntity topLevelStepInstance = (TopLevelStepInstanceEntity) stepThreadInstance; boolean restartAfterCompletion = false; BatchStatus stepBatchStatus = topLevelStepInstance.getLatestStepThreadExecution().getBatchStatus(); if (stepBatchStatus.equals(BatchStatus.COMPLETED)) { // A bit of parsing involved since the model gives us a String not a // boolean, but it should default to 'false', which is the spec'd default. if (!Boolean.parseBoolean(getStep().getAllowStartIfComplete())) { logger.fine("Step: " + getStepName() + " already has batch status of COMPLETED, so won't be run again since it does not allow start if complete."); throw new DoNotRestartStepThreadException(); } else { logger.fine("Step: " + getStepName() + " already has batch status of COMPLETED, and allow-start-if-complete is set to 'true'"); // Save the fact that the step has already completed, but we'll see if we've reached the start-limit before actually restarting. restartAfterCompletion = true; } } validateStartLimitNotExceeded(); if (restartAfterCompletion) { markRestartAfterCompletion(); return getPersistenceManagerService().createTopLevelStepExecutionOnRestartAndCleanStepInstance(getJobExecutionId(), topLevelStepInstance); } else { return getPersistenceManagerService().createTopLevelStepExecutionOnRestartFromPreviousStepInstance(getJobExecutionId(), topLevelStepInstance); } }
String subJobId = generateSubJobId(jobContext.getInstanceId(), step.getId(), partitionInstance); subJob.setId(subJobId); newStep.setId(step.getId()); newStep.setAllowStartIfComplete(step.getAllowStartIfComplete()); if (step.getBatchlet() != null){ newStep.setBatchlet(CloneUtility.cloneBatchlet(step.getBatchlet())); if (step.getChunk() != null) { newStep.setChunk(CloneUtility.cloneChunk(step.getChunk())); Partition partition = step.getPartition(); if (partition != null) { if (partition.getCollector() != null) { newStep.setPartition(basePartition); newStep.setStartLimit(step.getStartLimit()); JSLProperties newProperties = CloneUtility.cloneJSLProperties(step.getProperties()); newStep.setProperties(newProperties); newStep.setListeners(CloneUtility.cloneListeners(step.getListeners()));