Beispiel #1
0
 /// <summary>
 /// Checks if the IAllocatedEvaluator is for master
 /// </summary>
 /// <param name="evaluator"></param>
 /// <returns></returns>
 internal bool IsEvaluatorForMaster(IAllocatedEvaluator evaluator)
 {
     return evaluator.EvaluatorBatchId.StartsWith(MasterBatchId);
 }
Beispiel #2
0
 /// <summary>
 /// Add master evaluator
 /// </summary>
 /// <param name="evaluator">Evaluator to add</param>
 internal void AddMasterEvaluator(IAllocatedEvaluator evaluator)
 {
     SetMasterEvaluatorId(evaluator.Id);
     _allocatedEvaluatorIds.Add(evaluator.Id);
 }
Beispiel #3
0
        /// <summary>
        /// Add an Evaluator id to _allocatedEvaluators.
        /// If the IAllocatedEvaluator is for master, set master Evaluator id
        /// IMRUSystemException will be thrown in the following cases:
        ///   The Evaluator Id is already in the allocated Evaluator collection
        ///   The added IAllocatedEvaluator is the last one expected, and master Evaluator is still not added yet
        ///   The number of AllocatedEvaluators has reached the total expected Evaluators
        /// </summary>
        /// <param name="evaluator"></param>
        internal void AddAllocatedEvaluator(IAllocatedEvaluator evaluator)
        {
            if (IsAllocatedEvaluator(evaluator.Id))
            {
                string msg = string.Format("The allocated evaluator {0} already exists.", evaluator.Id);
                Exceptions.Throw(new IMRUSystemException(msg), Logger);
            }

            if (IsEvaluatorForMaster(evaluator))
            {
                SetMasterEvaluatorId(evaluator.Id);
            }

            if (NumberOfAllocatedEvaluators >= _totalExpectedEvaluators)
            {
                string msg = string.Format("Trying to add an additional Evaluator {0}, but the total expected Evaluator number {1} has been reached.", evaluator.Id, _totalExpectedEvaluators);
                Exceptions.Throw(new IMRUSystemException(msg), Logger);
            }
            
            _allocatedEvaluatorIds.Add(evaluator.Id);

            if (_masterEvaluatorId == null && NumberOfAllocatedEvaluators == _totalExpectedEvaluators)
            {
                string msg = string.Format("Added the last Evaluator {0} but master Evaluator is not added yet.", evaluator.Id);
                Exceptions.Throw(new IMRUSystemException(msg), Logger);
            }
        }
Beispiel #4
0
 public virtual void OnNext(IAllocatedEvaluator value)
 {
     value.SubmitContext(ContextConfiguration.ConfigurationModule
                         .Set(ContextConfiguration.Identifier, ContextId)
                         .Build());
 }