harden DurableDataSpec, #22037

This commit is contained in:
Patrik Nordwall 2016-12-21 16:44:39 +01:00
parent eeda6cc2c5
commit 38a133ece0
3 changed files with 36 additions and 26 deletions

View file

@ -44,6 +44,7 @@ import akka.actor.ExtendedActorSystem
import akka.actor.SupervisorStrategy import akka.actor.SupervisorStrategy
import akka.actor.OneForOneStrategy import akka.actor.OneForOneStrategy
import akka.actor.ActorInitializationException import akka.actor.ActorInitializationException
import java.util.concurrent.TimeUnit
object ReplicatorSettings { object ReplicatorSettings {
@ -894,7 +895,12 @@ final class Replicator(settings: ReplicatorSettings) extends Actor with ActorLog
else normalReceive else normalReceive
val load: Receive = { val load: Receive = {
val startTime = System.nanoTime()
var count = 0
{
case LoadData(data) case LoadData(data)
count += data.size
data.foreach { data.foreach {
case (key, d) case (key, d)
val envelope = DataEnvelope(d) val envelope = DataEnvelope(d)
@ -906,6 +912,9 @@ final class Replicator(settings: ReplicatorSettings) extends Actor with ActorLog
} }
} }
case LoadAllCompleted case LoadAllCompleted
log.debug(
"Loading {} entries from durable store took {} ms",
count, TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime))
context.become(normalReceive) context.become(normalReceive)
self ! FlushChanges self ! FlushChanges
@ -919,6 +928,7 @@ final class Replicator(settings: ReplicatorSettings) extends Actor with ActorLog
// ignore gossip and replication when loading durable data // ignore gossip and replication when loading durable data
log.debug("ignoring message [{}] when loading durable data", m.getClass.getName) log.debug("ignoring message [{}] when loading durable data", m.getClass.getName)
} }
}
val normalReceive: Receive = { val normalReceive: Receive = {
case Get(key, consistency, req) receiveGet(key, consistency, req) case Get(key, consistency, req) receiveGet(key, consistency, req)

View file

@ -112,7 +112,7 @@ abstract class DurableDataSpec(multiNodeConfig: DurableDataSpecConfig)
runOn(first) { runOn(first) {
val r = newReplicator() val r = newReplicator()
within(5.seconds) { within(10.seconds) {
awaitAssert { awaitAssert {
r ! GetReplicaCount r ! GetReplicaCount
expectMsg(ReplicaCount(1)) expectMsg(ReplicaCount(1))
@ -158,7 +158,7 @@ abstract class DurableDataSpec(multiNodeConfig: DurableDataSpecConfig)
join(second, first) join(second, first)
val r = newReplicator() val r = newReplicator()
within(5.seconds) { within(10.seconds) {
awaitAssert { awaitAssert {
r ! GetReplicaCount r ! GetReplicaCount
expectMsg(ReplicaCount(2)) expectMsg(ReplicaCount(2))
@ -247,7 +247,7 @@ abstract class DurableDataSpec(multiNodeConfig: DurableDataSpecConfig)
new TestKit(sys1) with ImplicitSender { new TestKit(sys1) with ImplicitSender {
val r = newReplicator(sys1) val r = newReplicator(sys1)
within(5.seconds) { within(10.seconds) {
awaitAssert { awaitAssert {
r ! GetReplicaCount r ! GetReplicaCount
expectMsg(ReplicaCount(1)) expectMsg(ReplicaCount(1))