/// <summary> /// @see IJobOperator#Stop . /// </summary> /// <param name="executionId"></param> /// <returns></returns> /// <exception cref="NoSuchJobException"> </exception> /// <exception cref="JobExecutionNotRunningException"> </exception> public bool Stop(long executionId) { JobExecution jobExecution = FindExecutionById(executionId); // Indicate the execution should be stopped by setting it's status to // 'STOPPING'. It is assumed that // the step implementation will check this status at chunk boundaries. BatchStatus status = jobExecution.Status; if (!(status == BatchStatus.Started || status == BatchStatus.Starting)) { throw new JobExecutionNotRunningException( string.Format("JobExecution must be running so that it can be stopped: {0}", jobExecution)); } jobExecution.Status = BatchStatus.Stopping; JobRepository.Update(jobExecution); try { IJob job = JobRegistry.GetJob(jobExecution.JobInstance.JobName); var locator = job as IStepLocator; if (locator != null) { //can only process as StepLocator is the only way to get the step object //get the current stepExecution foreach (StepExecution stepExecution in jobExecution.StepExecutions) { if (stepExecution.BatchStatus.IsRunning()) { try { //have the step execution that's running -> need to 'stop' it IStep step = locator.GetStep(stepExecution.StepName); var taskletStep = step as TaskletStep; if (taskletStep != null) { ITasklet tasklet = taskletStep.Tasklet; var stoppableTasklet = tasklet as IStoppableTasklet; if (stoppableTasklet != null) { StepSynchronizationManager.Register(stepExecution); stoppableTasklet.Stop(); StepSynchronizationManager.Release(); } } } catch (NoSuchStepException e) { _logger.Warn("Step not found {0}", e.Message); } } } } } catch (NoSuchJobException e) { _logger.Warn("Cannot find Job object {0}", e.Message); } return(true); }
public void TestGetValue() { var manager = new StepScopeLifetimeManager(); StepSynchronizationManager.Register(_stepExecution1); var result = manager.GetValue(); Assert.IsNull(result); }
public void TestSetValue1() { var obj = new object(); var manager = new StepScopeLifetimeManager(); StepSynchronizationManager.Register(_stepExecution1); manager.SetValue(obj); var result = manager.GetValue(); Assert.AreEqual(obj, result); }
private void Check(IUnityContainer container) { var a = container.Resolve <A>("a"); Assert.IsNotNull(a); Assert.IsNotNull(a.I); Assert.IsTrue(a.I is IProxyObject); StepSynchronizationManager.Register(_stepExecution); Assert.IsNotNull(((IProxyObject)a.I).GetInstance()); Assert.AreEqual("B", a.M()); }
public void TestAllInStepScope() { IUnityContainer container = new UnityContainer(); container.AddNewExtension <StepScopeExtension>(); container.RegisterStepScope <A>("a", new InjectionConstructor(new ResolvedParameter <B>("i"))); container.RegisterStepScope <B>("i"); StepSynchronizationManager.Register(_stepExecution); var a = container.Resolve <A>("a"); Assert.IsNotNull(a.I); Assert.IsFalse(a.I is IProxyObject); }
/// <summary> /// Registers the StepExecution for property resolution via StepScope /// </summary> /// <param name="stepExecution"></param> protected void DoExecutionRegistration(StepExecution stepExecution) { StepSynchronizationManager.Register(stepExecution); }