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%2FMeteringBehavior.java;h=36c35be30a4cc1c4438af53f7c2a558f4ad99ca8;hp=9ff185a61e27d61c335223d8b1150fa3738a41c6;hb=733a52ecd52c0319827f167724e188361b0eba5b;hpb=dd32d3d246ebad8b7c76afb93239a4462f329a6b diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteringBehavior.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteringBehavior.java index 9ff185a61e..36c35be30a 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteringBehavior.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteringBehavior.java @@ -12,6 +12,7 @@ import akka.japi.Procedure; import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.Timer; import com.google.common.base.Preconditions; +import com.google.common.base.Throwables; import org.opendaylight.controller.cluster.reporting.MetricsReporter; /** @@ -26,10 +27,11 @@ import org.opendaylight.controller.cluster.reporting.MetricsReporter; * The information is reported to {@link org.opendaylight.controller.cluster.reporting.MetricsReporter} */ public class MeteringBehavior implements Procedure { + public static final String DOMAIN = "org.opendaylight.controller.actor.metric"; private final UntypedActor meteredActor; - private final MetricRegistry METRICREGISTRY = MetricsReporter.getInstance().getMetricsRegistry(); + private final MetricRegistry METRICREGISTRY = MetricsReporter.getInstance(DOMAIN).getMetricsRegistry(); private final String MSG_PROCESSING_RATE = "msg-rate"; private String actorQualifiedName; @@ -39,7 +41,7 @@ public class MeteringBehavior implements Procedure { * * @param actor whose behaviour needs to be metered */ - public MeteringBehavior(AbstractUntypedActorWithMetering actor){ + public MeteringBehavior(final AbstractUntypedActorWithMetering actor) { Preconditions.checkArgument(actor != null, "actor must not be null"); this.meteredActor = actor; @@ -48,7 +50,7 @@ public class MeteringBehavior implements Procedure { init(actorName); } - public MeteringBehavior(UntypedActor actor){ + public MeteringBehavior(final UntypedActor actor) { Preconditions.checkArgument(actor != null, "actor must not be null"); this.meteredActor = actor; @@ -56,7 +58,7 @@ public class MeteringBehavior implements Procedure { init(actorName); } - private void init(String actorName){ + private void init(final String actorName) { actorQualifiedName = new StringBuilder(meteredActor.getSelf().path().parent().toStringWithoutAddress()). append("/").append(actorName).toString(); @@ -81,7 +83,7 @@ public class MeteringBehavior implements Procedure { * @throws Exception */ @Override - public void apply(Object message) throws Exception { + public void apply(final Object message) throws Exception { final String messageType = message.getClass().getSimpleName(); final String msgProcessingTimeByMsgType = @@ -93,7 +95,12 @@ public class MeteringBehavior implements Procedure { final Timer.Context context = msgProcessingTimer.time(); final Timer.Context contextByMsgType = msgProcessingTimerByMsgType.time(); - meteredActor.onReceive(message); + try { + meteredActor.onReceive(message); + } catch (Throwable t) { + Throwables.propagateIfPossible(t, Exception.class); + throw Throwables.propagate(t); + } //stop timers contextByMsgType.stop();