コード例 #1
0
 public void Initialize()
 {
     _jobInstance = new JobInstance(1, "testJob");
     _jobExecution = new JobExecution(_jobInstance, new JobParameters());
     _stepExecution1 = new StepExecution("testStep1", _jobExecution, 1);
     _stepExecution2 = new StepExecution("testStep2", _jobExecution, 2);
 }
コード例 #2
0
 public void Initialize()
 {
     _jobExecutionDao = new MapJobExecutionDao();
     _instance = new JobInstance(1, "testJob");
     _parameters = new JobParameters();
     _execution = new JobExecution(_instance, _parameters);
 }
コード例 #3
0
 /// <summary>
 ///  Constructor with mandatory properties.
 /// </summary>
 /// <param name="stepName"></param>
 /// <param name="jobExecution"></param>
 /// <param name="id"></param>
 public StepExecution(string stepName, JobExecution jobExecution, long id)
     : this(stepName, jobExecution)
 {
     Assert.NotNull(jobExecution, "JobExecution must be provided to re-hydrate an existing StepExecution");
     Assert.NotNull(id, "The entity Id must be provided to re-hydrate an existing StepExecution");
     Id = id;
     jobExecution.AddStepExecution(this);
 }
コード例 #4
0
        public void TestClear()
        {
            var execution = new JobExecution(1);
            var originalContext = new ExecutionContext();
            execution.ExecutionContext = originalContext;

            _executionContextDao.SaveExecutionContext(execution);
            _executionContextDao.Clear();
            _executionContextDao.GetExecutionContext(execution);
        }
コード例 #5
0
 /// <summary>
 /// Launched before the job. Fills the job context with the injected properties.
 /// </summary>
 /// <param name="jobExecution"></param>
 public void BeforeJob(JobExecution jobExecution)
 {
     ExecutionContext context = jobExecution.ExecutionContext;
     if (Properties != null)
     {
         foreach (KeyValuePair<string,string> entry in Properties)
         {
             context.PutString(entry.Key,entry.Value);
         }
     }
 }
コード例 #6
0
        public void TestSaveExecutionContextJob1()
        {
            var execution = new JobExecution(1);
            var originalContext = new ExecutionContext();
            execution.ExecutionContext = originalContext;

            _executionContextDao.SaveExecutionContext(execution);
            var context = _executionContextDao.GetExecutionContext(execution);

            Assert.AreEqual(originalContext, context);
        }
コード例 #7
0
        public void TestSaveExecutionContextStep1()
        {
            Insert(@"TestData\DbDao\ExecutionContextTestData.xml");
            var jobExecution = new JobExecution(1);
            var execution = new StepExecution("TestStep", jobExecution, 1);
            var originalContext = new ExecutionContext();
            execution.ExecutionContext = originalContext;

            _executionContextDao.SaveExecutionContext(execution);
            var context = _executionContextDao.GetExecutionContext(execution);

            Assert.AreEqual(originalContext, context);
        }
コード例 #8
0
        public void TestSaveExecutionContextJob2()
        {
            var execution = new JobExecution(1);
            var originalContext = new ExecutionContext();
            execution.ExecutionContext = originalContext;
            originalContext.PutString("test1", "test1");
            originalContext.PutLong("test2", 2L);

            _executionContextDao.SaveExecutionContext(execution);
            var context = _executionContextDao.GetExecutionContext(execution);

            Assert.AreEqual(originalContext, context);
        }
コード例 #9
0
        public void TestFindJobExecutions()
        {
            var execution2 = new JobExecution(_instance, _parameters);
            var instance2 = new JobInstance(2, "testJob2");
            var execution3 = new JobExecution(instance2, _parameters);
            _jobExecutionDao.SaveJobExecution(_execution);
            _jobExecutionDao.SaveJobExecution(execution2);
            _jobExecutionDao.SaveJobExecution(execution3);

            var executions = _jobExecutionDao.FindJobExecutions(_instance);

            Assert.AreEqual(2, executions.Count);
            Assert.IsTrue(executions.Contains(_execution));
            Assert.IsTrue(executions.Contains(execution2));
        }
コード例 #10
0
 public new void Initialize()
 {
     base.Initialize();
     _stepExecutionDao = new DbStepExecutionDao
     {
         DbOperator = DbOperator,
         PlaceholderGetter = new PlaceholderGetter(name => "@" + name, true),
         StepIncrementer = new SqlServerIncrementer
         {
             ConnectionStringSettings = ConnectionStringSettings,
             IncrementerName = "BATCH_STEP_EXECUTION_SEQ",
             ColumnName = "ID"
         }
     };
     _jobExecution = new JobExecution(1);
 }
コード例 #11
0
 /// <summary>
 /// Custom constructor using JobExecution.
 /// </summary>
 /// <param name="original"></param>
 public JobExecution(JobExecution original)
 {
     JobParameters         = original.JobParameters;
     JobInstance           = original.JobInstance;
     _stepExecutions       = original._stepExecutions;
     _status               = original.Status;
     StartTime             = original.StartTime;
     CreateTime            = original.CreateTime;
     EndTime               = original.EndTime;
     LastUpdated           = original.LastUpdated;
     _exitStatus           = original.ExitStatus;
     _executionContext     = original.ExecutionContext;
     _failureExceptions    = original.FailureExceptions;
     _jobConfigurationName = original.JobConfigurationName;
     Id      = original.Id;
     Version = original.Version;
 }
コード例 #12
0
        public void TestSaveJobExecution()
        {
            ResetSequence("BATCH_JOB_EXECUTION_SEQ");
            Insert(@"TestData\DbDao\JobExecutionTestData1.xml");
            var dictionary = new Dictionary<string, JobParameter>();
            dictionary["string"] = new JobParameter("string");
            dictionary["long"] = new JobParameter(3);
            dictionary["double"] = new JobParameter(4.3);
            dictionary["date"] = new JobParameter(DateTime.Now);
            _parameters = new JobParameters(dictionary);
            _execution = new JobExecution(_instance, _parameters);

            _jobExecutionDao.SaveJobExecution(_execution);

            Assert.AreEqual(1L, _execution.Id);
            Assert.AreEqual(_execution, _jobExecutionDao.GetJobExecution(1L));
        }
コード例 #13
0
 public new void Initialize()
 {
     base.Initialize();
     _jobExecutionDao = new DbJobExecutionDao
     {
         DbOperator = DbOperator,
         PlaceholderGetter = new PlaceholderGetter(name => "@" + name, true),
         JobIncrementer = new SqlServerIncrementer
         {
             IncrementerName = "BATCH_JOB_EXECUTION_SEQ",
             ConnectionStringSettings = ConnectionStringSettings,
             ColumnName = "ID"
         }
     };
     _instance = new JobInstance(1, "TestJob");
     _parameters = new JobParameters();
     _execution = new JobExecution(_instance, _parameters);
 }
コード例 #14
0
        /// <summary>
        /// Retrieves all job executions for a given minimal status
        /// </summary>
        /// <param name="jobIdentifier"></param>
        /// <param name="minStatus"></param>
        /// <param name="jobExplorer"></param>
        /// <returns></returns>
        private static List <JobExecution> GetJobExecutionsWithStatusGreaterThan(string jobIdentifier,
                                                                                 BatchStatus minStatus, IJobExplorer jobExplorer)
        {
            long?executionId = GetLongIdentifier(jobIdentifier);

            if (executionId != null)
            {
                JobExecution jobExecution = jobExplorer.GetJobExecution(executionId.Value);
                if (jobExecution.Status.IsGreaterThan(minStatus))
                {
                    return(new List <JobExecution> {
                        jobExecution
                    });
                }

                //empmty list
                return(new List <JobExecution>());
            }

            int start = 0;
            int count = 100;
            List <JobExecution> executions    = new List <JobExecution>();
            IList <JobInstance> lastInstances = jobExplorer.GetJobInstances(jobIdentifier, start, count);

            while (lastInstances.Any())
            {
                foreach (JobInstance jobInstance in lastInstances)
                {
                    IList <JobExecution> jobExecutions = jobExplorer.GetJobExecutions(jobInstance);
                    if (jobExecutions == null || !jobExecutions.Any())
                    {
                        continue;
                    }

                    executions.AddRange(
                        jobExecutions.Where(jobExecution => jobExecution.Status.IsGreaterThan(minStatus)));
                }

                start        += count;
                lastInstances = jobExplorer.GetJobInstances(jobIdentifier, start, count);
            }

            return(executions);
        }
コード例 #15
0
 /// <summary>
 /// Custom constructor used for serialize/deserialize
 /// </summary>
 /// <param name="original"></param>
 /// <param name="stepExecutions"></param>
 public JobExecution(JobExecution original, ICollection <StepExecution> stepExecutions)
 {
     JobParameters         = original.JobParameters;
     JobInstance           = original.JobInstance;
     _status               = original.Status;
     StartTime             = original.StartTime;
     CreateTime            = original.CreateTime;
     EndTime               = original.EndTime;
     LastUpdated           = original.LastUpdated;
     _exitStatus           = original.ExitStatus;
     _executionContext     = original.ExecutionContext;
     _failureExceptions    = original.FailureExceptions;
     _jobConfigurationName = original.JobConfigurationName;
     Id              = original.Id;
     Version         = original.Version;
     _stepExecutions = new ConcurrentBag <StepExecution>();
     if (stepExecutions != null)
     {
         foreach (StepExecution item in stepExecutions)
         {
             _stepExecutions.TryAdd(item);
         }
     }
 }
コード例 #16
0
        public void TestGetJobInstanceJobExecution()
        {
            Insert(@"TestData\DbDao\JobInstanceTestData1.xml");
            var jobExecution = new JobExecution(1L);

            var instance = _jobInstanceDao.GetJobInstance(jobExecution);

            Assert.IsNotNull(instance);
            Assert.AreEqual("TestJob", instance.JobName);
        }
コード例 #17
0
 public void Initialize()
 {
     _stepExecutionDao = new MapStepExecutionDao();
     _jobExecution = new JobExecution(1L);
 }
コード例 #18
0
        public void TestGetLastJobExecution()
        {
            var execution2 = new JobExecution(_instance, _parameters);
            _execution.CreateTime = DateTime.Now;
            _jobExecutionDao.SaveJobExecution(_execution);
            execution2.CreateTime = DateTime.Now.AddMinutes(1);
            _jobExecutionDao.SaveJobExecution(execution2);

            var lastExecution = _jobExecutionDao.GetLastJobExecution(_instance);

            Assert.AreEqual(execution2, lastExecution);
        }
コード例 #19
0
 /// <summary>
 /// Constructor that substitues in null for execution id.
 /// </summary>
 /// <param name="stepName"></param>
 /// <param name="jobExecution"></param>
 public StepExecution(string stepName, JobExecution jobExecution)
 {
     Assert.HasLength(stepName);
     _stepName     = stepName;
     _jobExecution = jobExecution;
 }
コード例 #20
0
        public void TestSynchronizeStatus()
        {
            _jobExecutionDao.SaveJobExecution(_execution);
            var execution2 = new JobExecution(_execution);
            _execution.Status = BatchStatus.Completed;
            _execution.EndTime = DateTime.Now;
            _jobExecutionDao.UpdateJobExecution(_execution);

            _jobExecutionDao.SynchronizeStatus(execution2);

            Assert.AreEqual(BatchStatus.Completed, execution2.Status);
            Assert.AreEqual(_execution.Version, execution2.Version);
            Assert.AreNotEqual(_execution.EndTime, execution2.EndTime);
        }
コード例 #21
0
        public void TestFindRunningJobExecutions()
        {
            var instance2 = new JobInstance(2, "testJob2");
            var execution2 = new JobExecution(instance2, _parameters);
            _jobExecutionDao.SaveJobExecution(_execution);
            _jobExecutionDao.SaveJobExecution(execution2);

            var runningExecutions = _jobExecutionDao.FindRunningJobExecutions("testJob");

            Assert.AreEqual(1, runningExecutions.Count);
            Assert.IsTrue(runningExecutions.Contains(_execution));
        }
コード例 #22
0
ファイル: JobExecution.cs プロジェクト: pkubryk/SummerBatch
 /// <summary>
 /// Custom constructor using JobExecution.
 /// </summary>
 /// <param name="original"></param>
 public JobExecution(JobExecution original)
 {
     JobParameters = original.JobParameters;
     JobInstance = original.JobInstance;
     _stepExecutions = original._stepExecutions;
     _status = original.Status;
     StartTime = original.StartTime;
     CreateTime = original.CreateTime;
     EndTime = original.EndTime;
     LastUpdated = original.LastUpdated;
     _exitStatus = original.ExitStatus;
     _executionContext = original.ExecutionContext;
     _failureExceptions = original.FailureExceptions;
     _jobConfigurationName = original.JobConfigurationName;
     Id = original.Id;
     Version = original.Version;
 }
コード例 #23
0
ファイル: StepExecution.cs プロジェクト: pkubryk/SummerBatch
 /// <summary>
 ///  Constructor with mandatory properties.
 /// </summary>
 /// <param name="stepName"></param>
 /// <param name="jobExecution"></param>
 /// <param name="id"></param>
 public StepExecution(string stepName, JobExecution jobExecution, long id)
     : this(stepName, jobExecution)
 {
     Assert.NotNull(jobExecution, "JobExecution must be provided to re-hydrate an existing StepExecution");
     Assert.NotNull(id, "The entity Id must be provided to re-hydrate an existing StepExecution");
     Id = id;
     jobExecution.AddStepExecution(this);
 }
コード例 #24
0
ファイル: StepExecution.cs プロジェクト: pkubryk/SummerBatch
 /// <summary>
 /// Constructor that substitues in null for execution id.
 /// </summary>
 /// <param name="stepName"></param>
 /// <param name="jobExecution"></param>
 public StepExecution(string stepName, JobExecution jobExecution)
 {
     Assert.HasLength(stepName);
     _stepName = stepName;
     _jobExecution = jobExecution;
 }
コード例 #25
0
 /// <summary>
 /// Launched after the job. Not used, thus does nothing.
 /// </summary>
 /// <param name="jobExecution"></param>
 public void AfterJob(JobExecution jobExecution)
 {
    //do nothing, on purpose.
 }
コード例 #26
0
        public void TestSaveExecutionContexts()
        {
            Insert(@"TestData\DbDao\ExecutionContextTestData.xml");
            var jobExecution = new JobExecution(1);
            var execution1 = new StepExecution("TestStep", jobExecution, 1);
            var execution2 = new StepExecution("TestStep", jobExecution, 2);
            execution1.ExecutionContext = new ExecutionContext();
            execution2.ExecutionContext = new ExecutionContext();
            execution2.ExecutionContext.PutString("test1", "test1");
            execution2.ExecutionContext.PutLong("test2", 2L);

            IList<StepExecution> executions = new List<StepExecution>();
            executions.Add(execution1);
            executions.Add(execution2);
            _executionContextDao.SaveExecutionContexts(executions);
            var context1 = _executionContextDao.GetExecutionContext(execution1);
            var context2 = _executionContextDao.GetExecutionContext(execution2);

            Assert.AreEqual(execution1.ExecutionContext, context1);
            Assert.AreEqual(execution2.ExecutionContext, context2);
        }