public void DeserializeRegister()
 {
     Register d = new Register();
     string xml = d.SerializeToXML();
     d = (Register)xml.DeserializeXML();
     Assert.IsNotNull(d);
 }
        protected override Register GenerateRegister()
        {
            Register register = new Register();
            register.Type = this.TypeName;

            //List<RegisterSolvableProblemsProblemName> solvableProblems = new List<RegisterSolvableProblemsProblemName>();
            //foreach (ProblemType type in this.SolvableProblems) {
            //    RegisterSolvableProblemsProblemName solvProb = new RegisterSolvableProblemsProblemName();
            //    solvProb.Value = Utilities.ProblemNameForType(type);
            //    solvableProblems.Add(solvProb);
            //}
            //register.SolvableProblems = solvableProblems.ToArray();

            return register;
        }
示例#3
0
 protected abstract string ReceivedRegister(Register register, IPAddress senderAddr);
 public void SerializeRegister()
 {
     Register d = new Register();
     string xml = d.SerializeToXML();
     Assert.IsNotNull(xml);
 }
 protected override string ReceivedRegister(Register register, IPAddress senderAddr)
 {
     Debug.Assert(false, "Should not be here");
     return null;
 }
示例#6
0
        protected override string ReceivedRegister(Register register, IPAddress senderAddr)
        {
            string type = register.Type;
            Node newNode;
            ulong ID = RegisteredNodes.NextNodeID;
            switch (Utilities.NodeTypeForName(type)) {
                case NodeType.TaskManager:
                    newNode = new TaskManager();
                    if(senderAddr != null)
                        newNode.IP = senderAddr;
                    newNode.NodeType = Nodes.NodeType.TaskManager;
                    newNode.ID = register.Id;
                    this.RegisteredComponents.RegisterTaskManager(newNode);
                    break;
                case NodeType.ComputationalNode:
                    newNode = new ComputationalNode();
                    newNode.ID = register.Id;
                    if (senderAddr != null)
                        newNode.IP = senderAddr;
                    newNode.NodeType = Nodes.NodeType.ComputationalNode;
                    this.RegisteredComponents.RegisterComputationalNode(newNode);
                    break;
                case NodeType.Server:
                    newNode = new Server();
                    newNode.ID = ID;
                    BackupServerQueue bsq = new BackupServerQueue {
                        backupServerId = ID,
                        messages = new Queue<string>()
                    };
                    if (senderAddr != null)
                        newNode.IP = senderAddr;
                    newNode.NodeType = Nodes.NodeType.Server;
                    this.backupServerQueues.Add(bsq);
                    this.RegisteredComponents.RegisterBackupServer(newNode);
                    this.backupServerQueues.Add(bsq);
                    break;
                case NodeType.Client: //not needed!
                    break;
                default:
                    break;
            }

            //Register message is sent by TM, CN and Backup CS to the CS after they are activated.
            RegisterResponse response = new RegisterResponse();
            response.Id = ID;
            response.Timeout = this.Timeout;
            List<RegisterResponseBackupCommunicationServersBackupCommunicationServer> backupServers = new List<RegisterResponseBackupCommunicationServersBackupCommunicationServer>();
            foreach (Node comp in this.RegisteredComponents.BackupServers) {
                RegisterResponseBackupCommunicationServersBackupCommunicationServer backup = new RegisterResponseBackupCommunicationServersBackupCommunicationServer();
                if (comp.IP == null)
                    break ;
                backup.address = comp.IP.ToString();
                if (comp.Port > 0) {
                    backup.port = comp.Port;
                    backup.portSpecified = true;
                }
                backupServers.Add(backup);
            }

            response.BackupCommunicationServers = backupServers.ToArray();
            if(!this.BackupMode)
            Console.WriteLine("Sending RegisterResponse");
            return response.SerializeToXML();
        }
示例#7
0
 protected override Register GenerateRegister()
 {
     Register register = new Register();
     register.Type = this.TypeName;
     return register;
 }