/// <summary>
            /// Initialize function. Sends integer array with value 1 to all mappers first time.
            /// In recovery case, restore the state and iterations from task state.
            /// </summary>
            /// <returns>Map input</returns>
            UpdateResult <int[], int[]> IUpdateFunction <int[], int[], int[]> .Initialize()
            {
                if (_taskState.Result != null)
                {
                    Restore(_taskState.Result);
                    _iterations = _taskState.Iterations;
                    return(UpdateResult <int[], int[]> .Done(_intArr));
                }

                if (_taskState.Input != null)
                {
                    Restore(_taskState.Input);
                    _iterations = _taskState.Iterations;
                    return(UpdateResult <int[], int[]> .AnotherRound(_intArr));
                }

                for (int i = 0; i < _dim; i++)
                {
                    _intArr[i] = 1;
                }
                return(UpdateResult <int[], int[]> .AnotherRound(_intArr));
            }
示例#2
0
        /// <summary>
        /// Update function
        /// </summary>
        /// <param name="input">Input containing sum of all mappers arrays</param>
        /// <returns>The Update Result</returns>
        UpdateResult <int[], int[]> IUpdateFunction <int[], int[], int[]> .Update(int[] input)
        {
            Logger.Log(Level.Info, string.Format("Received value {0}", input[0]));

            if (input[0] != (_iterations + 1) * _workers)
            {
                Exceptions.Throw(new Exception("Expected input to update functon not same as actual input"), Logger);
            }

            _iterations++;

            if (_iterations < _maxIters)
            {
                for (int i = 0; i < _dim; i++)
                {
                    _intArr[i] = _iterations + 1;
                }

                return(UpdateResult <int[], int[]> .AnotherRound(_intArr));
            }

            return(UpdateResult <int[], int[]> .Done(input));
        }
            /// <summary>
            /// Update function
            /// </summary>
            /// <param name="input">Input containing sum of all mappers arrays</param>
            /// <returns>The Update Result</returns>
            UpdateResult <int[], int[]> IUpdateFunction <int[], int[], int[]> .Update(int[] input)
            {
                Logger.Log(Level.Info, "Received value {0} in iterations {1}.", input[0], _iterations + 1);

                if (input[0] != (_iterations + 1) * _workers)
                {
                    throw new Exception("Expected input to update function not same as actual input");
                }

                _iterations++;

                if (_iterations < _maxIters)
                {
                    for (int i = 0; i < _dim; i++)
                    {
                        _intArr[i] = _iterations + 1;
                    }

                    SaveState(_intArr);
                    return(UpdateResult <int[], int[]> .AnotherRound(_intArr));
                }
                SaveResult(input);
                return(UpdateResult <int[], int[]> .Done(input));
            }
 /// <summary>
 /// Update function
 /// </summary>
 /// <param name="input">Input containing sum of all mappers</param>
 /// <returns>The Update Result with only result</returns>
 public UpdateResult <int, int> Update(int input)
 {
     return(UpdateResult <int, int> .Done(input));
 }