Esempio n. 1
0
        /// <summary>Run a job.</summary>
        internal static void RunJob(string name, Job job, DistSum.Machine machine, string
                                    startmessage, Util.Timer timer)
        {
            JobSemaphore.AcquireUninterruptibly();
            long starttime = null;

            try
            {
                try
                {
                    starttime = timer.Tick("starting " + name + " ...\n  " + startmessage);
                    //initialize and submit a job
                    machine.Init(job);
                    job.Submit();
                    // Separate jobs
                    long sleeptime = 1000L * job.GetConfiguration().GetInt(JobSeparationProperty, 10);
                    if (sleeptime > 0)
                    {
                        [email protected](name + "> sleep(" + Org.Apache.Hadoop.Examples.PI.Util
                                                                          .Millis2String(sleeptime) + ")");
                        Sharpen.Thread.Sleep(sleeptime);
                    }
                }
                finally
                {
                    JobSemaphore.Release();
                }
                if (!job.WaitForCompletion(false))
                {
                    throw new RuntimeException(name + " failed.");
                }
            }
            catch (Exception e)
            {
                throw e is RuntimeException ? (RuntimeException)e : new RuntimeException(e);
            }
            finally
            {
                if (starttime != null)
                {
                    timer.Tick(name + "> timetaken=" + Org.Apache.Hadoop.Examples.PI.Util.Millis2String
                                   (timer.Tick() - starttime));
                }
            }
        }