Remove NextId from internal stores when the NextObj fails
Change-Id: I105d32ea3a2278254edd8746d41552c2c4a699fa
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
index 6b16c2b..967f83c 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
@@ -384,10 +384,11 @@
ObjectiveContext context = new DefaultObjectiveContext(
(objective) -> log.debug("addToHash port/label {} addedTo "
+ "NextObj {} on {}", portLabels, nextId, deviceId),
- (objective, error) ->
- log.warn("addToHash failed to add port/label {} to"
- + " NextObj {} on {}: {}", portLabels,
- nextId, deviceId, error));
+ (objective, error) -> {
+ log.warn("addToHash failed to add port/label {} to NextObj {} on {}: {}",
+ portLabels, nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObjective = nextObjBuilder.addToExisting(context);
flowObjectiveService.next(deviceId, nextObjective);
}
@@ -428,9 +429,11 @@
ObjectiveContext context = new DefaultObjectiveContext(
(objective) -> log.debug("port/label {} removedFrom NextObj"
+ " {} on {}", portLabels, nextId, deviceId),
- (objective, error) ->
- log.warn("port/label {} failed to removeFrom NextObj {} on "
- + "{}: {}", portLabels, nextId, deviceId, error));
+ (objective, error) -> {
+ log.warn("port/label {} failed to removeFrom NextObj {} on {}: {}",
+ portLabels, nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObjective = nextObjBuilder.removeFromExisting(context);
flowObjectiveService.next(deviceId, nextObjective);
}
@@ -710,10 +713,11 @@
(objective) -> log.debug("port {} successfully {} NextObj {} on {}",
port, (portUp) ? "addedTo" : "removedFrom",
nextId, deviceId),
- (objective, error) ->
- log.warn("port {} failed to {} NextObj {} on {}: {}",
- port, (portUp) ? "addTo" : "removeFrom",
- nextId, deviceId, error));
+ (objective, error) -> {
+ log.warn("port {} failed to {} NextObj {} on {}: {}",
+ port, (portUp) ? "addTo" : "removeFrom", nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObj = (portUp) ? nextObjBuilder.addToExisting(context)
: nextObjBuilder.removeFromExisting(context);
@@ -1017,10 +1021,11 @@
(objective) ->
log.debug("createGroupsFromDestinationSet installed "
+ "NextObj {} on {}", nextId, deviceId),
- (objective, error) ->
- log.warn("createGroupsFromDestinationSet failed to install"
- + " NextObj {} on {}: {}", nextId, deviceId, error)
- );
+ (objective, error) -> {
+ log.warn("createGroupsFromDestinationSet failed to install NextObj {} on {}: {}",
+ nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObj = nextObjBuilder.add(context);
log.debug(".. createGroupsFromDestinationSet: Submitted "
+ "next objective {} in device {}", nextId, deviceId);
@@ -1078,10 +1083,11 @@
(objective) ->
log.debug("createBroadcastGroupFromVlan installed "
+ "NextObj {} on {}", nextId, deviceId),
- (objective, error) ->
- log.warn("createBroadcastGroupFromVlan failed to install"
- + " NextObj {} on {}: {}", nextId, deviceId, error)
- );
+ (objective, error) -> {
+ log.warn("createBroadcastGroupFromVlan failed to install NextObj {} on {}: {}",
+ nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObj = nextObjBuilder.add(context);
flowObjectiveService.next(deviceId, nextObj);
log.debug("createBcastGroupFromVlan: Submitted next objective {} "
@@ -1129,10 +1135,11 @@
(objective) ->
log.debug("removeBroadcastGroupFromVlan removed "
+ "NextObj {} on {}", nextId, deviceId),
- (objective, error) ->
- log.warn("removeBroadcastGroupFromVlan failed to remove "
- + " NextObj {} on {}: {}", nextId, deviceId, error)
- );
+ (objective, error) -> {
+ log.warn("removeBroadcastGroupFromVlan failed to remove NextObj {} on {}: {}",
+ nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObj = nextObjBuilder.remove(context);
flowObjectiveService.next(deviceId, nextObj);
log.debug("removeBcastGroupFromVlan: Submited next objective {} in device {}",
@@ -1179,10 +1186,10 @@
(objective) ->
log.debug("createGroupFromPort installed "
+ "NextObj {} on {}", nextId, deviceId),
- (objective, error) ->
- log.warn("createGroupFromPort failed to install"
- + " NextObj {} on {}: {}", nextId, deviceId, error)
- );
+ (objective, error) -> {
+ log.warn("createGroupFromPort failed to install NextObj {} on {}: {}", nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObj = nextObjBuilder.add(context);
flowObjectiveService.next(deviceId, nextObj);
log.debug("createGroupFromPort: Submited next objective {} in device {} "
@@ -1221,9 +1228,11 @@
ObjectiveContext context = new DefaultObjectiveContext(
(objective) -> log.debug("removePortNextObjective removes NextObj {} on {}",
portNextObjId, deviceId),
- (objective, error) ->
- log.warn("removePortNextObjective failed to remove NextObj {} on {}: {}",
- portNextObjId, deviceId, error));
+ (objective, error) -> {
+ log.warn("removePortNextObjective failed to remove NextObj {} on {}: {}",
+ portNextObjId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObjective = nextObjBuilder.remove(context);
log.info("**removePortNextObjective: Submitted "
+ "next objective {} in device {}",
@@ -1254,9 +1263,10 @@
ObjectiveContext context = new DefaultObjectiveContext(
(objective) -> log.debug("RemoveGroup removes NextObj {} on {}",
objectiveId, deviceId),
- (objective, error) ->
- log.warn("RemoveGroup failed to remove NextObj {} on {}: {}",
- objectiveId, deviceId, error));
+ (objective, error) -> {
+ log.warn("RemoveGroup failed to remove NextObj {} on {}: {}", objectiveId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObjective = nextObjBuilder.remove(context);
log.info("**removeGroup: Submited "
+ "next objective {} in device {}",
@@ -1294,9 +1304,10 @@
(objective) ->
log.info("removeGroupFromPort installed "
+ "NextObj {} on {}", nextId, deviceId),
- (objective, error) ->
- log.warn("removeGroupFromPort failed to install"
- + " NextObj {} on {}: {}", nextId, deviceId, error)
+ (objective, error) -> {
+ log.warn("removeGroupFromPort failed to install NextObj {} on {}: {}", nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ }
);
NextObjective nextObj = nextObjBuilder.remove(context);
flowObjectiveService.next(deviceId, nextObj);
@@ -1367,9 +1378,10 @@
ObjectiveContext context = new DefaultObjectiveContext(
(objective) -> log.debug("port {} successfully updated NextObj {} on {}",
portNumber, nextId, deviceId),
- (objective, error) ->
- log.warn("port {} failed to updated NextObj {} on {}: {}",
- portNumber, nextId, deviceId, error));
+ (objective, error) -> {
+ log.warn("port {} failed to updated NextObj {} on {}: {}", portNumber, nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
flowObjectiveService.next(deviceId, nextObjBuilder.modify(context));
}
@@ -1401,9 +1413,10 @@
ObjectiveContext context = new DefaultObjectiveContext(
(objective) -> log.debug("port {} successfully removedFrom NextObj {} on {}",
portNum, nextId, deviceId),
- (objective, error) ->
- log.warn("port {} failed to removedFrom NextObj {} on {}: {}",
- portNum, nextId, deviceId, error));
+ (objective, error) -> {
+ log.warn("port {} failed to removedFrom NextObj {} on {}: {}", portNum, nextId, deviceId, error);
+ srManager.invalidateNextObj(objective.id());
+ });
if (install) {
flowObjectiveService.next(deviceId, nextObjBuilder.addToExisting(context));
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
index 4f70a1b..f359998 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
@@ -1175,8 +1175,11 @@
ObjectiveContext context = new DefaultObjectiveContext(
(objective) -> log.debug("Successfully add {} on {}/{}, vlan {}",
mcastIp, deviceId, port.toLong(), assignedVlan),
- (objective, error) -> log.warn("Failed to add {} on {}/{}, vlan {}: {}",
- mcastIp, deviceId, port.toLong(), assignedVlan, error));
+ (objective, error) -> {
+ log.warn("Failed to add {} on {}/{}, vlan {}: {}",
+ mcastIp, deviceId, port.toLong(), assignedVlan, error);
+ srManager.invalidateNextObj(objective.id());
+ });
ForwardingObjective fwdObj = mcastUtils.fwdObjBuilder(mcastIp, assignedVlan,
newNextObj.id()).add(context);
srManager.flowObjectiveService.next(deviceId, newNextObj);
@@ -1231,8 +1234,11 @@
context = new DefaultObjectiveContext(
(objective) -> log.debug("Successfully update {} on {}/{}, vlan {}",
mcastIp, deviceId, port.toLong(), assignedVlan),
- (objective, error) -> log.warn("Failed to update {} on {}/{}, vlan {}: {}",
- mcastIp, deviceId, port.toLong(), assignedVlan, error));
+ (objective, error) -> {
+ log.warn("Failed to update {} on {}/{}, vlan {}: {}",
+ mcastIp, deviceId, port.toLong(), assignedVlan, error);
+ srManager.invalidateNextObj(objective.id());
+ });
// Here we store the next objective with the remaining port
newNextObj = mcastUtils.nextObjBuilder(mcastIp, assignedVlan,
existingPorts, nextObj.id()).removeFromExisting();
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/DefaultL2TunnelHandler.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/DefaultL2TunnelHandler.java
index d6b6dfa..a634479 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/DefaultL2TunnelHandler.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/DefaultL2TunnelHandler.java
@@ -930,14 +930,12 @@
nextObjectiveBuilder.withId(nextId);
String key = generateKey(l2Tunnel.tunnelId(), direction);
l2InitiationNextObjStore.put(key, nextObjectiveBuilder.add());
- ObjectiveContext context = new DefaultObjectiveContext((objective) ->
- log.debug("Initiation l2 tunnel rule " +
- "for {} populated",
- l2Tunnel.tunnelId()),
- (objective, error) ->
- log.warn("Failed to populate Initiation " +
- "l2 tunnel rule for {}: {}",
- l2Tunnel.tunnelId(), error));
+ ObjectiveContext context = new DefaultObjectiveContext(
+ (objective) -> log.debug("Initiation l2 tunnel rule for {} populated", l2Tunnel.tunnelId()),
+ (objective, error) -> {
+ log.warn("Failed to populate Initiation l2 tunnel rule for {}: {}", l2Tunnel.tunnelId(), error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObjective = nextObjectiveBuilder.add(context);
srManager.flowObjectiveService.next(ingress.deviceId(), nextObjective);
log.debug("Initiation next objective for {} not found. Creating new NextObj with id={}",
@@ -984,14 +982,12 @@
nextObjectiveBuilder.withId(nextId);
String key = generateKey(l2Tunnel.tunnelId(), direction);
l2TerminationNextObjStore.put(key, nextObjectiveBuilder.add());
- ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("Termination l2 tunnel rule " +
- "for {} populated",
- l2Tunnel.tunnelId()),
- (objective, error) -> log.warn("Failed to populate " +
- "termination l2 tunnel " +
- "rule for {}: {}",
- l2Tunnel.tunnelId(),
- error));
+ ObjectiveContext context = new DefaultObjectiveContext(
+ (objective) -> log.debug("Termination l2 tunnel rule for {} populated", l2Tunnel.tunnelId()),
+ (objective, error) -> {
+ log.warn("Failed to populate termination l2 tunnel rule for {}: {}", l2Tunnel.tunnelId(), error);
+ srManager.invalidateNextObj(objective.id());
+ });
NextObjective nextObjective = nextObjectiveBuilder.add(context);
srManager.flowObjectiveService.next(egress.deviceId(), nextObjective);
log.debug("Termination next objective for {} not found. Creating new NextObj with id={}",
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/xconnect/impl/XconnectManager.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/xconnect/impl/XconnectManager.java
index ab4ec53..e9ca1f0c 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/xconnect/impl/XconnectManager.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/xconnect/impl/XconnectManager.java
@@ -327,9 +327,10 @@
// To serialize this with kryo
(Serializable & Consumer<Objective>) (objective) ->
log.debug("XConnect NextObj for {} added", key),
- (Serializable & BiConsumer<Objective, ObjectiveError>) (objective, error) ->
- log.warn("Failed to add XConnect NextObj for {}: {}", key, error)
- );
+ (Serializable & BiConsumer<Objective, ObjectiveError>) (objective, error) -> {
+ log.warn("Failed to add XConnect NextObj for {}: {}", key, error);
+ srService.invalidateNextObj(objective.id());
+ });
nextObj = nextObjBuilder.add(nextContext);
flowObjectiveService.next(key.deviceId(), nextObj);
xconnectNextObjStore.put(key, nextObj);
@@ -434,6 +435,7 @@
if (nextFuture != null) {
nextFuture.complete(error);
}
+ srService.invalidateNextObj(objective.id());
}
};
flowObjectiveService.next(key.deviceId(),