Esempio n. 1
0
 private IEnumerator<IDependency<IModule>> GetDependencyEnumerator(JobExeWrapper jobWrapper, IDependency<IModule> dep, IEnumerator<IDependency<IModule>> iEnumerator)
 {
     switch (jobWrapper.Job.DependencyTraversalMode)
     {
         case "Breadth-first":
             iEnumerator = dep.GetBreadthFirstEnumerator();
             break;
         case "Depth-first":
             iEnumerator = dep.GetDepthFirstEnumerator();
             break;
     }
     return iEnumerator;
 }
Esempio n. 2
0
        private void ResetDependentOutputs(JobExeWrapper jobWrapper, IDependency<IModule> dep)
        {
            #region pick enumeration type

            IEnumerator<IDependency<IModule>> iEnumerator =
                dep.GetBreadthFirstEnumerator(); //default mode

            iEnumerator = GetDependencyEnumerator(jobWrapper, dep, iEnumerator);

            #endregion

            //execution
            log.InfoFormat("Resetting dependent outputs on {0}/{1}.", jobWrapper.Job.JobName, dep.Name);

            iEnumerator = GetDependencyEnumerator(jobWrapper, dep, iEnumerator);
            while (iEnumerator.MoveNext())
            {
                IDependency<IModule> d = iEnumerator.Current;

                d.Module.ResetOutput();
            }
        }
Esempio n. 3
0
        private ErrorCode ProcessJobFromRoot(JobExeWrapper jobWrapper, DateTime jobkey, IDependency<IModule> dep)
        {
            ErrorCode retval = ErrorCode.SUCCESS;

            if (killJobs.Contains(jobWrapper.Job.JobName))
                killJobs.Remove(jobWrapper.Job.JobName);

            // pick enumeration type
            IEnumerator<IDependency<IModule>> iEnumerator =
                dep.GetBreadthFirstEnumerator(); //default mode

            //execution
            log.InfoFormat(jobWrapper.Job.KeyCode, "Beginning executing job {0} in {1} mode.", jobWrapper.Job.JobName, jobWrapper.Mode.ToString());

            ArrayList trackWaitState = new ArrayList();

            iEnumerator = GetDependencyEnumerator(jobWrapper, dep, iEnumerator);
            while (iEnumerator.MoveNext())
            {
                IDependency<IModule> d = iEnumerator.Current;
                if (d.Name.Equals(jobWrapper.Job.JobName))
                    continue;
                if (!jobWrapper.States.ContainsKey(d.Name))
                    jobWrapper.States[d.Name] = State.CurrentStateEnum.PendingInitialization;
            }

            iEnumerator = GetDependencyEnumerator(jobWrapper, dep, iEnumerator);
            while (iEnumerator.MoveNext() && retval.Equals(ErrorCode.ABORT_JOB) == false)
            {
                IDependency<IModule> d = iEnumerator.Current;

                if (killJobs.Contains(jobWrapper.Job.JobName))
                {
                    killJobs.Remove(jobWrapper.Job.JobName);
                    ReenableJob(jobWrapper, trackWaitState, d);

                    log.WarnFormat(jobWrapper.Job.KeyCode, "Killing job {0} ", jobWrapper.Job.JobName);

                    Thread.CurrentThread.Abort();
                    break;
                }

                if (d.Name.Equals(jobWrapper.Job.JobName))
                    continue;

                if ((jobWrapper.Mode.Equals(State.ExecutionModeEnum.Initialization) &&
                        !jobWrapper.States[d.Name].Equals(State.CurrentStateEnum.InitializationSuccessful)) ||
                     (jobWrapper.Mode.Equals(State.ExecutionModeEnum.Execution) &&
                        !jobWrapper.States[d.Name].Equals(State.CurrentStateEnum.ExecutionSuccessful) &&
                        !jobWrapper.Job.Limiter.ifWaitingForFirstTrigger))
                {

                    bool ifAllParentsAreReady = true;
                    foreach (IDependency<IModule> dParent in d.Parents)
                    {
                        if (!dParent.Name.Equals(jobWrapper.Job.JobName))
                        {
                            if (jobWrapper.Mode == State.ExecutionModeEnum.Initialization)
                            {
                                if (!jobWrapper.States[dParent.Name].Equals(State.CurrentStateEnum.WaitState) &&
                                    !jobWrapper.States[dParent.Name].Equals(State.CurrentStateEnum.InitializationSuccessful))
                                {
                                    ifAllParentsAreReady = false;
                                    break;
                                }
                            }
                            else if (jobWrapper.Mode == State.ExecutionModeEnum.Execution)
                            {
                                if (!jobWrapper.States[dParent.Name].Equals(State.CurrentStateEnum.WaitState) &&
                                    !jobWrapper.States[dParent.Name].Equals(State.CurrentStateEnum.ExecutionSuccessful))
                                {
                                    ifAllParentsAreReady = false;
                                    break;
                                }
                            }
                        }
                    }

                    if (ifAllParentsAreReady)
                    {
                        int result = ProcessDependency(jobWrapper, jobkey, d);
                        if (result == -99)
                            retval = ErrorCode.ABORT_JOB;
                        else if (result != 0)
                            retval = ErrorCode.MODULE_FAILED;

                        if (retval.Equals(ErrorCode.ABORT_JOB) == false)
                            ReenableJob(jobWrapper, trackWaitState, d);

                        log.InfoFormat("Processed {0}", d.ToString());
                    }
                }
            }

            foreach (string job in trackWaitState)
            {
                if (jobWrapper.States.ContainsKey(job))
                    jobWrapper.States[job] = State.CurrentStateEnum.WaitState;
            }

            return retval;
        }
Esempio n. 4
0
	    private ErrorCode ProcessJobFromRoot(JobExeWrapper jobWrapper, Job job, IDependency<IModule> dep)
		{
			ErrorCode returnCode = ErrorCode.SUCCESS;

			if (killJobs.Contains(job.JobName))
                killJobs.Remove(job.JobName);

			// pick enumeration type
			IEnumerator<IDependency<IModule>> iEnumerator =
				dep.GetBreadthFirstEnumerator(); //default mode

			//execution
            log.InfoFormat(job.KeyHash, "Beginning executing job {0} in {1} mode.", job.JobName, jobWrapper.DependencyState.ToString());

			ArrayList trackWaitState = new ArrayList();

            job.StartStats();
            iEnumerator = GetDependencyEnumerator(jobWrapper, dep, iEnumerator);
			while (iEnumerator.MoveNext())
			{
				IDependency<IModule> d = iEnumerator.Current;
				if (d.Name.Equals(job.JobName))
					continue;
				if (!jobWrapper.DependencyStates.ContainsKey(d.Name))
					jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.PendingInitialization;
			}

			iEnumerator = GetDependencyEnumerator(jobWrapper, dep, iEnumerator);
            while (iEnumerator.MoveNext() && returnCode.Equals(ErrorCode.ABORT_JOB) == false)
			{
				IDependency<IModule> d = iEnumerator.Current;

				if (killJobs.Contains(job.JobName))
				{
                    killJobs.Remove(job.JobName);
					ReenableJob(jobWrapper, trackWaitState, d);

                    log.WarnFormat(job.KeyHash, "Killing job {0} ", job.JobName);

					Thread.CurrentThread.Abort();
					break;
				}

                if (d.Name.Equals(job.JobName))
					continue;

                if ((jobWrapper.DependencyState.Equals(StateEnums.ExecutionMode.Initialization) &&
						!jobWrapper.DependencyStates[d.Name].Equals(StateEnums.ExecutionState.InitializationSuccessful)) ||
                     (jobWrapper.DependencyState.Equals(StateEnums.ExecutionMode.Execution) &&
						!jobWrapper.DependencyStates[d.Name].Equals(StateEnums.ExecutionState.ExecutionSuccessful) &&
						!jobWrapper.Job.Limiter.ifWaitingForFirstTrigger))
				{

					bool ifAllParentsAreReady = true;
					foreach (IDependency<IModule> dParent in d.Parents)
					{
						if (!dParent.Name.Equals(jobWrapper.Job.JobName))
						{
                            if (jobWrapper.DependencyState == StateEnums.ExecutionMode.Initialization)
							{
								if (!jobWrapper.DependencyStates[dParent.Name].Equals(StateEnums.ExecutionState.WaitState) &&
									!jobWrapper.DependencyStates[dParent.Name].Equals(StateEnums.ExecutionState.InitializationSuccessful))
								{
									ifAllParentsAreReady = false;
									break;
								}
							}
                            else if (jobWrapper.DependencyState == StateEnums.ExecutionMode.Execution)
							{
								if (!jobWrapper.DependencyStates[dParent.Name].Equals(StateEnums.ExecutionState.WaitState) &&
									!jobWrapper.DependencyStates[dParent.Name].Equals(StateEnums.ExecutionState.ExecutionSuccessful))
								{
									ifAllParentsAreReady = false;
									break;
								}
							}
						}
					}

					if (ifAllParentsAreReady)
					{
                        #region Status Update
                        if (jobWrapper.DependencyState.Equals(StateEnums.ExecutionMode.Initialization))
                            job.JobState.CurrentStatusCollection[d.Name].Status = StateEnums.Status.Initializing;
                        else
                        {
                            job.JobState.CurrentStatusCollection[d.Name].Status = StateEnums.Status.Running;
                            //Required for UpdateStatus (Dashboard)
                            job.JobState.CurrentStatusCollection[d.Name].StartTime = DateTime.Now;
                        }

                        OnStatusEvent(job);
                        #endregion

                        //Begin dependency/module processing...
						StateEnums.Status result = ProcessDependency(jobWrapper, job, d);

                        #region Status Update
                        switch (result)
                        {
                            #region Normal Cases
                            case StateEnums.Status.Success:
                                if (jobWrapper.DependencyState.Equals(StateEnums.ExecutionMode.Initialization))
                                    jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.InitializationSuccessful;
                                else
                                {
                                    jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.ExecutionSuccessful;
                                    job.JobState.CurrentStatusCollection[d.Name].EndTime = DateTime.Now;
                                }
                                job.JobState.CurrentStatusCollection[d.Name].Status = StateEnums.Status.Success;
                                break;
                            case StateEnums.Status.WaitingForSqlNotification:
                                jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.WaitState;
                                job.JobState.CurrentStatusCollection[d.Name].Status = StateEnums.Status.WaitingForSqlNotification;
                                break;
                            case StateEnums.Status.WaitingForFile:
                                jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.WaitState;
                                job.JobState.CurrentStatusCollection[d.Name].Status = StateEnums.Status.WaitingForFile;
                                break;
                            #endregion

                            #region Abnormal Cases
                            case StateEnums.Status.Warnings:
                                if (jobWrapper.DependencyState.Equals(StateEnums.ExecutionMode.Initialization))
                                    jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.InitializationSuccessful;
                                else
                                {
                                    jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.ExecutionSuccessful;
                                    job.JobState.CurrentStatusCollection[d.Name].EndTime = DateTime.Now;
                                }
                                job.JobState.CurrentStatusCollection[d.Name].Status = StateEnums.Status.Warnings;
                                break;
                            case StateEnums.Status.Error:
                                if (jobWrapper.DependencyState.Equals(StateEnums.ExecutionMode.Initialization))
                                    jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.InitializationSuccessful;
                                else
                                {
                                    //jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.ExecutionSuccessful;
                                    jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.ExecutionFailed;
                                    job.JobState.CurrentStatusCollection[d.Name].EndTime = DateTime.Now;
                                }
                                job.JobState.CurrentStatusCollection[d.Name].Status = StateEnums.Status.Error;
                                returnCode = ErrorCode.ABORT_JOB;
                                break;
                            default:
                                if (jobWrapper.DependencyState.Equals(StateEnums.ExecutionMode.Initialization))
                                    jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.InitializationSuccessful;
                                else
                                {
                                    jobWrapper.DependencyStates[d.Name] = StateEnums.ExecutionState.ExecutionSuccessful;
                                    job.JobState.CurrentStatusCollection[d.Name].EndTime = DateTime.Now;
                                }
                                job.JobState.CurrentStatusCollection[d.Name].Status = StateEnums.Status.Error;
                                returnCode = ErrorCode.MODULE_FAILED;
                                break;
                            #endregion
                        }
                        OnStatusEvent(job);
                        #endregion

                        if ( !returnCode.Equals(ErrorCode.ABORT_JOB))
							ReenableJob(jobWrapper, trackWaitState, d);

						log.DebugFormat(job.KeyHash,"Processed {0}", d.ToString());
					}
				}
			}
            job.StopStats();

			foreach (string jobName in trackWaitState)
			{
                if (jobWrapper.DependencyStates.ContainsKey(jobName))
                    jobWrapper.DependencyStates[jobName] = StateEnums.ExecutionState.WaitState;
			}

            return returnCode;
		}