Esempio n. 1
0
        public void AllTypesOfNodesAreProperlyRegistered()
        {
            _overseer = new ComponentOverseer(5, 5);

            var solvableProblems = new List<string> {"dvrp"};

            var serverInfo = new ServerInfo
            {
                IpAddress = "127.0.0.1",
                Port = 9135
            };

            ComponentInfo taskManager = new SolverNodeInfo(ComponentType.TaskManager, solvableProblems, 5);
            ComponentInfo computationalNode = new SolverNodeInfo(ComponentType.ComputationalNode, solvableProblems, 5);
            ComponentInfo backupServer = new BackupServerInfo(serverInfo, 5);

            Assert.IsNull(taskManager.ComponentId);
            Assert.IsNull(computationalNode.ComponentId);
            Assert.IsNull(backupServer.ComponentId);

            _overseer.TryRegister(taskManager);
            _overseer.TryRegister(computationalNode);
            _overseer.TryRegister(backupServer);

            Assert.IsTrue(_overseer.IsRegistered(taskManager.ComponentId.Value));
            Assert.IsTrue(_overseer.IsRegistered(computationalNode.ComponentId.Value));
            Assert.IsTrue(_overseer.IsRegistered(backupServer.ComponentId.Value));
        }
Esempio n. 2
0
 /// <summary>
 /// Creates BackupServerInfo instance.
 /// </summary>
 /// <param name="serverInfo">Communication Server specific information.</param>
 /// <param name="numberOfThreads">Number of threads provided by the backup.</param>
 public BackupServerInfo(ServerInfo serverInfo, int numberOfThreads)
     : base(ComponentType.CommunicationServer, numberOfThreads)
 {
     Address = new IPEndPoint(
         IPAddress.Parse(serverInfo.IpAddress),
         serverInfo.Port);
 }
Esempio n. 3
0
        public void RegisterResponseMessageXmlIsProperlySerializedAndDeserialized()
        {
            var si = new ServerInfo
            {
                IpAddress = "192.168.1.0",
                Port = 9001
            };

            var message = new RegisterResponseMessage
            {
                AssignedId = 5,
                BackupServers = new List<ServerInfo> {si},
                CommunicationTimeout = 50
            };

            var serializedMessage = _serializer.Serialize(message);
            var deserializedMessage = _serializer.Deserialize(serializedMessage);

            Assert.IsInstanceOfType(deserializedMessage, typeof (RegisterResponseMessage));
        }