Exemplo n.º 1
0
        /*
         *
         *
         */
        public void beAuxiliar(string masterUrl, int jobId, int filelines, int trackerId, int trackerFactor)
        {
            //get the job information using the meta from the worker
            JobMeta myMeta = this.metas[jobId];
            Job     j      = new Job(masterUrl, myMeta, filelines, trackerId, trackerFactor);

            this.steve[j.Id] = j;
        }
Exemplo n.º 2
0
 /*
  * Creates a job using a JobMeta struct, needed if this worker will act as an auxiliary job tracker
  */
 public Job(string masterUrl, JobMeta meta, int filelines, int trackerId, int trackerCount)
 {
     this.id                   = meta.jobId;
     this.fileLines            = filelines;
     this.meta                 = meta;
     this.trackerCount         = trackerCount;
     this.trackerId            = trackerId;
     this.runningTrackersCount = 1;  //if secondary I am the only one
     this.master               = (IJobTracker)Activator.GetObject(typeof(IJobTracker), masterUrl);
 }
Exemplo n.º 3
0
        /*
         * This constructor is used by the main job tracker
         */
        public Job(string client, string filename, int fileLines, string map, byte[] code)
        {
            this.id        = new Random().Next();
            this.fileLines = fileLines;
            this.meta      = new JobMeta(this.id, client, filename, map, code);

            this.trackerCount         = JOB_TRACKER_FACTOR;
            this.trackerId            = 1;
            this.runningTrackersCount = JOB_TRACKER_FACTOR;
            this.master = null;
        }
Exemplo n.º 4
0
        public void mainThread()
        {
            List <KeyValuePair <String, String> > taskOutputs = new List <KeyValuePair <String, String> >();
            IClient client = null;


            while (true)
            {
                while (true)
                {
                    Task?task = this.getTask();
                    if (task == null)
                    {
                        break;
                    }
                    this.statusWorking(task.Value);


                    JobMeta meta = metas[task.Value.jobId];
                    client = ((IClient)Activator.GetObject(typeof(IClient), meta.clientAddr));

                    String[] splits = client.getSplit(meta.filename, task.Value.lower, task.Value.higher);
                    if (splits == null)
                    {
                        break;
                    }

                    Map map = myMaps[meta.map];
                    foreach (String s in splits)
                    {
                        taskOutputs.AddRange(map.map(s));
                    }

                    workerMre.WaitOne();

                    Console.WriteLine("Did: " + task.Value.id + "; Tracker: " + task.Value.trackerUrl);
                    client.storeSplit(meta.filename, taskOutputs, task.Value.id);
                    taskOutputs.Clear();


                    //This supposes that no tasks were stolen from the worker
                    //If a task is stolen then the counter must go down
                    if (--taskCounter[task.Value.jobId][task.Value.trackerUrl] <= 0)
                    {
                        IJobTracker tracker = (IJobTracker)Activator.GetObject(typeof(WorkRemote), task.Value.trackerUrl);
                        new Thread(() => tracker.finishWorker(task.Value.jobId)).Start();
                    }
                }
                this.statusIdle();
                Thread.Sleep(100);  //sleep while no jobs in queue
            }
        }
Exemplo n.º 5
0
 public void createMeta(JobMeta meta)
 {
     this.metas[meta.jobId] = meta;
     this.myMaps[meta.map]  = createMapper(meta.code, meta.map);
 }