Esempio n. 1
0
        private void broadcastUpdatedExecutionState(NodeExecutionState newstate)
        {
            var m = new UpdatedExecutionStateMessage(settings.directorNodeName, newstate);

            foreach (var item in allNodeNames)
            {
                (proxyProvider.getProxy(item) as IAmbrosiaNodeProxy).ReceiveDCEPControlMessageFork(m);
            }
        }
Esempio n. 2
0
        public void processEvent(AbstractEvent e)
        {
            ForwardRule rule;

            if (forwardRules.TryGetValue(e.type, out rule))
            {
                foreach (var nodeName in rule.destinations)
                {
                    // avoiding forwarding circles
                    if (!e.knownToNodes.Contains(nodeName))
                    {
                        Console.WriteLine(String.Format(TAG + "Sending {0} to Node {1}", e, nodeName));
                        proxyProvider.getProxy(nodeName).ReceiveExternalEventFork(e.DeepClone());
                    }
                }
            }
        }
Esempio n. 3
0
        public void threadStartMethod()
        {
            stopwatch.Start();

            while (true)
            {
                processControlMessages();

                switch (state)
                {
                case NodeExecutionState.WaitForStart:
                    /*                        // broadcast isready signal to directorNode every second
                     *                     if (stopwatch.ElapsedMilliseconds - lastStatusMessageToCoordinator > 1000){
                     *                         proxyProvider.getProxy(settings.directorNodeName).ReceiveDCEPControlMessageFork(new NodeIsReadyToStartMessage(nodeName));
                     *                         //Console.WriteLine(TAG + "sending ready to start message to director node "+settings.directorNodeName.ToString());
                     *                         lastStatusMessageToCoordinator = stopwatch.ElapsedMilliseconds;
                     *                     } */

                    if (!sentReadyToStartMessage)
                    {
                        proxyProvider.getProxy(settings.directorNodeName).ReceiveDCEPControlMessageFork(new NodeIsReadyToStartMessage(nodeName));
                        sentReadyToStartMessage = true;
                    }

                    break;

                case NodeExecutionState.DoStartInputGeneration:
                    // TODO: check if this is not already running and throw an error if it is
                    primitiveEventSourceService.start();
                    state = NodeExecutionState.Running;
                    processingStep();
                    break;

                case NodeExecutionState.Running:
                    processingStep();
                    break;

                case NodeExecutionState.DoStopInputGeneration:
                    primitiveEventSourceService.stop();
                    state = NodeExecutionState.ProcessingRemainder;

                    break;

                case NodeExecutionState.ProcessingRemainder:
                    processingStep();

                    // when queues are empty, send isReadyToTerminate message every second
                    if (getQueuedEventCount() == 0)
                    {
                        if (stopwatch.ElapsedMilliseconds - lastStatusMessageToCoordinator > 1000)
                        {
                            proxyProvider.getProxy(settings.directorNodeName)
                            .ReceiveDCEPControlMessageFork(new NodeIsReadyToTerminateMessage(nodeName));
                            lastStatusMessageToCoordinator = stopwatch.ElapsedMilliseconds;
                        }
                    }

                    break;

                case NodeExecutionState.DoSendExperimentDataAndTerminate:

                    var data = new ExperimentRunData(
                        locallyGeneratedComplexEventCount,
                        receivedEventCount,
                        locallyGeneratedPrimitiveEventCount,
                        locallyDroppedComplexEvents);

                    proxyProvider.getProxy(settings.directorNodeName).ReceiveDCEPControlMessageFork(new ExperimentRunNodeDataMessage(nodeName, data));
                    Console.WriteLine(TAG + "Sent experiment data. Update loop is terminating.");
                    Thread.Sleep(500);
                    if (getQueuedEventCount() > 0)
                    {
                        Console.WriteLine(TAG + String.Format("WARNING: requested to terminate with {0} events left in queue.", getQueuedEventCount()));
                    }

                    if (directorNodeService != null)
                    {
                        while (!directorNodeService.localNodeCanTerminate)
                        {
                            processControlMessages();
                        }
                    }
                    return;



                case NodeExecutionState.DoTerminate:
                    if (getQueuedEventCount() > 0)
                    {
                        Console.WriteLine(TAG + String.Format("WARNING: requested to terminate with {0} events left in queue.", getQueuedEventCount()));
                    }
                    return;
                }
            }
        }