private void modifyStatus <T>(Action <JobStatusDTO> change, string failureMessage)
        {
            var jobKey = JobStatus.GetKey(typeof(T));

            try
            {
                var status = _persistence.Find(_channels.Name, jobKey);
                if (status == null)
                {
                    _logger.Info(() => "Unable to find a persisted record of Job {0} on channel {1}, creating a new one".ToFormat(jobKey, _channels.Name));
                    status = new JobStatusDTO {
                        NodeName = _channels.Name, JobKey = jobKey
                    };
                }

                status.Started = null;

                var current = status.LastExecution;

                change(status);

                _persistence.Persist(status);

                if (status.LastExecution != null && !ReferenceEquals(current, status.LastExecution))
                {
                    _persistence.RecordHistory(_channels.Name, jobKey, status.LastExecution);
                }
            }
            catch (Exception e)
            {
                var id = JobStatusDTO.ToId(_channels.Name, jobKey);
                _logger.Error(id, failureMessage, e);
            }
        }
        public void Persist(JobStatusDTO status)
        {
            if (_statusCache.Has(status.Id) && status.LastExecution == null)
            {
                status.LastExecution = _statusCache[status.Id].LastExecution;
            }

            _statusCache[status.Id] = status;
        }
Exemple #3
0
        public void Persist(JobStatusDTO status)
        {
            if (_statusCache.Has(status.Id) && status.LastExecution == null)
            {
                status.LastExecution = _statusCache[status.Id].LastExecution;
            }

            _statusCache[status.Id] = status;
        }
 public JobStatus ToStatus(JobStatusDTO dto)
 {
     return(new JobStatus(_jobTypes[dto.JobKey])
     {
         Status = dto.Status,
         LastExecution = dto.LastExecution,
         NextTime = dto.NextTime
     });
 }
        public void SetUp()
        {
            foo1 = new JobStatusDTO { JobKey = "1", NodeName = "foo" };
            foo2 = new JobStatusDTO { JobKey = "2", NodeName = "foo" };
            foo3 = new JobStatusDTO { JobKey = "3", NodeName = "foo" };
            bar1 = new JobStatusDTO { JobKey = "1", NodeName = "bar" };
            bar2 = new JobStatusDTO { JobKey = "2", NodeName = "bar" };

            thePersistence = new InMemorySchedulePersistence();
            thePersistence.Persist(new []{foo1, foo2, foo3, bar1, bar2});
        }
        public void persist_job_status()
        {
            foo1.Status = foo2.Status = foo3.Status = bar1.Status = bar2.Status = JobExecutionStatus.Inactive;

            var change = new JobStatusDTO { JobKey = "1", NodeName = "foo", Status = JobExecutionStatus.Scheduled };

            thePersistence.Persist(change);

            thePersistence.FindAllActive("foo")
                .ShouldHaveTheSameElementsAs(change);

            thePersistence.Find("foo", "1").ShouldBeTheSameAs(change);
        }
Exemple #7
0
 protected bool Equals(JobStatusDTO other)
 {
     return string.Equals(NodeName, other.NodeName) && string.Equals(JobKey, other.JobKey);
 }
        private void addJobRow(TableRowTag row, JobStatusDTO job, IUrlRegistry urls)
        {
            row.Cell().Add("a").Text(job.JobKey).Attr("href", urls.UrlFor(new ScheduledJobRequest{Job = job.JobKey}));
            row.Cell(job.NextTime.HasValue ? job.NextTime.Value.ToLocalTime().ToString() : "Not scheduled");
            row.Cell(job.GetStatusDescription());
            row.Cell(job.GetLastExecutionDescription());

            var url = urls.UrlFor(new RunJobRequest {Name = job.JobKey});

            row.Cell().Add("button").Text("Execute").Attr("data-url", url).AddClass("button").AddClass("executor").Attr("onclick", "if (window.confirm('Ok to run this job?')) window.location='" + url + "'");
        }
 public static string ToId(string node, string job)
 {
     return("History-" + JobStatusDTO.ToId(node, job));
 }
Exemple #10
0
 public JobStatusDTO Find(string nodeName, string jobKey)
 {
     return(_statusCache[JobStatusDTO.ToId(nodeName, jobKey)]);
 }
 public void Persist(JobStatusDTO status)
 {
     _transaction.Execute<IDocumentSession>(session => { session.Store(status); });
 }
        public void SetUp()
        {
            foo1 = new JobStatusDTO { JobKey = "1", NodeName = "foo" };
            foo2 = new JobStatusDTO { JobKey = "2", NodeName = "foo" };
            foo3 = new JobStatusDTO { JobKey = "3", NodeName = "foo" };
            bar1 = new JobStatusDTO { JobKey = "1", NodeName = "bar" };
            bar2 = new JobStatusDTO { JobKey = "2", NodeName = "bar" };

            thePersistence = new InMemorySchedulePersistence();
            thePersistence.Persist(new[] { foo1, foo2, foo3, bar1, bar2 });

            theLogger = new RecordingLogger();

            theStatusMonitor = new ScheduleStatusMonitor(theChannelGraph, new ScheduledJobGraph(), thePersistence, theLogger, SystemTime.Default());
        }
        public void SetUp()
        {
            runtime = FubuRuntime.BasicBus();
            runtime.Get<IContainer>().UseInMemoryDatastore();

            thePersistence = runtime.Get<RavenDbSchedulePersistence>();

            foo1 = new JobStatusDTO {JobKey = "1", NodeName = "foo"};
            foo2 = new JobStatusDTO {JobKey = "2", NodeName = "foo"};
            foo3 = new JobStatusDTO {JobKey = "3", NodeName = "foo"};
            bar1 = new JobStatusDTO {JobKey = "1", NodeName = "bar"};
            bar2 = new JobStatusDTO {JobKey = "2", NodeName = "bar"};

            thePersistence.Persist(new[] {foo1, foo2, foo3, bar1, bar2});
        }
Exemple #14
0
 protected bool Equals(JobStatusDTO other)
 {
     return(string.Equals(NodeName, other.NodeName) && string.Equals(JobKey, other.JobKey));
 }