Class ShardRegion

  • All Implemented Interfaces:
    Actor, Timers

    public class ShardRegion
    extends java.lang.Object
    implements Actor, Timers
    INTERNAL API

    This actor creates children shard actors on demand that it is told to be responsible for. The shard actors in turn create entity actors on demand. It delegates messages targeted to other shards to the responsible ShardRegion actor on other nodes.

    See Also:
    ClusterSharding extension
    • Constructor Detail

      • ShardRegion

        public ShardRegion​(java.lang.String typeName,
                           scala.Option<scala.Function1<java.lang.String,​Props>> entityProps,
                           scala.Option<java.lang.String> dataCenter,
                           ClusterShardingSettings settings,
                           java.lang.String coordinatorPath,
                           scala.PartialFunction<java.lang.Object,​scala.Tuple2<java.lang.String,​java.lang.Object>> extractEntityId,
                           scala.Function1<java.lang.Object,​java.lang.String> extractShardId,
                           java.lang.Object handOffStopMessage,
                           scala.Option<RememberEntitiesProvider> rememberEntitiesProvider)
    • Method Detail

      • props

        public static Props props​(java.lang.String typeName,
                                  scala.Function1<java.lang.String,​Props> entityProps,
                                  ClusterShardingSettings settings,
                                  java.lang.String coordinatorPath,
                                  scala.PartialFunction<java.lang.Object,​scala.Tuple2<java.lang.String,​java.lang.Object>> extractEntityId,
                                  scala.Function1<java.lang.Object,​java.lang.String> extractShardId,
                                  java.lang.Object handOffStopMessage,
                                  scala.Option<RememberEntitiesProvider> rememberEntitiesProvider)
        INTERNAL API Factory method for the Props of the ShardRegion actor.
      • proxyProps

        public static Props proxyProps​(java.lang.String typeName,
                                       scala.Option<java.lang.String> dataCenter,
                                       ClusterShardingSettings settings,
                                       java.lang.String coordinatorPath,
                                       scala.PartialFunction<java.lang.Object,​scala.Tuple2<java.lang.String,​java.lang.Object>> extractEntityId,
                                       scala.Function1<java.lang.Object,​java.lang.String> extractShardId)
        INTERNAL API Factory method for the Props of the ShardRegion actor when using it in proxy only mode.
      • gracefulShutdownInstance

        public static ShardRegion.GracefulShutdown$ gracefulShutdownInstance()
        Java API: Send this message to the ShardRegion actor to handoff all shards that are hosted by the ShardRegion and then the ShardRegion actor will be stopped. You can watch it to know when it is completed.
      • handOffStopperProps

        public static Props handOffStopperProps​(java.lang.String shard,
                                                ActorRef replyTo,
                                                scala.collection.immutable.Set<ActorRef> entities,
                                                java.lang.Object stopMessage,
                                                scala.concurrent.duration.FiniteDuration handoffTimeout)
      • context

        public ActorContext context()
        Description copied from interface: Actor
        Scala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such as forward.

        WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!

        ActorContext is the Scala API. getContext returns a AbstractActor.ActorContext, which is the Java API of the actor context.

        Specified by:
        context in interface Actor
      • self

        public final ActorRef self()
        Description copied from interface: Actor
        The 'self' field holds the ActorRef for this actor.

        Can be used to send messages to itself:
         self ! message
         
        Specified by:
        self in interface Actor
      • akka$actor$Actor$_setter_$context_$eq

        protected void akka$actor$Actor$_setter_$context_$eq​(ActorContext x$1)
        Description copied from interface: Actor
        Scala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such as forward.

        WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!

        ActorContext is the Scala API. getContext returns a AbstractActor.ActorContext, which is the Java API of the actor context.

        Specified by:
        akka$actor$Actor$_setter_$context_$eq in interface Actor
      • akka$actor$Actor$_setter_$self_$eq

        protected final void akka$actor$Actor$_setter_$self_$eq​(ActorRef x$1)
        Description copied from interface: Actor
        The 'self' field holds the ActorRef for this actor.

        Can be used to send messages to itself:
         self ! message
         
        Specified by:
        akka$actor$Actor$_setter_$self_$eq in interface Actor
      • cluster

        public Cluster cluster()
      • ageOrdering

        public scala.math.Ordering<Member> ageOrdering()
      • membersByAge

        public scala.collection.immutable.SortedSet<Member> membersByAge()
      • membersByAge_$eq

        public void membersByAge_$eq​(scala.collection.immutable.SortedSet<Member> x$1)
      • regions

        public scala.collection.immutable.Map<ActorRef,​scala.collection.immutable.Set<java.lang.String>> regions()
      • regions_$eq

        public void regions_$eq​(scala.collection.immutable.Map<ActorRef,​scala.collection.immutable.Set<java.lang.String>> x$1)
      • regionByShard

        public scala.collection.immutable.Map<java.lang.String,​ActorRef> regionByShard()
      • regionByShard_$eq

        public void regionByShard_$eq​(scala.collection.immutable.Map<java.lang.String,​ActorRef> x$1)
      • shardBuffers_$eq

        public void shardBuffers_$eq​(MessageBufferMap<java.lang.String> x$1)
      • loggedFullBufferWarning

        public boolean loggedFullBufferWarning()
      • loggedFullBufferWarning_$eq

        public void loggedFullBufferWarning_$eq​(boolean x$1)
      • shards

        public scala.collection.immutable.Map<java.lang.String,​ActorRef> shards()
      • shards_$eq

        public void shards_$eq​(scala.collection.immutable.Map<java.lang.String,​ActorRef> x$1)
      • shardsByRef

        public scala.collection.immutable.Map<ActorRef,​java.lang.String> shardsByRef()
      • shardsByRef_$eq

        public void shardsByRef_$eq​(scala.collection.immutable.Map<ActorRef,​java.lang.String> x$1)
      • startingShards

        public scala.collection.immutable.Set<java.lang.String> startingShards()
      • startingShards_$eq

        public void startingShards_$eq​(scala.collection.immutable.Set<java.lang.String> x$1)
      • handingOff

        public scala.collection.immutable.Set<ActorRef> handingOff()
      • handingOff_$eq

        public void handingOff_$eq​(scala.collection.immutable.Set<ActorRef> x$1)
      • gracefulShutdownInProgress

        public boolean gracefulShutdownInProgress()
      • gracefulShutdownInProgress_$eq

        public void gracefulShutdownInProgress_$eq​(boolean x$1)
      • retryCount

        public int retryCount()
      • retryCount_$eq

        public void retryCount_$eq​(int x$1)
      • initRegistrationDelay

        public scala.concurrent.duration.FiniteDuration initRegistrationDelay()
      • nextRegistrationDelay

        public scala.concurrent.duration.FiniteDuration nextRegistrationDelay()
      • nextRegistrationDelay_$eq

        public void nextRegistrationDelay_$eq​(scala.concurrent.duration.FiniteDuration x$1)
      • gracefulShutdownProgress

        public scala.concurrent.Promise<Done> gracefulShutdownProgress()
      • preStart

        public void preStart()
        Description copied from interface: Actor
        User overridable callback.

        Is called when an Actor is started. Actors are automatically started asynchronously when created. Empty default implementation.
        Specified by:
        preStart in interface Actor
      • postStop

        public void postStop()
        Description copied from interface: Actor
        User overridable callback.

        Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.
        Specified by:
        postStop in interface Actor
      • matchingRole

        public boolean matchingRole​(Member member)
      • coordinatorSelection

        public scala.collection.immutable.List<ActorSelection> coordinatorSelection()
        When leaving the coordinator singleton is started rather quickly on next oldest node and therefore it is good to send the Register and GracefulShutdownReq to the likely locations of the coordinator.
      • coordinator

        public scala.Option<ActorRef> coordinator()
      • coordinator_$eq

        public void coordinator_$eq​(scala.Option<ActorRef> x$1)
      • changeMembers

        public void changeMembers​(scala.collection.immutable.SortedSet<Member> newMembers)
      • receive

        public scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> receive()
        Description copied from interface: Actor
        Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.
        Specified by:
        receive in interface Actor
      • receiveCoordinatorMessage

        public void receiveCoordinatorMessage​(akka.cluster.sharding.ShardCoordinator.Internal.CoordinatorMessage msg)
      • receiveTerminated

        public void receiveTerminated​(ActorRef ref)
      • replyToRegionStateQuery

        public void replyToRegionStateQuery​(ActorRef ref)
      • replyToRegionStatsQuery

        public void replyToRegionStatsQuery​(ActorRef ref)
      • queryShards

        public <T> scala.concurrent.Future<ShardingQueries.ShardsQueryResult<T>> queryShards​(scala.collection.immutable.Map<java.lang.String,​ActorRef> shards,
                                                                                             java.lang.Object msg,
                                                                                             scala.reflect.ClassTag<T> evidence$1)
        Query all or a subset of shards, e.g. unresponsive shards that initially timed out. If the number of shards are less than this.shards.size, this could be a retry. Returns a partitioned set of any shards that may have not replied within the timeout and shards that did reply, to provide retry on only that subset.

        Logs a warning if any of the group timed out.

        To check subset unresponsive:

         queryShards[T](shards.filterKeys(u.contains), shardQuery) 
      • startRegistration

        public void startRegistration()
      • scheduleNextRegistration

        public void scheduleNextRegistration()
      • finishRegistration

        public void finishRegistration()
      • register

        public void register()
      • registrationMessage

        public java.lang.Object registrationMessage()
      • tryRequestShardBufferHomes

        public void tryRequestShardBufferHomes()
        Send GetShardHome for all shards with buffered messages If coordinator is empty, nothing happens
      • initializeShard

        public void initializeShard​(java.lang.String id,
                                    ActorRef shard)
      • bufferMessage

        public void bufferMessage​(java.lang.String shardId,
                                  java.lang.Object msg,
                                  ActorRef snd)
      • deliverBufferedMessages

        public void deliverBufferedMessages​(java.lang.String shardId,
                                            ActorRef receiver)
      • deliverMessage

        public void deliverMessage​(java.lang.Object msg,
                                   ActorRef snd)
      • getShard

        public scala.Option<ActorRef> getShard​(java.lang.String id)
      • sendGracefulShutdownToCoordinatorIfInProgress

        public void sendGracefulShutdownToCoordinatorIfInProgress()