CORD-1071 Refactor VTN node service

Done
- Separated interface, implementation and store for node management
- Added unit tests for node manager and handler
- Offloaded more of the event handling off of the Atomix event thread

Todo
- Add REST interface for the node service

Change-Id: Ibf90d3a621013497cc891ca3086db6648f5d49df
diff --git a/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java b/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
index e8983c6..bd5e528 100644
--- a/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
@@ -268,23 +268,26 @@
 
         @Override
         public void event(ServiceNetworkEvent event) {
-            NodeId leader = leadershipService.getLeader(appId.name());
-            if (!Objects.equals(localNodeId, leader)) {
-                // do not allow to proceed without leadership
-                return;
-            }
+            eventExecutor.execute(() -> {
+                NodeId leader = leadershipService.getLeader(appId.name());
+                if (!Objects.equals(localNodeId, leader)) {
+                    // do not allow to proceed without leadership
+                    return;
+                }
+                handle(event);
+            });
+        }
 
+        private void handle(ServiceNetworkEvent event) {
             switch (event.type()) {
                 case SERVICE_PORT_CREATED:
                 case SERVICE_PORT_UPDATED:
                     log.debug("Processing service port {}", event.servicePort());
                     PortId portId = event.servicePort().id();
-                    eventExecutor.execute(() -> {
-                        Instance instance = getInstance(portId);
-                        if (instance != null) {
-                            addInstance(instance.host().location());
-                        }
-                    });
+                    Instance instance = getInstance(portId);
+                    if (instance != null) {
+                        addInstance(instance.host().location());
+                    }
                     break;
                 case SERVICE_PORT_REMOVED:
                 case SERVICE_NETWORK_CREATED: