/// <summary>
        /// 
        /// </summary>
        /// <param name="id">
        ///     The ID assigned by the Communication Server
        /// </param>
        /// <param name="timeout">
        ///     The communication timeout configured on Communication Server
        /// </param>
        /// <param name="backupServer">
        ///     The list of Backup servers
        /// </param>
        public RegisterResponseMessage(ulong id, uint timeout, BackupCommunicationServer[] backupServers)
        {
            Id = id;
            Timeout = timeout;

            BackupCommunicationServers = backupServers;
        }
        public void Parse_NoOperationMessage_XMLString()
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"xml_samples\NoOperation.xml");

            BackupCommunicationServer backupServer1
                = new BackupCommunicationServer("192.168.1.0", 80);

            BackupCommunicationServer backupServer2
                = new BackupCommunicationServer("192.168.1.0", 80);

            BackupCommunicationServer[] backupServers =
            {
                backupServer1, backupServer2
            };

            NoOperationMessage noOperation = new NoOperationMessage(backupServers);

            string actualXmlStr = noOperation.ToXmlString();

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

            Assert.AreEqual(expectedXmlStr, actualXmlStr);
        }
        public NoOperationMessage(BackupCommunicationServer backupServer)
        {
            BackupCommunicationServer[] backupServers =
            {
                backupServer
            };

            BackupCommunicationServers = backupServers;
        }
Esempio n. 4
0
        public override bool Equals(object obj)
        {
            BackupCommunicationServer server = obj as BackupCommunicationServer;

            return(address == server.address && port == server.port);
        }
        public void Parse_XMLString_NoOperationMessage()
        {
            /*********** Actual message ***********/
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"xml_samples\NoOperation.xml");

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

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

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

            /*********** Expected message ***********/
            BackupCommunicationServer backupServer1
               = new BackupCommunicationServer("192.168.1.0", 80);

            BackupCommunicationServer backupServer2
                = new BackupCommunicationServer("192.168.1.0", 80);

            BackupCommunicationServer[] backupServers =
            {
                backupServer1, backupServer2
            };

            NoOperationMessage expectedMessage = new NoOperationMessage(backupServers);

            Assert.AreEqual(expectedMessage, actualMessage);
        }
 /// <summary>
 ///     Adds a network node to the list of clients
 /// </summary>
 /// <param name="node"></param>
 public void AddNode(NetworkNode node)
 {
     switch (node.Type)
     {
         case RegisterType.CommunicationServer:
             backupServersList.Add(node);
             BackupCommunicationServer bserver = new BackupCommunicationServer(node.Address.ToString(), node.Port);
             AddBackupServer(bserver);
             break;
         case RegisterType.ComputationalNode:
             compNodes.Add(node);
             break;
         case RegisterType.TaskManager:
             taskManagers.Add(node);
             break;
     }
 }
        public BackupCommunicationServer[] ToBackupServersArray() 
        {
            int backupSize = backupServersList.Count;
            BackupCommunicationServer[] backupServersArr = new BackupCommunicationServer[backupSize];

            for (int i = 0; i < backupSize; i++)
            {
                NetworkNode server = backupServersList[i];
                BackupCommunicationServer backupServer = new BackupCommunicationServer(server.Address.ToString(), server.Port);
                backupServersArr[i] = backupServer;
            }
            
            return backupServersArr;
        }
        public void RemoveBackupServer(int index)
        {
            int newSize = backupServersArray.Length - 1;
            BackupCommunicationServer[] newBackupServers = new BackupCommunicationServer[newSize];

            int j = 0;
            for (int i = 0; i < newSize + 1; i++)
            {
                if (i != index)
                {
                    newBackupServers[j] = backupServersArray[i];
                    j++;
                }

            }

            backupServersArray = newBackupServers;
        }
        /*******************************************************************/
        /************************* PUBLIC METHODS **************************/
        /*******************************************************************/

        public void AddBackupServer(BackupCommunicationServer backupServer)
        {
            int newSize = backupServersArray.Length + 1;
            BackupCommunicationServer[] newBackupServers = new BackupCommunicationServer[newSize];

            for (int i = 0; i < newSize - 1; i++)
            {
                newBackupServers[i] = backupServersArray[i];
            }
            newBackupServers[newSize - 1] = backupServer;

            backupServersArray = newBackupServers;
        }
Esempio n. 10
0
        public static NoOperationMessage CreateNoOperationMessage()
        {
            BackupCommunicationServer backupServer1
              = new BackupCommunicationServer("192.168.1.0", 80);

            BackupCommunicationServer backupServer2
                = new BackupCommunicationServer("192.168.1.0", 80);

            BackupCommunicationServer[] backupServers =
            {
                backupServer1, backupServer2
            };

            NoOperationMessage expectedMessage = new NoOperationMessage(backupServers);
            return expectedMessage;
        }
Esempio n. 11
0
      /*  public NetworkNode(RegisterType type, ulong id, uint timeout, string[] problems)
        {
            Type = type;

            Id = id;
            Timeout = timeout;

            TaskThreads = taskThreads;
            ParallelThreads = (byte)TaskThreads.Count();
        }*/

        /******************************************************************/
        /******************* CONSTRUCTORS (SERVER SIDE) *******************/
        /******************************************************************/
        public NetworkNode(RegisterType type, ulong id, uint timeout, byte parallelThreads, string[] solvableProblems, BackupCommunicationServer[] backupCommunicationServer)
        {
            Type = type;

            Id = id;
            Timeout = timeout;
            TaskThread[] taskThreads = new TaskThread[parallelThreads];
            for (int i = 0; i < parallelThreads; i++)
            {
                taskThreads[i] = new TaskThread((int)id, solvableProblems[0], messageProcessor,(int)Id);
            }
            TaskThreads = taskThreads;
            ParallelThreads = parallelThreads;
            BackupServers = backupCommunicationServer;
            SolvableProblems = solvableProblems;
        }