Ejemplo n.º 1
0
 /// <returns>the state of this job</returns>
 public virtual int GetState()
 {
     lock (this)
     {
         ControlledJob.State state = base.GetJobState();
         if (state == ControlledJob.State.Success)
         {
             return(Success);
         }
         if (state == ControlledJob.State.Waiting)
         {
             return(Waiting);
         }
         if (state == ControlledJob.State.Running)
         {
             return(Running);
         }
         if (state == ControlledJob.State.Ready)
         {
             return(Ready);
         }
         if (state == ControlledJob.State.Failed)
         {
             return(Failed);
         }
         if (state == ControlledJob.State.DependentFailed)
         {
             return(DependentFailed);
         }
         return(-1);
     }
 }
Ejemplo n.º 2
0
 /// <summary>Check the state of this running job.</summary>
 /// <remarks>
 /// Check the state of this running job. The state may
 /// remain the same, become SUCCESS or FAILED.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 private void CheckRunningState()
 {
     try
     {
         if (job.IsComplete())
         {
             if (job.IsSuccessful())
             {
                 this.state = ControlledJob.State.Success;
             }
             else
             {
                 this.state   = ControlledJob.State.Failed;
                 this.message = "Job failed!";
             }
         }
     }
     catch (IOException ioe)
     {
         this.state   = ControlledJob.State.Failed;
         this.message = StringUtils.StringifyException(ioe);
         try
         {
             if (job != null)
             {
                 job.KillJob();
             }
         }
         catch (IOException)
         {
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>Set the state for this job.</summary>
 /// <param name="state">the new state for this job.</param>
 protected internal virtual void SetJobState(ControlledJob.State state)
 {
     lock (this)
     {
         this.state = state;
     }
 }
Ejemplo n.º 4
0
 /// <summary>Construct a job.</summary>
 /// <param name="job">a mapreduce job to be executed.</param>
 /// <param name="dependingJobs">an array of jobs the current job depends on</param>
 /// <exception cref="System.IO.IOException"/>
 public ControlledJob(Job job, IList <Org.Apache.Hadoop.Mapreduce.Lib.Jobcontrol.ControlledJob
                                      > dependingJobs)
 {
     // A job will be in one of the following states
     // assigned and used by JobControl class
     // mapreduce job to be executed.
     // some info for human consumption, e.g. the reason why the job failed
     // the jobs the current job depends on
     this.job           = job;
     this.dependingJobs = dependingJobs;
     this.state         = ControlledJob.State.Waiting;
     this.controlID     = "unassigned";
     this.message       = "just initialized";
 }
Ejemplo n.º 5
0
 private IList <ControlledJob> GetJobsIn(ControlledJob.State state)
 {
     lock (this)
     {
         List <ControlledJob> l = new List <ControlledJob>();
         foreach (ControlledJob j in jobsInProgress)
         {
             if (j.GetJobState() == state)
             {
                 l.AddItem(j);
             }
         }
         return(l);
     }
 }
Ejemplo n.º 6
0
 /// <summary>Check and update the state of this job.</summary>
 /// <remarks>
 /// Check and update the state of this job. The state changes
 /// depending on its current state and the states of the depending jobs.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 internal virtual ControlledJob.State CheckState()
 {
     lock (this)
     {
         if (this.state == ControlledJob.State.Running)
         {
             CheckRunningState();
         }
         if (this.state != ControlledJob.State.Waiting)
         {
             return(this.state);
         }
         if (this.dependingJobs == null || this.dependingJobs.Count == 0)
         {
             this.state = ControlledJob.State.Ready;
             return(this.state);
         }
         Org.Apache.Hadoop.Mapreduce.Lib.Jobcontrol.ControlledJob pred = null;
         int n = this.dependingJobs.Count;
         for (int i = 0; i < n; i++)
         {
             pred = this.dependingJobs[i];
             ControlledJob.State s = pred.CheckState();
             if (s == ControlledJob.State.Waiting || s == ControlledJob.State.Ready || s == ControlledJob.State
                 .Running)
             {
                 break;
             }
             // a pred is still not completed, continue in WAITING
             // state
             if (s == ControlledJob.State.Failed || s == ControlledJob.State.DependentFailed)
             {
                 this.state   = ControlledJob.State.DependentFailed;
                 this.message = "depending job " + i + " with jobID " + pred.GetJobID() + " failed. "
                                + pred.GetMessage();
                 break;
             }
             // pred must be in success state
             if (i == n - 1)
             {
                 this.state = ControlledJob.State.Ready;
             }
         }
         return(this.state);
     }
 }
Ejemplo n.º 7
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public virtual void FailJob(string message)
 {
     lock (this)
     {
         try
         {
             if (job != null && this.state == ControlledJob.State.Running)
             {
                 job.KillJob();
             }
         }
         finally
         {
             this.state   = ControlledJob.State.Failed;
             this.message = message;
         }
     }
 }
Ejemplo n.º 8
0
 /// <summary>Submit this job to mapred.</summary>
 /// <remarks>
 /// Submit this job to mapred. The state becomes RUNNING if submission
 /// is successful, FAILED otherwise.
 /// </remarks>
 protected internal virtual void Submit()
 {
     lock (this)
     {
         try
         {
             Configuration conf = job.GetConfiguration();
             if (conf.GetBoolean(CreateDir, false))
             {
                 FileSystem fs         = FileSystem.Get(conf);
                 Path[]     inputPaths = FileInputFormat.GetInputPaths(job);
                 for (int i = 0; i < inputPaths.Length; i++)
                 {
                     if (!fs.Exists(inputPaths[i]))
                     {
                         try
                         {
                             fs.Mkdirs(inputPaths[i]);
                         }
                         catch (IOException)
                         {
                         }
                     }
                 }
             }
             job.Submit();
             this.state = ControlledJob.State.Running;
         }
         catch (Exception ioe)
         {
             Log.Info(GetJobName() + " got an error while submitting ", ioe);
             this.state   = ControlledJob.State.Failed;
             this.message = StringUtils.StringifyException(ioe);
         }
     }
 }