Fixed session deletion after CP disconnects (op_id is set to -1 for session deletions, might need to change)
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java
index f29b1a2..19ecb71 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java
@@ -352,6 +352,7 @@
Sets.newHashSet()
);
contexts.add(context.contextId());
+ CLIENT_CONTEXTS_INFO.put(clientInfo.clientId(), contexts);
}));
// FIXME why downlink is in session while uplink is not?
@@ -377,6 +378,7 @@
Sets.newHashSet()
);
contexts.add(context.contextId());
+ CLIENT_CONTEXTS_INFO.put(clientInfo.clientId(), contexts);
}));
}
} else if (commands.contains("indirect-forward")) {
@@ -567,9 +569,12 @@
return configureOutput;
}
- public Collection<Callable<Object>> deleteSessions(ClientIdentifier clientIdentifier) {
- Collection<Callable<Object>> tasks = new ArrayList<>();
+ public void deleteSessions(ClientIdentifier clientIdentifier) {
try {
+ if (!CLIENT_CONTEXTS_INFO.keySet().contains(clientIdentifier)) {
+ return;
+ }
+ Collection<Callable<Object>> tasks = new ArrayList<>();
FpcIdentity tenantId = CLIENT_INFO.get(clientIdentifier).tenantId();
CacheManager cacheManager = CacheManager.getInstance(tenantId);
@@ -650,10 +655,19 @@
}));
}
}
+ Executors.newWorkStealingPool().invokeAll(tasks).forEach(
+ future -> {
+ try {
+ future.get();
+ } catch (Exception e) {
+ log.error(ExceptionUtils.getFullStackTrace(e));
+ throw new RuntimeException(e);
+ }
+ }
+ );
} catch (Exception e) {
log.error(ExceptionUtils.getFullStackTrace(e));
}
- return tasks;
}
public Collection<Callable<Object>> deleteSession(
@@ -1174,7 +1188,6 @@
}
}
- CLIENT_INFO.remove(input.clientId());
deregisterClientOutput.clientId(input.clientId());
cpProviderService.getListener().deviceRemoved(input.clientId().toString());
@@ -1194,6 +1207,7 @@
.build());
dynamicConfigService.deleteNode(resourceVal);
+ CLIENT_INFO.remove(input.clientId());
}
} catch (Exception e) {
// if there is an exception respond with an error.
@@ -1311,3 +1325,4 @@
}
}
}
+
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java
index 23934b7..0f7dd6c 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java
@@ -324,11 +324,7 @@
.build()
);
dataNode.dataNodes().forEach(
- node -> {
- if (!dynamicConfigService.nodeExist(dataNode.resourceId())) {
- dynamicConfigService.createNode(dataNode.resourceId(), node);
- }
- }
+ node -> dynamicConfigService.createNode(dataNode.resourceId(), node)
);
}
@@ -346,11 +342,7 @@
.build()
);
dataNode.dataNodes().forEach(
- node -> {
- if (!dynamicConfigService.nodeExist(dataNode.resourceId())) {
- dynamicConfigService.updateNode(dataNode.resourceId(), node);
- }
- }
+ node -> dynamicConfigService.updateNode(dataNode.resourceId(), node)
);
}
diff --git a/scripts/get-topology.sh b/scripts/get-topology.sh
index 834cf8b..ec03527 100755
--- a/scripts/get-topology.sh
+++ b/scripts/get-topology.sh
@@ -9,7 +9,6 @@
echo ""
curl -i -s \
---header "Content-type: application/json" \
--request GET \
-u onos:rocks \
http://localhost:8181/onos/restconf/data/ietf-dmm-fpcagent:tenants/tenant=default/fpc-topology