Hyunsun Moon
Committed by Gerrit Code Review

[Falcon] Fixed to avoid exception cases for compute node bootstrap

- Handled network config event with thread
- Considered ONOS restart situation, where node state in the store
is not the same as real state

Change-Id: Iec8c063317f1292052f299b680b7944821e60b7f
...@@ -264,13 +264,7 @@ public class CordVtn implements CordVtnService { ...@@ -264,13 +264,7 @@ public class CordVtn implements CordVtnService {
264 return; 264 return;
265 } 265 }
266 266
267 - NodeState state = getNodeState(node); 267 + NodeState state = checkNodeState(node);
268 - if (state == null) {
269 - return;
270 - } else if (state.equals(NodeState.INCOMPLETE)) {
271 - state = checkNodeState(node);
272 - }
273 -
274 state.process(this, node); 268 state.process(this, node);
275 } 269 }
276 270
......
...@@ -30,6 +30,10 @@ import org.onosproject.net.config.NetworkConfigService; ...@@ -30,6 +30,10 @@ import org.onosproject.net.config.NetworkConfigService;
30 import org.onosproject.net.config.basics.SubjectFactories; 30 import org.onosproject.net.config.basics.SubjectFactories;
31 import org.slf4j.Logger; 31 import org.slf4j.Logger;
32 32
33 +import java.util.concurrent.ExecutorService;
34 +
35 +import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
36 +import static org.onlab.util.Tools.groupedThreads;
33 import static org.slf4j.LoggerFactory.getLogger; 37 import static org.slf4j.LoggerFactory.getLogger;
34 38
35 /** 39 /**
...@@ -63,13 +67,15 @@ public class CordVtnConfigManager { ...@@ -63,13 +67,15 @@ public class CordVtnConfigManager {
63 }; 67 };
64 68
65 private final NetworkConfigListener configListener = new InternalConfigListener(); 69 private final NetworkConfigListener configListener = new InternalConfigListener();
66 -
67 private ApplicationId appId; 70 private ApplicationId appId;
71 + protected ExecutorService eventExecutor;
72 +
68 73
69 @Activate 74 @Activate
70 protected void active() { 75 protected void active() {
71 appId = coreService.getAppId(CordVtnService.CORDVTN_APP_ID); 76 appId = coreService.getAppId(CordVtnService.CORDVTN_APP_ID);
72 77
78 + eventExecutor = newSingleThreadScheduledExecutor(groupedThreads("onos/cordvtncfg", "event-handler"));
73 configService.addListener(configListener); 79 configService.addListener(configListener);
74 configRegistry.registerConfigFactory(configFactory); 80 configRegistry.registerConfigFactory(configFactory);
75 } 81 }
...@@ -78,6 +84,7 @@ public class CordVtnConfigManager { ...@@ -78,6 +84,7 @@ public class CordVtnConfigManager {
78 protected void deactivate() { 84 protected void deactivate() {
79 configRegistry.unregisterConfigFactory(configFactory); 85 configRegistry.unregisterConfigFactory(configFactory);
80 configService.removeListener(configListener); 86 configService.removeListener(configListener);
87 + eventExecutor.shutdown();
81 } 88 }
82 89
83 private void readConfiguration() { 90 private void readConfiguration() {
...@@ -106,11 +113,11 @@ public class CordVtnConfigManager { ...@@ -106,11 +113,11 @@ public class CordVtnConfigManager {
106 switch (event.type()) { 113 switch (event.type()) {
107 case CONFIG_ADDED: 114 case CONFIG_ADDED:
108 log.info("Network configuration added"); 115 log.info("Network configuration added");
109 - readConfiguration(); 116 + eventExecutor.execute(CordVtnConfigManager.this::readConfiguration);
110 break; 117 break;
111 case CONFIG_UPDATED: 118 case CONFIG_UPDATED:
112 log.info("Network configuration updated"); 119 log.info("Network configuration updated");
113 - readConfiguration(); 120 + eventExecutor.execute(CordVtnConfigManager.this::readConfiguration);
114 break; 121 break;
115 default: 122 default:
116 break; 123 break;
......