/// <summary> /// TBD /// </summary> /// <param name="pubSubMediator">TBD</param> /// <param name="settings">TBD</param> /// <exception cref="ArgumentException">TBD</exception> public ClusterReceptionist(IActorRef pubSubMediator, ClusterReceptionistSettings settings) { _log = Context.GetLogger(); _pubSubMediator = pubSubMediator; _settings = settings; _cluster = Cluster.Get(Context.System); if (!(_settings.Role == null || _cluster.SelfRoles.Contains(_settings.Role))) { throw new ArgumentException($"This cluster member [{_cluster.SelfAddress}] does not have a role [{_settings.Role}]"); } _nodes = ImmutableSortedSet <Address> .Empty.WithComparer(RingOrdering.Instance); _virtualNodesFactor = 10; _consistentHash = ConsistentHash.Create(_nodes, _virtualNodesFactor); _clientInteractions = ImmutableDictionary <IActorRef, DeadlineFailureDetector> .Empty; _clientsPublished = ImmutableHashSet <IActorRef> .Empty; _subscribers = ImmutableList <IActorRef> .Empty; _checkDeadlinesTask = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable( _settings.FailureDetectionInterval, _settings.FailureDetectionInterval, Self, CheckDeadlines.Instance, Self); }
public ClusterReceptionist(IActorRef pubSubMediator, ClusterReceptionistSettings settings) { _pubSubMediator = pubSubMediator; _settings = settings; if (!(_settings.Role == null || _cluster.SelfRoles.Contains(_settings.Role))) { throw new ArgumentException(string.Format("This cluster member [{0}] does not have a role [{1}]", _cluster.SelfAddress, _settings.Role)); } _nodes = GetNodes(); _consistentHash = new ConsistentHash <Address>(_nodes, VirtualNodesFactor); }
private IActorRef CreateReceptionist(Config config) { if (IsTerminated) { return(_system.DeadLetters); } else { var name = config.GetString("name"); var dispatcher = config.GetString("use-dispatcher"); if (string.IsNullOrEmpty(dispatcher)) { dispatcher = Dispatchers.DefaultDispatcherId; } // important to use val mediator here to activate it outside of ClusterReceptionist constructor var mediator = PubSubMediator; return(_system.SystemActorOf(ClusterReceptionist.Props(mediator, ClusterReceptionistSettings.Create(config)).WithDispatcher(dispatcher), name)); } }
/// <summary> /// Factory method for <see cref="ClusterReceptionist"/> <see cref="Actor.Props"/>. /// </summary> public static Actor.Props Props(IActorRef mediator, ClusterReceptionistSettings settings) { return(Actor.Props.Create(() => new ClusterReceptionist(mediator, settings)).WithDeploy(Deploy.Local)); }