示例#1
0
        private static void Main(string[] args)
        {
            ComputationalNode computationalNode;

            try
            {
                var config = ComponentConfigurationSection.LoadConfig("componentConfig", args);

                var serverAddress = IpEndPointParser.Parse(config.PrimaryServer.Address, config.PrimaryServer.Port);
                var taskSolversDirectoryRelativePath = config.TaskSolversPath;

                _logger.Info("Server address: " + serverAddress);

                ThreadManager threadManager = new ThreadPoolThreadManager();
                computationalNode = new ComputationalNode(threadManager, serverAddress, taskSolversDirectoryRelativePath);
            }
            catch (Exception ex)
            {
                var errorText = string.Format("{0}:{1}", ex.GetType().FullName, ex.Message);
                if (ex.InnerException != null)
                {
                    errorText += string.Format("|({0}:{1})", ex.InnerException.GetType().FullName,
                                               ex.InnerException.Message);
                }
                _logger.Error(errorText);
                return;
            }

            computationalNode.MessageEnqueuedToSend    += computationalNode_MessageEnqueuedToSend;
            computationalNode.MessageSent              += computationalNode_MessageSent;
            computationalNode.MessageReceived          += computationalNode_MessageReceived;
            computationalNode.MessageHandlingException += computationalNode_MessageHandlingException;
            computationalNode.MessageSendingException  += computationalNode_MessageSendingException;

            computationalNode.OnStarting += computationalNode_OnStarting;
            computationalNode.OnStarted  += computationalNode_OnStarted;

            computationalNode.Start();
            string line;

            while (true)
            {
                line = Console.ReadLine().ToLower();
                if (line == "stop" || line == "quit" || line == "exit")
                {
                    break;
                }
                if (line == "start")
                {
                    computationalNode.Start();
                }
                if (line == "running")
                {
                    Console.WriteLine("ComputationalNode.IsRunning={0}", computationalNode.IsRunning);
                }
            }
        }
示例#2
0
文件: Program.cs 项目: progala2/DVRP
        private static void Main(string[] args)
        {
            ComputationalNode computationalNode;
            try
            {
                var config = ComponentConfigurationSection.LoadConfig("componentConfig", args);

                var serverAddress = IpEndPointParser.Parse(config.PrimaryServer.Address, config.PrimaryServer.Port);
                var taskSolversDirectoryRelativePath = config.TaskSolversPath;

                _logger.Info("Server address: " + serverAddress);

                ThreadManager threadManager = new ThreadPoolThreadManager();
                computationalNode = new ComputationalNode(threadManager, serverAddress, taskSolversDirectoryRelativePath);
            }
            catch (Exception ex)
            {
                var errorText = string.Format("{0}:{1}", ex.GetType().FullName, ex.Message);
                if (ex.InnerException != null)
                    errorText += string.Format("|({0}:{1})", ex.InnerException.GetType().FullName,
                        ex.InnerException.Message);
                _logger.Error(errorText);
                return;
            }

            computationalNode.MessageEnqueuedToSend += computationalNode_MessageEnqueuedToSend;
            computationalNode.MessageSent += computationalNode_MessageSent;
            computationalNode.MessageReceived += computationalNode_MessageReceived;
            computationalNode.MessageHandlingException += computationalNode_MessageHandlingException;
            computationalNode.MessageSendingException += computationalNode_MessageSendingException;

            computationalNode.OnStarting += computationalNode_OnStarting;
            computationalNode.OnStarted += computationalNode_OnStarted;

            computationalNode.Start();
            string line;
            while (true)
            {
                line = Console.ReadLine().ToLower();
                if (line == "stop" || line == "quit" || line == "exit")
                    break;
                if (line == "start")
                    computationalNode.Start();
                if (line == "running")
                    Console.WriteLine("ComputationalNode.IsRunning={0}", computationalNode.IsRunning);
            }
        }