enable serializer for ShardRegionStats, #25348

This commit is contained in:
Patrik Nordwall 2019-03-19 15:12:13 +01:00 committed by Johan Andrén
parent dffd5da3a4
commit 157ef9929d
4 changed files with 22 additions and 4 deletions

View file

@ -76,9 +76,10 @@ private[akka] object Shard {
@SerialVersionUID(1L) final case class CurrentShardState(shardId: ShardRegion.ShardId, entityIds: Set[EntityId])
@SerialVersionUID(1L) case object GetShardStats extends ShardQuery
@SerialVersionUID(1L) case object GetShardStats extends ShardQuery with ClusterShardingSerializable
@SerialVersionUID(1L) final case class ShardStats(shardId: ShardRegion.ShardId, entityCount: Int)
extends ClusterShardingSerializable
object State {
val Empty = State()

View file

@ -14,12 +14,12 @@ import akka.cluster.Cluster
import akka.cluster.ClusterEvent._
import akka.cluster.Member
import akka.cluster.MemberStatus
import scala.collection.immutable
import scala.concurrent.duration._
import scala.concurrent.Future
import scala.reflect.ClassTag
import scala.concurrent.Promise
import akka.Done
import akka.annotation.InternalApi
import akka.cluster.ClusterSettings
@ -283,14 +283,15 @@ object ShardRegion {
*
* For the statistics for the entire cluster, see [[GetClusterShardingStats$]].
*/
@SerialVersionUID(1L) case object GetShardRegionStats extends ShardRegionQuery
@SerialVersionUID(1L) case object GetShardRegionStats extends ShardRegionQuery with ClusterShardingSerializable
/**
* Java API:
*/
def getRegionStatsInstance = GetShardRegionStats
@SerialVersionUID(1L) final case class ShardRegionStats(stats: Map[ShardId, Int]) {
@SerialVersionUID(1L) final case class ShardRegionStats(stats: Map[ShardId, Int])
extends ClusterShardingSerializable {
/**
* Java API

View file

@ -9,6 +9,7 @@ import akka.testkit.AkkaSpec
import akka.actor.Props
import akka.cluster.sharding.ShardRegion.ShardId
import akka.cluster.sharding.{ Shard, ShardCoordinator, ShardRegion }
import akka.serialization.SerializationExtension
class ClusterShardingMessageSerializerSpec extends AkkaSpec {
import ShardCoordinator.Internal._
@ -22,6 +23,7 @@ class ClusterShardingMessageSerializerSpec extends AkkaSpec {
val regionProxy2 = system.actorOf(Props.empty, "regionProxy2")
def checkSerialization(obj: AnyRef): Unit = {
SerializationExtension(system).findSerializerFor(obj).identifier should ===(serializer.identifier)
val blob = serializer.toBinary(obj)
val ref = serializer.fromBinary(blob, serializer.manifest(obj))
ref should ===(obj)

View file

@ -71,5 +71,19 @@ This change required a two phase update where the data was duplicated to be comp
This means that you can't update from 2.5.13 directly to 2.5.17. You must first update to one of the intermediate
versions 2.5.14, 2.5.15, or 2.5.16.
### 2.5.22 ClusterSharding serializer for `ShardRegionStats`
Issue: [#25348](https://github.com/akka/akka/issues/25348)
Intentional change was done in 2.5.22.
Changed serializer for classes: `GetShardRegionStats`, `ShardRegionStats`, `GetShardStats`, `ShardStats`
This change required a two phase update where new serializer was introduced but not enabled in an earlier version.
* 2.5.18 - serializer was added but not enabled, `JavaSerializer` still used
* 2.5.22 - `ClusterShardingMessageSerializer` was enabled for these classes
This means that you can't update from 2.5.17 directly to 2.5.22. You must first update to one of the intermediate
versions 2.5.18, 2.5.19, 2.5.20 or 2.5.21.