Use separate thread for ComponentsMonitor component checks
Change-Id: Iab9670b84640eb2ea1c2b6b58a45867e5d26634d
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ComponentsMonitor.java b/core/net/src/main/java/org/onosproject/cluster/impl/ComponentsMonitor.java
index 3dd5dda..5fed79e 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ComponentsMonitor.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ComponentsMonitor.java
@@ -24,7 +24,6 @@
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
-import org.onlab.util.SharedScheduledExecutors;
import org.onosproject.cluster.ClusterAdminService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -34,9 +33,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
+import static org.onlab.util.Tools.groupedThreads;
+
/**
* Monitors the system to make sure that all bundles and their components
* are properly activated and keeps the cluster node service appropriately
@@ -59,20 +62,22 @@
protected ClusterAdminService clusterAdminService;
private BundleContext bundleContext;
+
+ private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(
+ groupedThreads("components-monitor", "%d", log));
private ScheduledFuture<?> poller;
@Activate
protected void activate(ComponentContext context) {
bundleContext = context.getBundleContext();
- poller = SharedScheduledExecutors.getSingleThreadExecutor()
- .scheduleAtFixedRate(this::checkStartedState, PERIOD,
- PERIOD, TimeUnit.MILLISECONDS);
+ poller = executor.scheduleAtFixedRate(this::checkStartedState, PERIOD, PERIOD, TimeUnit.MILLISECONDS);
log.info("Started");
}
@Deactivate
protected void deactivate() {
poller.cancel(false);
+ executor.shutdownNow();
log.info("Stopped");
}