Beispiel #1
0
        /// <summary>
        /// Stops the recovery operation if all snapshots were received
        /// </summary>
        /// <param name="interest">The <see cref="MessageInterest"/> of the session which received the snapshot message</param>
        /// <param name="result">If the operation was successfully completed, it contains the results of the completed recovery</param>
        /// <returns>True if the recovery operation could be completed; False otherwise</returns>
        /// <exception cref="InvalidOperationException">The recovery operation is not running</exception>
        public bool TryComplete(MessageInterest interest, out RecoveryResult result)
        {
            result = null;
            if (!IsRunning)
            {
                ExecutionLog.LogError($"{_producer.Name}: trying to complete recovery which is not running.");
                return(false);
            }

            _snapshotReceivedSessions.Add(interest);
            if (IsRecoveryDone())
            {
                result    = RecoveryResult.ForSuccess(_requestId, _startTime, InterruptionTime);
                IsRunning = false;
                return(true);
            }

            if (HasTimedOut())
            {
                result    = RecoveryResult.ForTimeOut(_requestId, _startTime);
                IsRunning = false;
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Stops the the recovery operation if all snapshots were received
        /// </summary>
        /// <param name="interest">The <see cref="MessageInterest"/> of the session which received the snapshot message</param>
        /// <param name="result">If the operation was successfully completed, it contains the results of the completed recovery</param>
        /// <returns>True if the recovery operation could be completed; False otherwise</returns>
        /// <exception cref="InvalidOperationException">The recovery operation is not running</exception>
        public bool TryComplete(MessageInterest interest, out RecoveryResult result)
        {
            if (!IsRunning)
            {
                throw new InvalidOperationException("The recovery operation is not running");
            }

            result = null;
            _snapshotReceivedSessions.Add(interest);
            if (IsRecoveryDone())
            {
                result    = RecoveryResult.ForSuccess(_requestId, _startTime, _interruptionTime);
                IsRunning = false;
                return(true);
            }

            if (HasTimedOut())
            {
                result    = RecoveryResult.ForTimeOut(_requestId, _startTime);
                IsRunning = false;
                return(true);
            }
            return(false);
        }