Пример #1
0
        private static Func <JobExecutionStatus> GetStatus(JobExecutionFactoryContext context)
        {
            return(() =>
            {
                string root = context.Entry.Path;
                string path = Path.Combine(root, "metadata");

                if (File.Exists(Path.Combine(path, ".completed")))
                {
                    return JobExecutionStatus.Completed;
                }

                if (File.Exists(Path.Combine(path, ".pid")))
                {
                    return JobExecutionStatus.Running;
                }

                if (File.Exists(Path.Combine(path, ".scheduled")))
                {
                    return JobExecutionStatus.Pending;
                }

                if (File.Exists(Path.Combine(path, ".failed")))
                {
                    return JobExecutionStatus.Failed;
                }

                return JobExecutionStatus.Idle;
            });
        }
Пример #2
0
        private static Func <Blob, BlobDeployment> Deploy(JobExecutionFactoryContext context)
        {
            return(blob =>
            {
                string root = context.Entry.Path;
                string path = Path.Combine(root, "blob");

                return blob.DeployTo(path);
            });
        }
Пример #3
0
        private static Action OnCompleted(JobExecutionFactoryContext context)
        {
            return(() =>
            {
                string root = context.Entry.Path;
                string path = Path.Combine(root, "metadata");
                string file = Path.Combine(path, ".completed");

                File.WriteAllBytes(file, new byte[0]);
            });
        }
Пример #4
0
        private static Action <int> OnStarted(JobExecutionFactoryContext context)
        {
            return(pid =>
            {
                string root = context.Entry.Path;
                string path = Path.Combine(root, "metadata");
                string file = Path.Combine(path, ".pid");

                File.WriteAllText(file, pid.ToString());
            });
        }
Пример #5
0
        private static Func <int> GetPid(JobExecutionFactoryContext context)
        {
            return(() =>
            {
                string root = context.Entry.Path;
                string path = Path.Combine(root, "metadata");
                string file = Path.Combine(path, ".pid");

                return Int32.Parse(File.ReadAllText(file));
            });
        }
Пример #6
0
        private static Action <string> OnFailed(JobExecutionFactoryContext context)
        {
            return(reason =>
            {
                string root = context.Entry.Path;
                string path = Path.Combine(root, "metadata");
                string file = Path.Combine(path, ".failed");

                File.WriteAllText(file, reason);
            });
        }
Пример #7
0
        private static Func <JobSchedule, DateTime?> NextRun(JobExecutionFactoryContext context)
        {
            return(schedule =>
            {
                if (schedule == null)
                {
                    return null;
                }

                DateTime?lastExecutedAt = null;
                string root = context.Entry.Path;

                string path = Path.Combine(root, "metadata");
                string file = Path.Combine(path, ".completed");

                if (File.Exists(file))
                {
                    lastExecutedAt = File.GetCreationTime(file);
                }

                return schedule.Next(lastExecutedAt);
            });
        }
Пример #8
0
 private static Action <JobProcessorUsage> OnProcessor(JobExecutionFactoryContext context)
 {
     return(usage =>
     {
     });
 }
Пример #9
0
 private static Action <JobMemoryUsage> OnMemory(JobExecutionFactoryContext context)
 {
     return(usage =>
     {
     });
 }