Пример #1
0
        /// <summary>
        /// TBD
        /// </summary>
        public ClusterHeartbeatSender()
        {
            _cluster = Cluster.Get(Context.System);

            // the failureDetector is only updated by this actor, but read from other places
            _failureDetector = _cluster.FailureDetector;

            _selfHeartbeat = new Heartbeat(_cluster.SelfAddress);

            _state = new ClusterHeartbeatSenderState(
                ring: new HeartbeatNodeRing(
                    _cluster.SelfUniqueAddress,
                    ImmutableHashSet.Create(_cluster.SelfUniqueAddress),
                    ImmutableHashSet <UniqueAddress> .Empty,
                    _cluster.Settings.MonitoredByNrOfMembers),
                oldReceiversNowUnreachable: ImmutableHashSet <UniqueAddress> .Empty,
                failureDetector: _failureDetector);

            // start periodic heartbeat to other nodes in cluster
            _heartbeatTask = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(
                _cluster.Settings.PeriodicTasksInitialDelay.Max(_cluster.Settings.HeartbeatInterval),
                _cluster.Settings.HeartbeatInterval,
                Self,
                new HeartbeatTick(),
                Self);

            Initializing();
        }
Пример #2
0
        public RemoteWatcher(
            IFailureDetectorRegistry <Address> failureDetector,
            TimeSpan heartbeatInterval,
            TimeSpan unreachableReaperInterval,
            TimeSpan heartbeatExpectedResponseAfter
            )
        {
            _failureDetector = failureDetector;
            _heartbeatExpectedResponseAfter = heartbeatExpectedResponseAfter;
            var systemProvider = Context.System.AsInstanceOf <ExtendedActorSystem>().Provider as RemoteActorRefProvider;

            if (systemProvider != null)
            {
                _remoteProvider = systemProvider;
            }
            else
            {
                throw new ConfigurationException(String.Format("ActorSystem {0} needs to have a 'RemoteActorRefProvider' enabled in the configuration, current uses {1}", Context.System, Context.System.AsInstanceOf <ExtendedActorSystem>().Provider.GetType().FullName));
            }

            _heartbeatCancellable             = new CancellationTokenSource();
            _heartbeatTask                    = Context.System.Scheduler.Schedule(heartbeatInterval, heartbeatInterval, Self, HeartbeatTick.Instance, _heartbeatCancellable.Token);
            _failureDetectorReaperCancellable = new CancellationTokenSource();
            _failureDetectorReaperTask        = Context.System.Scheduler.Schedule(unreachableReaperInterval,
                                                                                  unreachableReaperInterval, Self, ReapUnreachableTick.Instance, _failureDetectorReaperCancellable.Token);
        }
Пример #3
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="ring">TBD</param>
 /// <param name="oldReceiversNowUnreachable">TBD</param>
 /// <param name="failureDetector">TBD</param>
 public ClusterHeartbeatSenderState(HeartbeatNodeRing ring, ImmutableHashSet <UniqueAddress> oldReceiversNowUnreachable, IFailureDetectorRegistry <Address> failureDetector)
 {
     Ring = ring;
     OldReceiversNowUnreachable = oldReceiversNowUnreachable;
     FailureDetector            = failureDetector;
     ActiveReceivers            = Ring.MyReceivers.Value.Union(OldReceiversNowUnreachable);
 }
Пример #4
0
 public ClusterRemoteWatcher(
     IFailureDetectorRegistry<Address> failureDetector,
     TimeSpan heartbeatInterval,
     TimeSpan unreachableReaperInterval,
     TimeSpan heartbeatExpectedResponseAfter) :base(failureDetector, heartbeatInterval, unreachableReaperInterval, heartbeatExpectedResponseAfter)
 {
     _cluster = Cluster.Get(Context.System);
 }
Пример #5
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="failureDetector">TBD</param>
 /// <param name="heartbeatInterval">TBD</param>
 /// <param name="unreachableReaperInterval">TBD</param>
 /// <param name="heartbeatExpectedResponseAfter">TBD</param>
 public ClusterRemoteWatcher(
     IFailureDetectorRegistry <Address> failureDetector,
     TimeSpan heartbeatInterval,
     TimeSpan unreachableReaperInterval,
     TimeSpan heartbeatExpectedResponseAfter) : base(failureDetector, heartbeatInterval, unreachableReaperInterval, heartbeatExpectedResponseAfter)
 {
     _cluster = Cluster.Get(Context.System);
 }
Пример #6
0
 public static Props Props(
     IFailureDetectorRegistry <Address> failureDetector,
     TimeSpan heartbeatInterval,
     TimeSpan unreachableReaperInterval,
     TimeSpan heartbeatExpectedResponseAfter)
 {
     return(Actor.Props.Create(() => new RemoteWatcher(failureDetector, heartbeatInterval, unreachableReaperInterval, heartbeatExpectedResponseAfter))
            .WithDeploy(Deploy.Local));
 }
Пример #7
0
 /// <summary>
 /// Factory method for <see cref="Akka.Remote.RemoteWatcher"/>
 /// </summary>
 public static Props Props(
     IFailureDetectorRegistry<Address> failureDetector,
     TimeSpan heartbeatInterval,
     TimeSpan unreachableReaperInterval,
     TimeSpan heartbeatExpectedResponseAfter)
 {
     return new Props(typeof(ClusterRemoteWatcher), new object[]
     {
         failureDetector, 
         heartbeatInterval, 
         unreachableReaperInterval, 
         heartbeatExpectedResponseAfter
     }).WithDeploy(Deploy.Local);
 }
Пример #8
0
 /// <summary>
 /// Factory method for <see cref="Akka.Remote.RemoteWatcher"/>
 /// </summary>
 /// <param name="failureDetector">TBD</param>
 /// <param name="heartbeatInterval">TBD</param>
 /// <param name="unreachableReaperInterval">TBD</param>
 /// <param name="heartbeatExpectedResponseAfter">TBD</param>
 public static Props Props(
     IFailureDetectorRegistry <Address> failureDetector,
     TimeSpan heartbeatInterval,
     TimeSpan unreachableReaperInterval,
     TimeSpan heartbeatExpectedResponseAfter)
 {
     return(new Props(typeof(ClusterRemoteWatcher), new object[]
     {
         failureDetector,
         heartbeatInterval,
         unreachableReaperInterval,
         heartbeatExpectedResponseAfter
     }).WithDeploy(Deploy.Local));
 }
Пример #9
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="failureDetector">TBD</param>
        /// <param name="heartbeatInterval">TBD</param>
        /// <param name="unreachableReaperInterval">TBD</param>
        /// <param name="heartbeatExpectedResponseAfter">TBD</param>
        /// <exception cref="ConfigurationException">
        /// This exception is thrown when the actor system does not have a <see cref="RemoteActorRefProvider"/> enabled in the configuration.
        /// </exception>
        public RemoteWatcher(
            IFailureDetectorRegistry <Address> failureDetector,
            TimeSpan heartbeatInterval,
            TimeSpan unreachableReaperInterval,
            TimeSpan heartbeatExpectedResponseAfter
            )
        {
            _failureDetector = failureDetector;
            _heartbeatExpectedResponseAfter = heartbeatExpectedResponseAfter;
            var systemProvider = Context.System.AsInstanceOf <ExtendedActorSystem>().Provider as IRemoteActorRefProvider;

            if (systemProvider != null)
            {
                _remoteProvider = systemProvider;
            }
            else
            {
                throw new ConfigurationException(
                          $"ActorSystem {Context.System} needs to have a 'RemoteActorRefProvider' enabled in the configuration, current uses {Context.System.AsInstanceOf<ExtendedActorSystem>().Provider.GetType().FullName}");
            }

            _heartbeatCancelable             = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(heartbeatInterval, heartbeatInterval, Self, HeartbeatTick.Instance, Self);
            _failureDetectorReaperCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(unreachableReaperInterval, unreachableReaperInterval, Self, ReapUnreachableTick.Instance, Self);
        }
Пример #10
0
 public ClusterHeartbeatSenderState Copy(HeartbeatNodeRing ring = null, ImmutableHashSet<UniqueAddress> unreachable = null, IFailureDetectorRegistry<Address> failureDetector = null)
 {
     return new ClusterHeartbeatSenderState(ring ?? Ring, unreachable ?? Unreachable, failureDetector ?? FailureDetector);
 }
Пример #11
0
 public ClusterHeartbeatSenderState(HeartbeatNodeRing ring, ImmutableHashSet<UniqueAddress> unreachable, IFailureDetectorRegistry<Address> failureDetector)
 {
     FailureDetector = failureDetector;
     Unreachable = unreachable;
     Ring = ring;
     ActiveReceivers = Ring.MyReceivers.Value.Union(Unreachable);
 }
Пример #12
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="ring">TBD</param>
 /// <param name="oldReceiversNowUnreachable">TBD</param>
 /// <param name="failureDetector">TBD</param>
 /// <returns>TBD</returns>
 public ClusterHeartbeatSenderState Copy(HeartbeatNodeRing ring = null, ImmutableHashSet <UniqueAddress> oldReceiversNowUnreachable = null, IFailureDetectorRegistry <Address> failureDetector = null)
 {
     return(new ClusterHeartbeatSenderState(ring ?? Ring, oldReceiversNowUnreachable ?? OldReceiversNowUnreachable, failureDetector ?? FailureDetector));
 }
Пример #13
0
        public RemoteWatcher(
            IFailureDetectorRegistry<Address> failureDetector,
            TimeSpan heartbeatInterval,
            TimeSpan unreachableReaperInterval,
            TimeSpan heartbeatExpectedResponseAfter
            )
        {
            _failureDetector = failureDetector;
            _heartbeatExpectedResponseAfter = heartbeatExpectedResponseAfter;
            var systemProvider = Context.System.AsInstanceOf<ExtendedActorSystem>().Provider as RemoteActorRefProvider;
            if (systemProvider != null) _remoteProvider = systemProvider;
            else throw new ConfigurationException(String.Format("ActorSystem {0} needs to have a 'RemoteActorRefProvider' enabled in the configuration, current uses {1}", Context.System, Context.System.AsInstanceOf<ExtendedActorSystem>().Provider.GetType().FullName));

            _heartbeatCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(heartbeatInterval, heartbeatInterval, Self, HeartbeatTick.Instance, Self);
            _failureDetectorReaperCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(unreachableReaperInterval, unreachableReaperInterval, Self, ReapUnreachableTick.Instance, Self);
        }