Bump upstream SNAPSHOTS
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / common / actor / AbstractUntypedPersistentActorWithMetering.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.common.actor;
9
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11
12 /**
13  * Actor with its behaviour metered. Metering is enabled by configuration.
14  */
15 public abstract class AbstractUntypedPersistentActorWithMetering extends AbstractUntypedPersistentActor {
16     @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Akka class design")
17     public AbstractUntypedPersistentActorWithMetering() {
18         if (isMetricsCaptureEnabled()) {
19             getContext().become(new MeteringBehavior(this));
20         }
21     }
22
23     private boolean isMetricsCaptureEnabled() {
24         return new CommonConfig(getContext().system().settings().config()).isMetricCaptureEnabled();
25     }
26 }