X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsamples%2Fclustering-test-app%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fclustering%2Fit%2Fprovider%2Fimpl%2FPublishNotificationsTask.java;h=043325fea285b2bbbf78db62c98e4545862683e9;hb=HEAD;hp=bd755d40c8b24fc87cb1ff9b608ca1b0970fb8c1;hpb=350d31783d2e7ebcaaa9cc48b572a4d1f2974650;p=controller.git diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PublishNotificationsTask.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PublishNotificationsTask.java index bd755d40c8..043325fea2 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PublishNotificationsTask.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PublishNotificationsTask.java @@ -5,24 +5,24 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider.impl; -import com.google.common.base.Preconditions; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.target.rev170215.IdSequence; import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.target.rev170215.IdSequenceBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PublishNotificationsTask implements Runnable { - +public final class PublishNotificationsTask implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(PublishNotificationsTask.class); - private static final int SECOND_AS_NANO = 1000000000; + private static final int SECOND_AS_NANO = 1_000_000_000; private final NotificationPublishService notificationPublishService; private final String notificationId; @@ -39,15 +39,13 @@ public class PublishNotificationsTask implements Runnable { public PublishNotificationsTask(final NotificationPublishService notificationPublishService, final String notificationId, final long secondsToTake, final long maxPerSecond) { - Preconditions.checkNotNull(notificationPublishService); - Preconditions.checkNotNull(notificationId); - Preconditions.checkArgument(secondsToTake > 0); - Preconditions.checkArgument(maxPerSecond > 0); - this.notificationPublishService = notificationPublishService; - this.notificationId = notificationId; - this.timeToTake = secondsToTake * SECOND_AS_NANO; - this.delay = SECOND_AS_NANO / maxPerSecond; + this.notificationPublishService = requireNonNull(notificationPublishService); + this.notificationId = requireNonNull(notificationId); + checkArgument(secondsToTake > 0); + timeToTake = secondsToTake * SECOND_AS_NANO; + checkArgument(maxPerSecond > 0); + delay = SECOND_AS_NANO / maxPerSecond; LOG.debug("Delay : {}", delay); } @@ -76,7 +74,7 @@ public class PublishNotificationsTask implements Runnable { LOG.debug("current {}, starttime: {}, timetotake: {}, current-start = {}", current, startTime, timeToTake, current - startTime); - if ((current - startTime) > timeToTake) { + if (current - startTime > timeToTake) { LOG.debug("Sequence number: {}", sequenceNumber); scheduledFuture.cancel(false); executor.shutdown();