2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.common.actor;
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13 * Actor with its behaviour metered. Metering is enabled by configuration.
15 public abstract class AbstractUntypedActorWithMetering extends AbstractUntypedActor {
16 // this is used in the metric name. Some transient actors do not have defined names
17 private String actorNameOverride;
19 @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Akka class design")
20 public AbstractUntypedActorWithMetering() {
21 if (isMetricsCaptureEnabled()) {
22 getContext().become(new MeteringBehavior(this));
26 @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Akka class design")
27 public AbstractUntypedActorWithMetering(final String actorNameOverride) {
28 this.actorNameOverride = actorNameOverride;
29 if (isMetricsCaptureEnabled()) {
30 getContext().become(new MeteringBehavior(this));
34 private boolean isMetricsCaptureEnabled() {
35 return new CommonConfig(getContext().system().settings().config()).isMetricCaptureEnabled();
38 public String getActorNameOverride() {
39 return actorNameOverride;