X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardDataTreeNotificationPublisherActor.java;h=81023562801926fb0aa05c394afb9014c4be5240;hb=refs%2Fchanges%2F06%2F40306%2F2;hp=e4e7eb33e9d4b176a4bb87f3212d12eb1d9b11bc;hpb=ba87ed620f13823ee798fda4241a2c1db37e2f33;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java index e4e7eb33e9..8102356280 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java @@ -8,6 +8,8 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.Props; +import com.google.common.base.Stopwatch; +import java.util.concurrent.TimeUnit; import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; @@ -18,16 +20,39 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; * @author Thomas Pantelis */ public class ShardDataTreeNotificationPublisherActor extends AbstractUntypedActor { + private final Stopwatch timer = Stopwatch.createUnstarted(); + private final String name; + + private ShardDataTreeNotificationPublisherActor(String name) { + this.name = name; + } @Override protected void handleReceive(Object message) { if(message instanceof PublishNotifications) { - ((PublishNotifications)message).publish(); + PublishNotifications publisher = (PublishNotifications)message; + timer.start(); + + try { + publisher.publish(); + } finally { + long elapsedTime = timer.elapsed(TimeUnit.MILLISECONDS); + + if(elapsedTime >= ShardDataTreeNotificationPublisher.PUBLISH_DELAY_THRESHOLD_IN_MS) { + LOG.warn("{}: Generation of change events for {} took longer than expected. Elapsed time: {}", + publisher.logContext, name, timer); + } else { + LOG.debug("{}: Elapsed time for generation of change events for {}: {}", publisher.logContext, + name, timer); + } + + timer.reset(); + } } } - static Props props() { - return Props.create(ShardDataTreeNotificationPublisherActor.class); + static Props props(String notificationType) { + return Props.create(ShardDataTreeNotificationPublisherActor.class, notificationType); } static class PublishNotifications {