X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fcommon%2Factor%2FQuarantinedMonitorActor.java;h=2ed5a24f535dda9a0171f889d9900e81d63311e7;hp=9cb592a4c7713f5d533870c92af38d0e0dfdf4e6;hb=a8349006607d36efd79fa58448cf8887c9fdbcf0;hpb=4e696d9795fe7eef40369c05c340d137394126f3 diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActor.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActor.java index 9cb592a4c7..2ed5a24f53 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActor.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActor.java @@ -10,11 +10,8 @@ package org.opendaylight.controller.cluster.common.actor; import akka.actor.Props; import akka.actor.UntypedActor; -import akka.japi.Creator; import akka.japi.Effect; -import akka.remote.AssociationErrorEvent; -import akka.remote.InvalidAssociation; -import akka.remote.RemotingLifecycleEvent; +import akka.remote.ThisActorSystemQuarantinedEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,12 +32,12 @@ public class QuarantinedMonitorActor extends UntypedActor { private final Effect callback; private boolean quarantined; - protected QuarantinedMonitorActor(Effect callback) { + protected QuarantinedMonitorActor(final Effect callback) { this.callback = callback; LOG.debug("Created QuarantinedMonitorActor"); - getContext().system().eventStream().subscribe(getSelf(), RemotingLifecycleEvent.class); + getContext().system().eventStream().subscribe(getSelf(), ThisActorSystemQuarantinedEvent.class); } @Override @@ -49,48 +46,26 @@ public class QuarantinedMonitorActor extends UntypedActor { } @Override - public void onReceive(Object message) throws Exception { + public void onReceive(final Object message) throws Exception { final String messageType = message.getClass().getSimpleName(); LOG.trace("onReceive {} {}", messageType, message); // check to see if we got quarantined by another node - if (quarantined) { return; } - // TODO: follow https://github.com/akka/akka/issues/18758 to see if Akka adds a named - // exception for quarantine detection - if (message instanceof AssociationErrorEvent) { - AssociationErrorEvent event = (AssociationErrorEvent) message; - Throwable cause = event.getCause(); - if (cause instanceof InvalidAssociation) { - Throwable cause2 = ((InvalidAssociation) cause).getCause(); - if (cause2.getMessage().contains("quarantined this system")) { - quarantined = true; - - LOG.warn("Got quarantined by {}", event.getRemoteAddress()); + if (message instanceof ThisActorSystemQuarantinedEvent) { + final ThisActorSystemQuarantinedEvent event = (ThisActorSystemQuarantinedEvent) message; + LOG.warn("Got quarantined by {}", event.remoteAddress()); + quarantined = true; - // execute the callback - callback.apply(); - } else { - LOG.debug("received AssociationErrorEvent, cause: InvalidAssociation", cause2); - } - } else { - LOG.debug("received AssociationErrorEvent", cause); - } + // execute the callback + callback.apply(); } } public static Props props(final Effect callback) { - return Props.create(new Creator() { - private static final long serialVersionUID = 1L; - - @Override - public QuarantinedMonitorActor create() throws Exception { - return new QuarantinedMonitorActor(callback); - } - }); + return Props.create(QuarantinedMonitorActor.class, callback); } - }