Provide access to known shard types #23912 (#23913)

* Provide access to known shard types #23912

* applied format
This commit is contained in:
danischroeter 2017-11-11 00:25:33 +01:00 committed by Konrad `ktoso` Malawski
parent ad33b343cc
commit e7bbbdf8ed
2 changed files with 18 additions and 0 deletions

View file

@ -6,6 +6,7 @@ package akka.cluster.sharding
import java.net.URLEncoder
import java.util.Optional
import java.util.concurrent.ConcurrentHashMap
import scala.concurrent.Await
import akka.actor.Actor
import akka.actor.ActorRef
@ -27,10 +28,15 @@ import akka.pattern.ask
import akka.dispatch.Dispatchers
import akka.cluster.ddata.ReplicatorSettings
import akka.cluster.ddata.Replicator
import scala.util.control.NonFatal
import akka.actor.Status
import akka.cluster.ClusterSettings
import akka.cluster.ClusterSettings.DataCenter
import akka.stream.{ Inlet, Outlet }
import scala.collection.immutable
import scala.collection.JavaConverters._
/**
* This extension provides sharding functionality of actors in a cluster.
@ -445,6 +451,16 @@ class ClusterSharding(system: ExtendedActorSystem) extends Extension {
}
/**
* Scala API: get all currently defined sharding type names.
*/
def shardTypeNames: immutable.Set[String] = regions.keySet().asScala.toSet
/**
* Java API: get all currently defined sharding type names.
*/
def getShardTypeNames: java.util.Set[String] = regions.keySet()
/**
* Retrieve the actor reference of the [[ShardRegion]] actor responsible for the named entity type.
* The entity type must be registered with the [[#start]] or [[#startProxy]] method before it

View file

@ -464,6 +464,8 @@ the identifiers of the shards running in a Region and what entities are alive fo
a `ShardRegion.ClusterShardingStats` containing the identifiers of the shards running in each region and a count
of entities that are alive in each shard.
The type names of all started shards can be aquired via @scala[`ClusterSharding.shardTypeNames`] @java[`ClusterSharding.getShardTypeNames`].
The purpose of these messages is testing and monitoring, they are not provided to give access to
directly sending messages to the individual entities.