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;
/**
* The information is reported to {@link org.opendaylight.controller.cluster.reporting.MetricsReporter}
*/
public class MeteringBehavior implements Procedure<Object> {
+ 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;
*
* @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;
init(actorName);
}
- public MeteringBehavior(UntypedActor actor){
+ public MeteringBehavior(final UntypedActor actor) {
Preconditions.checkArgument(actor != null, "actor must not be null");
this.meteredActor = actor;
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();
* @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 =
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();