diff options
author | CNlucius <lukai1@huawei.com> | 2016-09-13 11:40:12 +0800 |
---|---|---|
committer | CNlucius <lukai1@huawei.com> | 2016-09-13 11:41:53 +0800 |
commit | b731e2f1dd0972409b136aebc7b463dd72c9cfad (patch) | |
tree | 5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler | |
parent | ee93993458266114c29271a481ef9ce7ce621b2a (diff) |
ONOSFW-171
O/S-SFC-ONOS scenario documentation
Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365
Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler')
12 files changed, 0 insertions, 2125 deletions
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java deleted file mode 100644 index 32c53654..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.segmentrouting.grouphandler; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.onosproject.core.ApplicationId; -import org.onosproject.net.DeviceId; -import org.onosproject.net.Link; -import org.onosproject.net.flowobjective.FlowObjectiveService; -import org.onosproject.net.link.LinkService; -import org.onosproject.segmentrouting.config.DeviceProperties; -import org.onosproject.store.service.EventuallyConsistentMap; - -/** - * Default ECMP group handler creation module for an edge device. - * This component creates a set of ECMP groups for every neighbor - * that this device is connected to. - * For example, consider a network of 4 devices: D0 (Segment ID: 100), - * D1 (Segment ID: 101), D2 (Segment ID: 102) and D3 (Segment ID: 103), - * where D0 and D3 are edge devices and D1 and D2 are transit devices. - * Assume device D0 is connected to 2 neighbors (D1 and D2 ). - * The following groups will be created in D0: - * 1) all ports to D1 + with no label push, // direct attach case, seen - * 2) all ports to D1 + with label 102 pushed, // this is not needed - * 3) all ports to D1 + with label 103 pushed, // maybe needed, sometimes seen - * 4) all ports to D2 + with no label push, - * 5) all ports to D2 + with label 101 pushed, - * 6) all ports to D2 + with label 103 pushed, - * 7) all ports to D1 and D2 + with label 103 pushed // ecmp case - * 8) what about ecmp no label case - */ -public class DefaultEdgeGroupHandler extends DefaultGroupHandler { - - protected DefaultEdgeGroupHandler(DeviceId deviceId, - ApplicationId appId, - DeviceProperties config, - LinkService linkService, - FlowObjectiveService flowObjService, - EventuallyConsistentMap< - NeighborSetNextObjectiveStoreKey, - Integer> nsNextObjStore, - EventuallyConsistentMap<SubnetNextObjectiveStoreKey, - Integer> subnetNextObjStore, - EventuallyConsistentMap<PortNextObjectiveStoreKey, - Integer> portNextObjStore) { - super(deviceId, appId, config, linkService, flowObjService, - nsNextObjStore, subnetNextObjStore, portNextObjStore); - } - - @Override - public void createGroups() { - log.debug("Creating default groups " - + "for edge device {}", deviceId); - Set<DeviceId> neighbors = devicePortMap.keySet(); - if (neighbors == null || neighbors.isEmpty()) { - return; - } - - // Create all possible Neighbor sets from this router - Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(neighbors); - log.trace("createGroupsAtEdgeRouter: The size of neighbor powerset " - + "for sw {} is {}", deviceId, powerSet.size()); - Set<NeighborSet> nsSet = new HashSet<>(); - for (Set<DeviceId> combo : powerSet) { - if (combo.isEmpty()) { - continue; - } - List<Integer> groupSegmentIds = - getSegmentIdsTobePairedWithNeighborSet(combo); - for (Integer sId : groupSegmentIds) { - NeighborSet ns = new NeighborSet(combo, sId); - log.trace("createGroupsAtEdgeRouter: sw {} " - + "combo {} sId {} ns {}", - deviceId, combo, sId, ns); - nsSet.add(ns); - } - } - log.trace("createGroupsAtEdgeRouter: The neighborset " - + "with label for sw {} is {}", - deviceId, nsSet); - - //createGroupsFromNeighborsets(nsSet); - } - - @Override - protected void newNeighbor(Link newNeighborLink) { - log.debug("New Neighbor: Updating groups " - + "for edge device {}", deviceId); - // Recompute neighbor power set - addNeighborAtPort(newNeighborLink.dst().deviceId(), - newNeighborLink.src().port()); - // Compute new neighbor sets due to the addition of new neighbor - Set<NeighborSet> nsSet = computeImpactedNeighborsetForPortEvent( - newNeighborLink.dst().deviceId(), - devicePortMap.keySet()); - //createGroupsFromNeighborsets(nsSet); - } - - @Override - protected void newPortToExistingNeighbor(Link newNeighborLink) { - /*log.debug("New port to existing neighbor: Updating " - + "groups for edge device {}", deviceId); - addNeighborAtPort(newNeighborLink.dst().deviceId(), - newNeighborLink.src().port()); - Set<NeighborSet> nsSet = computeImpactedNeighborsetForPortEvent( - newNeighborLink.dst().deviceId(), - devicePortMap.keySet()); - for (NeighborSet ns : nsSet) { - // Create the new bucket to be updated - TrafficTreatment.Builder tBuilder = - DefaultTrafficTreatment.builder(); - tBuilder.setOutput(newNeighborLink.src().port()) - .setEthDst(deviceConfig.getDeviceMac( - newNeighborLink.dst().deviceId())) - .setEthSrc(nodeMacAddr); - if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { - tBuilder.pushMpls() - .setMpls(MplsLabel. - mplsLabel(ns.getEdgeLabel())); - } - - Integer nextId = deviceNextObjectiveIds.get(ns); - if (nextId != null) { - NextObjective.Builder nextObjBuilder = DefaultNextObjective - .builder().withId(nextId) - .withType(NextObjective.Type.HASHED).fromApp(appId); - - nextObjBuilder.addTreatment(tBuilder.build()); - - NextObjective nextObjective = nextObjBuilder.add(); - flowObjectiveService.next(deviceId, nextObjective); - } - }*/ - } - - @Override - protected Set<NeighborSet> computeImpactedNeighborsetForPortEvent( - DeviceId impactedNeighbor, - Set<DeviceId> updatedNeighbors) { - Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(updatedNeighbors); - - Set<DeviceId> tmp = new HashSet<>(); - tmp.addAll(updatedNeighbors); - tmp.remove(impactedNeighbor); - Set<Set<DeviceId>> tmpPowerSet = getPowerSetOfNeighbors(tmp); - - // Compute the impacted neighbor sets - powerSet.removeAll(tmpPowerSet); - - Set<NeighborSet> nsSet = new HashSet<>(); - for (Set<DeviceId> combo : powerSet) { - if (combo.isEmpty()) { - continue; - } - List<Integer> groupSegmentIds = - getSegmentIdsTobePairedWithNeighborSet(combo); - for (Integer sId : groupSegmentIds) { - NeighborSet ns = new NeighborSet(combo, sId); - log.trace("computeImpactedNeighborsetForPortEvent: sw {} " - + "combo {} sId {} ns {}", - deviceId, combo, sId, ns); - nsSet.add(ns); - } - } - log.trace("computeImpactedNeighborsetForPortEvent: The neighborset " - + "with label for sw {} is {}", - deviceId, nsSet); - return nsSet; - } - -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java deleted file mode 100644 index bc394b84..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java +++ /dev/null @@ -1,739 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.segmentrouting.grouphandler; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; - -import org.onlab.packet.Ip4Prefix; -import org.onlab.packet.IpPrefix; -import org.onlab.packet.MacAddress; -import org.onlab.packet.MplsLabel; -import org.onlab.util.KryoNamespace; -import org.onosproject.core.ApplicationId; -import org.onosproject.net.DeviceId; -import org.onosproject.net.Link; -import org.onosproject.net.PortNumber; -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.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.group.DefaultGroupKey; -import org.onosproject.net.group.GroupKey; -import org.onosproject.net.link.LinkService; -import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; -import org.onosproject.segmentrouting.config.DeviceProperties; -import org.onosproject.store.service.EventuallyConsistentMap; -import org.slf4j.Logger; - -/** - * Default ECMP group handler creation module. This component creates a set of - * ECMP groups for every neighbor that this device is connected to based on - * whether the current device is an edge device or a transit device. - */ -public class DefaultGroupHandler { - protected static final Logger log = getLogger(DefaultGroupHandler.class); - - protected final DeviceId deviceId; - protected final ApplicationId appId; - protected final DeviceProperties deviceConfig; - protected final List<Integer> allSegmentIds; - protected int nodeSegmentId = -1; - protected boolean isEdgeRouter = false; - protected MacAddress nodeMacAddr = null; - protected LinkService linkService; - protected FlowObjectiveService flowObjectiveService; - - protected ConcurrentHashMap<DeviceId, Set<PortNumber>> devicePortMap = - new ConcurrentHashMap<>(); - protected ConcurrentHashMap<PortNumber, DeviceId> portDeviceMap = - new ConcurrentHashMap<>(); - protected EventuallyConsistentMap< - NeighborSetNextObjectiveStoreKey, Integer> nsNextObjStore = null; - protected EventuallyConsistentMap< - SubnetNextObjectiveStoreKey, Integer> subnetNextObjStore = null; - protected EventuallyConsistentMap< - PortNextObjectiveStoreKey, Integer> portNextObjStore = null; - - protected KryoNamespace.Builder kryo = new KryoNamespace.Builder() - .register(URI.class).register(HashSet.class) - .register(DeviceId.class).register(PortNumber.class) - .register(NeighborSet.class).register(PolicyGroupIdentifier.class) - .register(PolicyGroupParams.class) - .register(GroupBucketIdentifier.class) - .register(GroupBucketIdentifier.BucketOutputType.class); - - protected DefaultGroupHandler(DeviceId deviceId, ApplicationId appId, - DeviceProperties config, - LinkService linkService, - FlowObjectiveService flowObjService, - EventuallyConsistentMap<NeighborSetNextObjectiveStoreKey, - Integer> nsNextObjStore, - EventuallyConsistentMap<SubnetNextObjectiveStoreKey, - Integer> subnetNextObjStore, - EventuallyConsistentMap<PortNextObjectiveStoreKey, - Integer> portNextObjStore) { - this.deviceId = checkNotNull(deviceId); - this.appId = checkNotNull(appId); - this.deviceConfig = checkNotNull(config); - this.linkService = checkNotNull(linkService); - this.allSegmentIds = checkNotNull(config.getAllDeviceSegmentIds()); - try { - this.nodeSegmentId = config.getSegmentId(deviceId); - this.isEdgeRouter = config.isEdgeDevice(deviceId); - this.nodeMacAddr = checkNotNull(config.getDeviceMac(deviceId)); - } catch (DeviceConfigNotFoundException e) { - log.warn(e.getMessage() - + " Skipping value assignment in DefaultGroupHandler"); - } - this.flowObjectiveService = flowObjService; - this.nsNextObjStore = nsNextObjStore; - this.subnetNextObjStore = subnetNextObjStore; - this.portNextObjStore = portNextObjStore; - - populateNeighborMaps(); - } - - /** - * Creates a group handler object based on the type of device. If device is - * of edge type it returns edge group handler, else it returns transit group - * handler. - * - * @param deviceId device identifier - * @param appId application identifier - * @param config interface to retrieve the device properties - * @param linkService link service object - * @param flowObjService flow objective service object - * @param nsNextObjStore NeighborSet next objective store map - * @param subnetNextObjStore subnet next objective store map - * @throws DeviceConfigNotFoundException if the device configuration is not found - * @return default group handler type - */ - public static DefaultGroupHandler createGroupHandler( - DeviceId deviceId, - ApplicationId appId, - DeviceProperties config, - LinkService linkService, - FlowObjectiveService flowObjService, - EventuallyConsistentMap<NeighborSetNextObjectiveStoreKey, - Integer> nsNextObjStore, - EventuallyConsistentMap<SubnetNextObjectiveStoreKey, - Integer> subnetNextObjStore, - EventuallyConsistentMap<PortNextObjectiveStoreKey, - Integer> portNextObjStore) - throws DeviceConfigNotFoundException { - // handle possible exception in the caller - if (config.isEdgeDevice(deviceId)) { - return new DefaultEdgeGroupHandler(deviceId, appId, config, - linkService, - flowObjService, - nsNextObjStore, - subnetNextObjStore, - portNextObjStore); - } else { - return new DefaultTransitGroupHandler(deviceId, appId, config, - linkService, - flowObjService, - nsNextObjStore, - subnetNextObjStore, - portNextObjStore); - } - } - - /** - * Creates the auto created groups for this device based on the current - * snapshot of the topology. - */ - // Empty implementations to be overridden by derived classes - public void createGroups() { - } - - /** - * Performs group creation or update procedures when a new link is - * discovered on this device. - * - * @param newLink new neighbor link - */ - public void linkUp(Link newLink, boolean isMaster) { - - if (newLink.type() != Link.Type.DIRECT) { - log.warn("linkUp: unknown link type"); - return; - } - - if (!newLink.src().deviceId().equals(deviceId)) { - log.warn("linkUp: deviceId{} doesn't match with link src{}", - deviceId, newLink.src().deviceId()); - return; - } - - log.info("* LinkUP: Device {} linkUp at local port {} to neighbor {}", deviceId, - newLink.src().port(), newLink.dst().deviceId()); - MacAddress dstMac; - try { - dstMac = deviceConfig.getDeviceMac(newLink.dst().deviceId()); - } catch (DeviceConfigNotFoundException e) { - log.warn(e.getMessage() + " Aborting linkUp."); - return; - } - - addNeighborAtPort(newLink.dst().deviceId(), - newLink.src().port()); - /*if (devicePortMap.get(newLink.dst().deviceId()) == null) { - // New Neighbor - newNeighbor(newLink); - } else { - // Old Neighbor - newPortToExistingNeighbor(newLink); - }*/ - Set<NeighborSet> nsSet = nsNextObjStore.keySet() - .stream() - .filter((nsStoreEntry) -> (nsStoreEntry.deviceId().equals(deviceId))) - .map((nsStoreEntry) -> (nsStoreEntry.neighborSet())) - .filter((ns) -> (ns.getDeviceIds() - .contains(newLink.dst().deviceId()))) - .collect(Collectors.toSet()); - log.trace("linkUp: nsNextObjStore contents for device {}:", - deviceId, - nsSet); - for (NeighborSet ns : nsSet) { - // Create the new bucket to be updated - TrafficTreatment.Builder tBuilder = - DefaultTrafficTreatment.builder(); - tBuilder.setOutput(newLink.src().port()) - .setEthDst(dstMac) - .setEthSrc(nodeMacAddr); - if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { - tBuilder.pushMpls() - .copyTtlOut() - .setMpls(MplsLabel.mplsLabel(ns.getEdgeLabel())); - } - - Integer nextId = nsNextObjStore. - get(new NeighborSetNextObjectiveStoreKey(deviceId, ns)); - if (nextId != null && isMaster) { - NextObjective.Builder nextObjBuilder = DefaultNextObjective - .builder().withId(nextId) - .withType(NextObjective.Type.HASHED).fromApp(appId); - - nextObjBuilder.addTreatment(tBuilder.build()); - log.info("**linkUp in device {}: Adding Bucket " - + "with Port {} to next object id {}", - deviceId, - newLink.src().port(), - nextId); - NextObjective nextObjective = nextObjBuilder. - addToExisting(new SRNextObjectiveContext(deviceId)); - flowObjectiveService.next(deviceId, nextObjective); - } else if (isMaster) { - log.warn("linkUp in device {}, but global store has no record " - + "for neighbor-set {}", deviceId, ns); - } - } - } - - /** - * Performs group recovery procedures when a port goes down on this device. - * - * @param port port number that has gone down - */ - public void portDown(PortNumber port) { - if (portDeviceMap.get(port) == null) { - log.warn("portDown: unknown port"); - return; - } - - MacAddress dstMac; - try { - dstMac = deviceConfig.getDeviceMac(portDeviceMap.get(port)); - } catch (DeviceConfigNotFoundException e) { - log.warn(e.getMessage() + " Aborting portDown."); - return; - } - - log.debug("Device {} portDown {} to neighbor {}", deviceId, port, - portDeviceMap.get(port)); - /*Set<NeighborSet> nsSet = computeImpactedNeighborsetForPortEvent(portDeviceMap - .get(port), - devicePortMap - .keySet());*/ - Set<NeighborSet> nsSet = nsNextObjStore.keySet() - .stream() - .filter((nsStoreEntry) -> (nsStoreEntry.deviceId().equals(deviceId))) - .map((nsStoreEntry) -> (nsStoreEntry.neighborSet())) - .filter((ns) -> (ns.getDeviceIds() - .contains(portDeviceMap.get(port)))) - .collect(Collectors.toSet()); - log.trace("portDown: nsNextObjStore contents for device {}:", - deviceId, - nsSet); - for (NeighborSet ns : nsSet) { - // Create the bucket to be removed - TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment - .builder(); - tBuilder.setOutput(port) - .setEthDst(dstMac) - .setEthSrc(nodeMacAddr); - if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { - tBuilder.pushMpls() - .copyTtlOut() - .setMpls(MplsLabel.mplsLabel(ns.getEdgeLabel())); - } - - Integer nextId = nsNextObjStore. - get(new NeighborSetNextObjectiveStoreKey(deviceId, ns)); - if (nextId != null) { - NextObjective.Builder nextObjBuilder = DefaultNextObjective - .builder().withType(NextObjective.Type.SIMPLE).withId(nextId).fromApp(appId); - - nextObjBuilder.addTreatment(tBuilder.build()); - - log.info("**portDown in device {}: Removing Bucket " - + "with Port {} to next object id {}", - deviceId, - port, - nextId); - // should do removefromexisting and only if master - /*NextObjective nextObjective = nextObjBuilder. - remove(new SRNextObjectiveContext(deviceId)); - - flowObjectiveService.next(deviceId, nextObjective);*/ - } - - } - - devicePortMap.get(portDeviceMap.get(port)).remove(port); - portDeviceMap.remove(port); - } - - /** - * Returns the next objective of type hashed associated with the neighborset. - * If there is no next objective for this neighborset, this method - * would create a next objective and return. Optionally metadata can be - * passed in for the creation of the next objective. - * - * @param ns neighborset - * @param meta metadata passed into the creation of a Next Objective - * @return int if found or -1 if there are errors in the creation of the - * neighbor set. - */ - public int getNextObjectiveId(NeighborSet ns, TrafficSelector meta) { - Integer nextId = nsNextObjStore. - get(new NeighborSetNextObjectiveStoreKey(deviceId, ns)); - if (nextId == null) { - log.trace("getNextObjectiveId in device{}: Next objective id " - + "not found for {} and creating", deviceId, ns); - log.trace("getNextObjectiveId: nsNextObjStore contents for device {}: {}", - deviceId, - nsNextObjStore.entrySet() - .stream() - .filter((nsStoreEntry) -> - (nsStoreEntry.getKey().deviceId().equals(deviceId))) - .collect(Collectors.toList())); - createGroupsFromNeighborsets(Collections.singleton(ns), meta); - nextId = nsNextObjStore. - get(new NeighborSetNextObjectiveStoreKey(deviceId, ns)); - if (nextId == null) { - log.warn("getNextObjectiveId: unable to create next objective"); - return -1; - } else { - log.debug("getNextObjectiveId in device{}: Next objective id {} " - + "created for {}", deviceId, nextId, ns); - } - } else { - log.trace("getNextObjectiveId in device{}: Next objective id {} " - + "found for {}", deviceId, nextId, ns); - } - return nextId; - } - - /** - * Returns the next objective of type broadcast associated with the subnet, - * or -1 if no such objective exists. Note that this method does NOT create - * the next objective as a side-effect. It is expected that is objective is - * created at startup from network configuration. - * - * @param prefix subnet information - * @return int if found or -1 - */ - public int getSubnetNextObjectiveId(IpPrefix prefix) { - Integer nextId = subnetNextObjStore. - get(new SubnetNextObjectiveStoreKey(deviceId, prefix)); - - return (nextId != null) ? nextId : -1; - } - - /** - * Returns the next objective of type simple associated with the port on the - * device, given the treatment. Different treatments to the same port result - * in different next objectives. If no such objective exists, this method - * creates one and returns the id. Optionally metadata can be passed in for - * the creation of the objective. - * - * @param portNum the port number for the simple next objective - * @param treatment the actions to apply on the packets (should include outport) - * @param meta optional metadata passed into the creation of the next objective - * @return int if found or created, -1 if there are errors during the - * creation of the next objective. - */ - public int getPortNextObjectiveId(PortNumber portNum, TrafficTreatment treatment, - TrafficSelector meta) { - Integer nextId = portNextObjStore. - get(new PortNextObjectiveStoreKey(deviceId, portNum, treatment)); - if (nextId == null) { - log.trace("getPortNextObjectiveId in device{}: Next objective id " - + "not found for {} and {} creating", deviceId, portNum); - createGroupFromPort(portNum, treatment, meta); - nextId = portNextObjStore.get( - new PortNextObjectiveStoreKey(deviceId, portNum, treatment)); - if (nextId == null) { - log.warn("getPortNextObjectiveId: unable to create next obj" - + "for dev:{} port{}", deviceId, portNum); - return -1; - } - } - return nextId; - } - - /** - * Checks if the next objective ID (group) for the neighbor set exists or not. - * - * @param ns neighbor set to check - * @return true if it exists, false otherwise - */ - public boolean hasNextObjectiveId(NeighborSet ns) { - Integer nextId = nsNextObjStore. - get(new NeighborSetNextObjectiveStoreKey(deviceId, ns)); - if (nextId == null) { - return false; - } - - return true; - } - - // Empty implementation - protected void newNeighbor(Link newLink) { - } - - // Empty implementation - protected void newPortToExistingNeighbor(Link newLink) { - } - - // Empty implementation - protected Set<NeighborSet> - computeImpactedNeighborsetForPortEvent(DeviceId impactedNeighbor, - Set<DeviceId> updatedNeighbors) { - return null; - } - - private void populateNeighborMaps() { - Set<Link> outgoingLinks = linkService.getDeviceEgressLinks(deviceId); - for (Link link : outgoingLinks) { - if (link.type() != Link.Type.DIRECT) { - continue; - } - addNeighborAtPort(link.dst().deviceId(), link.src().port()); - } - } - - protected void addNeighborAtPort(DeviceId neighborId, - PortNumber portToNeighbor) { - // Update DeviceToPort database - log.debug("Device {} addNeighborAtPort: neighbor {} at port {}", - deviceId, neighborId, portToNeighbor); - Set<PortNumber> ports = Collections - .newSetFromMap(new ConcurrentHashMap<PortNumber, Boolean>()); - ports.add(portToNeighbor); - Set<PortNumber> portnums = devicePortMap.putIfAbsent(neighborId, ports); - if (portnums != null) { - portnums.add(portToNeighbor); - } - - // Update portToDevice database - DeviceId prev = portDeviceMap.putIfAbsent(portToNeighbor, neighborId); - if (prev != null) { - log.warn("Device: {} port: {} has neighbor: {}. NOT updating " - + "to neighbor: {}", deviceId, portToNeighbor, prev, neighborId); - } - } - - protected Set<Set<DeviceId>> getPowerSetOfNeighbors(Set<DeviceId> neighbors) { - List<DeviceId> list = new ArrayList<>(neighbors); - Set<Set<DeviceId>> sets = new HashSet<>(); - // get the number of elements in the neighbors - int elements = list.size(); - // the number of members of a power set is 2^n - // including the empty set - int powerElements = (1 << elements); - - // run a binary counter for the number of power elements - // NOTE: Exclude empty set - for (long i = 1; i < powerElements; i++) { - Set<DeviceId> neighborSubSet = new HashSet<>(); - for (int j = 0; j < elements; j++) { - if ((i >> j) % 2 == 1) { - neighborSubSet.add(list.get(j)); - } - } - sets.add(neighborSubSet); - } - return sets; - } - - private boolean isSegmentIdSameAsNodeSegmentId(DeviceId deviceId, int sId) { - int segmentId; - try { - segmentId = deviceConfig.getSegmentId(deviceId); - } catch (DeviceConfigNotFoundException e) { - log.warn(e.getMessage() + " Aborting isSegmentIdSameAsNodeSegmentId."); - return false; - } - - return segmentId == sId; - } - - protected List<Integer> getSegmentIdsTobePairedWithNeighborSet(Set<DeviceId> neighbors) { - - List<Integer> nsSegmentIds = new ArrayList<>(); - - // Always pair up with no edge label - // If (neighbors.size() == 1) { - nsSegmentIds.add(-1); - // } - - // Filter out SegmentIds matching with the - // nodes in the combo - for (Integer sId : allSegmentIds) { - if (sId.equals(nodeSegmentId)) { - continue; - } - boolean filterOut = false; - // Check if the edge label being set is of - // any node in the Neighbor set - for (DeviceId deviceId : neighbors) { - if (isSegmentIdSameAsNodeSegmentId(deviceId, sId)) { - filterOut = true; - break; - } - } - if (!filterOut) { - nsSegmentIds.add(sId); - } - } - return nsSegmentIds; - } - - /** - * Creates Groups from a set of NeighborSet given. - * - * @param nsSet a set of NeighborSet - * @param meta metadata passed into the creation of a Next Objective - */ - public void createGroupsFromNeighborsets(Set<NeighborSet> nsSet, - TrafficSelector meta) { - for (NeighborSet ns : nsSet) { - int nextId = flowObjectiveService.allocateNextId(); - NextObjective.Builder nextObjBuilder = DefaultNextObjective - .builder().withId(nextId) - .withType(NextObjective.Type.HASHED).fromApp(appId); - for (DeviceId neighborId : ns.getDeviceIds()) { - if (devicePortMap.get(neighborId) == null) { - log.warn("Neighbor {} is not in the port map yet for dev:{}", - neighborId, deviceId); - return; - } else if (devicePortMap.get(neighborId).size() == 0) { - log.warn("There are no ports for " - + "the Device {} in the port map yet", neighborId); - return; - } - - MacAddress neighborMac; - try { - neighborMac = deviceConfig.getDeviceMac(neighborId); - } catch (DeviceConfigNotFoundException e) { - log.warn(e.getMessage() + " Aborting createGroupsFromNeighborsets."); - return; - } - - for (PortNumber sp : devicePortMap.get(neighborId)) { - TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment - .builder(); - tBuilder.setEthDst(neighborMac) - .setEthSrc(nodeMacAddr); - if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { - tBuilder.pushMpls() - .copyTtlOut() - .setMpls(MplsLabel.mplsLabel(ns.getEdgeLabel())); - } - tBuilder.setOutput(sp); - nextObjBuilder.addTreatment(tBuilder.build()); - } - } - if (meta != null) { - nextObjBuilder.withMeta(meta); - } - NextObjective nextObj = nextObjBuilder. - add(new SRNextObjectiveContext(deviceId)); - log.info("**createGroupsFromNeighborsets: Submited " - + "next objective {} in device {}", - nextId, deviceId); - flowObjectiveService.next(deviceId, nextObj); - nsNextObjStore.put(new NeighborSetNextObjectiveStoreKey(deviceId, ns), - nextId); - } - } - - /** - * Creates broadcast groups for all ports in the same configured subnet. - * - */ - public void createGroupsFromSubnetConfig() { - Map<Ip4Prefix, List<PortNumber>> subnetPortMap = - this.deviceConfig.getSubnetPortsMap(this.deviceId); - // Construct a broadcast group for each subnet - subnetPortMap.forEach((subnet, ports) -> { - SubnetNextObjectiveStoreKey key = - new SubnetNextObjectiveStoreKey(deviceId, subnet); - - if (subnetNextObjStore.containsKey(key)) { - log.debug("Broadcast group for device {} and subnet {} exists", - deviceId, subnet); - return; - } - - int nextId = flowObjectiveService.allocateNextId(); - - NextObjective.Builder nextObjBuilder = DefaultNextObjective - .builder().withId(nextId) - .withType(NextObjective.Type.BROADCAST).fromApp(appId); - - ports.forEach(port -> { - TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); - tBuilder.popVlan(); - tBuilder.setOutput(port); - nextObjBuilder.addTreatment(tBuilder.build()); - }); - - NextObjective nextObj = nextObjBuilder.add(); - flowObjectiveService.next(deviceId, nextObj); - log.debug("createGroupFromSubnetConfig: Submited " - + "next objective {} in device {}", - nextId, deviceId); - - subnetNextObjStore.put(key, nextId); - }); - } - - - /** - * Create simple next objective for a single port. The treatments can include - * all outgoing actions that need to happen on the packet. - * - * @param portNum the outgoing port on the device - * @param treatment the actions to apply on the packets (should include outport) - * @param meta optional data to pass to the driver - */ - public void createGroupFromPort(PortNumber portNum, TrafficTreatment treatment, - TrafficSelector meta) { - int nextId = flowObjectiveService.allocateNextId(); - PortNextObjectiveStoreKey key = new PortNextObjectiveStoreKey( - deviceId, portNum, treatment); - - NextObjective.Builder nextObjBuilder = DefaultNextObjective - .builder().withId(nextId) - .withType(NextObjective.Type.SIMPLE) - .addTreatment(treatment) - .fromApp(appId) - .withMeta(meta); - - NextObjective nextObj = nextObjBuilder.add(); - flowObjectiveService.next(deviceId, nextObj); - log.debug("createGroupFromPort: Submited next objective {} in device {} " - + "for port {}", nextId, deviceId, portNum); - - portNextObjStore.put(key, nextId); - } - - - public GroupKey getGroupKey(Object obj) { - return new DefaultGroupKey(kryo.build().serialize(obj)); - } - - /** - * Removes groups for the next objective ID given. - * - * @param objectiveId next objective ID to remove - * @return true if succeeds, false otherwise - */ - public boolean removeGroup(int objectiveId) { - - if (nsNextObjStore.containsValue(objectiveId)) { - NextObjective.Builder nextObjBuilder = DefaultNextObjective - .builder().withId(objectiveId) - .withType(NextObjective.Type.HASHED).fromApp(appId); - NextObjective nextObjective = nextObjBuilder. - remove(new SRNextObjectiveContext(deviceId)); - log.info("**removeGroup: Submited " - + "next objective {} in device {}", - objectiveId, deviceId); - flowObjectiveService.next(deviceId, nextObjective); - - for (Map.Entry<NeighborSetNextObjectiveStoreKey, Integer> entry: nsNextObjStore.entrySet()) { - if (entry.getValue().equals(objectiveId)) { - nsNextObjStore.remove(entry.getKey()); - break; - } - } - return true; - } - - return false; - } - - 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/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java deleted file mode 100644 index 7a43e73d..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.segmentrouting.grouphandler; - -import java.util.HashSet; -import java.util.Set; - -import org.onosproject.core.ApplicationId; -import org.onosproject.net.DeviceId; -import org.onosproject.net.Link; -import org.onosproject.net.flowobjective.FlowObjectiveService; -import org.onosproject.net.link.LinkService; -import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; -import org.onosproject.segmentrouting.config.DeviceProperties; -import org.onosproject.store.service.EventuallyConsistentMap; - -/** - * Default ECMP group handler creation module for a transit device. - * This component creates a set of ECMP groups for every neighbor - * that this device is connected to. - * For example, consider a network of 4 devices: D0 (Segment ID: 100), - * D1 (Segment ID: 101), D2 (Segment ID: 102) and D3 (Segment ID: 103), - * where D0 and D3 are edge devices and D1 and D2 are transit devices. - * Assume transit device D1 is connected to 2 neighbors (D0 and D3 ). - * The following groups will be created in D1: - * 1) all ports to D0 + with no label push, - * 2) all ports to D3 + with no label push, - */ -public class DefaultTransitGroupHandler extends DefaultGroupHandler { - - protected DefaultTransitGroupHandler(DeviceId deviceId, - ApplicationId appId, - DeviceProperties config, - LinkService linkService, - FlowObjectiveService flowObjService, - EventuallyConsistentMap< - NeighborSetNextObjectiveStoreKey, - Integer> nsNextObjStore, - EventuallyConsistentMap<SubnetNextObjectiveStoreKey, - Integer> subnetNextObjStore, - EventuallyConsistentMap<PortNextObjectiveStoreKey, - Integer> portNextObjStore) { - super(deviceId, appId, config, linkService, flowObjService, - nsNextObjStore, subnetNextObjStore, portNextObjStore); - } - - @Override - public void createGroups() { - Set<DeviceId> neighbors = devicePortMap.keySet(); - if (neighbors == null || neighbors.isEmpty()) { - return; - } - - // Create all possible Neighbor sets from this router - // NOTE: Avoid any pairings of edge routers only - Set<Set<DeviceId>> sets = getPowerSetOfNeighbors(neighbors); - sets = filterEdgeRouterOnlyPairings(sets); - log.debug("createGroupsAtTransitRouter: The size of neighbor powerset " - + "for sw {} is {}", deviceId, sets.size()); - Set<NeighborSet> nsSet = new HashSet<>(); - for (Set<DeviceId> combo : sets) { - if (combo.isEmpty()) { - continue; - } - NeighborSet ns = new NeighborSet(combo); - log.debug("createGroupsAtTransitRouter: sw {} combo {} ns {}", - deviceId, combo, ns); - nsSet.add(ns); - } - log.debug("createGroupsAtTransitRouter: The neighborset with label " - + "for sw {} is {}", deviceId, nsSet); - - //createGroupsFromNeighborsets(nsSet); - } - - @Override - protected void newNeighbor(Link newNeighborLink) { - log.debug("New Neighbor: Updating groups for " - + "transit device {}", deviceId); - // Recompute neighbor power set - addNeighborAtPort(newNeighborLink.dst().deviceId(), - newNeighborLink.src().port()); - // Compute new neighbor sets due to the addition of new neighbor - Set<NeighborSet> nsSet = computeImpactedNeighborsetForPortEvent( - newNeighborLink.dst().deviceId(), - devicePortMap.keySet()); - //createGroupsFromNeighborsets(nsSet); - } - - @Override - protected void newPortToExistingNeighbor(Link newNeighborLink) { - /*log.debug("New port to existing neighbor: Updating " - + "groups for transit device {}", deviceId); - addNeighborAtPort(newNeighborLink.dst().deviceId(), - newNeighborLink.src().port()); - Set<NeighborSet> nsSet = computeImpactedNeighborsetForPortEvent( - newNeighborLink.dst().deviceId(), - devicePortMap.keySet()); - for (NeighborSet ns : nsSet) { - // Create the new bucket to be updated - TrafficTreatment.Builder tBuilder = - DefaultTrafficTreatment.builder(); - tBuilder.setOutput(newNeighborLink.src().port()) - .setEthDst(deviceConfig.getDeviceMac( - newNeighborLink.dst().deviceId())) - .setEthSrc(nodeMacAddr); - if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) { - tBuilder.pushMpls() - .setMpls(MplsLabel. - mplsLabel(ns.getEdgeLabel())); - } - - - Integer nextId = deviceNextObjectiveIds.get(ns); - if (nextId != null) { - NextObjective.Builder nextObjBuilder = DefaultNextObjective - .builder().withId(nextId) - .withType(NextObjective.Type.HASHED).fromApp(appId); - - nextObjBuilder.addTreatment(tBuilder.build()); - - NextObjective nextObjective = nextObjBuilder.add(); - flowObjectiveService.next(deviceId, nextObjective); - } - }*/ - } - - @Override - protected Set<NeighborSet> computeImpactedNeighborsetForPortEvent( - DeviceId impactedNeighbor, - Set<DeviceId> updatedNeighbors) { - Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(updatedNeighbors); - - Set<DeviceId> tmp = new HashSet<>(); - tmp.addAll(updatedNeighbors); - tmp.remove(impactedNeighbor); - Set<Set<DeviceId>> tmpPowerSet = getPowerSetOfNeighbors(tmp); - - // Compute the impacted neighbor sets - powerSet.removeAll(tmpPowerSet); - - powerSet = filterEdgeRouterOnlyPairings(powerSet); - Set<NeighborSet> nsSet = new HashSet<>(); - for (Set<DeviceId> combo : powerSet) { - if (combo.isEmpty()) { - continue; - } - NeighborSet ns = new NeighborSet(combo); - log.debug("createGroupsAtTransitRouter: sw {} combo {} ns {}", - deviceId, combo, ns); - nsSet.add(ns); - } - log.debug("computeImpactedNeighborsetForPortEvent: The neighborset with label " - + "for sw {} is {}", deviceId, nsSet); - - return nsSet; - } - - private Set<Set<DeviceId>> filterEdgeRouterOnlyPairings(Set<Set<DeviceId>> sets) { - Set<Set<DeviceId>> fiteredSets = new HashSet<>(); - for (Set<DeviceId> deviceSubSet : sets) { - if (deviceSubSet.size() > 1) { - boolean avoidEdgeRouterPairing = true; - for (DeviceId device : deviceSubSet) { - boolean isEdge; - try { - isEdge = deviceConfig.isEdgeDevice(device); - } catch (DeviceConfigNotFoundException e) { - log.warn(e.getMessage() + " Skipping filterEdgeRouterOnlyPairings on this device."); - continue; - } - - if (!isEdge) { - avoidEdgeRouterPairing = false; - break; - } - } - if (!avoidEdgeRouterPairing) { - fiteredSets.add(deviceSubSet); - } - } else { - fiteredSets.add(deviceSubSet); - } - } - return fiteredSets; - } -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/GroupBucketIdentifier.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/GroupBucketIdentifier.java deleted file mode 100644 index 2ecb4493..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/GroupBucketIdentifier.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.segmentrouting.grouphandler; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.net.PortNumber; - -/** - * Representation of policy group bucket identifier. Not exposed to - * the application and only to be used internally. - */ -public class GroupBucketIdentifier { - private int label; - private BucketOutputType type; - private PortNumber outPort; - private PolicyGroupIdentifier outGroup; - - protected enum BucketOutputType { - PORT, - GROUP - } - - protected GroupBucketIdentifier(int label, - PortNumber outPort) { - this.label = label; - this.type = BucketOutputType.PORT; - this.outPort = checkNotNull(outPort); - this.outGroup = null; - } - - protected GroupBucketIdentifier(int label, - PolicyGroupIdentifier outGroup) { - this.label = label; - this.type = BucketOutputType.GROUP; - this.outPort = null; - this.outGroup = checkNotNull(outGroup); - } - - protected int label() { - return this.label; - } - - protected BucketOutputType type() { - return this.type; - } - - protected PortNumber outPort() { - return this.outPort; - } - - protected PolicyGroupIdentifier outGroup() { - return this.outGroup; - } -} - diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java deleted file mode 100644 index 44715d24..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onosproject.segmentrouting.grouphandler; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -import org.onosproject.net.DeviceId; - -/** - * Representation of a set of neighbor switch dpids along with edge node - * label. Meant to be used as a lookup-key in a hash-map to retrieve an - * ECMP-group that hashes packets to a set of ports connecting to the - * neighbors in this set. - */ -public class NeighborSet { - private final Set<DeviceId> neighbors; - private final int edgeLabel; - public static final int NO_EDGE_LABEL = -1; - - /** - * Constructor with set of neighbors. Edge label is - * default to -1. - * - * @param neighbors set of neighbors to be part of neighbor set - */ - public NeighborSet(Set<DeviceId> neighbors) { - checkNotNull(neighbors); - this.edgeLabel = NO_EDGE_LABEL; - this.neighbors = new HashSet<>(); - this.neighbors.addAll(neighbors); - } - - /** - * Constructor with set of neighbors and edge label. - * - * @param neighbors set of neighbors to be part of neighbor set - * @param edgeLabel label to be pushed as part of group operation - */ - public NeighborSet(Set<DeviceId> neighbors, int edgeLabel) { - checkNotNull(neighbors); - this.edgeLabel = edgeLabel; - this.neighbors = new HashSet<>(); - this.neighbors.addAll(neighbors); - } - - /** - * Default constructor for kryo serialization. - */ - public NeighborSet() { - this.edgeLabel = NO_EDGE_LABEL; - this.neighbors = new HashSet<>(); - } - - /** - * Gets the neighbors part of neighbor set. - * - * @return set of neighbor identifiers - */ - public Set<DeviceId> getDeviceIds() { - return neighbors; - } - - /** - * Gets the label associated with neighbor set. - * - * @return integer - */ - public int getEdgeLabel() { - return edgeLabel; - } - - // The list of neighbor ids and label are used for comparison. - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof NeighborSet)) { - return false; - } - NeighborSet that = (NeighborSet) o; - return (this.neighbors.containsAll(that.neighbors) && - that.neighbors.containsAll(this.neighbors) && - (this.edgeLabel == that.edgeLabel)); - } - - // The list of neighbor ids and label are used for comparison. - @Override - public int hashCode() { - int result = 17; - int combinedHash = 0; - for (DeviceId d : neighbors) { - combinedHash = combinedHash + Objects.hash(d); - } - result = 31 * result + combinedHash + Objects.hash(edgeLabel); - - return result; - } - - @Override - public String toString() { - return " Neighborset Sw: " + neighbors - + " and Label: " + edgeLabel; - } -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSetNextObjectiveStoreKey.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSetNextObjectiveStoreKey.java deleted file mode 100644 index 9ace5313..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSetNextObjectiveStoreKey.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onosproject.segmentrouting.grouphandler; - -import java.util.Objects; - -import org.onosproject.net.DeviceId; - -/** - * Class definition of Key for Neighborset to NextObjective store. - */ -public class NeighborSetNextObjectiveStoreKey { - private final DeviceId deviceId; - private final NeighborSet ns; - - public NeighborSetNextObjectiveStoreKey(DeviceId deviceId, - NeighborSet ns) { - this.deviceId = deviceId; - this.ns = ns; - } - - public DeviceId deviceId() { - return this.deviceId; - } - - public NeighborSet neighborSet() { - return this.ns; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof NeighborSetNextObjectiveStoreKey)) { - return false; - } - NeighborSetNextObjectiveStoreKey that = - (NeighborSetNextObjectiveStoreKey) o; - return (Objects.equals(this.deviceId, that.deviceId) && - Objects.equals(this.ns, that.ns)); - } - - // The list of neighbor ids and label are used for comparison. - @Override - public int hashCode() { - int result = 17; - result = 31 * result + Objects.hashCode(this.deviceId) - + Objects.hashCode(this.ns); - - return result; - } - - @Override - public String toString() { - return "Device: " + deviceId + " Neighborset: " + ns; - } -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java deleted file mode 100644 index ef143dc7..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.segmentrouting.grouphandler; - -import static com.google.common.base.Preconditions.checkArgument; -import static org.slf4j.LoggerFactory.getLogger; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.onlab.packet.MacAddress; -import org.onlab.packet.MplsLabel; -import org.onosproject.core.ApplicationId; -import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; -import org.onosproject.segmentrouting.config.DeviceProperties; -import org.onosproject.segmentrouting.grouphandler.GroupBucketIdentifier.BucketOutputType; -import org.onosproject.store.service.EventuallyConsistentMap; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.DefaultTrafficTreatment; -import org.onosproject.net.flow.TrafficTreatment; -import org.onosproject.net.flowobjective.FlowObjectiveService; -import org.onosproject.net.group.GroupBucket; -import org.onosproject.net.link.LinkService; -import org.slf4j.Logger; - -/** - * A module to create group chains based on the specified device - * ports and label stack to be applied on each port. - */ -public class PolicyGroupHandler extends DefaultGroupHandler { - - private final Logger log = getLogger(getClass()); - private HashMap<PolicyGroupIdentifier, PolicyGroupIdentifier> dependentGroups = new HashMap<>(); - - /** - * Policy group handler constructor. - * - * @param deviceId device identifier - * @param appId application identifier - * @param config interface to retrieve the device properties - * @param linkService link service object - * @param flowObjService flow objective service object - * @param nsNextObjStore NeighborSet next objective store map - * @param subnetNextObjStore subnet next objective store map - */ - public PolicyGroupHandler(DeviceId deviceId, - ApplicationId appId, - DeviceProperties config, - LinkService linkService, - FlowObjectiveService flowObjService, - EventuallyConsistentMap<NeighborSetNextObjectiveStoreKey, - Integer> nsNextObjStore, - EventuallyConsistentMap<SubnetNextObjectiveStoreKey, - Integer> subnetNextObjStore, - EventuallyConsistentMap<PortNextObjectiveStoreKey, - Integer> portNextObjStore) { - super(deviceId, appId, config, linkService, flowObjService, - nsNextObjStore, subnetNextObjStore, portNextObjStore); - } - - public PolicyGroupIdentifier createPolicyGroupChain(String id, - List<PolicyGroupParams> params) { - List<GroupBucketIdentifier> bucketIds = new ArrayList<>(); - for (PolicyGroupParams param: params) { - List<PortNumber> ports = param.getPorts(); - if (ports == null) { - log.warn("createPolicyGroupChain in sw {} with wrong " - + "input parameters", deviceId); - return null; - } - - int labelStackSize = (param.getLabelStack() != null) ? - param.getLabelStack().size() : 0; - - if (labelStackSize > 1) { - for (PortNumber sp : ports) { - PolicyGroupIdentifier previousGroupkey = null; - DeviceId neighbor = portDeviceMap.get(sp); - for (int idx = 0; idx < param.getLabelStack().size(); idx++) { - int label = param.getLabelStack().get(idx); - if (idx == (labelStackSize - 1)) { - // Innermost Group - GroupBucketIdentifier bucketId = - new GroupBucketIdentifier(label, - previousGroupkey); - bucketIds.add(bucketId); - } else if (idx == 0) { - // Outermost Group - List<GroupBucket> outBuckets = new ArrayList<>(); - GroupBucketIdentifier bucketId = - new GroupBucketIdentifier(label, sp); - PolicyGroupIdentifier key = new - PolicyGroupIdentifier(id, - Collections.singletonList(param), - Collections.singletonList(bucketId)); - MacAddress neighborEthDst; - try { - neighborEthDst = deviceConfig.getDeviceMac(neighbor); - } catch (DeviceConfigNotFoundException e) { - log.warn(e.getMessage() - + " Skipping createPolicyGroupChain for this label."); - continue; - } - - TrafficTreatment.Builder tBuilder = - DefaultTrafficTreatment.builder(); - tBuilder.setOutput(sp) - .setEthDst(neighborEthDst) - .setEthSrc(nodeMacAddr) - .pushMpls() - .setMpls(MplsLabel.mplsLabel(label)); - /*outBuckets.add(DefaultGroupBucket. - createSelectGroupBucket(tBuilder.build())); - GroupDescription desc = new - DefaultGroupDescription(deviceId, - GroupDescription.Type.INDIRECT, - new GroupBuckets(outBuckets)); - //TODO: BoS*/ - previousGroupkey = key; - //groupService.addGroup(desc); - //TODO: Use nextObjective APIs here - } else { - // Intermediate Groups - GroupBucketIdentifier bucketId = - new GroupBucketIdentifier(label, - previousGroupkey); - PolicyGroupIdentifier key = new - PolicyGroupIdentifier(id, - Collections.singletonList(param), - Collections.singletonList(bucketId)); - // Add to group dependency list - dependentGroups.put(previousGroupkey, key); - previousGroupkey = key; - } - } - } - } else { - int label = -1; - if (labelStackSize == 1) { - label = param.getLabelStack().get(0); - } - for (PortNumber sp : ports) { - GroupBucketIdentifier bucketId = - new GroupBucketIdentifier(label, sp); - bucketIds.add(bucketId); - } - } - } - PolicyGroupIdentifier innermostGroupkey = null; - if (!bucketIds.isEmpty()) { - innermostGroupkey = new - PolicyGroupIdentifier(id, - params, - bucketIds); - // Add to group dependency list - boolean fullyResolved = true; - for (GroupBucketIdentifier bucketId:bucketIds) { - if (bucketId.type() == BucketOutputType.GROUP) { - dependentGroups.put(bucketId.outGroup(), - innermostGroupkey); - fullyResolved = false; - } - } - - if (fullyResolved) { - List<GroupBucket> outBuckets = new ArrayList<>(); - for (GroupBucketIdentifier bucketId : bucketIds) { - DeviceId neighbor = portDeviceMap. - get(bucketId.outPort()); - - MacAddress neighborEthDst; - try { - neighborEthDst = deviceConfig.getDeviceMac(neighbor); - } catch (DeviceConfigNotFoundException e) { - log.warn(e.getMessage() - + " Skipping createPolicyGroupChain for this bucketId."); - continue; - } - - TrafficTreatment.Builder tBuilder = - DefaultTrafficTreatment.builder(); - tBuilder.setOutput(bucketId.outPort()) - .setEthDst(neighborEthDst) - .setEthSrc(nodeMacAddr); - if (bucketId.label() != NeighborSet.NO_EDGE_LABEL) { - tBuilder.pushMpls() - .setMpls(MplsLabel.mplsLabel(bucketId.label())); - } - //TODO: BoS - /*outBuckets.add(DefaultGroupBucket. - createSelectGroupBucket(tBuilder.build()));*/ - } - /*GroupDescription desc = new - DefaultGroupDescription(deviceId, - GroupDescription.Type.SELECT, - new GroupBuckets(outBuckets)); - groupService.addGroup(desc);*/ - //TODO: Use nextObjective APIs here - } - } - return innermostGroupkey; - } - - //TODO: Use nextObjective APIs to handle the group chains - /*@Override - protected void handleGroupEvent(GroupEvent event) { - if (event.type() == GroupEvent.Type.GROUP_ADDED) { - if (dependentGroups.get(event.subject().appCookie()) != null) { - PolicyGroupIdentifier dependentGroupKey = dependentGroups.get(event.subject().appCookie()); - dependentGroups.remove(event.subject().appCookie()); - boolean fullyResolved = true; - for (GroupBucketIdentifier bucketId: - dependentGroupKey.bucketIds()) { - if (bucketId.type() != BucketOutputType.GROUP) { - continue; - } - if (dependentGroups.containsKey(bucketId.outGroup())) { - fullyResolved = false; - break; - } - } - - if (fullyResolved) { - List<GroupBucket> outBuckets = new ArrayList<GroupBucket>(); - for (GroupBucketIdentifier bucketId: - dependentGroupKey.bucketIds()) { - TrafficTreatment.Builder tBuilder = - DefaultTrafficTreatment.builder(); - if (bucketId.label() != NeighborSet.NO_EDGE_LABEL) { - tBuilder.pushMpls() - .setMpls(MplsLabel. - mplsLabel(bucketId.label())); - } - //TODO: BoS - if (bucketId.type() == BucketOutputType.PORT) { - DeviceId neighbor = portDeviceMap. - get(bucketId.outPort()); - tBuilder.setOutput(bucketId.outPort()) - .setEthDst(deviceConfig. - getDeviceMac(neighbor)) - .setEthSrc(nodeMacAddr); - } else { - if (groupService. - getGroup(deviceId, - getGroupKey(bucketId. - outGroup())) == null) { - throw new IllegalStateException(); - } - GroupId indirectGroupId = groupService. - getGroup(deviceId, - getGroupKey(bucketId. - outGroup())).id(); - tBuilder.group(indirectGroupId); - } - outBuckets.add(DefaultGroupBucket. - createSelectGroupBucket(tBuilder.build())); - } - GroupDescription desc = new - DefaultGroupDescription(deviceId, - GroupDescription.Type.SELECT, - new GroupBuckets(outBuckets)); - groupService.addGroup(desc); - } - } - } - }*/ - - public PolicyGroupIdentifier generatePolicyGroupKey(String id, - List<PolicyGroupParams> params) { - List<GroupBucketIdentifier> bucketIds = new ArrayList<>(); - for (PolicyGroupParams param: params) { - List<PortNumber> ports = param.getPorts(); - if (ports == null) { - log.warn("generateGroupKey in sw {} with wrong " - + "input parameters", deviceId); - return null; - } - - int labelStackSize = (param.getLabelStack() != null) - ? param.getLabelStack().size() : 0; - - if (labelStackSize > 1) { - for (PortNumber sp : ports) { - PolicyGroupIdentifier previousGroupkey = null; - for (int idx = 0; idx < param.getLabelStack().size(); idx++) { - int label = param.getLabelStack().get(idx); - if (idx == (labelStackSize - 1)) { - // Innermost Group - GroupBucketIdentifier bucketId = - new GroupBucketIdentifier(label, - previousGroupkey); - bucketIds.add(bucketId); - } else if (idx == 0) { - // Outermost Group - GroupBucketIdentifier bucketId = - new GroupBucketIdentifier(label, sp); - PolicyGroupIdentifier key = new - PolicyGroupIdentifier(id, - Collections.singletonList(param), - Collections.singletonList(bucketId)); - previousGroupkey = key; - } else { - // Intermediate Groups - GroupBucketIdentifier bucketId = - new GroupBucketIdentifier(label, - previousGroupkey); - PolicyGroupIdentifier key = new - PolicyGroupIdentifier(id, - Collections.singletonList(param), - Collections.singletonList(bucketId)); - previousGroupkey = key; - } - } - } - } else { - int label = -1; - if (labelStackSize == 1) { - label = param.getLabelStack().get(0); - } - for (PortNumber sp : ports) { - GroupBucketIdentifier bucketId = - new GroupBucketIdentifier(label, sp); - bucketIds.add(bucketId); - } - } - } - PolicyGroupIdentifier innermostGroupkey = null; - if (!bucketIds.isEmpty()) { - innermostGroupkey = new - PolicyGroupIdentifier(id, - params, - bucketIds); - } - return innermostGroupkey; - } - - public void removeGroupChain(PolicyGroupIdentifier key) { - checkArgument(key != null); - List<PolicyGroupIdentifier> groupsToBeDeleted = new ArrayList<>(); - groupsToBeDeleted.add(key); - - Iterator<PolicyGroupIdentifier> it = - groupsToBeDeleted.iterator(); - - while (it.hasNext()) { - PolicyGroupIdentifier innerMostGroupKey = it.next(); - for (GroupBucketIdentifier bucketId: - innerMostGroupKey.bucketIds()) { - if (bucketId.type() != BucketOutputType.GROUP) { - groupsToBeDeleted.add(bucketId.outGroup()); - } - } - /*groupService.removeGroup(deviceId, - getGroupKey(innerMostGroupKey), - appId);*/ - //TODO: Use nextObjective APIs here - it.remove(); - } - } - -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupIdentifier.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupIdentifier.java deleted file mode 100644 index 44a0a2ce..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupIdentifier.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.segmentrouting.grouphandler; - -import java.util.List; - -/** - * Representation of policy based group identifiers. - * Opaque to group handler applications and only the outermost - * policy group identifier in a chain is visible to the applications. - */ -public class PolicyGroupIdentifier { - private String id; - private List<PolicyGroupParams> inputParams; - private List<GroupBucketIdentifier> bucketIds; - - /** - * Constructor. - * - * @param id unique identifier associated with the policy group - * @param input policy group params associated with this group - * @param bucketIds buckets associated with this group - */ - protected PolicyGroupIdentifier(String id, - List<PolicyGroupParams> input, - List<GroupBucketIdentifier> bucketIds) { - this.id = id; - this.inputParams = input; - this.bucketIds = bucketIds; - } - - /** - * Returns the bucket identifier list associated with the policy - * group identifier. - * - * @return list of bucket identifier - */ - protected List<GroupBucketIdentifier> bucketIds() { - return this.bucketIds; - } - - @Override - public int hashCode() { - int result = 17; - int combinedHash = 0; - for (PolicyGroupParams input:inputParams) { - combinedHash = combinedHash + input.hashCode(); - } - for (GroupBucketIdentifier bucketId:bucketIds) { - combinedHash = combinedHash + bucketId.hashCode(); - } - result = 31 * result + combinedHash; - - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof PolicyGroupIdentifier) { - PolicyGroupIdentifier that = (PolicyGroupIdentifier) obj; - boolean result = this.id.equals(that.id); - result = result && - this.inputParams.containsAll(that.inputParams) && - that.inputParams.containsAll(this.inputParams); - result = result && - this.bucketIds.containsAll(that.bucketIds) && - that.bucketIds.containsAll(this.bucketIds); - return result; - } - - return false; - } -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupParams.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupParams.java deleted file mode 100644 index 5a3f26b5..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupParams.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.segmentrouting.grouphandler; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; -import java.util.Objects; - -import org.onosproject.net.PortNumber; - -/** - * Representation of parameters used to create policy based groups. - */ -public class PolicyGroupParams { - private final List<PortNumber> ports; - private final List<Integer> labelStack; - - /** - * Constructor. - * - * @param labelStack mpls label stack to be applied on the ports - * @param ports ports to be part of the policy group - */ - public PolicyGroupParams(List<Integer> labelStack, - List<PortNumber> ports) { - this.ports = checkNotNull(ports); - this.labelStack = checkNotNull(labelStack); - } - - /** - * Returns the ports associated with the policy group params. - * - * @return list of port numbers - */ - public List<PortNumber> getPorts() { - return ports; - } - - /** - * Returns the label stack associated with the policy group params. - * - * @return list of integers - */ - public List<Integer> getLabelStack() { - return labelStack; - } - - @Override - public int hashCode() { - int result = 17; - int combinedHash = 0; - for (PortNumber port:ports) { - combinedHash = combinedHash + port.hashCode(); - } - combinedHash = combinedHash + Objects.hash(labelStack); - result = 31 * result + combinedHash; - - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof PolicyGroupParams) { - PolicyGroupParams that = (PolicyGroupParams) obj; - boolean result = this.labelStack.equals(that.labelStack); - result = result && - this.ports.containsAll(that.ports) && - that.ports.containsAll(this.ports); - return result; - } - - return false; - } -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PortNextObjectiveStoreKey.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PortNextObjectiveStoreKey.java deleted file mode 100644 index 5555565c..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PortNextObjectiveStoreKey.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.onosproject.segmentrouting.grouphandler; - -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.TrafficTreatment; - -import java.util.Objects; - -/** - * Class definition of Key for Device/Port to NextObjective store. Since there - * can be multiple next objectives to the same physical port, we differentiate - * between them by including the treatment in the key. - */ -public class PortNextObjectiveStoreKey { - private final DeviceId deviceId; - private final PortNumber portNum; - private final TrafficTreatment treatment; - - public PortNextObjectiveStoreKey(DeviceId deviceId, PortNumber portNum, - TrafficTreatment treatment) { - this.deviceId = deviceId; - this.portNum = portNum; - this.treatment = treatment; - } - - /** - * Gets device id in this PortNextObjectiveStoreKey. - * - * @return device id - */ - public DeviceId deviceId() { - return deviceId; - } - - /** - * Gets port information in this PortNextObjectiveStoreKey. - * - * @return port information - */ - public PortNumber portNumber() { - return portNum; - } - - /** - * Gets treatment information in this PortNextObjectiveStoreKey. - * - * @return treatment information - */ - public TrafficTreatment treatment() { - return treatment; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof PortNextObjectiveStoreKey)) { - return false; - } - PortNextObjectiveStoreKey that = - (PortNextObjectiveStoreKey) o; - return (Objects.equals(this.deviceId, that.deviceId) && - Objects.equals(this.portNum, that.portNum) && - Objects.equals(this.treatment, that.treatment)); - } - - @Override - public int hashCode() { - return Objects.hash(deviceId, portNum, treatment); - } - - @Override - public String toString() { - return "Device: " + deviceId + " Port: " + portNum + " Treatment: " + treatment; - } -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/SubnetNextObjectiveStoreKey.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/SubnetNextObjectiveStoreKey.java deleted file mode 100644 index d6b16c7a..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/SubnetNextObjectiveStoreKey.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onosproject.segmentrouting.grouphandler; - -import org.onlab.packet.IpPrefix; -import org.onosproject.net.DeviceId; - -import java.util.Objects; - -/** - * Class definition of Key for Subnet to NextObjective store. - */ -public class SubnetNextObjectiveStoreKey { - private final DeviceId deviceId; - private final IpPrefix prefix; - - public SubnetNextObjectiveStoreKey(DeviceId deviceId, - IpPrefix prefix) { - this.deviceId = deviceId; - this.prefix = prefix; - } - - /** - * Gets device id in this SubnetNextObjectiveStoreKey. - * - * @return device id - */ - public DeviceId deviceId() { - return this.deviceId; - } - - /** - * Gets subnet information in this SubnetNextObjectiveStoreKey. - * - * @return subnet information - */ - public IpPrefix prefix() { - return this.prefix; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof SubnetNextObjectiveStoreKey)) { - return false; - } - SubnetNextObjectiveStoreKey that = - (SubnetNextObjectiveStoreKey) o; - return (Objects.equals(this.deviceId, that.deviceId) && - Objects.equals(this.prefix, that.prefix)); - } - - @Override - public int hashCode() { - return Objects.hash(deviceId, prefix); - } - - @Override - public String toString() { - return "Device: " + deviceId + " Subnet: " + prefix; - } -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/package-info.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/package-info.java deleted file mode 100644 index 1a8d595e..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Segment routing group handling. - */ -package org.onosproject.segmentrouting.grouphandler;
\ No newline at end of file |