示例#1
0
 /// <summary>
 /// Creates a new MDSController object.
 /// </summary>
 /// <param name="name">Name of the controller</param>
 public MDSController(string name)
     : base(name, CommunicationLayer.CreateApplicationId())
 {
     _settings = MDSSettings.Instance;
     _designSettings = MDSDesignSettings.Instance;
     MessageReceived += MDSController_MessageReceived;
 }
示例#2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public MDSServer()
 {
     _settings = MDSSettings.Instance;
     _serverGraph = new MDSServerGraph();
     _clientApplicationList = new MDSClientApplicationList();
     _mdsManager = new MDSController("MDSController");
     _storageManager = StorageManagerFactory.CreateStorageManager();
     _routingTable = new RoutingTable();
     _communicationLayer = new CommunicationLayer();
     _organizationLayer = new OrganizationLayer(_communicationLayer, _storageManager, _routingTable, _serverGraph, _clientApplicationList, _mdsManager);
     _mdsManager.OrganizationLayer = _organizationLayer;
 }
 /// <summary>
 /// Contructor. Gets applications from given settings file.
 /// </summary>
 public MDSClientApplicationList()
 {
     _settings = MDSSettings.Instance;
     Applications = new SortedList<string, MDSClientApplication>();
     try
     {
         CreateApplicationList();
     }
     catch (MDSException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new MDSException("Can not read settings file.", ex);
     }
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="communicationLayer">Reference to the Communication Layer</param>
 /// <param name="storageManager">Reference to the Storage Manager</param>
 /// <param name="routingTable">Reference to the routing table</param>
 /// <param name="serverGraph">Reference to server graph</param>
 /// <param name="clientApplicationList">Reference to application list</param>
 /// <param name="mdsManager">Reference to MDS Manager object</param>
 public OrganizationLayer(CommunicationLayer communicationLayer, IStorageManager storageManager, RoutingTable routingTable, MDSServerGraph serverGraph, MDSClientApplicationList clientApplicationList, MDSController mdsManager)
 {
     _settings = MDSSettings.Instance;
     _communicationLayer = communicationLayer;
     _storageManager = storageManager;
     _routingTable = routingTable;
     _serverGraph = serverGraph;
     _clientApplicationList = clientApplicationList;
     _mdsManager = mdsManager;
     _waitingMessages = new SortedList<string, WaitingMessage>();
     PrepareCommunicationLayer();
 }
示例#5
0
        /// <summary>
        /// Processes UpdateServerGraphMessage.
        /// </summary>
        /// <param name="communicator">Communicator that sent message</param>
        /// <param name="controlMessage">The message to be processed</param>
        /// <param name="controllerMessage">MDSControllerMessage object that includes controlMessage</param>
        private void ProcessUpdateServerGraphMessage(ICommunicator communicator, UpdateServerGraphMessage controlMessage, MDSControllerMessage controllerMessage)
        {
            try
            {
                var newSettings = new MDSSettings(Path.Combine(GeneralHelper.GetCurrentDirectory(), "MDSSettings.xml"));
                var newDesignSettings = new MDSDesignSettings(Path.Combine(GeneralHelper.GetCurrentDirectory(), "MDSSettings.design.xml"));

                //Clear existing server lists
                newSettings.Servers.Clear();
                newDesignSettings.Servers.Clear();

                //Add servers from UpdateServerGraphMessage
                newSettings.ThisServerName = controlMessage.ServerGraph.ThisServerName;
                foreach (var server in controlMessage.ServerGraph.Servers)
                {
                    //Settings
                    newSettings.Servers.Add(
                        new ServerInfoItem
                        {
                            Name = server.Name,
                            IpAddress = server.IpAddress,
                            Port = server.Port,
                            Adjacents = server.Adjacents
                        });
                    //Design settings
                    newDesignSettings.Servers.Add(
                        new ServerDesignItem
                        {
                            Name = server.Name,
                            Location = server.Location
                        });
                }

                //Save settings
                newSettings.SaveToXml();
                newDesignSettings.SaveToXml();
            }
            catch (Exception ex)
            {
                //Send fail message
                ReplyMessageToCommunicator(
                    communicator,
                    new OperationResultMessage {Success = false, ResultMessage = ex.Message},
                    controllerMessage
                    );
                return;
            }

            //Send success message
            ReplyMessageToCommunicator(
                communicator,
                new OperationResultMessage {Success = true, ResultMessage = "Success"},
                controllerMessage
                );
        }
示例#6
0
 /// <summary>
 /// Contructor.
 /// </summary>
 public MDSServerGraph()
 {
     _settings = MDSSettings.Instance;
     ServerNodes = new SortedList<string, MDSServerNode>();
     AdjacentServers = new SortedList<string, MDSAdjacentServer>();
     _pingTimer = new Timer(PingTimer_Elapsed, null, Timeout.Infinite, Timeout.Infinite);
     try
     {
         CreateGraph();
     }
     catch (MDSException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new MDSException("Can not read settings file. Detail: " + ex.Message, ex);
     }
 }
示例#7
0
 /// <summary>
 /// Creates a new RoutingTable object.
 /// </summary>
 public RoutingTable()
 {
     _settings = MDSSettings.Instance;
     Rules = new List<RoutingRule>();
     CreateRuleList();
 }
示例#8
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public CommunicationLayer()
        {
            _settings = MDSSettings.Instance;
            _remoteApplications = new SortedList<int, MDSRemoteApplication>();
            _communicators = new SortedList<long, ICommunicator>();
            _communicationManagers =
                new List<ICommunicationManager>
                    {
                        new TCPCommunicationManager(Convert.ToInt32(_settings["__ThisServerTCPPort"].Trim()))
                    };

            foreach (var manager in _communicationManagers)
            {
                manager.CommunicatorConnected += Manager_CommunicatorConnected;
            }
        }