Example #1
0
 public Job(JobConf conf)
     : this(conf.Name)
 {
     this.Conf = conf;
     conf.WorkerFiles.Each(confFile =>
     {
         WorkerConf workerConf = WorkerConf.Load(confFile);
         this.AddWorker(workerConf.CreateWorker(this));
     });
 }
Example #2
0
        public virtual bool WorkerExists(string jobName, string workerName)
        {
            bool result = false;

            if (JobExists(jobName))
            {
                JobConf conf = GetJob(jobName);
                result = conf.WorkerExists(workerName);
            }

            return(result);
        }
Example #3
0
        /// <summary>
        /// Add a worker of the specified type to the job with the specified
        /// jobName assigning the specified workerName .
        /// </summary>
        /// <param name="jobName"></param>
        /// <param name="workerTypeName"></param>
        /// <param name="workerName"></param>
        /// <returns></returns>
        public virtual void AddWorker(string jobName, string workerTypeName, string workerName)
        {
            Type type = TypeResolver.ResolveType(workerTypeName);

            if (type == null)
            {
                throw new ArgumentNullException("workerTypeName", $"Unable to find the specified WorkerType: {workerTypeName}");
            }

            JobConf jobConf = GetJob(jobName);

            AddWorker(jobConf, type, workerName);
        }
Example #4
0
        protected internal JobConf CreateJobConf(string name, bool overwrite = false)
        {
            if (JobExists(name))
            {
                throw new InvalidOperationException("The specified job {0} already exists, use GetJob to get the existing job"._Format(name));
            }

            JobConf conf = new JobConf(name)
            {
                JobDirectory = GetJobDirectoryPath(name)
            };

            conf.Save();
            return(conf);
        }
Example #5
0
 protected internal JobConf GetJobConf(string name)
 {
     if (JobExists(name))
     {
         JobConf conf = new JobConf(name)
         {
             JobDirectory = GetJobDirectoryPath(name)
         };
         return(JobConf.Load(conf.GetFilePath()));
     }
     else
     {
         return(CreateJobConf(name));
     }
 }
Example #6
0
        protected internal void EnqueueJob(JobConf conf, int stepNumber = 0)
        {
            Args.ThrowIfNull(conf, "JobConf");

            lock (_jobQueueLock)
            {
                if (!_isRunning)
                {
                    StartJobRunnerThread();
                }

                Job job = conf.CreateJob();
                job.StepNumber = stepNumber;
                JobQueue.Enqueue(job);
                _enqueueSignal.Set();
            }
        }
Example #7
0
        /// <summary>
        /// Enqueue a job to be run next (typically instant if no other
        /// jobs are running).
        /// </summary>
        /// <param name="name"></param>
        /// <param name="stepNumber"></param>
        public virtual void EnqueueJob(string name, int stepNumber = 0)
        {
            JobConf conf = GetJobConf(name);

            EnqueueJob(conf, stepNumber);
        }
Example #8
0
 public void AddWorker(JobConf conf, Type type, string name)
 {
     conf.AddWorker(type, name);
 }
Example #9
0
 public void AddWorker <T>(JobConf conf, string name)
 {
     AddWorker(conf, typeof(T), name);
 }