public void read_normal_exception() { var record = new JobExecutionRecord(); var ex = new DivideByZeroException("Only Chuck Norris can do that"); record.ReadException(ex); record.ExceptionText.ShouldBe(ex.ToString()); }
public DateTimeOffset ScheduleNextTime(DateTimeOffset currentTime, JobExecutionRecord lastExecution) { var next = currentTime.Subtract(new TimeSpan(0, 0, 0, currentTime.Second, currentTime.Millisecond)); while (next < currentTime) { next = next.Add(_seconds.Seconds()); } return(next); }
void IScheduledJob.Initialize(DateTimeOffset now, IJobExecutor executor, JobSchedule schedule) { var status = schedule.Find(JobType); LastExecution = status.LastExecution; var next = Scheduler.ScheduleNextTime(now, LastExecution); schedule.Schedule(JobType, next); executor.Schedule(this, next); }
public DateTimeOffset ScheduleNextTime(DateTimeOffset currentTime, JobExecutionRecord lastExecution) { var hour = new DateTimeOffset(currentTime.Year, currentTime.Month, currentTime.Day, currentTime.Hour, 0, 0, currentTime.Offset); while (hour < currentTime) { hour = hour.AddMinutes(10); } return(hour); }
public DateTimeOffset ScheduleNextTime(DateTimeOffset currentTime, JobExecutionRecord lastExecution) { var localTime = currentTime.ToLocalTime(); var oneAmToday = new DateTime(localTime.Year, localTime.Month, localTime.Day, _hour, _minute, 0, 0, DateTimeKind.Local); var nextScheduledTime = oneAmToday; if (localTime.Hour > _hour || (localTime.Hour == _hour && localTime.Minute >= _minute)) { // Switch to tomorrow nextScheduledTime = oneAmToday.AddDays(1); } return(nextScheduledTime.ToUniversalTime()); }
public void RecordHistory(string nodeName, string jobKey, JobExecutionRecord record) { var id = ScheduledRunHistory.ToId(nodeName, jobKey); _transaction.Execute <IDocumentSession>(session => { var history = session.Load <ScheduledRunHistory>(id) ?? new ScheduledRunHistory { JobKey = jobKey, NodeName = nodeName }; history.Append(record, _maxHistory); session.Store(history); }); }
public void mark_completion_with_failure_persistence() { var record = new JobExecutionRecord { Success = false }; theStatusMonitor.MarkCompletion <FooJob1>(record); foo1.Status.ShouldEqual(JobExecutionStatus.Failed); foo1.LastExecution.ShouldBeTheSameAs(record); foo1.Executor.ShouldBeNull(); record.Executor.ShouldEqual(theChannelGraph.NodeId); }
public void store_history() { var record1 = new JobExecutionRecord(); var record2 = new JobExecutionRecord(); var record3 = new JobExecutionRecord(); var record4 = new JobExecutionRecord(); thePersistence.RecordHistory("foo", "1", record1); thePersistence.RecordHistory("foo", "1", record2); thePersistence.RecordHistory("foo", "2", record3); thePersistence.RecordHistory("foo", "2", record4); thePersistence.FindHistory("foo", "1").ShouldHaveTheSameElementsAs(record1, record2); thePersistence.FindHistory("foo", "2").ShouldHaveTheSameElementsAs(record3, record4); }
private void addRecord(JobExecutionRecord record, TableRowTag row) { row.Cell(record.Finished.ToLocalTime().ToString()).Style("vertical-align", "top"); row.Cell(record.Executor).Style("vertical-align", "top"); row.Cell(record.Success ? "Success" : "Failed").Style("vertical-align", "top"); row.Cell(record.Duration.ToString()).Attr("align", "right").Style("vertical-align", "top"); row.Cell(record.Attempts.ToString()).Attr("align", "right").Style("vertical-align", "top"); if (record.ExceptionText.IsEmpty()) { row.Cell("None"); } else { row.Cell().Add("pre").Text(record.ExceptionText).Style("font-size", "xx-small"); } }
public void mark_completion_persistence() { var record = new JobExecutionRecord { Success = true }; theStatusMonitor.MarkCompletion <FooJob1>(record); foo1.Status.ShouldEqual(JobExecutionStatus.Completed); foo1.LastExecution.ShouldBeTheSameAs(record); foo1.Executor.ShouldBeNull(); record.Executor.ShouldEqual(theChannelGraph.NodeId); thePersistence.FindHistory(foo1.NodeName, foo1.JobKey) .ShouldHaveTheSameElementsAs(record); }
public void read_aggregate_exception() { var ex1 = new DivideByZeroException("Only Chuck Norris can do that"); var ex2 = new RankException("You're last!"); var ex3 = new InvalidTimeZoneException("You are in the wrong place!"); var ex = new AggregateException(ex1, ex2, ex3); var record = new JobExecutionRecord(); record.ReadException(ex); record.ExceptionText.ShouldNotBe(ex.ToString()); record.ExceptionText.ShouldContain(ex1.ToString()); record.ExceptionText.ShouldContain(ex2.ToString()); record.ExceptionText.ShouldContain(ex3.ToString()); record.ExceptionText.ShouldContain(JobExecutionRecord.ExceptionSeparator); }
public void SetUp() { theSchedule = new JobSchedule(); theRule = new StubbedScheduleRule(); theRule.ScheduledTimes[now] = next; theExecutor = new StubJobExecutor(); theJob = new ScheduledJob <AJob>(theRule); theLastRun = new JobExecutionRecord(); theSchedule.Find(theJob.JobType) .LastExecution = theLastRun; theJob.As <IScheduledJob>().Initialize(now, theExecutor, theSchedule); }
public DateTimeOffset ScheduleNextTime(DateTimeOffset currentTime, JobExecutionRecord lastExecution) { return(_nextTime); }
public void Reschedule <T>(IScheduledJob <T> job, DateTimeOffset nextTime, JobExecutionRecord record = null) where T : IJob { Scheduled[typeof(T)] = nextTime; }