Skip to content

Commit

Permalink
feat: CommitLogActor stop itself when its shard id is defined as disa…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
nyamada-tis committed Oct 19, 2022
1 parent 2622d6b commit 5f8f982
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import akka.Done
import akka.actor.{ ActorLogging, ActorRef, ActorSystem, Props }
import akka.cluster.sharding.ShardRegion.HashCodeMessageExtractor
import akka.cluster.sharding.{ ClusterSharding, ClusterShardingSettings }
import akka.persistence.{ PersistentActor, RecoveryCompleted, SaveSnapshotFailure, SaveSnapshotSuccess, SnapshotOffer }
import akka.persistence.{
PersistentActor,
Recovery,
RecoveryCompleted,
SaveSnapshotFailure,
SaveSnapshotSuccess,
SnapshotOffer,
}
import akka.util.ByteString
import lerna.akka.entityreplication.{ ClusterReplicationSerializable, ClusterReplicationSettings }
import lerna.akka.entityreplication.model.{ NormalizedShardId, TypeName }
Expand Down Expand Up @@ -307,4 +314,19 @@ private[entityreplication] class CommitLogStoreActor(typeName: TypeName, setting
}
}

private def isDisabled: Boolean = settings.raftSettings.disabledShards.contains(shardId)

override def recovery: Recovery = {
if (isDisabled) {
Recovery.none
} else {
Recovery()
}
}

override def preStart(): Unit = {
if (isDisabled) {
context.stop(self)
}
}
}

0 comments on commit 5f8f982

Please sign in to comment.