Пример #1
0
        static void Main(string[] args)
        {
            IScheduler scheduler   = new Scheduler();
            string     clustername = null;
            string     username    = null;

            if (args.Length != 2)
            {
                Console.Error.WriteLine("Usage: Finish clustername username ");
                return;
            }
            clustername = args[0];
            username    = args[1];

            scheduler.Connect(clustername);

            ISchedulerJob job = scheduler.CreateJob();

            job.UnitType             = JobUnitType.Core;
            job.MinimumNumberOfCores = 1;
            job.MaximumNumberOfCores = 1;


            scheduler.AddJob(job);

            ISchedulerTask task = job.CreateTask();

            task.CommandLine = @"ping -t localhost";

            job.AddTask(task);


            scheduler.SubmitJob(job, username, null);
            Console.WriteLine("job {0} Submitted ", job.Id);

            Thread.Sleep(12 * 1000);

            job.Refresh();
            Console.WriteLine("Job {0} State {1}", job.Id, job.State);

            ((ISchedulerJobV3)job).Finish();
            Thread.Sleep(10000);
            job.Refresh();
            task.Refresh();
            Console.WriteLine("After finish Job {0} State {1} message {2}", job.Id, job.State, task.Output);
        }
Пример #2
0
        static void job_OnJobState(object sender, JobStateEventArg e)
        {
            if (e.NewState == JobState.Finished) //the job is finished
            {
                task.Refresh();                  // update the task object with updates from the scheduler

                Console.WriteLine("Job completed.");
                Console.WriteLine("Output: " + task.Output); //print the task's output
                jobFinishedEvent.Set();
            }
            else if (e.NewState == JobState.Canceled || e.NewState == JobState.Failed)
            {
                Console.WriteLine("Job did not finish.");
                jobFinishedEvent.Set();
            }
            else if (e.NewState == JobState.Queued && e.PreviousState != JobState.Validating)
            {
                Console.WriteLine("The job is currently queued.");
                Console.WriteLine("Waiting for job to start...");
            }
        }