Пример #1
0
            /// <summary>
            /// Initializes a new instance of the ScheduleRequest class
            /// </summary>
            /// <param name="schedulerName">the name of the responsible Scheduler for this request</param>
            /// <param name="targetProcessor">the target processor that is used to run this request</param>
            /// <param name="task">the task to run on the given processor</param>
            /// <param name="instruction">the default-instruction for this request</param>
            /// <param name="lastExecution">the last time, the underlaying task was executed</param>
            public ScheduleRequest(string schedulerName, ParallelTaskProcessor targetProcessor, ITask task,
                                   DateTime?lastExecution = null)
            {
                SchedulerName = schedulerName;
                Target        = targetProcessor;
                Task          = task;
                LastExecution = lastExecution ?? DateTime.MinValue;
                StringBuilder metaInfo = new StringBuilder();
                var           metaData = task.BuildMetaData();

                if (metaData != null)
                {
                    foreach (KeyValuePair <string, object> metaRecord in metaData)
                    {
                        metaInfo.AppendFormat(":{0}:{1}", metaRecord.Key, metaRecord.Value);
                    }
                }
                LogEnvironment.LogDebugEvent($"Creating Schedule-Requeset for the following Meta-Data: {metaInfo}",
                                             LogSeverity.Report);
                RequestId =
                    BitConverter.ToString(
                        sha.ComputeHash(
                            Encoding.UTF32.GetBytes(
                                string.Format("{0:yyyyMMddHHmmssffff}:{1}:{2}:{3:yyyyMMddHHmmssffff}{4}", DateTime.Now,
                                              targetProcessor.GetHashCode(), task.Description, LastExecution, metaInfo))));
            }
Пример #2
0
 /// <summary>
 /// Initializes a ScheduleRequest from its serialization representation
 /// </summary>
 /// <param name="info">the serialization info containing the objects that have been serialized</param>
 /// <param name="context">the current streaming context</param>
 public ScheduleRequest(SerializationInfo info, StreamingContext context)
 {
     Target        = ParallelTaskProcessor.GetInstance(info.GetString("TargetName"));
     Task          = info.GetValue("Task", typeof(ITask)) as ITask;
     LastExecution = info.GetDateTime("LastExecution");
     instructions  = new List <string>((string[])info.GetValue("Instructions", typeof(string[])));
     Remarks       = info.GetString("Remarks");
     RequestId     = info.GetString("RequestId");
     SchedulerName = info.GetString("SchedulerName");
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the TaskProcessor class
 /// </summary>
 /// <param name="worker">the worker that is used to process tasks</param>
 /// <param name="workerPulse">an object that is used to pulse this worker when new tasks have arrived</param>
 /// <param name="stopEvent">a reset event used to stop this processor</param>
 /// <param name="workerPollTime">the pollTime after which a new poll cycle is started when no further intervetion is done</param>
 /// <param name="highestPriority">the highest priority that is processed by this worker</param>
 /// <param name="lowestPriority">the lowest priority that is processed by this worker</param>
 /// <param name="parent">the parent from which this processor gets tasks to process</param>
 /// <param name="tasks">the task queues that are used to process tasks</param>
 internal AsyncTaskProcessor(ITaskWorker worker, object workerPulse, System.Threading.ManualResetEvent stopEvent,
                             int workerPollTime, int highestPriority, int lowestPriority,
                             ParallelTaskProcessor parent,
                             Dictionary <int, System.Collections.Concurrent.ConcurrentQueue <TaskContainer> > tasks)
     : this()
 {
     this.worker          = worker;
     this.workerPulse     = workerPulse;
     this.stopEvent       = stopEvent;
     this.workerPollTime  = workerPollTime;
     this.highestPriority = highestPriority;
     this.lowestPriority  = lowestPriority;
     this.tasks           = tasks;
     this.parent          = parent;
     ((ITaskProcessor)this).StartupThread();
     BuildProcessCycle();
     lastActivity = DateTime.Now;
     enterprocessingLoopWait.Set();
 }
Пример #4
0
 /// <summary>
 /// Creates a Task request for this TaskScheduler with the Task that needs to be executed and the queue that will execute it
 /// </summary>
 /// <param name="parallelTaskProcessor">the TaskProcessor that will run the provided task later</param>
 /// <param name="task">the task that needs to be executed</param>
 /// <returns>a scheduler - request for the given processor and task</returns>
 public virtual ScheduleRequest CreateRequest(ParallelTaskProcessor parallelTaskProcessor, ITask task)
 {
     return(new ScheduleRequest(UniqueName, parallelTaskProcessor, task));
 }