Refactoring SegmentRouting, OFDPA driver and Group Store
- Replace SRNextObjectiveContext with DefaultObjectiveContext
- Move several log messages to lower log level
Change-Id: Ice2fb598b8e4502cb4acee1a95235551ec7c8db7
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
index 457be6d..b2d52e9 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
@@ -44,11 +44,10 @@
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flowobjective.DefaultNextObjective;
+import org.onosproject.net.flowobjective.DefaultObjectiveContext;
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.flowobjective.NextObjective;
-import org.onosproject.net.flowobjective.Objective;
import org.onosproject.net.flowobjective.ObjectiveContext;
-import org.onosproject.net.flowobjective.ObjectiveError;
import org.onosproject.net.link.LinkService;
import org.onosproject.segmentrouting.SegmentRoutingManager;
import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
@@ -258,8 +257,14 @@
deviceId,
newLink.src().port(),
nextId);
- NextObjective nextObjective = nextObjBuilder.
- addToExisting(new SRNextObjectiveContext(deviceId));
+
+ ObjectiveContext context = new DefaultObjectiveContext(
+ (objective) -> log.debug("LinkUp installed NextObj {} on {}",
+ nextId, deviceId),
+ (objective, error) ->
+ log.warn("LinkUp failed to install NextObj {} on {}: {}",
+ nextId, deviceId, error));
+ NextObjective nextObjective = nextObjBuilder.addToExisting(context);
flowObjectiveService.next(deviceId, nextObjective);
// the addition of a bucket may actually change the neighborset
@@ -666,9 +671,15 @@
if (meta != null) {
nextObjBuilder.withMeta(meta);
}
- NextObjective nextObj = nextObjBuilder.
- add(new SRNextObjectiveContext(deviceId));
- log.info("**createGroupsFromNeighborsets: Submited "
+
+ ObjectiveContext context = new DefaultObjectiveContext(
+ (objective) -> log.debug("createGroupsFromNeighborsets installed NextObj {} on {}",
+ nextId, deviceId),
+ (objective, error) ->
+ log.warn("createGroupsFromNeighborsets failed to install NextObj {} on {}: {}",
+ nextId, deviceId, error));
+ NextObjective nextObj = nextObjBuilder.add(context);
+ log.debug("**createGroupsFromNeighborsets: Submited "
+ "next objective {} in device {}",
nextId, deviceId);
flowObjectiveService.next(deviceId, nextObj);
@@ -819,8 +830,13 @@
NextObjective.Builder nextObjBuilder = DefaultNextObjective
.builder().withId(objectiveId)
.withType(NextObjective.Type.HASHED).fromApp(appId);
- NextObjective nextObjective = nextObjBuilder.
- remove(new SRNextObjectiveContext(deviceId));
+ 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));
+ NextObjective nextObjective = nextObjBuilder.remove(context);
log.info("**removeGroup: Submited "
+ "next objective {} in device {}",
objectiveId, deviceId);
@@ -856,23 +872,4 @@
}
// should probably clean local stores port-neighbor
}
-
- protected static class SRNextObjectiveContext implements ObjectiveContext {
- final DeviceId deviceId;
-
- SRNextObjectiveContext(DeviceId deviceId) {
- this.deviceId = deviceId;
- }
- @Override
- public void onSuccess(Objective objective) {
- log.info("Next objective {} operation successful in device {}",
- objective.id(), deviceId);
- }
-
- @Override
- public void onError(Objective objective, ObjectiveError error) {
- log.warn("Next objective {} operation failed with error: {} in device {}",
- objective.id(), error, deviceId);
- }
- }
}
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/storekey/McastNextObjectiveStoreKey.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/storekey/McastNextObjectiveStoreKey.java
index dcab1fa..8fed202 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/storekey/McastNextObjectiveStoreKey.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/storekey/McastNextObjectiveStoreKey.java
@@ -50,7 +50,7 @@
* @return multicast IP
*/
public IpAddress mcastIp() {
- return this.mcastIp;
+ return mcastIp;
}
/**
@@ -59,7 +59,7 @@
* @return device ID
*/
public DeviceId deviceId() {
- return this.deviceId;
+ return deviceId;
}
@Override
diff --git a/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java b/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
index a142e5f..8c2308d 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
@@ -390,7 +390,7 @@
// Check if a group is existing with the same key
Group existingGroup = getGroup(groupDesc.deviceId(), groupDesc.appCookie());
if (existingGroup != null) {
- log.warn("Group already exists with the same key {} in dev:{} with id:0x{}",
+ log.info("Group already exists with the same key {} in dev:{} with id:0x{}",
groupDesc.appCookie(), groupDesc.deviceId(),
Integer.toHexString(existingGroup.id().id()));
return;
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/Ofdpa2GroupHandler.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/Ofdpa2GroupHandler.java
index f21ae4c..6a2eb7e 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/Ofdpa2GroupHandler.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/Ofdpa2GroupHandler.java
@@ -1105,7 +1105,7 @@
Set<GroupChainElem> gceSet = pendingGroups.remove(key);
if (gceSet != null) {
for (GroupChainElem gce : gceSet) {
- log.info("Group service {} group key {} in device {}. "
+ log.debug("Group service {} group key {} in device {}. "
+ "Processing next group in group chain with group id 0x{}",
(added) ? "ADDED" : "processed",
key, deviceId,
@@ -1118,7 +1118,7 @@
if (nextGrpList != null) {
pendingNextObjectives.invalidate(key);
nextGrpList.forEach(nextGrp -> {
- log.info("Group service {} group key {} in device:{}. "
+ log.debug("Group service {} group key {} in device:{}. "
+ "Done implementing next objective: {} <<-->> gid:0x{}",
(added) ? "ADDED" : "processed",
key, deviceId, nextGrp.nextObjective().id(),