Exemplo n.º 1
0
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
            RuntimeClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            IInjector injector)
        {
            _injector            = injector;
            _applicationId       = applicationId;
            _evaluatorId         = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            if (string.IsNullOrWhiteSpace(rootContextConfigString))
            {
                Utilities.Diagnostics.Exceptions.Throw(
                    new ArgumentException("empty or null rootContextConfigString"), Logger);
            }
            _rootContextConfig        = new ContextConfiguration(rootContextConfigString);
            _rootTaskConfiguration    = CreateTaskConfiguration();
            _rootServiceConfiguration = CreateRootServiceConfiguration();

            _remoteManager  = remoteManagerFactory.GetInstance(reefMessageCodec);
            _operationState = EvaluatorOperationState.OPERATIONAL;
        }
Exemplo n.º 2
0
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
            RuntimeClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            IInjector injector)
        {
            _injector = injector;
            _applicationId = applicationId;
            _evaluatorId = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            if (string.IsNullOrWhiteSpace(rootContextConfigString))
            {
                Utilities.Diagnostics.Exceptions.Throw(
                    new ArgumentException("empty or null rootContextConfigString"), Logger);
            }
            _rootContextConfig = new ContextConfiguration(rootContextConfigString);
            _rootTaskConfiguration = CreateTaskConfiguration();
            _rootServiceConfiguration = CreateRootServiceConfiguration();

            _remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
            _operationState = EvaluatorOperationState.OPERATIONAL;
        }
Exemplo n.º 3
0
 private EvaluatorSettings(
     [Parameter(typeof(ApplicationIdentifier))] string applicationId,
     [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
     [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
     [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
     IClock clock,
     IRemoteManagerFactory remoteManagerFactory,
     REEFMessageCodec reefMessageCodec) :
     this(applicationId, evaluatorId, heartbeatPeriodInMs, maxHeartbeatRetries,
          clock, remoteManagerFactory, reefMessageCodec, null)
 {
 }
Exemplo n.º 4
0
 private EvaluatorSettings(
     [Parameter(typeof(ApplicationIdentifier))] string applicationId,
     [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
     [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
     [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
     IClock clock,
     IRemoteManagerFactory remoteManagerFactory,
     REEFMessageCodec reefMessageCodec) :
     this(applicationId, evaluatorId, heartbeatPeriodInMs, maxHeartbeatRetries, 
     clock, remoteManagerFactory, reefMessageCodec, null)
 {
 }
Exemplo n.º 5
0
 private EvaluatorSettings(
     [Parameter(typeof(ApplicationIdentifier))] string applicationId,
     [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
     [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
     [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
     [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
     AvroConfigurationSerializer serializer,
     RuntimeClock clock,
     IRemoteManagerFactory remoteManagerFactory,
     REEFMessageCodec reefMessageCodec,
     IInjector injector) :
     this(applicationId, evaluatorId, heartbeatPeriodInMs, maxHeartbeatRetries, rootContextConfigString, serializer,
     clock, remoteManagerFactory, reefMessageCodec, injector, null)
 {
 }
Exemplo n.º 6
0
 private EvaluatorSettings(
     [Parameter(typeof(ApplicationIdentifier))] string applicationId,
     [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
     [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
     [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
     [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
     AvroConfigurationSerializer serializer,
     RuntimeClock clock,
     IRemoteManagerFactory remoteManagerFactory,
     REEFMessageCodec reefMessageCodec,
     IInjector injector) :
     this(applicationId, evaluatorId, heartbeatPeriodInMs, maxHeartbeatRetries, rootContextConfigString, serializer,
          clock, remoteManagerFactory, reefMessageCodec, injector, null)
 {
 }
Exemplo n.º 7
0
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
            AvroConfigurationSerializer serializer,
            RuntimeClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            IInjector injector)
        {
            _serializer = serializer;
            _injector = injector;
            _applicationId = applicationId;
            _evaluatorId = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            if (string.IsNullOrWhiteSpace(rootContextConfigString))
            {
                Utilities.Diagnostics.Exceptions.Throw(
                    new ArgumentException("empty or null rootContextConfigString"), Logger);
            }
            _rootContextConfig = _serializer.FromString(rootContextConfigString);

            try
            {
                _rootContextId = injector.ForkInjector(_rootContextConfig).GetNamedInstance<ContextConfigurationOptions.ContextIdentifier, string>();
            }
            catch (InjectionException)
            {
                Logger.Log(Level.Info, "Using deprecated ContextConfiguration.");
                
                // TODO[JIRA REEF-1167]: Remove this catch.
                var deprecatedContextConfig = new Context.ContextConfiguration(rootContextConfigString);
                _rootContextConfig = deprecatedContextConfig;
                _rootContextId = deprecatedContextConfig.Id;
            }

            _rootTaskConfiguration = CreateTaskConfiguration();
            _rootServiceConfiguration = CreateRootServiceConfiguration();

            _remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
            _operationState = EvaluatorOperationState.OPERATIONAL;
        }
Exemplo n.º 8
0
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            IClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            INameClient nameClient)
        {
            _applicationId       = applicationId;
            _evaluatorId         = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            _remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
            OperationState = EvaluatorOperationState.OPERATIONAL;
            NameClient     = nameClient;
        }
Exemplo n.º 9
0
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            IClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            INameClient nameClient)
        {
            _applicationId = applicationId;
            _evaluatorId = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            _remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
            OperationState = EvaluatorOperationState.OPERATIONAL;
            NameClient = nameClient;
        }
Exemplo n.º 10
0
        public static void Main(string[] args)
        {
            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "START: {0} Evaluator::InitInjector.", DateTime.Now));
            Stopwatch timer = new Stopwatch();

            InitInjector();
            SetCustomTraceListners();
            timer.Stop();
            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, timer.Elapsed));

            RuntimeClock clock;

            using (_logger.LogScope("Evaluator::Main"))
            {
                string debugEnabledString = Environment.GetEnvironmentVariable("Org.Apache.Reef.EvaluatorDebug");
                if (!string.IsNullOrWhiteSpace(debugEnabledString) &&
                    debugEnabledString.Equals("enabled", StringComparison.OrdinalIgnoreCase))
                {
                    while (true)
                    {
                        if (Debugger.IsAttached)
                        {
                            break;
                        }
                        else
                        {
                            _logger.Log(Level.Info, "Evaluator in debug mode, waiting for debugger to be attached...");
                            Thread.Sleep(2000);
                        }
                    }
                }

                AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;

                string heartbeatPeriodFromConfig = ConfigurationManager.AppSettings["EvaluatorHeartbeatPeriodInMs"];

                int heartbeatPeriod = 0;

                if (!string.IsNullOrWhiteSpace(heartbeatPeriodFromConfig) &&
                    int.TryParse(heartbeatPeriodFromConfig, out heartbeatPeriod))
                {
                    _heartbeatPeriodInMs = heartbeatPeriod;
                }
                _logger.Log(Level.Verbose,
                            "Evaluator heartbeat period set to be " + _heartbeatPeriodInMs + " milliSeconds.");

                int    maxHeartbeatRetry           = 0;
                string heartbeatMaxRetryFromConfig = ConfigurationManager.AppSettings["EvaluatorHeartbeatRetryMaxTimes"];

                if (!string.IsNullOrWhiteSpace(heartbeatMaxRetryFromConfig) &&
                    int.TryParse(heartbeatMaxRetryFromConfig, out maxHeartbeatRetry))
                {
                    _heartbeatMaxRetry = maxHeartbeatRetry;
                }
                _logger.Log(Level.Verbose, "Evaluator heatrbeat max retry set to be " + _heartbeatMaxRetry + " times.");

                if (args.Count() < 2)
                {
                    var e = new InvalidOperationException("must supply at least the rId and evaluator config file");
                    Exceptions.Throw(e, _logger);
                }

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

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

                ICodec <REEFMessage> reefMessageCodec = new REEFMessageCodec();

                _evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath);

                string rootContextConfigString = _evaluatorConfig.RootContextConfiguration;
                if (string.IsNullOrWhiteSpace(rootContextConfigString))
                {
                    Exceptions.Throw(new ArgumentException("empty or null rootContextConfigString"), _logger);
                }
                ContextConfiguration rootContextConfiguration = new ContextConfiguration(rootContextConfigString);

                string taskConfig = _evaluatorConfig.TaskConfiguration;
                Optional <TaskConfiguration> rootTaskConfig = string.IsNullOrEmpty(taskConfig)
                                        ? Optional <TaskConfiguration> .Empty()
                                        : Optional <TaskConfiguration> .Of(
                    new TaskConfiguration(taskConfig));

                string rootServiceConfigString = _evaluatorConfig.RootServiceConfiguration;
                Optional <ServiceConfiguration> rootServiceConfig = string.IsNullOrEmpty(rootServiceConfigString)
                                        ? Optional <ServiceConfiguration> .Empty()
                                        : Optional <ServiceConfiguration> .Of(
                    new ServiceConfiguration(
                        rootServiceConfigString));

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

                ConfigurationModule module             = new ConfigurationModuleBuilder().Build();
                IConfiguration      clockConfiguraiton = module.Build();

                clock =
                    TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance <RuntimeClock>();
                _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: repalce with injectionFuture
                heartBeatManager._evaluatorRuntime = evaluatorRuntime;
                heartBeatManager._contextManager   = contextManager;

                SetRuntimeHanlders(evaluatorRuntime, clock);
            }

            Task evaluatorTask = Task.Run(new Action(clock.Run));

            evaluatorTask.Wait();
        }