Exemplo n.º 1
0
        /// <summary>
        /// Initializes the job execution context with given scheduler and bundle.
        /// </summary>
        /// <param name="sched">The scheduler.</param>
        /// <param name="cancellationToken">The cancellation instruction.</param>
        public virtual async Task Initialize(
            QuartzScheduler sched,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            qs = sched;

            IJob       job;
            IJobDetail jobDetail = firedTriggerBundle.JobDetail;

            try
            {
                job = sched.JobFactory.NewJob(firedTriggerBundle, scheduler);
            }
            catch (SchedulerException se)
            {
                await sched.NotifySchedulerListenersError($"An error occurred instantiating job to be executed. job= '{jobDetail.Key}'", se, cancellationToken).ConfigureAwait(false);

                throw;
            }
            catch (Exception e)
            {
                SchedulerException se = new SchedulerException($"Problem instantiating type '{jobDetail.JobType.FullName}'", e);
                await sched.NotifySchedulerListenersError($"An error occurred instantiating job to be executed. job= '{jobDetail.Key}'", se, cancellationToken).ConfigureAwait(false);

                throw se;
            }

            jec = new JobExecutionContextImpl(scheduler, firedTriggerBundle, job);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the job execution context with given scheduler and bundle.
        /// </summary>
        /// <param name="sched">The scheduler.</param>
        public virtual void Initialize(QuartzScheduler sched)
        {
            qs = sched;

            IJob       job;
            IJobDetail jobDetail = firedTriggerBundle.JobDetail;

            try
            {
                job = sched.JobFactory.NewJob(firedTriggerBundle, scheduler);
            }
            catch (SchedulerException se)
            {
                sched.NotifySchedulerListenersError(string.Format(CultureInfo.InvariantCulture, "An error occured instantiating job to be executed. job= '{0}'", jobDetail.Key), se);
                throw;
            }
            catch (Exception e)
            {
                SchedulerException se = new SchedulerException(string.Format(CultureInfo.InvariantCulture, "Problem instantiating type '{0}'", jobDetail.JobType.FullName), e);
                sched.NotifySchedulerListenersError(string.Format(CultureInfo.InvariantCulture, "An error occured instantiating job to be executed. job= '{0}'", jobDetail.Key), se);
                throw se;
            }

            jec = new JobExecutionContextImpl(scheduler, firedTriggerBundle, job);
        }
Exemplo n.º 3
0
        private static IJobExecutionContext CreateMinimalJobExecutionContext()
        {
            IScheduler           sched = A.Fake <IScheduler>();
            IJobExecutionContext ctx   = new JobExecutionContextImpl(sched, ConstructMinimalTriggerFiredBundle(), null);

            return(ctx);
        }
Exemplo n.º 4
0
        public void TestToString()
        {
            // QRTZNET-48
            IJobExecutionContext ctx = new JobExecutionContextImpl(null, TestUtil.NewMinimalTriggerFiredBundle(), null);

            ctx.ToString();
        }
        private static IJobExecutionContext CreateMinimalJobExecutionContext()
        {
            MockRepository       repo  = new MockRepository();
            IScheduler           sched = (IScheduler)repo.DynamicMock(typeof(IScheduler));
            IJobExecutionContext ctx   = new JobExecutionContextImpl(sched, ConstructMinimalTriggerFiredBundle(), null);

            return(ctx);
        }
Exemplo n.º 6
0
        protected virtual ICancellableJobExecutionContext CreateJobExecutionContext()
        {
            IOperableTrigger   t                = new SimpleTriggerImpl("name", "group");
            TriggerFiredBundle firedBundle      = TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), t);
            ICancellableJobExecutionContext ctx = new JobExecutionContextImpl(null, firedBundle, null);

            return(ctx);
        }
        public void RecoveryTriggerKeyAndGroup()
        {
            IJobExecutionContext ctx = new JobExecutionContextImpl(null, TestUtil.NewMinimalRecoveringTriggerFiredBundle(), null);

            ctx.MergedJobDataMap[SchedulerConstants.FailedJobOriginalTriggerName]  = "originalTriggerName";
            ctx.MergedJobDataMap[SchedulerConstants.FailedJobOriginalTriggerGroup] = "originalTriggerGroup";
            var recoveringTriggerKey = ctx.RecoveringTriggerKey;

            Assert.That(recoveringTriggerKey.Name, Is.EqualTo("originalTriggerName"));
            Assert.That(recoveringTriggerKey.Group, Is.EqualTo("originalTriggerGroup"));
        }
        public async Task TestTriggerCompleteMessage()
        {
            ITrigger t = TriggerBuilder.Create()
                         .WithSchedule(SimpleScheduleBuilder.Create())
                         .Build();

            IJobExecutionContext ctx = new JobExecutionContextImpl(
                null,
                TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), (IOperableTrigger)t),
                null);

            await plugin.TriggerComplete(t, ctx, SchedulerInstruction.ReExecuteJob);

            Assert.That(plugin.InfoMessages.Count, Is.EqualTo(1));
        }
        public void TestTriggerCompleteMessage()
        {
            // arrange
            mockLog.Stub(log => log.IsInfoEnabled).Return(true);

            ITrigger t = TriggerBuilder.Create()
                                        .WithSchedule(SimpleScheduleBuilder.Create())
                                        .Build();

            IJobExecutionContext ctx = new JobExecutionContextImpl(
                null,
                TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), (IOperableTrigger) t),
                null);

            // act
            plugin.TriggerComplete(t, ctx, SchedulerInstruction.ReExecuteJob);

            // assert
            mockLog.AssertWasCalled(log => log.Info(Arg<string>.Is.NotNull));
        }
Exemplo n.º 10
0
        public async Task TestTriggerCompleteMessage()
        {
            // arrange
            A.CallTo(() => mockLog.Log(LogLevel.Info, null, null, null)).Returns(true);

            ITrigger t = TriggerBuilder.Create()
                         .WithSchedule(SimpleScheduleBuilder.Create())
                         .Build();

            IJobExecutionContext ctx = new JobExecutionContextImpl(
                null,
                TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), (IOperableTrigger)t),
                null);

            // act
            await plugin.TriggerComplete(t, ctx, SchedulerInstruction.ReExecuteJob);

            // assert
            A.CallTo(() => mockLog.Log(A <LogLevel> .That.IsEqualTo(LogLevel.Info), A <Func <string> > .That.IsNull(), A <Exception> .That.IsNull(), A <object[]> .That.Not.IsNull())).MustHaveHappened();
        }
        public void TestTriggerCompleteMessage()
        {
            // arrange
            mockLog.Stub(log => log.IsInfoEnabled).Return(true);

            ITrigger t = TriggerBuilder.Create()
                         .WithSchedule(SimpleScheduleBuilder.Create())
                         .Build();

            IJobExecutionContext ctx = new JobExecutionContextImpl(
                null,
                TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), (IOperableTrigger)t),
                null);

            // act
            plugin.TriggerComplete(t, ctx, SchedulerInstruction.ReExecuteJob);

            // assert
            mockLog.AssertWasCalled(log => log.Info(Arg <string> .Is.NotNull));
        }
Exemplo n.º 12
0
 /// <summary>
 /// Passivates this instance.
 /// </summary>
 public virtual void Passivate()
 {
     jec = null;
     qs  = null;
 }
Exemplo n.º 13
0
 private static IJobExecutionContext CreateMinimalJobExecutionContext()
 {
     MockRepository repo = new MockRepository();
     IScheduler sched = (IScheduler)repo.DynamicMock(typeof(IScheduler));
     IJobExecutionContext ctx = new JobExecutionContextImpl(sched, ConstructMinimalTriggerFiredBundle(), null);
     return ctx;
 }
Exemplo n.º 14
0
 public void TestToString()
 {
     // QRTZNET-48
     IJobExecutionContext ctx = new JobExecutionContextImpl(null, TestUtil.NewMinimalTriggerFiredBundle(), null);
     ctx.ToString();
 }
Exemplo n.º 15
0
        protected virtual IJobExecutionContext CreateJobExecutionContext()
        {
            IOperableTrigger t = new SimpleTriggerImpl("name", "group");
            TriggerFiredBundle firedBundle = TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), t);
            IJobExecutionContext ctx = new JobExecutionContextImpl(null,  firedBundle, null);

            return ctx;
        }
Exemplo n.º 16
0
 /// <summary>
 /// Passivates this instance.
 /// </summary>
 public virtual void Passivate()
 {
     jec = null;
     qs = null;
 }
Exemplo n.º 17
0
        /// <summary>
        /// Initializes the job execution context with given scheduler and bundle.
        /// </summary>
        /// <param name="sched">The scheduler.</param>
        public virtual void Initialize(QuartzScheduler sched)
        {
            qs = sched;

            IJob job;
            IJobDetail jobDetail = firedTriggerBundle.JobDetail;

            try
            {
                job = sched.JobFactory.NewJob(firedTriggerBundle, scheduler);
            }
            catch (SchedulerException se)
            {
                sched.NotifySchedulerListenersError(string.Format(CultureInfo.InvariantCulture, "An error occured instantiating job to be executed. job= '{0}'", jobDetail.Key), se);
                throw;
            }
            catch (Exception e)
            {
                SchedulerException se = new SchedulerException(string.Format(CultureInfo.InvariantCulture, "Problem instantiating type '{0}'", jobDetail.JobType.FullName), e);
                sched.NotifySchedulerListenersError(string.Format(CultureInfo.InvariantCulture, "An error occured instantiating job to be executed. job= '{0}'", jobDetail.Key), se);
                throw se;
            }

            jec = new JobExecutionContextImpl(scheduler, firedTriggerBundle, job);
        }