Assigning names to various threads
- specify nearby logger when possible
Change-Id: Ia8925ab1459c4d1da922becd0e201388d44d4294
diff --git a/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java b/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java
index 358fa75..870ea06 100644
--- a/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java
+++ b/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java
@@ -30,11 +30,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.util.concurrent.Executors.newScheduledThreadPool;
+import static org.onlab.util.Tools.groupedThreads;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
-import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
@@ -58,7 +60,8 @@
private DeviceConfiguration config;
private final Lock statusLock = new ReentrantLock();
private volatile Status populationStatus;
- private ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
+ private ScheduledExecutorService executorService
+ = newScheduledThreadPool(1, groupedThreads("RoutingHandler", "retry-%d", log));
/**
* Represents the default routing population status.
diff --git a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index c115704..fce63fe 100644
--- a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -102,6 +102,7 @@
import java.util.concurrent.TimeUnit;
import static com.google.common.base.Preconditions.checkState;
+import static org.onlab.util.Tools.groupedThreads;
/**
@@ -178,12 +179,12 @@
private final InternalCordConfigListener cordConfigListener = new InternalCordConfigListener();
private ScheduledExecutorService executorService = Executors
- .newScheduledThreadPool(1);
+ .newScheduledThreadPool(1, groupedThreads("SegmentRoutingManager", "event-%d", log));
@SuppressWarnings("unused")
private static ScheduledFuture<?> eventHandlerFuture = null;
@SuppressWarnings("rawtypes")
- private ConcurrentLinkedQueue<Event> eventQueue = new ConcurrentLinkedQueue<Event>();
+ private ConcurrentLinkedQueue<Event> eventQueue = new ConcurrentLinkedQueue<>();
private Map<DeviceId, DefaultGroupHandler> groupHandlerMap =
new ConcurrentHashMap<>();
/**
@@ -712,7 +713,7 @@
} else if (event.type() == DeviceEvent.Type.PORT_ADDED ||
event.type() == DeviceEvent.Type.PORT_UPDATED) {
log.info("** PORT ADDED OR UPDATED {}/{} -> {}",
- (Device) event.subject(),
+ event.subject(),
((DeviceEvent) event).port(),
event.type());
/* XXX create method for single port filtering rules