Use dedicated executor for BGPCEP Stats 53/70653/3
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Mon, 9 Apr 2018 12:59:30 +0000 (14:59 +0200)
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Mon, 9 Apr 2018 14:47:22 +0000 (14:47 +0000)
BGPCEP-786
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
Change-Id: I85d227f237509e3646805258ebeb1c22ebb3a54b

bgp/openconfig-state/src/main/java/org/opendaylight/protocol/bgp/state/StateProviderImpl.java
pcep/topology/topology-stats/src/main/java/org/opendaylight/bgpcep/pcep/topology/stats/provider/TopologyStatsProviderImpl.java

index a387032498cb7fe0bd046fe72de6cb983568e083..c657f24491499f25a8587b1e71f6cbb37737ceb0 100644 (file)
@@ -9,16 +9,17 @@
 package org.opendaylight.protocol.bgp.state;
 
 import static java.util.Objects.requireNonNull;
+import static java.util.concurrent.TimeUnit.SECONDS;
 
-import io.netty.util.concurrent.GlobalEventExecutor;
-import io.netty.util.concurrent.ScheduledFuture;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TimerTask;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
 import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 import javax.annotation.concurrent.GuardedBy;
@@ -68,6 +69,7 @@ public final class StateProviderImpl implements TransactionChainListener, AutoCl
     private BindingTransactionChain transactionChain;
     @GuardedBy("this")
     private ScheduledFuture<?> scheduleTask;
+    private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
 
     public StateProviderImpl(@Nonnull final DataBroker dataBroker, final int timeout,
             @Nonnull final BGPTableTypeRegistryConsumer bgpTableTypeRegistry,
@@ -100,8 +102,7 @@ public final class StateProviderImpl implements TransactionChainListener, AutoCl
             }
         };
 
-        this.scheduleTask = GlobalEventExecutor.INSTANCE.scheduleAtFixedRate(task, 0, this.timeout,
-                TimeUnit.SECONDS);
+        this.scheduleTask = this.scheduler.scheduleAtFixedRate(task, 0, this.timeout, SECONDS);
     }
 
     private synchronized void updateBGPStats(final WriteTransaction wtx) {
@@ -151,6 +152,7 @@ public final class StateProviderImpl implements TransactionChainListener, AutoCl
             wTx.submit().get();
         }
         this.transactionChain.close();
+        this.scheduler.shutdown();
     }
 
     @Override
index 173691c02811dd5223f607a9428f12971c59267a..05791767492c09d47edc98c9e04b47f060cfff4b 100644 (file)
@@ -9,14 +9,15 @@
 package org.opendaylight.bgpcep.pcep.topology.stats.provider;
 
 import static java.util.Objects.requireNonNull;
+import static java.util.concurrent.TimeUnit.SECONDS;
 
-import io.netty.util.concurrent.GlobalEventExecutor;
-import io.netty.util.concurrent.ScheduledFuture;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.TimerTask;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
 import javax.annotation.Nonnull;
 import javax.annotation.concurrent.GuardedBy;
 import org.opendaylight.bgpcep.pcep.topology.spi.stats.TopologySessionStatsRegistry;
@@ -48,6 +49,7 @@ public final class TopologyStatsProviderImpl implements TransactionChainListener
     private final int timeout;
     private BindingTransactionChain transactionChain;
     private ScheduledFuture<?> scheduleTask;
+    private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
 
     public TopologyStatsProviderImpl(@Nonnull final DataBroker dataBroker, final int timeout) {
         this.dataBroker = requireNonNull(dataBroker);
@@ -64,8 +66,7 @@ public final class TopologyStatsProviderImpl implements TransactionChainListener
             }
         };
 
-        this.scheduleTask = GlobalEventExecutor.INSTANCE.scheduleAtFixedRate(task, 0, this.timeout,
-                TimeUnit.SECONDS);
+        this.scheduleTask = this.scheduler.scheduleAtFixedRate(task, 0, this.timeout, SECONDS);
     }
 
     private synchronized void updatePcepStats() {
@@ -93,6 +94,7 @@ public final class TopologyStatsProviderImpl implements TransactionChainListener
         wTx.submit().get();
         this.statsMap.clear();
         this.transactionChain.close();
+        this.scheduler.shutdown();
     }
 
     @Override