Remove NextId from internal stores when the NextObj fails
Change-Id: I105d32ea3a2278254edd8746d41552c2c4a699fa
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 21a8761..fe65e6e 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
@@ -931,14 +931,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={}",
@@ -985,14 +983,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={}",