VTN: offload more of the event handling off of the Atomix event thread.
Change-Id: Icd42fad7f4ae436b95b83acf9528720a06d03e71
diff --git a/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java b/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
index 8a8bc37..2e51c6a 100644
--- a/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
@@ -220,7 +220,7 @@
.withApplicationId(appId)
.build();
- nodeStore.addListener(nodeStoreListener);
+ nodeStore.addListener(nodeStoreListener, eventExecutor);
deviceService.addListener(deviceListener);
configService.addListener(configListener);
@@ -906,30 +906,30 @@
CordVtnNode newNode;
switch (event.type()) {
- case UPDATE:
- oldNode = event.oldValue().value();
- newNode = event.newValue().value();
+ case UPDATE:
+ oldNode = event.oldValue().value();
+ newNode = event.newValue().value();
- log.info("Reloaded {}", newNode.hostname());
- if (!newNode.equals(oldNode)) {
- log.debug("New node: {}", newNode);
- }
- // performs init procedure even if the node is not changed
- // for robustness since it's no harm to run init procedure
- // multiple times
- eventExecutor.execute(() -> initNode(newNode));
- break;
- case INSERT:
- newNode = event.newValue().value();
- log.info("Added {}", newNode.hostname());
- eventExecutor.execute(() -> initNode(newNode));
- break;
- case REMOVE:
- oldNode = event.oldValue().value();
- log.info("Removed {}", oldNode.hostname());
- break;
- default:
- break;
+ log.info("Reloaded {}", newNode.hostname());
+ if (!newNode.equals(oldNode)) {
+ log.debug("New node: {}", newNode);
+ }
+ // performs init procedure even if the node is not changed
+ // for robustness since it's no harm to run init procedure
+ // multiple times
+ initNode(newNode);
+ break;
+ case INSERT:
+ newNode = event.newValue().value();
+ log.info("Added {}", newNode.hostname());
+ initNode(newNode);
+ break;
+ case REMOVE:
+ oldNode = event.oldValue().value();
+ log.info("Removed {}", oldNode.hostname());
+ break;
+ default:
+ break;
}
}
}