Ejemplo n.º 1
0
        private void ProcessPartialSolutionsMessage(SolutionsMessage solutionsMessage)
        {
            ComponentsInfo taskManager = GetTaskManagerByProblemId(solutionsMessage.Id);

            if (taskManager == null)
            {
                EventLogger.GetLog().ErrorFormat("Brak task managera dla problemu {0}", solutionsMessage.Id);
                return;
            }
            SendMessage(solutionsMessage.Serialize(), taskManager.Client);
        }
Ejemplo n.º 2
0
        private void ProcessFinalSolutionsMessage(SolutionsMessage solutionsMessage)
        {
            ComponentsInfo computationalClient = GetComputationalClientByProblemId(solutionsMessage.Id);
            var            solution            = solutionsMessage.Solutions[0];

            var finalSolutionMessage = new SolutionsMessage(solutionsMessage.ProblemType, solutionsMessage.Id,
                                                            solutionsMessage.CommonData, new List <Solution>()
            {
                solution
            });

            SendMessage(finalSolutionMessage.Serialize(), computationalClient.Client);
            //throw new NotImplementedException();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// generates id for the component, adds it to an adequate list, and sends returning message
        /// </summary>
        /// <param name="client"></param>
        /// <param name="type"></param>
        /// <param name="parallelThreads"></param>
        /// <param name="solvableProblems"></param>
        public void RegisterComponent(TcpClient client, EComponentType type, int parallelThreads = 1, List <string> solvableProblems = null)
        {
            var componentsInfo = new ComponentsInfo(type, ++_maxComponentId, client, _timeout, parallelThreads, solvableProblems);

            componentsInfo.ComponentTimedOut += componentsInfo_ComponentTimedOut;
            switch (type.ToString())
            {
            case ("TaskManager"):
                _taskManagers.Add(componentsInfo);
                break;

            case ("ComputationalNode"):
                _computationalNodes.Add(componentsInfo);
                break;

            case ("ComputationalClient"):
                _computationalClients.Add(componentsInfo);
                break;
            }
            var responseMsg = new RegisterResponseMessage(_maxComponentId, DateTime.Now);

            SendMessage(responseMsg.Serialize(), client);
            EventLogger.GetLog().InfoFormat("Zarejestrowano {0} z Id:{1}", componentsInfo.Type, componentsInfo.Id);
        }
Ejemplo n.º 4
0
 public void TerminateComponent(ComponentsInfo cInfo)
 {
     EventLogger.GetLog().WarnFormat("{0}({1}) Odłączony", cInfo.Type, cInfo.Id);
     RemoveClient(cInfo.Client);
 }