Cluster heartbeat timings (#26757)

* Serializer for Heartbeat and HeartbeatRsp that includes sendTime and sequenceNr

A future release will be required to use the serialiser once there has
been a release with this PR so that old nodes can deserialise the new
message.

* Cross DC heartbeating sequenceNr and sendTime
This commit is contained in:
Christopher Batey 2019-07-04 14:21:24 +01:00 committed by GitHub
parent f9d76aa030
commit 7c94367d13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 1744 additions and 100 deletions

View file

@ -9,11 +9,13 @@ import akka.actor.{ ActorSystem, Address, ExtendedActorSystem }
import akka.cluster.InternalClusterAction.CompatibleConfig
import akka.cluster.routing.{ ClusterRouterPool, ClusterRouterPoolSettings }
import akka.routing.RoundRobinPool
import akka.cluster.protobuf.msg.{ ClusterMessages => cm }
import collection.immutable.SortedSet
import akka.testkit.{ AkkaSpec, TestKit }
import com.github.ghik.silencer.silent
import com.typesafe.config.ConfigFactory
@silent
class ClusterMessageSerializerSpec extends AkkaSpec("akka.actor.provider = cluster") {
@ -59,8 +61,8 @@ class ClusterMessageSerializerSpec extends AkkaSpec("akka.actor.provider = clust
checkSerialization(InternalClusterAction.InitJoin(ConfigFactory.empty))
checkSerialization(InternalClusterAction.InitJoinAck(address, CompatibleConfig(ConfigFactory.empty)))
checkSerialization(InternalClusterAction.InitJoinNack(address))
checkSerialization(ClusterHeartbeatSender.Heartbeat(address))
checkSerialization(ClusterHeartbeatSender.HeartbeatRsp(uniqueAddress))
checkSerialization(ClusterHeartbeatSender.Heartbeat(address, -1, -1))
checkSerialization(ClusterHeartbeatSender.HeartbeatRsp(uniqueAddress, -1, -1))
checkSerialization(InternalClusterAction.ExitingConfirmed(uniqueAddress))
val node1 = VectorClock.Node("node1")
@ -168,6 +170,47 @@ class ClusterMessageSerializerSpec extends AkkaSpec("akka.actor.provider = clust
join.roles should be(Set(ClusterSettings.DcRolePrefix + "default"))
}
}
"Rolling upgrades for heart beat message changes in 2.5.23" must {
// FIXME, add issue for serializing this as the new message type
"serialize heart beats as Address to support versions prior or 2.5.23" in {
serializer.manifest(ClusterHeartbeatSender.Heartbeat(a1.address, -1, -1)) should ===(
ClusterMessageSerializer.HeartBeatManifestPre2523)
}
"serialize heart beat responses as UniqueAddress to support versions prior to 2.5.23" in {
serializer.manifest(ClusterHeartbeatSender.HeartbeatRsp(a1.uniqueAddress, -1, -1)) should ===(
ClusterMessageSerializer.HeartBeatRspManifest2523)
}
"be able to deserialize HeartBeat protobuf message" in {
val hbProtobuf = cm.Heartbeat
.newBuilder()
.setFrom(serializer.addressToProto(a1.address))
.setSequenceNr(1)
.setCreationTime(2)
.build()
.toByteArray
serializer.fromBinary(hbProtobuf, ClusterMessageSerializer.HeartBeatManifest) should ===(
ClusterHeartbeatSender.Heartbeat(a1.address, 1, 2))
}
"be able to deserialize HeartBeatRsp probuf message" in {
val hbrProtobuf = cm.HeartBeatResponse
.newBuilder()
.setFrom(serializer.uniqueAddressToProto(a1.uniqueAddress))
.setSequenceNr(1)
.setCreationTime(2)
.build()
.toByteArray
serializer.fromBinary(hbrProtobuf, ClusterMessageSerializer.HeartBeatRspManifest) should ===(
ClusterHeartbeatSender.HeartbeatRsp(a1.uniqueAddress, 1, 2))
}
}
"Cluster router pool" must {
"be serializable with no role" in {
checkSerialization(