예제 #1
0
        public static SolveRequestResponseMessage CreateSolveRequestResponseMessage()
        {
            ulong id = 12;

            SolveRequestResponseMessage expectedMessage = new SolveRequestResponseMessage(id);
            return expectedMessage;
        }
        public void Parse_XMLString_SolveRequestResponseMessage()
        {
            /*********** Actual message ***********/
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"xml_samples\SolveRequestResponse.xml");

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(path);
            string xmlStr = xmlDoc.OuterXml;

            string name = Message.GetMessageName(xmlStr);
            SolveRequestResponseMessage actualMessage = null;

            if (name == SolveRequestResponseMessage.ELEMENT_NAME)
                actualMessage = SolveRequestResponseMessage.Construct(xmlStr);

            /*********** Expected message ***********/
            ulong id = 12;

            SolveRequestResponseMessage expectedMessage = new SolveRequestResponseMessage(id);

            Assert.AreEqual(expectedMessage, actualMessage);
        }
        public void Parse_SolveRequestResponseMessage_XMLString()
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"xml_samples\SolveRequestResponse.xml");

            ulong id = 12;

            SolveRequestResponseMessage message = new SolveRequestResponseMessage(id);

            string actualXmlStr = message.ToXmlString();

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(path);
            string expectedXmlStr = xmlDoc.OuterXml;

            Assert.AreEqual(expectedXmlStr, actualXmlStr);
        }
예제 #4
0
        /// <summary>
        ///     SolveRequest is sent by Computational Client
        /// </summary>
        /// <param name="messagePackage"></param>
        private void handleSolveRequestMessage(MessagePackage messagePackage)
        {
            SolveRequestMessage message = (SolveRequestMessage)messagePackage.Message;

            InformBackup(message);

            // if the cluster can solve this problem
            if (clientTracker.CanSolveProblem(message.ProblemType))
            {
                Task task = new Task((int)systemTracker.GetNextTaskID(), message.ProblemType,
                                        message.Data);
                taskTracker.AddTask(task);

                if (Server.primaryMode)
                {

                    NoOperationMessage responseNoOp = new NoOperationMessage(clientTracker.BackupServers);
                    SolveRequestResponseMessage response = new SolveRequestResponseMessage((ulong)task.ID);

                    List<Message> messages = new List<Message>();
                    messages.Add(responseNoOp);
                    messages.Add(response);

                    server.Send(messagePackage.Socket, messages);
                    SmartConsole.PrintLine("Sent a SolveRequestResponse Message", SmartConsole.DebugLevel.Basic);
                }
                
            }
            else
            {
                //TODO RESPONSE MESSAGE

                Console.Write(" >> TM ERROR\n");
            }
        }
예제 #5
0
        public override bool Equals(object obj)
        {
            SolveRequestResponseMessage message = obj as SolveRequestResponseMessage;

            return(Id == message.Id);
        }
예제 #6
0
        private void handleSolverRequestResponseMessage(SolveRequestResponseMessage solveRequestResponseMessage)
        {
            SmartConsole.PrintLine("Solve request respone message has been received", SmartConsole.DebugLevel.Advanced);

            systemTracker.Node.Id = solveRequestResponseMessage.Id;

            keepAliveTimer.Start(solveRequestResponseMessage.Id);
        }