X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fcommon%2Factor%2FAbstractUntypedActorWithMetering.java;h=d20ceb525224a2e91844d4e1be7f5dab140adcd6;hb=HEAD;hp=5497f93c4371a2c044bdaf05266e40656b4ff50e;hpb=eeb7581f3d675fa499638e90f01e657c73c67c73;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedActorWithMetering.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedActorWithMetering.java index 5497f93c43..d20ceb5252 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedActorWithMetering.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedActorWithMetering.java @@ -7,18 +7,35 @@ */ package org.opendaylight.controller.cluster.common.actor; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * Actor with its behaviour metered. Metering is enabled by configuration. */ public abstract class AbstractUntypedActorWithMetering extends AbstractUntypedActor { + // this is used in the metric name. Some transient actors do not have defined names + private String actorNameOverride; + @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Akka class design") public AbstractUntypedActorWithMetering() { - if (isMetricsCaptureEnabled()) + if (isMetricsCaptureEnabled()) { + getContext().become(new MeteringBehavior(this)); + } + } + + @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Akka class design") + public AbstractUntypedActorWithMetering(final String actorNameOverride) { + this.actorNameOverride = actorNameOverride; + if (isMetricsCaptureEnabled()) { getContext().become(new MeteringBehavior(this)); + } + } + + private boolean isMetricsCaptureEnabled() { + return new CommonConfig(getContext().system().settings().config()).isMetricCaptureEnabled(); } - private boolean isMetricsCaptureEnabled(){ - CommonConfig config = new CommonConfig(getContext().system().settings().config()); - return config.isMetricCaptureEnabled(); + public String getActorNameOverride() { + return actorNameOverride; } }