Log changes to the ShardCoordinator ddata state (#27444)

The number of shards is configurable, in the order of magnitude of the number
of nodes in the cluster. Logging the ActorRef for each allocated shard is
useful to see on which node the shard is allocated.
This commit is contained in:
Arnout Engelen 2019-08-01 15:19:45 +02:00 committed by GitHub
parent 1fe2659203
commit 75de45d9ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -329,6 +329,8 @@ object ShardCoordinator {
rememberEntities: Boolean = false)
extends ClusterShardingSerializable {
override def toString = s"State($shards)"
def withRememberEntities(enabled: Boolean): State = {
if (enabled)
copy(rememberEntities = enabled)
@ -1049,6 +1051,7 @@ class DDataShardCoordinator(
({
case g @ GetSuccess(CoordinatorStateKey, _) =>
state = g.get(CoordinatorStateKey).value.withRememberEntities(settings.rememberEntities)
log.debug("Received initial coordinator state [{}]", state)
val newRemainingKeys = remainingKeys - CoordinatorStateKey
if (newRemainingKeys.isEmpty)
becomeWaitingForStateInitialized()
@ -1178,6 +1181,7 @@ class DDataShardCoordinator(
private def unbecomeAfterUpdate[E <: DomainEvent](evt: E, afterUpdateCallback: E => Unit): Unit = {
context.unbecome()
afterUpdateCallback(evt)
log.debug("New coordinator state after [{}]: [{}]", evt, state)
unstashGetShardHomeRequests()
unstashAll()
}
@ -1236,6 +1240,7 @@ class DDataShardCoordinator(
def sendCoordinatorStateUpdate(evt: DomainEvent) = {
val s = state.updated(evt)
log.debug("Publishing new coordinator state [{}]", state)
replicator ! Update(CoordinatorStateKey, LWWRegister(selfUniqueAddress, initEmptyState), writeMajority, Some(evt)) {
reg =>
reg.withValueOf(s)