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
Showing
4 changed files
with
30 additions
and
33 deletions
| ... | @@ -44,11 +44,10 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; | ... | @@ -44,11 +44,10 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 44 | import org.onosproject.net.flow.TrafficSelector; | 44 | import org.onosproject.net.flow.TrafficSelector; |
| 45 | import org.onosproject.net.flow.TrafficTreatment; | 45 | import org.onosproject.net.flow.TrafficTreatment; |
| 46 | import org.onosproject.net.flowobjective.DefaultNextObjective; | 46 | import org.onosproject.net.flowobjective.DefaultNextObjective; |
| 47 | +import org.onosproject.net.flowobjective.DefaultObjectiveContext; | ||
| 47 | import org.onosproject.net.flowobjective.FlowObjectiveService; | 48 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 48 | import org.onosproject.net.flowobjective.NextObjective; | 49 | import org.onosproject.net.flowobjective.NextObjective; |
| 49 | -import org.onosproject.net.flowobjective.Objective; | ||
| 50 | import org.onosproject.net.flowobjective.ObjectiveContext; | 50 | import org.onosproject.net.flowobjective.ObjectiveContext; |
| 51 | -import org.onosproject.net.flowobjective.ObjectiveError; | ||
| 52 | import org.onosproject.net.link.LinkService; | 51 | import org.onosproject.net.link.LinkService; |
| 53 | import org.onosproject.segmentrouting.SegmentRoutingManager; | 52 | import org.onosproject.segmentrouting.SegmentRoutingManager; |
| 54 | import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | 53 | import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; |
| ... | @@ -258,8 +257,14 @@ public class DefaultGroupHandler { | ... | @@ -258,8 +257,14 @@ public class DefaultGroupHandler { |
| 258 | deviceId, | 257 | deviceId, |
| 259 | newLink.src().port(), | 258 | newLink.src().port(), |
| 260 | nextId); | 259 | nextId); |
| 261 | - NextObjective nextObjective = nextObjBuilder. | 260 | + |
| 262 | - addToExisting(new SRNextObjectiveContext(deviceId)); | 261 | + ObjectiveContext context = new DefaultObjectiveContext( |
| 262 | + (objective) -> log.debug("LinkUp installed NextObj {} on {}", | ||
| 263 | + nextId, deviceId), | ||
| 264 | + (objective, error) -> | ||
| 265 | + log.warn("LinkUp failed to install NextObj {} on {}: {}", | ||
| 266 | + nextId, deviceId, error)); | ||
| 267 | + NextObjective nextObjective = nextObjBuilder.addToExisting(context); | ||
| 263 | flowObjectiveService.next(deviceId, nextObjective); | 268 | flowObjectiveService.next(deviceId, nextObjective); |
| 264 | 269 | ||
| 265 | // the addition of a bucket may actually change the neighborset | 270 | // the addition of a bucket may actually change the neighborset |
| ... | @@ -666,9 +671,15 @@ public class DefaultGroupHandler { | ... | @@ -666,9 +671,15 @@ public class DefaultGroupHandler { |
| 666 | if (meta != null) { | 671 | if (meta != null) { |
| 667 | nextObjBuilder.withMeta(meta); | 672 | nextObjBuilder.withMeta(meta); |
| 668 | } | 673 | } |
| 669 | - NextObjective nextObj = nextObjBuilder. | 674 | + |
| 670 | - add(new SRNextObjectiveContext(deviceId)); | 675 | + ObjectiveContext context = new DefaultObjectiveContext( |
| 671 | - log.info("**createGroupsFromNeighborsets: Submited " | 676 | + (objective) -> log.debug("createGroupsFromNeighborsets installed NextObj {} on {}", |
| 677 | + nextId, deviceId), | ||
| 678 | + (objective, error) -> | ||
| 679 | + log.warn("createGroupsFromNeighborsets failed to install NextObj {} on {}: {}", | ||
| 680 | + nextId, deviceId, error)); | ||
| 681 | + NextObjective nextObj = nextObjBuilder.add(context); | ||
| 682 | + log.debug("**createGroupsFromNeighborsets: Submited " | ||
| 672 | + "next objective {} in device {}", | 683 | + "next objective {} in device {}", |
| 673 | nextId, deviceId); | 684 | nextId, deviceId); |
| 674 | flowObjectiveService.next(deviceId, nextObj); | 685 | flowObjectiveService.next(deviceId, nextObj); |
| ... | @@ -819,8 +830,13 @@ public class DefaultGroupHandler { | ... | @@ -819,8 +830,13 @@ public class DefaultGroupHandler { |
| 819 | NextObjective.Builder nextObjBuilder = DefaultNextObjective | 830 | NextObjective.Builder nextObjBuilder = DefaultNextObjective |
| 820 | .builder().withId(objectiveId) | 831 | .builder().withId(objectiveId) |
| 821 | .withType(NextObjective.Type.HASHED).fromApp(appId); | 832 | .withType(NextObjective.Type.HASHED).fromApp(appId); |
| 822 | - NextObjective nextObjective = nextObjBuilder. | 833 | + ObjectiveContext context = new DefaultObjectiveContext( |
| 823 | - remove(new SRNextObjectiveContext(deviceId)); | 834 | + (objective) -> log.debug("RemoveGroup removes NextObj {} on {}", |
| 835 | + objectiveId, deviceId), | ||
| 836 | + (objective, error) -> | ||
| 837 | + log.warn("RemoveGroup failed to remove NextObj {} on {}: {}", | ||
| 838 | + objectiveId, deviceId, error)); | ||
| 839 | + NextObjective nextObjective = nextObjBuilder.remove(context); | ||
| 824 | log.info("**removeGroup: Submited " | 840 | log.info("**removeGroup: Submited " |
| 825 | + "next objective {} in device {}", | 841 | + "next objective {} in device {}", |
| 826 | objectiveId, deviceId); | 842 | objectiveId, deviceId); |
| ... | @@ -856,23 +872,4 @@ public class DefaultGroupHandler { | ... | @@ -856,23 +872,4 @@ public class DefaultGroupHandler { |
| 856 | } | 872 | } |
| 857 | // should probably clean local stores port-neighbor | 873 | // should probably clean local stores port-neighbor |
| 858 | } | 874 | } |
| 859 | - | ||
| 860 | - protected static class SRNextObjectiveContext implements ObjectiveContext { | ||
| 861 | - final DeviceId deviceId; | ||
| 862 | - | ||
| 863 | - SRNextObjectiveContext(DeviceId deviceId) { | ||
| 864 | - this.deviceId = deviceId; | ||
| 865 | - } | ||
| 866 | - @Override | ||
| 867 | - public void onSuccess(Objective objective) { | ||
| 868 | - log.info("Next objective {} operation successful in device {}", | ||
| 869 | - objective.id(), deviceId); | ||
| 870 | - } | ||
| 871 | - | ||
| 872 | - @Override | ||
| 873 | - public void onError(Objective objective, ObjectiveError error) { | ||
| 874 | - log.warn("Next objective {} operation failed with error: {} in device {}", | ||
| 875 | - objective.id(), error, deviceId); | ||
| 876 | - } | ||
| 877 | - } | ||
| 878 | } | 875 | } | ... | ... |
| ... | @@ -50,7 +50,7 @@ public class McastNextObjectiveStoreKey { | ... | @@ -50,7 +50,7 @@ public class McastNextObjectiveStoreKey { |
| 50 | * @return multicast IP | 50 | * @return multicast IP |
| 51 | */ | 51 | */ |
| 52 | public IpAddress mcastIp() { | 52 | public IpAddress mcastIp() { |
| 53 | - return this.mcastIp; | 53 | + return mcastIp; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | /** | 56 | /** |
| ... | @@ -59,7 +59,7 @@ public class McastNextObjectiveStoreKey { | ... | @@ -59,7 +59,7 @@ public class McastNextObjectiveStoreKey { |
| 59 | * @return device ID | 59 | * @return device ID |
| 60 | */ | 60 | */ |
| 61 | public DeviceId deviceId() { | 61 | public DeviceId deviceId() { |
| 62 | - return this.deviceId; | 62 | + return deviceId; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | @Override | 65 | @Override | ... | ... |
| ... | @@ -390,7 +390,7 @@ public class DistributedGroupStore | ... | @@ -390,7 +390,7 @@ public class DistributedGroupStore |
| 390 | // Check if a group is existing with the same key | 390 | // Check if a group is existing with the same key |
| 391 | Group existingGroup = getGroup(groupDesc.deviceId(), groupDesc.appCookie()); | 391 | Group existingGroup = getGroup(groupDesc.deviceId(), groupDesc.appCookie()); |
| 392 | if (existingGroup != null) { | 392 | if (existingGroup != null) { |
| 393 | - log.warn("Group already exists with the same key {} in dev:{} with id:0x{}", | 393 | + log.info("Group already exists with the same key {} in dev:{} with id:0x{}", |
| 394 | groupDesc.appCookie(), groupDesc.deviceId(), | 394 | groupDesc.appCookie(), groupDesc.deviceId(), |
| 395 | Integer.toHexString(existingGroup.id().id())); | 395 | Integer.toHexString(existingGroup.id().id())); |
| 396 | return; | 396 | return; | ... | ... |
| ... | @@ -1105,7 +1105,7 @@ public class Ofdpa2GroupHandler { | ... | @@ -1105,7 +1105,7 @@ public class Ofdpa2GroupHandler { |
| 1105 | Set<GroupChainElem> gceSet = pendingGroups.remove(key); | 1105 | Set<GroupChainElem> gceSet = pendingGroups.remove(key); |
| 1106 | if (gceSet != null) { | 1106 | if (gceSet != null) { |
| 1107 | for (GroupChainElem gce : gceSet) { | 1107 | for (GroupChainElem gce : gceSet) { |
| 1108 | - log.info("Group service {} group key {} in device {}. " | 1108 | + log.debug("Group service {} group key {} in device {}. " |
| 1109 | + "Processing next group in group chain with group id 0x{}", | 1109 | + "Processing next group in group chain with group id 0x{}", |
| 1110 | (added) ? "ADDED" : "processed", | 1110 | (added) ? "ADDED" : "processed", |
| 1111 | key, deviceId, | 1111 | key, deviceId, |
| ... | @@ -1118,7 +1118,7 @@ public class Ofdpa2GroupHandler { | ... | @@ -1118,7 +1118,7 @@ public class Ofdpa2GroupHandler { |
| 1118 | if (nextGrpList != null) { | 1118 | if (nextGrpList != null) { |
| 1119 | pendingNextObjectives.invalidate(key); | 1119 | pendingNextObjectives.invalidate(key); |
| 1120 | nextGrpList.forEach(nextGrp -> { | 1120 | nextGrpList.forEach(nextGrp -> { |
| 1121 | - log.info("Group service {} group key {} in device:{}. " | 1121 | + log.debug("Group service {} group key {} in device:{}. " |
| 1122 | + "Done implementing next objective: {} <<-->> gid:0x{}", | 1122 | + "Done implementing next objective: {} <<-->> gid:0x{}", |
| 1123 | (added) ? "ADDED" : "processed", | 1123 | (added) ? "ADDED" : "processed", |
| 1124 | key, deviceId, nextGrp.nextObjective().id(), | 1124 | key, deviceId, nextGrp.nextObjective().id(), | ... | ... |
-
Please register or login to post a comment