public void SerializeSolvePartialProblems() { SolvePartialProblems d = new SolvePartialProblems(); string xml = d.SerializeToXML(); Assert.IsNotNull(xml); }
protected override string ReceivedDivideProblem(DivideProblem divideProblem) { /* Divide Problem is sent to TM to start the action of dividing the problem instance to smaller tasks. * TM is provided with information about the computational power of the cluster in terms of total number * of available threads. The same message is used to relay information for synchronizing info with Backup CS. */ //Debug.Assert(false, "Unimplemented"); //!!!!!!!!!!!!!!!!!!! ////we are not dividing yet - inserting everything into CommonData ////the same should be done in the ComputationalNode SolvePartialProblems solvePartialProblems = new SolvePartialProblems(); solvePartialProblems.CommonData = divideProblem.Data; solvePartialProblems.Id = divideProblem.Id; solvePartialProblems.SolvingTimeoutSpecified = false; if (divideProblem.ProblemType != null) { solvePartialProblems.ProblemType = divideProblem.ProblemType; } CMSocket.Instance.SendMessage(this.Port, this.IP, solvePartialProblems.SerializeToXML(), this); return(null); }
public void DeserializeSolvePartialProblems() { SolvePartialProblems d = new SolvePartialProblems(); string xml = d.SerializeToXML(); d = (SolvePartialProblems)xml.DeserializeXML(); Assert.IsNotNull(d); }
protected override string ReceivedStatus(Status status) { Debug.Assert(this.serverQueues != null, "null server queue"); Node node = this.RegisteredComponents.NodeWithID(status.Id); NoOperation noOperationResponse = this.GenerateNoOperation(); if (!this.ensureNode(node)) { return(noOperationResponse.SerializeToXML()); } switch (node.NodeType) { case NodeType.TaskManager: if (this.serverQueues.SolveRequests.Count > 0) { SolveRequest solveRequest = this.serverQueues.SolveRequests.Dequeue(); DivideProblem divideProblem = new DivideProblem(); divideProblem.Data = solveRequest.Data; divideProblem.Id = solveRequest.Id; Console.WriteLine("Sending DivideProblem to TM"); return(divideProblem.SerializeToXML()); } //TM is not going to join the solutions //if (this.serverQueues.Solutions.Count > 0) { // Solutions solutions = this.serverQueues.Solutions.Dequeue(); // return solutions.SerializeToXML(); //} break; case NodeType.ComputationalNode: //TODO: check!! bool busy = false; if (status.Threads != null) { Console.WriteLine("Threads field not null"); foreach (StatusThreadsThread stt in status.Threads) { if (stt.ProblemInstanceIdSpecified || stt.TaskIdSpecified) { busy = true; Console.WriteLine("Busy = true"); } } } if (this.serverQueues.ProblemsToSolve.Count > 0 && !busy) { Console.WriteLine("Busy = true"); SolvePartialProblems partialProblems = this.serverQueues.ProblemsToSolve.Dequeue(); Console.WriteLine("Sending PartialProblems to CN"); return(partialProblems.SerializeToXML()); } break; case NodeType.Server: { foreach (BackupServerQueue bsq in this.backupServerQueues) { if (bsq.backupServerId == status.Id) { Console.WriteLine("Sending queued message to BackupCS"); if (bsq.messages.Count > 0) { return(bsq.messages.Dequeue()); } } } } break; default: break; } Debug.Assert(node != null, "Received unregistered node status"); if (node == null) { Console.WriteLine("Received unregistered node status"); return(noOperationResponse.SerializeToXML()); } if (!this.BackupMode) { Console.WriteLine("Sending NoOp"); } return(noOperationResponse.SerializeToXML()); }