Charles Chan
Committed by Gerrit Code Review

Refactoring SegmentRouting, OFDPA driver and Group Store

- Replace SRNextObjectiveContext with DefaultObjectiveContext
- Move several log messages to lower log level

Change-Id: Ice2fb598b8e4502cb4acee1a95235551ec7c8db7
......@@ -44,11 +44,10 @@ import org.onosproject.net.flow.DefaultTrafficTreatment;
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 @@ public class DefaultGroupHandler {
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 @@ public class DefaultGroupHandler {
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 @@ public class DefaultGroupHandler {
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 @@ public class DefaultGroupHandler {
}
// 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);
}
}
}
......
......@@ -50,7 +50,7 @@ public class McastNextObjectiveStoreKey {
* @return multicast IP
*/
public IpAddress mcastIp() {
return this.mcastIp;
return mcastIp;
}
/**
......@@ -59,7 +59,7 @@ public class McastNextObjectiveStoreKey {
* @return device ID
*/
public DeviceId deviceId() {
return this.deviceId;
return deviceId;
}
@Override
......
......@@ -390,7 +390,7 @@ public class DistributedGroupStore
// 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;
......
......@@ -1105,7 +1105,7 @@ public class Ofdpa2GroupHandler {
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 @@ public class Ofdpa2GroupHandler {
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(),
......