Ejemplo n.º 1
0
        public void NodeIsDeregisteredAfterTimeout()
        {
            uint communicationTimeout = 1;
            uint checkInterval = 1;
            var stopwatch = new Stopwatch();
            var deregistrationEventLock = new AutoResetEvent(false);

            _overseer = new ComponentOverseer(communicationTimeout, checkInterval);
            _overseer.Deregistration += (o, e) => { deregistrationEventLock.Set(); };
            _overseer.StartMonitoring();

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

            ComponentInfo computationalNode = new SolverNodeInfo(ComponentType.ComputationalNode, solvableProblems, 5);
            _overseer.TryRegister(computationalNode);

            stopwatch.Start();

            Assert.IsTrue(_overseer.IsRegistered(computationalNode.ComponentId.Value));

            deregistrationEventLock.WaitOne(1000*(int) (communicationTimeout + checkInterval + 1));

            stopwatch.Stop();

            Assert.IsFalse(_overseer.IsRegistered(computationalNode.ComponentId.Value));
            Assert.IsTrue((ulong) stopwatch.ElapsedMilliseconds >= communicationTimeout);

            _overseer.StopMonitoring();
        }
Ejemplo n.º 2
0
        public void NodeIsDeregisteredAfterTimeout()
        {
            uint communicationTimeout    = 1;
            uint checkInterval           = 1;
            var  stopwatch               = new Stopwatch();
            var  deregistrationEventLock = new AutoResetEvent(false);

            _overseer = new ComponentOverseer(communicationTimeout, checkInterval);
            _overseer.Deregistration += (o, e) => { deregistrationEventLock.Set(); };
            _overseer.StartMonitoring();

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

            ComponentInfo computationalNode = new SolverNodeInfo(ComponentType.ComputationalNode, solvableProblems, 5);

            _overseer.TryRegister(computationalNode);

            stopwatch.Start();

            Assert.IsTrue(_overseer.IsRegistered(computationalNode.ComponentId.Value));

            deregistrationEventLock.WaitOne(1000 * (int)(communicationTimeout + checkInterval + 1));

            stopwatch.Stop();

            Assert.IsFalse(_overseer.IsRegistered(computationalNode.ComponentId.Value));
            Assert.IsTrue((ulong)stopwatch.ElapsedMilliseconds >= communicationTimeout);

            _overseer.StopMonitoring();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Starts all modules of the server.
 /// </summary>
 public void Start()
 {
     _tcpServer.StartListening();
     _msgProcessor.StartProcessing();
     _componentOverseer.StartMonitoring();
 }