Bump versions 9.0.4-SNAPSHOT
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / common / actor / AbstractUntypedActorWithMetering.java
index 5497f93c4371a2c044bdaf05266e40656b4ff50e..d20ceb525224a2e91844d4e1be7f5dab140adcd6 100644 (file)
@@ -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;
     }
 }