CORD-280 Fix the way to add and remove a node to consistent store
Change-Id: Iff55398d0a78acf3cdce8a5b43146f95b562d5a5
diff --git a/src/main/java/org/onosproject/cordvtn/CordVtn.java b/src/main/java/org/onosproject/cordvtn/CordVtn.java
index 2813205..4b28a14 100644
--- a/src/main/java/org/onosproject/cordvtn/CordVtn.java
+++ b/src/main/java/org/onosproject/cordvtn/CordVtn.java
@@ -146,9 +146,7 @@
public void addNode(OvsdbNode ovsdb) {
checkNotNull(ovsdb);
- if (!nodeStore.containsKey(ovsdb.deviceId())) {
- nodeStore.put(ovsdb.deviceId(), ovsdb);
- }
+ nodeStore.putIfAbsent(ovsdb.deviceId(), ovsdb);
if (isNodeConnected(ovsdb)) {
init(ovsdb);
@@ -161,10 +159,6 @@
public void deleteNode(OvsdbNode ovsdb) {
checkNotNull(ovsdb);
- if (!nodeStore.containsKey(ovsdb.deviceId())) {
- return;
- }
-
if (deviceService.getDevice(ovsdb.deviceId()) != null) {
if (deviceService.isAvailable(ovsdb.deviceId())) {
log.warn("Cannot delete connected node {}", ovsdb.host());