/// <summary>Set the priority of the job, defaulting to NORMAL.</summary> /// <param name="jp">new job priority</param> public virtual void SetJobPriority(JobPriority jp) { lock (this) { base.SetPriority(JobPriority.ValueOf(jp.ToString())); } }
/// <summary>Return the priority of the job</summary> /// <returns>job priority</returns> public virtual JobPriority GetJobPriority() { lock (this) { return(JobPriority.ValueOf(base.GetPriority().ToString())); } }
/// <summary>Create a job status object for a given jobid.</summary> /// <param name="jobid">The jobid of the job</param> /// <param name="setupProgress">The progress made on the setup</param> /// <param name="mapProgress">The progress made on the maps</param> /// <param name="reduceProgress">The progress made on the reduces</param> /// <param name="cleanupProgress">The progress made on the cleanup</param> /// <param name="runState">The current state of the job</param> /// <param name="jp">Priority of the job.</param> /// <param name="user">userid of the person who submitted the job.</param> /// <param name="jobName">user-specified job name.</param> /// <param name="queue">job queue name.</param> /// <param name="jobFile">job configuration file.</param> /// <param name="trackingUrl">link to the web-ui for details of the job.</param> /// <param name="isUber">Whether job running in uber mode</param> public JobStatus(JobID jobid, float setupProgress, float mapProgress, float reduceProgress , float cleanupProgress, int runState, JobPriority jp, string user, string jobName , string queue, string jobFile, string trackingUrl, bool isUber) : base(jobid, setupProgress, mapProgress, reduceProgress, cleanupProgress, GetEnum (runState), JobPriority.ValueOf(jp.ToString()), user, jobName, queue, jobFile, trackingUrl , isUber) { }
/// <summary>Get the job priority</summary> public virtual JobPriority GetPriority() { return(JobPriority.ValueOf(datum.priority.ToString())); }
/// <exception cref="System.Exception"/> public virtual int Run(string[] argv) { int exitCode = -1; if (argv.Length < 1) { DisplayUsage(string.Empty); return(exitCode); } // process arguments string cmd = argv[0]; string submitJobFile = null; string jobid = null; string taskid = null; string historyFile = null; string counterGroupName = null; string counterName = null; JobPriority jp = null; string taskType = null; string taskState = null; int fromEvent = 0; int nEvents = 0; bool getStatus = false; bool getCounter = false; bool killJob = false; bool listEvents = false; bool viewHistory = false; bool viewAllHistory = false; bool listJobs = false; bool listAllJobs = false; bool listActiveTrackers = false; bool listBlacklistedTrackers = false; bool displayTasks = false; bool killTask = false; bool failTask = false; bool setJobPriority = false; bool logs = false; if ("-submit".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } submitJobFile = argv[1]; } else { if ("-status".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; getStatus = true; } else { if ("-counter".Equals(cmd)) { if (argv.Length != 4) { DisplayUsage(cmd); return(exitCode); } getCounter = true; jobid = argv[1]; counterGroupName = argv[2]; counterName = argv[3]; } else { if ("-kill".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; killJob = true; } else { if ("-set-priority".Equals(cmd)) { if (argv.Length != 3) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; try { jp = JobPriority.ValueOf(argv[2]); } catch (ArgumentException iae) { Log.Info(iae); DisplayUsage(cmd); return(exitCode); } setJobPriority = true; } else { if ("-events".Equals(cmd)) { if (argv.Length != 4) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; fromEvent = System.Convert.ToInt32(argv[2]); nEvents = System.Convert.ToInt32(argv[3]); listEvents = true; } else { if ("-history".Equals(cmd)) { if (argv.Length != 2 && !(argv.Length == 3 && "all".Equals(argv[1]))) { DisplayUsage(cmd); return(exitCode); } viewHistory = true; if (argv.Length == 3 && "all".Equals(argv[1])) { viewAllHistory = true; historyFile = argv[2]; } else { historyFile = argv[1]; } } else { if ("-list".Equals(cmd)) { if (argv.Length != 1 && !(argv.Length == 2 && "all".Equals(argv[1]))) { DisplayUsage(cmd); return(exitCode); } if (argv.Length == 2 && "all".Equals(argv[1])) { listAllJobs = true; } else { listJobs = true; } } else { if ("-kill-task".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } killTask = true; taskid = argv[1]; } else { if ("-fail-task".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } failTask = true; taskid = argv[1]; } else { if ("-list-active-trackers".Equals(cmd)) { if (argv.Length != 1) { DisplayUsage(cmd); return(exitCode); } listActiveTrackers = true; } else { if ("-list-blacklisted-trackers".Equals(cmd)) { if (argv.Length != 1) { DisplayUsage(cmd); return(exitCode); } listBlacklistedTrackers = true; } else { if ("-list-attempt-ids".Equals(cmd)) { if (argv.Length != 4) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; taskType = argv[2]; taskState = argv[3]; displayTasks = true; if (!taskTypes.Contains(StringUtils.ToUpperCase(taskType))) { System.Console.Out.WriteLine("Error: Invalid task-type: " + taskType); DisplayUsage(cmd); return(exitCode); } if (!taskStates.Contains(StringUtils.ToLowerCase(taskState))) { System.Console.Out.WriteLine("Error: Invalid task-state: " + taskState); DisplayUsage(cmd); return(exitCode); } } else { if ("-logs".Equals(cmd)) { if (argv.Length == 2 || argv.Length == 3) { logs = true; jobid = argv[1]; if (argv.Length == 3) { taskid = argv[2]; } else { taskid = null; } } else { DisplayUsage(cmd); return(exitCode); } } else { DisplayUsage(cmd); return(exitCode); } } } } } } } } } } } } } } // initialize cluster cluster = CreateCluster(); // Submit the request try { if (submitJobFile != null) { Job job = Job.GetInstance(new JobConf(submitJobFile)); job.Submit(); System.Console.Out.WriteLine("Created job " + job.GetJobID()); exitCode = 0; } else { if (getStatus) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { Counters counters = job.GetCounters(); System.Console.Out.WriteLine(); System.Console.Out.WriteLine(job); if (counters != null) { System.Console.Out.WriteLine(counters); } else { System.Console.Out.WriteLine("Counters not available. Job is retired."); } exitCode = 0; } } else { if (getCounter) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { Counters counters = job.GetCounters(); if (counters == null) { System.Console.Out.WriteLine("Counters not available for retired job " + jobid); exitCode = -1; } else { System.Console.Out.WriteLine(GetCounter(counters, counterGroupName, counterName)); exitCode = 0; } } } else { if (killJob) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { JobStatus jobStatus = job.GetStatus(); if (jobStatus.GetState() == JobStatus.State.Failed) { System.Console.Out.WriteLine("Could not mark the job " + jobid + " as killed, as it has already failed." ); exitCode = -1; } else { if (jobStatus.GetState() == JobStatus.State.Killed) { System.Console.Out.WriteLine("The job " + jobid + " has already been killed."); exitCode = -1; } else { if (jobStatus.GetState() == JobStatus.State.Succeeded) { System.Console.Out.WriteLine("Could not kill the job " + jobid + ", as it has already succeeded." ); exitCode = -1; } else { job.KillJob(); System.Console.Out.WriteLine("Killed job " + jobid); exitCode = 0; } } } } } else { if (setJobPriority) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { job.SetPriority(jp); System.Console.Out.WriteLine("Changed job priority."); exitCode = 0; } } else { if (viewHistory) { ViewHistory(historyFile, viewAllHistory); exitCode = 0; } else { if (listEvents) { ListEvents(cluster.GetJob(JobID.ForName(jobid)), fromEvent, nEvents); exitCode = 0; } else { if (listJobs) { ListJobs(cluster); exitCode = 0; } else { if (listAllJobs) { ListAllJobs(cluster); exitCode = 0; } else { if (listActiveTrackers) { ListActiveTrackers(cluster); exitCode = 0; } else { if (listBlacklistedTrackers) { ListBlacklistedTrackers(cluster); exitCode = 0; } else { if (displayTasks) { DisplayTasks(cluster.GetJob(JobID.ForName(jobid)), taskType, taskState); exitCode = 0; } else { if (killTask) { TaskAttemptID taskID = TaskAttemptID.ForName(taskid); Job job = cluster.GetJob(taskID.GetJobID()); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { if (job.KillTask(taskID, false)) { System.Console.Out.WriteLine("Killed task " + taskid); exitCode = 0; } else { System.Console.Out.WriteLine("Could not kill task " + taskid); exitCode = -1; } } } else { if (failTask) { TaskAttemptID taskID = TaskAttemptID.ForName(taskid); Job job = cluster.GetJob(taskID.GetJobID()); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { if (job.KillTask(taskID, true)) { System.Console.Out.WriteLine("Killed task " + taskID + " by failing it"); exitCode = 0; } else { System.Console.Out.WriteLine("Could not fail task " + taskid); exitCode = -1; } } } else { if (logs) { try { JobID jobID = JobID.ForName(jobid); TaskAttemptID taskAttemptID = TaskAttemptID.ForName(taskid); LogParams logParams = cluster.GetLogParams(jobID, taskAttemptID); LogCLIHelpers logDumper = new LogCLIHelpers(); logDumper.SetConf(GetConf()); exitCode = logDumper.DumpAContainersLogs(logParams.GetApplicationId(), logParams. GetContainerId(), logParams.GetNodeId(), logParams.GetOwner()); } catch (IOException e) { if (e is RemoteException) { throw; } System.Console.Out.WriteLine(e.Message); } } } } } } } } } } } } } } } } } catch (RemoteException re) { IOException unwrappedException = re.UnwrapRemoteException(); if (unwrappedException is AccessControlException) { System.Console.Out.WriteLine(unwrappedException.Message); } else { throw; } } finally { cluster.Close(); } return(exitCode); }
public static Org.Apache.Hadoop.Mapred.JobStatus Downgrade(Org.Apache.Hadoop.Mapreduce.JobStatus stat) { Org.Apache.Hadoop.Mapred.JobStatus old = new Org.Apache.Hadoop.Mapred.JobStatus(JobID .Downgrade(stat.GetJobID()), stat.GetSetupProgress(), stat.GetMapProgress(), stat .GetReduceProgress(), stat.GetCleanupProgress(), stat.GetState().GetValue(), JobPriority .ValueOf(stat.GetPriority().ToString()), stat.GetUsername(), stat.GetJobName(), stat.GetQueue(), stat.GetJobFile(), stat.GetTrackingUrl(), stat.IsUber()); old.SetStartTime(stat.GetStartTime()); old.SetFinishTime(stat.GetFinishTime()); old.SetSchedulingInfo(stat.GetSchedulingInfo()); old.SetHistoryFile(stat.GetHistoryFile()); return(old); }