Exemple #1
0
            /// <summary>Choose a Machine in runtime according to the cluster status.</summary>
            /// <exception cref="System.IO.IOException"/>
            private DistSum.Machine ChooseMachine(Configuration conf)
            {
                int parts = conf.GetInt(NParts, int.MaxValue);

                try
                {
                    for (; ; Sharpen.Thread.Sleep(2000))
                    {
                        //get cluster status
                        ClusterMetrics status = cluster.GetClusterStatus();
                        int            m      = status.GetMapSlotCapacity() - status.GetOccupiedMapSlots();
                        int            r      = status.GetReduceSlotCapacity() - status.GetOccupiedReduceSlots();
                        if (m >= parts || r >= parts)
                        {
                            //favor ReduceSide machine
                            DistSum.Machine value = r >= parts ? DistSum.ReduceSide.Instance : DistSum.MapSide
                                                    .Instance;
                            [email protected]("  " + this + " is " + value +
                                                                              " (m=" + m + ", r=" + r + ")");
                            return(value);
                        }
                    }
                }
                catch (Exception e)
                {
                    throw new IOException(e);
                }
            }
Exemple #2
0
 private Parameters(DistSum.Machine machine, int nThreads, int nJobs, int nParts,
                    string remoteDir, FilePath localDir)
 {
     /////////////////////////////////////////////////////////////////////////////
     this.machine   = machine;
     this.nThreads  = nThreads;
     this.nJobs     = nJobs;
     this.nParts    = nParts;
     this.remoteDir = remoteDir;
     this.localDir  = localDir;
 }
Exemple #3
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));
                }
            }
        }