Beispiel #1
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="persistentActor">TBD</param>
 /// <param name="mode">TBD</param>
 /// <param name="windowSize">TBD</param>
 /// <param name="maxOldWriters">TBD</param>
 /// <param name="debugEnabled">TBD</param>
 public ReplayFilter(IActorRef persistentActor, ReplayFilterMode mode, int windowSize, int maxOldWriters, bool debugEnabled)
 {
     PersistentActor = persistentActor;
     Mode            = mode;
     WindowSize      = windowSize;
     MaxOldWriters   = maxOldWriters;
     DebugEnabled    = debugEnabled;
 }
Beispiel #2
0
 public ReplayFilter(IActorRef persistentActor, ReplayFilterMode mode, int windowSize, int maxOldWriters, bool debugEnabled)
 {
     PersistentActor = persistentActor;
     Mode = mode;
     WindowSize = windowSize;
     MaxOldWriters = maxOldWriters;
     DebugEnabled = debugEnabled;
 }
Beispiel #3
0
 public static Props Props(IActorRef persistentActor, ReplayFilterMode mode, int windowSize, int maxOldWriters, bool debugEnabled)
 {
     if (windowSize <= 0)
         throw new ArgumentNullException("windowSize", "windowSize must be > 0");
     if (maxOldWriters <= 0)
         throw new ArgumentNullException("maxOldWriters", "maxOldWriters must be > 0");
     if (mode == ReplayFilterMode.Disabled)
         throw new ArgumentNullException("mode", "mode must not be Disabled");
     return Actor.Props.Create(() => new ReplayFilter(persistentActor, mode, windowSize, maxOldWriters, debugEnabled));
 }
Beispiel #4
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <exception cref="ArgumentException">TBD</exception>
        protected AsyncWriteJournal()
        {
            var extension = Persistence.Instance.Apply(Context.System);

            if (extension == null)
            {
                throw new ArgumentException("Couldn't initialize SyncWriteJournal instance, because associated Persistence extension has not been used in current actor system context.");
            }

            CanPublish = extension.Settings.Internal.PublishPluginCommands;
            var config = extension.ConfigFor(Self);

            _breaker = new CircuitBreaker(
                config.GetInt("circuit-breaker.max-failures"),
                config.GetTimeSpan("circuit-breaker.call-timeout"),
                config.GetTimeSpan("circuit-breaker.reset-timeout")
                );

            var replayFilterMode = config.GetString("replay-filter.mode").ToLower();

            switch (replayFilterMode)
            {
            case "off":
                _replayFilterMode = ReplayFilterMode.Disabled;
                break;

            case "repair-by-discard-old":
                _replayFilterMode = ReplayFilterMode.RepairByDiscardOld;
                break;

            case "fail":
                _replayFilterMode = ReplayFilterMode.Fail;
                break;

            case "warn":
                _replayFilterMode = ReplayFilterMode.Warn;
                break;

            default:
                throw new ArgumentException(string.Format("Invalid replay-filter.mode [{0}], supported values [off, repair-by-discard-old, fail, warn]", replayFilterMode));
            }
            _isReplayFilterEnabled     = _replayFilterMode != ReplayFilterMode.Disabled;
            _replayFilterWindowSize    = config.GetInt("replay-filter.window-size");
            _replayFilterMaxOldWriters = config.GetInt("replay-filter.max-old-writers");
            _replayDebugEnabled        = config.GetBoolean("replay-filter.debug");

            _resequencer = Context.System.ActorOf(Props.Create(() => new Resequencer()));
        }
Beispiel #5
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="persistentActor">TBD</param>
 /// <param name="mode">TBD</param>
 /// <param name="windowSize">TBD</param>
 /// <param name="maxOldWriters">TBD</param>
 /// <param name="debugEnabled">TBD</param>
 /// <exception cref="ArgumentNullException">
 /// This exception is thrown for a number of reasons. These include:
 /// <ul>
 /// <li>The specified <paramref name="windowSize"/> is less than or equal to zero.</li>
 /// <li>The specified <paramref name="maxOldWriters"/> is less than or equal to zero.</li>
 /// <li>The specified <paramref name="mode"/> is <see cref="ReplayFilterMode.Disabled"/>.</li>
 /// </ul>
 /// </exception>
 /// <returns>TBD</returns>
 public static Props Props(IActorRef persistentActor, ReplayFilterMode mode, int windowSize, int maxOldWriters, bool debugEnabled)
 {
     if (windowSize <= 0)
     {
         throw new ArgumentNullException(nameof(windowSize), "windowSize must be > 0");
     }
     if (maxOldWriters <= 0)
     {
         throw new ArgumentNullException(nameof(maxOldWriters), "maxOldWriters must be > 0");
     }
     if (mode == ReplayFilterMode.Disabled)
     {
         throw new ArgumentNullException(nameof(mode), "mode must not be Disabled");
     }
     return(Actor.Props.Create(() => new ReplayFilter(persistentActor, mode, windowSize, maxOldWriters, debugEnabled)));
 }
        protected AsyncWriteJournal()
        {
            var extension = Persistence.Instance.Apply(Context.System);
            if (extension == null)
            {
                throw new ArgumentException("Couldn't initialize SyncWriteJournal instance, because associated Persistence extension has not been used in current actor system context.");
            }

            CanPublish = extension.Settings.Internal.PublishPluginCommands;
            var config = extension.ConfigFor(Self);
            _breaker = new CircuitBreaker(
                config.GetInt("circuit-breaker.max-failures"),
                config.GetTimeSpan("circuit-breaker.call-timeout"),
                config.GetTimeSpan("circuit-breaker.reset-timeout")
                );

            var replayFilterMode = config.GetString("replay-filter.mode").ToLower();
            switch (replayFilterMode)
            {
                case "off":
                    _replayFilterMode = ReplayFilterMode.Disabled;
                    break;
                case "repair-by-discard-old":
                    _replayFilterMode = ReplayFilterMode.RepairByDiscardOld;
                    break;
                case "fail":
                    _replayFilterMode = ReplayFilterMode.Fail;
                    break;
                case "warn":
                    _replayFilterMode = ReplayFilterMode.Warn;
                    break;
                default:
                    throw new ArgumentException(string.Format("Invalid replay-filter.mode [{0}], supported values [off, repair-by-discard-old, fail, warn]", replayFilterMode));
            }
            _isReplayFilterEnabled = _replayFilterMode != ReplayFilterMode.Disabled;
            _replayFilterWindowSize = config.GetInt("replay-filter.window-size");
            _replayFilterMaxOldWriters = config.GetInt("replay-filter.max-old-writers");
            _replayDebugEnabled = config.GetBoolean("replay-filter.debug");

            _resequencer = Context.System.ActorOf(Props.Create(() => new Resequencer()));
        }