Ejemplo n.º 1
0
 public HeartBeatManager(EvaluatorSettings settings, IRemoteIdentifier remoteId)
 {
     using (LOGGER.LogFunction("HeartBeatManager::HeartBeatManager"))
     {
         _remoteManager = settings.RemoteManager;
         _remoteId      = remoteId;
         _evaluatorId   = settings.EvalutorId;
         _observer      = _remoteManager.GetRemoteObserver(new RemoteEventEndPoint <REEFMessage>(_remoteId));
         _clock         = settings.RuntimeClock;
         _heartBeatPeriodInMillSeconds = settings.HeartBeatPeriodInMs;
         _maxHeartbeatRetries          = settings.MaxHeartbeatFailures;
         EvaluatorSettings             = settings;
         MachineStatus.ToString(); // kick start the CPU perf counter
     }
 }
Ejemplo n.º 2
0
 private HeartBeatManager(
     EvaluatorSettings settings,
     IInjectionFuture<EvaluatorRuntime> evaluatorRuntime,
     IInjectionFuture<ContextManager> contextManager,
     [Parameter(typeof(ErrorHandlerRid))] string errorHandlerRid)
 {
     using (LOGGER.LogFunction("HeartBeatManager::HeartBeatManager"))
     {
         _evaluatorSettings = settings;
         _evaluatorRuntime = evaluatorRuntime;
         _contextManager = contextManager;
         _remoteManager = settings.RemoteManager;
         _remoteId = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(errorHandlerRid));
         _observer = _remoteManager.GetRemoteObserver(new RemoteEventEndPoint<REEFMessage>(_remoteId));
         _clock = settings.RuntimeClock;
         _heartBeatPeriodInMillSeconds = settings.HeartBeatPeriodInMs;
         _maxHeartbeatRetries = settings.MaxHeartbeatRetries;
         MachineStatus.ToString(); // kick start the CPU perf counter
     }
 }
Ejemplo n.º 3
0
 private HeartBeatManager(
     EvaluatorSettings settings,
     IInjectionFuture <EvaluatorRuntime> evaluatorRuntime,
     IInjectionFuture <ContextManager> contextManager,
     [Parameter(typeof(ErrorHandlerRid))] string errorHandlerRid)
 {
     using (LOGGER.LogFunction("HeartBeatManager::HeartBeatManager"))
     {
         _evaluatorSettings            = settings;
         _evaluatorRuntime             = evaluatorRuntime;
         _contextManager               = contextManager;
         _remoteManager                = settings.RemoteManager;
         _remoteId                     = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(errorHandlerRid));
         _observer                     = _remoteManager.GetRemoteObserver(new RemoteEventEndPoint <REEFMessage>(_remoteId));
         _clock                        = settings.RuntimeClock;
         _heartBeatPeriodInMillSeconds = settings.HeartBeatPeriodInMs;
         _maxHeartbeatRetries          = settings.MaxHeartbeatRetries;
         MachineStatus.ToString(); // kick start the CPU perf counter
     }
 }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("START: {0} Evaluator::InitInjector.", DateTime.Now);
                Stopwatch timer = new Stopwatch();
                InitInjector();
                SetCustomTraceListeners();  // logger is reset by this.
                timer.Stop();
                Console.WriteLine("EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, timer.Elapsed);
                
                using (logger.LogScope("Evaluator::Main"))
                {
                    if (IsDebuggingEnabled())
                    {
                        AttachDebugger();
                    }

                    // Register our exception handler
                    AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;

                    // Fetch some settings from the ConfigurationManager
                    SetHeartbeatPeriod();
                    SetHeartbeatMaxRetry();

                    // Parse the command line
                    // The error handler RID should now be written in the configuration file instead
                    if (args.Count() != 1)
                    {
                        var e = new InvalidOperationException("must supply only the evaluator config file!");
                        Utilities.Diagnostics.Exceptions.Throw(e, logger);
                    }

                    // evaluator configuration file
                    string evaluatorConfigurationPath = args[0];

                    // Parse the evaluator configuration.
                    evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath);

                    string rId = evaluatorConfig.ErrorHandlerRID;
                    ContextConfiguration rootContextConfiguration = evaluatorConfig.RootContextConfiguration;
                    Optional<TaskConfiguration> rootTaskConfig = evaluatorConfig.TaskConfiguration;
                    Optional<ServiceConfiguration> rootServiceConfig = evaluatorConfig.RootServiceConfiguration;

                    // remoteManager used as client-only in evaluator
                    IRemoteManager<REEFMessage> remoteManager = injector.GetInstance<IRemoteManagerFactory>().GetInstance(new REEFMessageCodec());
                    IRemoteIdentifier remoteId = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(rId));

                    RuntimeClock clock = InstantiateClock();
                    logger.Log(Level.Info, "Application Id: " + evaluatorConfig.ApplicationId);
                    EvaluatorSettings evaluatorSettings = new EvaluatorSettings(
                        evaluatorConfig.ApplicationId,
                        evaluatorConfig.EvaluatorId,
                        heartbeatPeriodInMs,
                        heartbeatMaxRetry,
                        rootContextConfiguration,
                        clock,
                        remoteManager,
                        injector);

                    HeartBeatManager heartBeatManager = new HeartBeatManager(evaluatorSettings, remoteId);
                    ContextManager contextManager = new ContextManager(heartBeatManager, rootServiceConfig, rootTaskConfig);
                    EvaluatorRuntime evaluatorRuntime = new EvaluatorRuntime(contextManager, heartBeatManager);

                    // TODO: replace with injectionFuture
                    heartBeatManager._evaluatorRuntime = evaluatorRuntime;
                    heartBeatManager._contextManager = contextManager;

                    SetRuntimeHandlers(evaluatorRuntime, clock);

                    clock.Run();
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            
            try
            {
                Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "START: {0} Evaluator::InitInjector.",
                    DateTime.Now));
                Stopwatch timer = new Stopwatch();
                InitInjector();
                SetCustomTraceListners();  // _logger is reset by this.
                timer.Stop();
                Console.WriteLine(string.Format(CultureInfo.InvariantCulture,
                    "EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, timer.Elapsed));

                
                using (_logger.LogScope("Evaluator::Main"))
                {
                    // Wait for the debugger, if enabled
                    AttachDebuggerIfEnabled();

                    // Register our exception handler
                    AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;

                    // Fetch some settings from the ConfigurationManager
                    SetHeartbeatPeriod();
                    SetHeartbeatMaxRetry();
                    
                    
                    // Parse the command line
                    if (args.Count() < 2)
                    {
                        var e = new InvalidOperationException("must supply at least the rId and evaluator config file");
                        Utilities.Diagnostics.Exceptions.Throw(e, _logger);
                    }

                    // remote driver Id
                    string rId = args[0];

                    // evaluator configuraiton file
                    string evaluatorConfigurationPath = args[1];

                    // Parse the evaluator configuration.
                    _evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath);

                    ContextConfiguration rootContextConfiguration = _evaluatorConfig.RootContextConfiguration;
                    Optional<TaskConfiguration> rootTaskConfig = _evaluatorConfig.TaskConfiguration;
                    Optional<ServiceConfiguration> rootServiceConfig = _evaluatorConfig.RootServiceConfiguration;

                    // remoteManager used as client-only in evaluator
                    IRemoteManager<REEFMessage> remoteManager = _injector.GetInstance<IRemoteManagerFactory>().GetInstance(new REEFMessageCodec());
                    IRemoteIdentifier remoteId = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(rId));


                    RuntimeClock clock = InstantiateClock();
                    _logger.Log(Level.Info, "Application Id: " + _evaluatorConfig.ApplicationId);
                    EvaluatorSettings evaluatorSettings = new EvaluatorSettings(
                        _evaluatorConfig.ApplicationId,
                        _evaluatorConfig.EvaluatorId,
                        _heartbeatPeriodInMs,
                        _heartbeatMaxRetry,
                        rootContextConfiguration,
                        clock,
                        remoteManager,
                        _injector);

                    HeartBeatManager heartBeatManager = new HeartBeatManager(evaluatorSettings, remoteId);
                    ContextManager contextManager = new ContextManager(heartBeatManager, rootServiceConfig,
                        rootTaskConfig);
                    EvaluatorRuntime evaluatorRuntime = new EvaluatorRuntime(contextManager, heartBeatManager);

                    // TODO: replace with injectionFuture
                    heartBeatManager._evaluatorRuntime = evaluatorRuntime;
                    heartBeatManager._contextManager = contextManager;

                    SetRuntimeHandlers(evaluatorRuntime, clock);


                    Task evaluatorTask = Task.Run(new Action(clock.Run));
                    evaluatorTask.Wait();
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
        }