Exemplo n.º 1
0
        /// <summary>
        /// IAllocatedEvaluator handler. It will take the following action based on the system state:
        /// Case WaitingForEvaluator
        ///    Add Evaluator to the Evaluator Manager
        ///    submit Context and Services
        /// Case Fail
        ///    Do nothing. This is because the code that sets system Fail has executed FailedAction. It has shut down all the allocated evaluators/contexts.
        ///    If a new IAllocatedEvaluator comes after it, we should not submit anything so that the evaluator is returned.
        /// Other cases - not expected
        /// </summary>
        /// <param name="allocatedEvaluator">The allocated evaluator</param>
        public void OnNext(IAllocatedEvaluator allocatedEvaluator)
        {
            Logger.Log(Level.Info, "AllocatedEvaluator memory [{0}], systemState {1}.", allocatedEvaluator.GetEvaluatorDescriptor().Memory, _systemState.CurrentState);
            lock (_lock)
            {
                using (Logger.LogFunction("IMRUDriver::IAllocatedEvaluator"))
                {
                    switch (_systemState.CurrentState)
                    {
                    case SystemState.WaitingForEvaluator:
                        if (!_evaluatorManager.IsMasterEvaluatorAllocated())
                        {
                            _evaluatorManager.AddMasterEvaluator(allocatedEvaluator);
                            _evaluatorManager.RequestMapEvaluators(_totalMappers);
                        }
                        else
                        {
                            _evaluatorManager.AddAllocatedEvaluator(allocatedEvaluator);
                        }
                        SubmitContextAndService(allocatedEvaluator);
                        break;

                    case SystemState.Fail:
                        Logger.Log(Level.Info,
                                   "Receiving IAllocatedEvaluator event, but system is in FAIL state, ignore it.");
                        allocatedEvaluator.Dispose();
                        break;

                    default:
                        UnexpectedState(allocatedEvaluator.Id, "IAllocatedEvaluator");
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void OnNext(IAllocatedEvaluator eval)
 {
     Logger.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received evaluator. Runtime Name: {0}.", eval.GetEvaluatorDescriptor().RuntimeName));
     eval.Dispose();
 }
 public void OnNext(IAllocatedEvaluator allocatedEvaluator)
 {
     Logger.Log(Level.Info, "Trigger {0} and close {1}", _countdownEvent, allocatedEvaluator.Id);
     _countdownEvent.Signal();
     allocatedEvaluator.Dispose();
 }