public void CheckValidGetInfoSpecific()
        {
            WorkerDetails worker = new WorkerDetails(founder);
            WorkerDetails res    = store.GetInfoSpecific("founder", "founder");

            Assert.IsTrue(res.Equals(worker));
        }
Example #2
0
        //update status of rela
        public void resultSentToClient(int nodeId, int splitId, string nodeURL)
        {
            /*A failed node sending its split*/
            if (!existingWorkerMap.ContainsKey(nodeId))
            {
                Console.WriteLine("Tracker received a completed split from recovered node");
                WorkerDetails workerObj = getWorker(nodeId, nodeURL);
                existingWorkerMap.Add(nodeId, workerObj);
                // requestWorkerStatus(nodeId);

                //retrieve his status and send split if he has no job
                WorkerCommunicator communicator = new WorkerCommunicator();
                Dictionary <StatusType, List <int> > statusOfWorker = communicator.getRecoveredStatus(nodeURL);
                Dictionary <StatusType, List <int> > updatedStatus  = getStatusForWorker(statusOfWorker, nodeId, nodeURL);
                communicator.updateRecoveredWorker(updatedStatus, nodeURL);
                notifyWorkersAboutUnfreezed(nodeId, nodeURL);
            }

            lock (taskList[splitId])
            {
                Common.Logger().LogInfo("*************************************", string.Empty, string.Empty);
                foreach (var item in taskList)
                {
                    Common.Logger().LogInfo(" Split ID= " + item.Key + " WorkerID = " + item.Value.WorkerId + " Status= " + item.Value.StatusType.ToString(), string.Empty, string.Empty);
                }
                taskList[splitId].StatusType = StatusType.COMPLETED;
                existingWorkerMap[nodeId].ProcessedSplits.Add(splitId);
            }

            if (existingWorkerMap[nodeId].State == WorkerState.ABOUT_TO_IDLE)
            {
                existingWorkerMap[nodeId].State = WorkerState.IDLE;
                ReplaceSlowTasks(nodeId);
            }
        }
Example #3
0
 // Code to execute when the application is activated (brought to foreground)
 // This code will not execute when the application is first launched
 private async void Application_Activated(object sender, ActivatedEventArgs e)
 {
     WorkerDetails details = new WorkerDetails {
         Id = "123", Name = "Awesome item", Location = "", Mobile = 9037964446, Work = ""
     };
     //await App.MobileService.geGetTable<WorkerDetails>().InsertAsync(details);
 }
 public static WorkerDetailsDTO FromWorkerDetails(WorkerDetails workerDetails)
 {
     return(new WorkerDetailsDTO
     {
         Username = workerDetails.Username,
         Role = workerDetails.Position,
         Permissions = workerDetails.Permissions,
     });
 }
Example #5
0
        private WorkerDetails getWorker(int nodeId, string nodeURL)
        {
            WorkerDetails worker = new WorkerDetails();

            worker.Nodeid          = nodeId;
            worker.Nodeurl         = nodeURL;
            worker.State           = WorkerState.IDLE;
            worker.ProcessedSplits = new List <int>();
            return(worker);
        }
Example #6
0
        private WorkerDetails GetBestWorker(Task task, int nodeId)
        {
            WorkerDetails bestWorker = null;

            int completedSplitCount = existingWorkerMap[task.WorkerId].ProcessedSplits.Count;

            if (task.PercentageCompleted <= Constants.jobReplaceBoundaryPercentage)
            {
                bestWorker = (from worker in existingWorkerMap.Values
                              where worker.ProcessedSplits.Count > completedSplitCount && worker.State == WorkerState.IDLE && worker.Nodeid != nodeId
                              orderby worker.ProcessedSplits.Count descending
                              select worker).FirstOrDefault();
            }

            return(bestWorker);
        }
Example #7
0
        /*going to replace one slow task*/
        private void ReplaceSlowTasks(int nodeId)
        {
            if (!HasPendingTasks())
            {
                WorkerDetails     bestWorker    = null;
                FileSplitMetadata splitMetadata = null;
                int splitId = 0;
                lock (taskList)
                {
                    foreach (var pair in taskList)
                    {
                        /* later change this to have from suspended as well */
                        if (pair.Value.StatusType == StatusType.INPROGRESS)
                        {
                            splitId    = pair.Key;
                            bestWorker = GetBestWorker(pair.Value, nodeId);
                            if (bestWorker != null)
                            {
                                bestWorker.State = WorkerState.ABOUT_TO_BUSY;
                                string         url    = existingWorkerMap[taskList[splitId].WorkerId].Nodeurl;
                                IWorkerTracker worker = (IWorkerTracker)Activator.GetObject(typeof(IWorkerTracker), url);
                                worker.suspendTask(splitId);

                                //reschedule
                                splitMetadata = pair.Value.SplitMetadata;
                                taskList[splitId].StatusType = StatusType.INPROGRESS;
                                taskList[splitId].WorkerId   = bestWorker.Nodeid;
                                sendTaskToWorker(bestWorker.Nodeid, splitMetadata);
                            }
                        }
                    }
                }
            }
            else
            {
                readyForNewTask(nodeId);
            }
        }
Example #8
0
        internal Dictionary <StatusType, List <int> > getStatusForWorker(Dictionary <StatusType, List <int> > freezedWorkerStatus, int nodeId, string nodeURL)
        {
            //Worker has come back. first thing to do is add to worker map and notify others
            WorkerDetails workerObj = getWorker(nodeId, nodeURL);

            if (!existingWorkerMap.ContainsKey(nodeId))
            {
                existingWorkerMap.Add(nodeId, workerObj);
                Thread thread = new Thread(() => notifyWorkersAboutUnfreezed(nodeId, nodeURL));
                thread.Start();
            }

            //make him upto date
            List <Int32> inProgress      = new List <int>();
            List <Int32> sendToClient    = new List <int>();
            bool         isTaskAvailable = false;
            Dictionary <StatusType, List <int> > result = new Dictionary <StatusType, List <int> >();

            for (int i = 0; i < freezedWorkerStatus.Count; i++)
            {
                KeyValuePair <StatusType, List <int> > entry = freezedWorkerStatus.ElementAt(i);
                switch (entry.Key)
                {
                case StatusType.COMPLETED:
                    foreach (int split in entry.Value)
                    {
                        lock (taskList[split])
                        {
                            if (taskList[split].StatusType == StatusType.INPROGRESS || taskList[split].StatusType == StatusType.NOT_SEND_TO_WORKER)
                            {
                                if (taskList[split].StatusType == StatusType.INPROGRESS)
                                {
                                    string         url    = existingWorkerMap[taskList[split].WorkerId].Nodeurl;
                                    IWorkerTracker worker = (IWorkerTracker)Activator.GetObject(typeof(IWorkerTracker), url);
                                    worker.suspendTask(split);
                                }
                                taskList[split].WorkerId = nodeId;    //later will receive completed once result sent to client
                                sendToClient.Add(split);
                            }
                        }
                    }
                    break;

                case StatusType.NOT_STARTED:
                    foreach (int split in entry.Value)
                    {
                        lock (taskList[split])
                        {
                            if (taskList[split].StatusType == StatusType.INPROGRESS && taskList[split].WorkerId != nodeId && taskList[split].PercentageCompleted > Constants.jobReplaceBoundaryPercentage || taskList[split].StatusType == StatusType.COMPLETED)
                            {
                                isTaskAvailable = false;
                            }
                            else
                            {
                                inProgress.Add(split);
                                isTaskAvailable = true;
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            if (isTaskAvailable == false)
            {
                FileSplitMetadata newSplitData = getNextPendingSplitFromList(nodeId);
                if (newSplitData != null)
                {
                    sendTaskToWorker(nodeId, newSplitData);
                    existingWorkerMap[nodeId].State = WorkerState.BUSY;
                }
            }
            else
            {
                existingWorkerMap[nodeId].State = WorkerState.BUSY;
            }
            result.Add(StatusType.COMPLETED, sendToClient); //cmpare completed and ResultTask and remove from resulttask if not in
            result.Add(StatusType.NOT_STARTED, inProgress); //compare with split metatdata,and remove from metadata if not
            return(result);
        }