protected DiscoveryService(ClusterDiscoverySettings settings)
        {
            this.Cluster  = Cluster.Get(Context.System);
            this.Log      = Context.GetLogger();
            this.settings = settings;
            this.Entry    = new MemberEntry(Context.System.Name, Cluster.SelfAddress, Cluster.SelfRoles);

            var retries = settings.JoinRetries;

            ReceiveAsync <Join>(async _ =>
            {
                retries--;
                try
                {
                    var joined = await TryJoinAsync();
                    if (!joined)
                    {
                        SendJoinSignal();
                    }
                }
                catch (Exception cause)
                {
                    if (retries > 0)
                    {
                        SendJoinSignal();
                    }
                    else
                    {
                        Log.Error(cause, "Failed to obtain a distributed lock for actor system [{0}] after {1} retries. Closing.", Context.System.Name, retries);
                        Context.Stop(Self);
                    }
                }
            });
        }
예제 #2
0
        protected DiscoveryService(ClusterDiscoverySettings settings)
        {
            this.Cluster  = Cluster.Get(Context.System);
            this.Log      = Context.GetLogger();
            this.settings = settings;
            this.Entry    = new MemberEntry(Context.System.Name, Cluster.SelfAddress, Cluster.SelfRoles);

            var retries = settings.JoinRetries;

            Receive <Init>(_ => SendJoinSignal());
            ReceiveAsync <Join>(async _ =>
            {
                retries--;
                try
                {
                    var joined = await TryJoinAsync();
                    if (!joined)
                    {
                        SendJoinSignal();
                    }
                }
                catch (Exception cause)
                {
                    if (retries > 0)
                    {
                        Log.Error(cause, "Failed to join actor system [{0}] to the cluster. Remaining retries: [{1}]", Context.System.Name, retries);
                        SendJoinSignal();
                    }
                    else
                    {
                        Log.Error(cause, "Failed to join actor system [{0}] to the cluster after {1} retries. Closing.", Context.System.Name, settings.JoinRetries);
                        Context.Stop(Self);
                    }
                }
            });
            Receive <ClusterEvent.MemberRemoved>(removed => StopOnClusterShutdown(removed.Member.Address));
        }
예제 #3
0
 /// <summary>
 /// Used for health checks. Triggers healt check heartbeat, marking current
 /// <paramref name="node"/> as alive.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 protected abstract Task MarkAsAliveAsync(MemberEntry node);
예제 #4
0
 /// <summary>
 /// Deregisters (potentially previously registered) <paramref name="node"/>
 /// from the external service. Used i.e. for graceful shutdown scenarios.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 protected abstract Task DeregisterNodeAsync(MemberEntry node);