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); } } }); }
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)); }