コード例 #1
0
ファイル: Evaluator.cs プロジェクト: gyeongin/reef
        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);
            }
        }
コード例 #2
0
ファイル: Evaluator.cs プロジェクト: kijungs/incubator-reef
        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);
            }
        }