Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / StatisticsPollingService.java
index 4c8a7f520d28be74b3f35bcaab0d2a4cf792c037..e1b8d98ad3cb84b3be75bde955614ea23bce2512 100644 (file)
@@ -16,12 +16,17 @@ import com.google.common.util.concurrent.Service;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.CancellationException;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.function.Supplier;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.openflowplugin.api.ConnectionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class StatisticsPollingService extends AbstractScheduledService {
+    private static final Logger LOG = LoggerFactory.getLogger(StatisticsPollingService.class);
     private static final long DEFAULT_STATS_TIMEOUT = 50000;
 
     private final TimeCounter counter;
@@ -30,10 +35,10 @@ public class StatisticsPollingService extends AbstractScheduledService {
     private final Supplier<ListenableFuture<Boolean>> gatheringSupplier;
     private final SettableFuture<Void> future = SettableFuture.create();
 
-    StatisticsPollingService(@Nonnull final TimeCounter counter,
+    StatisticsPollingService(@NonNull final TimeCounter counter,
                              final long pollingInterval,
                              final long maximumTimerDelay,
-                             @Nonnull final Supplier<ListenableFuture<Boolean>> gatheringSupplier) {
+                             @NonNull final Supplier<ListenableFuture<Boolean>> gatheringSupplier) {
         this.counter = counter;
         this.pollingInterval = pollingInterval;
         this.maximumTimerDelay = maximumTimerDelay;
@@ -59,18 +64,20 @@ public class StatisticsPollingService extends AbstractScheduledService {
 
         Futures.addCallback(gatheringSupplier.get(), new FutureCallback<Boolean>() {
             @Override
-            public void onSuccess(@Nonnull final Boolean result) {
+            public void onSuccess(final Boolean result) {
                 waitFuture.complete(result);
             }
 
             @Override
-            public void onFailure(@Nonnull final Throwable throwable) {
+            public void onFailure(final Throwable throwable) {
                 waitFuture.completeExceptionally(throwable);
             }
         }, MoreExecutors.directExecutor());
 
         try {
             waitFuture.get(statsTimeout, TimeUnit.MILLISECONDS);
+        } catch (InterruptedException | ExecutionException | TimeoutException e) {
+            LOG.warn("Exception occured while waiting for the stats collection.", e);
         } finally {
             counter.addTimeMark();
         }