From 76dc892491948adae5e5e62cf94448967e8d865b Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Sun, 6 Dec 2015 07:15:03 -0800 Subject: Fixes bad POM file with ONOS commit 8c68536972f63069c263635c9d9f4f31d7f3e9a2 Change-Id: I7adb5a2d3738d53dbc41db7577768b0e7ced5450 Signed-off-by: Ashlee Young --- .../net/edgeservice/impl/EdgeManager.java | 55 ++++---- .../onosproject/net/flow/impl/FlowRuleManager.java | 2 +- .../flowobjective/impl/FlowObjectiveManager.java | 9 +- .../net/intent/impl/ObjectiveTracker.java | 7 +- .../impl/compiler/MplsPathIntentCompiler.java | 31 +++-- .../OpticalConnectivityIntentCompiler.java | 12 +- .../net/link/impl/BasicLinkOperator.java | 4 + .../newresource/impl/ResourceDeviceListener.java | 103 +++++++++++++- .../net/newresource/impl/ResourceLinkListener.java | 153 -------------------- .../net/newresource/impl/ResourceRegistrar.java | 11 +- .../net/edgeservice/impl/EdgeManagerTest.java | 155 +++++++++++---------- .../net/intent/impl/ObjectiveTrackerTest.java | 5 +- 12 files changed, 255 insertions(+), 292 deletions(-) delete mode 100644 framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java (limited to 'framework/src/onos/core/net') diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/EdgeManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/EdgeManager.java index e992f7a4..cd7335d6 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/EdgeManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/EdgeManager.java @@ -27,10 +27,10 @@ import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.Service; import org.onosproject.event.AbstractListenerManager; -import org.onosproject.event.Event; import org.onosproject.net.ConnectPoint; import org.onosproject.net.DeviceId; import org.onosproject.net.device.DeviceEvent; +import org.onosproject.net.device.DeviceListener; import org.onosproject.net.device.DeviceService; import org.onosproject.net.edge.EdgePortEvent; import org.onosproject.net.edge.EdgePortListener; @@ -38,17 +38,16 @@ import org.onosproject.net.edge.EdgePortService; import org.onosproject.net.flow.DefaultTrafficTreatment; import org.onosproject.net.flow.TrafficTreatment; import org.onosproject.net.link.LinkEvent; +import org.onosproject.net.link.LinkListener; +import org.onosproject.net.link.LinkService; import org.onosproject.net.packet.DefaultOutboundPacket; import org.onosproject.net.packet.OutboundPacket; import org.onosproject.net.packet.PacketService; import org.onosproject.net.topology.Topology; -import org.onosproject.net.topology.TopologyEvent; -import org.onosproject.net.topology.TopologyListener; import org.onosproject.net.topology.TopologyService; import org.slf4j.Logger; import java.nio.ByteBuffer; -import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -73,7 +72,9 @@ public class EdgeManager private final Map> connectionPoints = Maps.newConcurrentMap(); - private final TopologyListener topologyListener = new InnerTopologyListener(); + private final LinkListener linkListener = new InnerLinkListener(); + + private final DeviceListener deviceListener = new InnerDeviceListener(); @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected PacketService packetService; @@ -84,17 +85,23 @@ public class EdgeManager @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected TopologyService topologyService; + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected LinkService linkService; + @Activate public void activate() { eventDispatcher.addSink(EdgePortEvent.class, listenerRegistry); - topologyService.addListener(topologyListener); + deviceService.addListener(deviceListener); + linkService.addListener(linkListener); + loadAllEdgePorts(); log.info("Started"); } @Deactivate public void deactivate() { eventDispatcher.removeSink(EdgePortEvent.class); - topologyService.removeListener(topologyListener); + deviceService.removeListener(deviceListener); + linkService.removeListener(linkListener); log.info("Stopped"); } @@ -142,31 +149,27 @@ public class EdgeManager return new DefaultOutboundPacket(point.deviceId(), builder.build(), data); } - // Internal listener for topo events used to keep our edge-port cache - // up to date. - private class InnerTopologyListener implements TopologyListener { + private class InnerLinkListener implements LinkListener { + @Override - public void event(TopologyEvent event) { - topology = event.subject(); - List triggers = event.reasons(); - if (triggers != null) { - triggers.forEach(reason -> { - if (reason instanceof DeviceEvent) { - processDeviceEvent((DeviceEvent) reason); - } else if (reason instanceof LinkEvent) { - processLinkEvent((LinkEvent) reason); - } - }); - } else { - //FIXME special case of preexisting edgeport & no triggerless events could cause this to never hit and - //never discover an edgeport that should have been discovered. - loadAllEdgePorts(); - } + public void event(LinkEvent event) { + topology = topologyService.currentTopology(); + processLinkEvent(event); + } + } + + private class InnerDeviceListener implements DeviceListener { + + @Override + public void event(DeviceEvent event) { + topology = topologyService.currentTopology(); + processDeviceEvent(event); } } // Initial loading of the edge port cache. private void loadAllEdgePorts() { + topology = topologyService.currentTopology(); deviceService.getAvailableDevices().forEach(d -> deviceService.getPorts(d.id()) .forEach(p -> addEdgePort(new ConnectPoint(d.id(), p.number())))); } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java index 5958d1f5..63ee03ec 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java @@ -436,7 +436,7 @@ public class FlowRuleManager log.debug("Adding rule in store, but not on switch {}", rule); flowMissing(rule); } catch (Exception e) { - log.debug("Can't add missing flow rule {}", e.getMessage()); + log.debug("Can't add missing flow rule:", e); continue; } } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java index 5ecdc7a2..33200b1a 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java @@ -16,7 +16,6 @@ package org.onosproject.net.flowobjective.impl; import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -53,9 +52,11 @@ import org.onosproject.net.group.GroupService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Collections; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import static com.google.common.base.Preconditions.checkNotNull; @@ -228,8 +229,10 @@ public class FlowObjectiveManager implements FlowObjectiveService { flowObjectiveStore.getNextGroup(fwd.nextId()) == null) { log.trace("Queuing forwarding objective for nextId {}", fwd.nextId()); // TODO: change to computeIfAbsent - Set pnext = pendingForwards.putIfAbsent(fwd.nextId(), - Sets.newHashSet(new PendingNext(deviceId, fwd))); + Set newset = Collections.newSetFromMap( + new ConcurrentHashMap()); + newset.add(new PendingNext(deviceId, fwd)); + Set pnext = pendingForwards.putIfAbsent(fwd.nextId(), newset); if (pnext != null) { pnext.add(new PendingNext(deviceId, fwd)); } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java index ebf681a2..ff711a02 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java @@ -34,6 +34,7 @@ import org.onosproject.net.HostId; import org.onosproject.net.Link; import org.onosproject.net.LinkKey; import org.onosproject.net.NetworkResource; +import org.onosproject.net.PortNumber; import org.onosproject.net.device.DeviceEvent; import org.onosproject.net.device.DeviceListener; import org.onosproject.net.device.DeviceService; @@ -302,11 +303,11 @@ public class ObjectiveTracker implements ObjectiveTrackerService { private class InternalResourceListener implements ResourceListener { @Override public void event(ResourceEvent event) { - Optional> linkEvent = event.subject().components().stream() + Optional> deviceEvent = event.subject().components().stream() .map(Object::getClass) - .filter(x -> x == LinkKey.class) + .filter(x -> x == PortNumber.class) .findFirst(); - if (linkEvent.isPresent()) { + if (deviceEvent.isPresent()) { executorService.execute(() -> { if (delegate == null) { return; diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java index 718c7bbf..5549918c 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java @@ -15,6 +15,7 @@ */ package org.onosproject.net.intent.impl.compiler; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import org.apache.felix.scr.annotations.Activate; @@ -59,9 +60,9 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.Stream; import static com.google.common.base.Preconditions.checkNotNull; import static org.onosproject.net.LinkKey.linkKey; @@ -120,11 +121,16 @@ public class MplsPathIntentCompiler implements IntentCompiler { return Collections.emptyMap(); } - List resources = labels.entrySet().stream() - .map(x -> ResourcePath.discrete(linkKey(x.getKey().src(), x.getKey().src()), x.getValue())) - .collect(Collectors.toList()); + // for short term solution: same label is used for both directions + // TODO: introduce the concept of Tx and Rx resources of a port + Set resources = labels.entrySet().stream() + .flatMap(x -> Stream.of( + ResourcePath.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue()), + ResourcePath.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue()) + )) + .collect(Collectors.toSet()); List allocations = - resourceService.allocate(intent.id(), resources); + resourceService.allocate(intent.id(), ImmutableList.copyOf(resources)); if (allocations.isEmpty()) { Collections.emptyMap(); } @@ -135,20 +141,23 @@ public class MplsPathIntentCompiler implements IntentCompiler { private Map findMplsLabels(Set links) { Map labels = new HashMap<>(); for (LinkKey link : links) { - Optional label = findMplsLabel(link); - if (label.isPresent()) { - labels.put(link, label.get()); + Set forward = findMplsLabel(link.src()); + Set backward = findMplsLabel(link.dst()); + Set common = Sets.intersection(forward, backward); + if (common.isEmpty()) { + continue; } + labels.put(link, common.iterator().next()); } return labels; } - private Optional findMplsLabel(LinkKey link) { - return resourceService.getAvailableResources(ResourcePath.discrete(link)).stream() + private Set findMplsLabel(ConnectPoint cp) { + return resourceService.getAvailableResources(ResourcePath.discrete(cp.deviceId(), cp.port())).stream() .filter(x -> x.last() instanceof MplsLabel) .map(x -> (MplsLabel) x.last()) - .findFirst(); + .collect(Collectors.toSet()); } private MplsLabel getMplsLabel(Map labels, LinkKey link) { diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java index 2941ddba..e017ac58 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java @@ -57,9 +57,9 @@ import java.util.Collections; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.Stream; import static com.google.common.base.Preconditions.checkArgument; -import static org.onosproject.net.LinkKey.linkKey; /** * An intent compiler for {@link org.onosproject.net.intent.OpticalConnectivityIntent}. @@ -182,7 +182,10 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler lambdaResources = path.links().stream() - .map(x -> ResourcePath.discrete(linkKey(x.src(), x.dst()))) + .flatMap(x -> Stream.of( + ResourcePath.discrete(x.src().deviceId(), x.src().port()), + ResourcePath.discrete(x.dst().deviceId(), x.dst().port()) + )) .map(x -> x.child(minLambda)) .collect(Collectors.toList()); @@ -197,7 +200,10 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler findCommonLambdasOverLinks(List links) { return links.stream() - .map(x -> ResourcePath.discrete(linkKey(x.src(), x.dst()))) + .flatMap(x -> Stream.of( + ResourcePath.discrete(x.src().deviceId(), x.src().port()), + ResourcePath.discrete(x.dst().deviceId(), x.dst().port()) + )) .map(resourceService::getAvailableResources) .map(x -> Iterables.filter(x, r -> r.last() instanceof IndexedLambda)) .map(x -> Iterables.transform(x, r -> (IndexedLambda) r.last())) diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java index 801092f4..ff74dbde 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java @@ -38,6 +38,7 @@ import org.slf4j.Logger; public final class BasicLinkOperator implements ConfigOperator { private static final long DEF_BANDWIDTH = -1L; + private static final double DEF_METRIC = -1; private static final Duration DEF_DURATION = Duration.ofNanos(-1L); private static final Logger log = getLogger(BasicLinkOperator.class); @@ -77,6 +78,9 @@ public final class BasicLinkOperator implements ConfigOperator { */ public static SparseAnnotations combine(BasicLinkConfig cfg, SparseAnnotations an) { DefaultAnnotations.Builder b = DefaultAnnotations.builder(); + if (cfg.metric() != DEF_METRIC) { + b.set(AnnotationKeys.METRIC, String.valueOf(cfg.metric())); + } if (cfg.latency() != DEF_DURATION) { b.set(AnnotationKeys.LATENCY, cfg.latency().toString()); } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java index 4fb0d7ba..bfc6a995 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java @@ -16,19 +16,32 @@ package org.onosproject.net.newresource.impl; import com.google.common.collect.Lists; +import org.onlab.packet.MplsLabel; +import org.onlab.packet.VlanId; +import org.onlab.util.ItemNotFoundException; import org.onosproject.net.Device; +import org.onosproject.net.DeviceId; import org.onosproject.net.Port; import org.onosproject.net.OchPort; +import org.onosproject.net.OchSignal; +import org.onosproject.net.PortNumber; import org.onosproject.net.TributarySlot; import org.onosproject.net.OduSignalType; +import org.onosproject.net.behaviour.LambdaQuery; +import org.onosproject.net.behaviour.MplsQuery; +import org.onosproject.net.behaviour.VlanQuery; import org.onosproject.net.device.DeviceEvent; import org.onosproject.net.device.DeviceListener; +import org.onosproject.net.driver.DriverHandler; +import org.onosproject.net.driver.DriverService; import org.onosproject.net.newresource.ResourceAdminService; import org.onosproject.net.newresource.ResourcePath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Collections; import java.util.List; +import java.util.SortedSet; import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -42,12 +55,19 @@ final class ResourceDeviceListener implements DeviceListener { private static final Logger log = LoggerFactory.getLogger(ResourceDeviceListener.class); + private static final int MAX_VLAN_ID = VlanId.MAX_VLAN; + private static final List ENTIRE_VLAN_IDS = getEntireVlans(); + + private static final int MAX_MPLS_LABEL = 1048576; + private static final List ENTIRE_MPLS_LABELS = getEntireMplsLabels(); + private static final int TOTAL_ODU2_TRIBUTARY_SLOTS = 8; private static final int TOTAL_ODU4_TRIBUTARY_SLOTS = 80; private static final List ENTIRE_ODU2_TRIBUTARY_SLOTS = getEntireOdu2TributarySlots(); private static final List ENTIRE_ODU4_TRIBUTARY_SLOTS = getEntireOdu4TributarySlots(); private final ResourceAdminService adminService; + private final DriverService driverService; private final ExecutorService executor; /** @@ -56,8 +76,10 @@ final class ResourceDeviceListener implements DeviceListener { * @param adminService instance invoked to register resources * @param executor executor used for processing resource registration */ - ResourceDeviceListener(ResourceAdminService adminService, ExecutorService executor) { + ResourceDeviceListener(ResourceAdminService adminService, DriverService driverService, + ExecutorService executor) { this.adminService = checkNotNull(adminService); + this.driverService = checkNotNull(driverService); this.executor = checkNotNull(executor); } @@ -95,6 +117,26 @@ final class ResourceDeviceListener implements DeviceListener { executor.submit(() -> { adminService.registerResources(portPath); + // for VLAN IDs + if (isVlanEnabled(device.id(), port.number())) { + adminService.registerResources(Lists.transform(ENTIRE_VLAN_IDS, portPath::child)); + } + + // for MPLS labels + if (isMplsEnabled(device.id(), port.number())) { + adminService.registerResources(Lists.transform(ENTIRE_MPLS_LABELS, portPath::child)); + } + + // for Lambdas + SortedSet lambdas = queryLambdas(device.id(), port.number()); + if (!lambdas.isEmpty()) { + adminService.registerResources(lambdas.stream() + .map(portPath::child) + .collect(Collectors.toList())); + } + + // for Tributary slots + // TODO: need to define Behaviour to make a query about OCh port switch (port.type()) { case OCH: // register ODU TributarySlots against the OCH port @@ -124,15 +166,68 @@ final class ResourceDeviceListener implements DeviceListener { executor.submit(() -> adminService.unregisterResources(resource)); } + private SortedSet queryLambdas(DeviceId did, PortNumber port) { + try { + DriverHandler handler = driverService.createHandler(did); + if (handler == null) { + return Collections.emptySortedSet(); + } + LambdaQuery query = handler.behaviour(LambdaQuery.class); + return query.queryLambdas(port); + } catch (ItemNotFoundException e) { + return Collections.emptySortedSet(); + } + } + + private boolean isVlanEnabled(DeviceId device, PortNumber port) { + try { + DriverHandler handler = driverService.createHandler(device); + if (handler == null) { + return false; + } + + VlanQuery query = handler.behaviour(VlanQuery.class); + return query != null && query.isEnabled(port); + } catch (ItemNotFoundException e) { + return false; + } + } + + private boolean isMplsEnabled(DeviceId device, PortNumber port) { + try { + DriverHandler handler = driverService.createHandler(device); + if (handler == null) { + return false; + } + + MplsQuery query = handler.behaviour(MplsQuery.class); + return query != null && query.isEnabled(port); + } catch (ItemNotFoundException e) { + return false; + } + } + + private static List getEntireVlans() { + return IntStream.range(0, MAX_VLAN_ID) + .mapToObj(x -> VlanId.vlanId((short) x)) + .collect(Collectors.toList()); + } + + private static List getEntireMplsLabels() { + // potentially many objects are created + return IntStream.range(0, MAX_MPLS_LABEL) + .mapToObj(MplsLabel::mplsLabel) + .collect(Collectors.toList()); + } + private static List getEntireOdu2TributarySlots() { return IntStream.rangeClosed(1, TOTAL_ODU2_TRIBUTARY_SLOTS) - .mapToObj(x -> TributarySlot.of(x)) + .mapToObj(TributarySlot::of) .collect(Collectors.toList()); } private static List getEntireOdu4TributarySlots() { return IntStream.rangeClosed(1, TOTAL_ODU4_TRIBUTARY_SLOTS) - .mapToObj(x -> TributarySlot.of(x)) + .mapToObj(TributarySlot::of) .collect(Collectors.toList()); } - } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java deleted file mode 100644 index 9d2e06f5..00000000 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java +++ /dev/null @@ -1,153 +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.net.newresource.impl; - -import com.google.common.collect.Lists; -import org.onlab.packet.MplsLabel; -import org.onlab.packet.VlanId; -import org.onlab.util.ItemNotFoundException; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.Link; -import org.onosproject.net.LinkKey; -import org.onosproject.net.behaviour.MplsQuery; -import org.onosproject.net.behaviour.VlanQuery; -import org.onosproject.net.driver.DriverHandler; -import org.onosproject.net.driver.DriverService; -import org.onosproject.net.link.LinkEvent; -import org.onosproject.net.link.LinkListener; -import org.onosproject.net.newresource.ResourceAdminService; -import org.onosproject.net.newresource.ResourcePath; - -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * An implementation of LinkListener registering links as resources. - */ -final class ResourceLinkListener implements LinkListener { - - private static final int TOTAL_VLANS = 1024; - private static final List ENTIRE_VLAN_IDS = getEntireVlans(); - - private static final int TOTAL_MPLS_LABELS = 1048576; - private static final List ENTIRE_MPLS_LABELS = getEntireMplsLabels(); - - private final ResourceAdminService adminService; - private final DriverService driverService; - private final ExecutorService executor; - - /** - * Creates an instance with the specified ResourceAdminService and ExecutorService. - * - * @param adminService instance invoked to register resources - * @param driverService driver service instance - * @param executor executor used for processing resource registration - */ - ResourceLinkListener(ResourceAdminService adminService, DriverService driverService, ExecutorService executor) { - this.adminService = checkNotNull(adminService); - this.driverService = checkNotNull(driverService); - this.executor = checkNotNull(executor); - } - - @Override - public void event(LinkEvent event) { - Link link = event.subject(); - switch (event.type()) { - case LINK_ADDED: - registerLinkResource(link); - break; - case LINK_REMOVED: - unregisterLinkResource(link); - break; - default: - break; - } - } - - private void registerLinkResource(Link link) { - executor.submit(() -> { - // register the link - LinkKey linkKey = LinkKey.linkKey(link); - adminService.registerResources(ResourcePath.discrete(linkKey)); - - ResourcePath linkPath = ResourcePath.discrete(linkKey); - // register VLAN IDs against the link - if (isEnabled(link, this::isVlanEnabled)) { - adminService.registerResources(Lists.transform(ENTIRE_VLAN_IDS, linkPath::child)); - } - - // register MPLS labels against the link - if (isEnabled(link, this::isMplsEnabled)) { - adminService.registerResources(Lists.transform(ENTIRE_MPLS_LABELS, linkPath::child)); - } - }); - } - - private void unregisterLinkResource(Link link) { - LinkKey linkKey = LinkKey.linkKey(link); - executor.submit(() -> adminService.unregisterResources(ResourcePath.discrete(linkKey))); - } - - private boolean isEnabled(Link link, Predicate predicate) { - return predicate.test(link.src()) && predicate.test(link.dst()); - } - - private boolean isVlanEnabled(ConnectPoint cp) { - try { - DriverHandler handler = driverService.createHandler(cp.deviceId()); - if (handler == null) { - return false; - } - - VlanQuery query = handler.behaviour(VlanQuery.class); - return query != null && query.isEnabled(cp.port()); - } catch (ItemNotFoundException e) { - return false; - } - } - - private boolean isMplsEnabled(ConnectPoint cp) { - try { - DriverHandler handler = driverService.createHandler(cp.deviceId()); - if (handler == null) { - return false; - } - - MplsQuery query = handler.behaviour(MplsQuery.class); - return query != null && query.isEnabled(cp.port()); - } catch (ItemNotFoundException e) { - return false; - } - } - - private static List getEntireVlans() { - return IntStream.range(0, TOTAL_VLANS) - .mapToObj(x -> VlanId.vlanId((short) x)) - .collect(Collectors.toList()); - } - - private static List getEntireMplsLabels() { - // potentially many objects are created - return IntStream.range(0, TOTAL_MPLS_LABELS) - .mapToObj(MplsLabel::mplsLabel) - .collect(Collectors.toList()); - } -} diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java index 143f8c2b..e8042661 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java @@ -24,8 +24,6 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; import org.onosproject.net.device.DeviceListener; import org.onosproject.net.device.DeviceService; import org.onosproject.net.driver.DriverService; -import org.onosproject.net.link.LinkListener; -import org.onosproject.net.link.LinkService; import org.onosproject.net.newresource.ResourceAdminService; import java.util.concurrent.ExecutorService; @@ -49,25 +47,18 @@ public final class ResourceRegistrar { @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected DeviceService deviceService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected LinkService linkService; - private DeviceListener deviceListener; - private LinkListener linkListener; private final ExecutorService executor = Executors.newSingleThreadExecutor(groupedThreads("onos/resource", "registrar")); @Activate public void activate() { - deviceListener = new ResourceDeviceListener(adminService, executor); + deviceListener = new ResourceDeviceListener(adminService, driverService, executor); deviceService.addListener(deviceListener); - linkListener = new ResourceLinkListener(adminService, driverService, executor); - linkService.addListener(linkListener); } @Deactivate public void deactivate() { deviceService.removeListener(deviceListener); - linkService.removeListener(linkListener); } } diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/edgeservice/impl/EdgeManagerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/edgeservice/impl/EdgeManagerTest.java index 319412fe..70be5deb 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/edgeservice/impl/EdgeManagerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/edgeservice/impl/EdgeManagerTest.java @@ -22,7 +22,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onosproject.common.event.impl.TestEventDispatcher; -import org.onosproject.event.Event; import org.onosproject.net.ConnectPoint; import org.onosproject.net.DefaultPort; import org.onosproject.net.Device; @@ -31,15 +30,17 @@ import org.onosproject.net.NetTestTools; import org.onosproject.net.Port; import org.onosproject.net.PortNumber; import org.onosproject.net.device.DeviceEvent; +import org.onosproject.net.device.DeviceListener; import org.onosproject.net.device.DeviceServiceAdapter; import org.onosproject.net.edge.EdgePortEvent; import org.onosproject.net.edge.EdgePortListener; import org.onosproject.net.flow.TrafficTreatment; import org.onosproject.net.link.LinkEvent; +import org.onosproject.net.link.LinkListener; +import org.onosproject.net.link.LinkServiceAdapter; import org.onosproject.net.packet.OutboundPacket; import org.onosproject.net.packet.PacketServiceAdapter; import org.onosproject.net.topology.Topology; -import org.onosproject.net.topology.TopologyEvent; import org.onosproject.net.topology.TopologyListener; import org.onosproject.net.topology.TopologyServiceAdapter; @@ -58,7 +59,6 @@ import static org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_ADDED; import static org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_REMOVED; import static org.onosproject.net.link.LinkEvent.Type.LINK_ADDED; import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED; -import static org.onosproject.net.topology.TopologyEvent.Type.TOPOLOGY_CHANGED; /** * Test of the edge port manager. Each device has ports '0' through 'numPorts - 1' @@ -74,6 +74,8 @@ public class EdgeManagerTest { private final Map devices = Maps.newConcurrentMap(); private Set packets = Sets.newConcurrentHashSet(); private final EdgePortListener testListener = new TestListener(events); + private TestLinkManager testLinkManager; + private TestDeviceManager testDeviceManager; private TestTopologyManager testTopologyManager; @Before @@ -82,8 +84,11 @@ public class EdgeManagerTest { injectEventDispatcher(mgr, new TestEventDispatcher()); testTopologyManager = new TestTopologyManager(infrastructurePorts); mgr.topologyService = testTopologyManager; - mgr.deviceService = new TestDeviceManager(devices); + testDeviceManager = new TestDeviceManager(devices); + mgr.deviceService = testDeviceManager; mgr.packetService = new TestPacketManager(); + testLinkManager = new TestLinkManager(); + mgr.linkService = testLinkManager; mgr.activate(); mgr.addListener(testListener); @@ -108,11 +113,11 @@ public class EdgeManagerTest { assertFalse("no ports expected", mgr.getEdgePoints().iterator().hasNext()); assertFalse("Expected isEdge to return false", - mgr.isEdgePoint(NetTestTools.connectPoint(Integer.toString(1), 1))); + mgr.isEdgePoint(NetTestTools.connectPoint(Integer.toString(1), 1))); removeInfraPort(NetTestTools.connectPoint(Integer.toString(1), 1)); assertTrue("Expected isEdge to return false", - mgr.isEdgePoint(NetTestTools.connectPoint(Integer.toString(1), 1))); + mgr.isEdgePoint(NetTestTools.connectPoint(Integer.toString(1), 1))); } @Test @@ -121,69 +126,57 @@ public class EdgeManagerTest { ConnectPoint testPoint, referencePoint; //Testing link removal - List eventsToAdd = Lists.newArrayList(); - eventsToAdd.add(new LinkEvent(LINK_REMOVED, NetTestTools.link("a", 1, "b", 2))); - TopologyEvent event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); - testTopologyManager.listener.event(event); + testLinkManager.listener.event(new LinkEvent(LINK_REMOVED, NetTestTools.link("a", 1, "b", 2))); assertTrue("The list contained an unexpected number of events", events.size() == 2); assertTrue("The first element is of the wrong type.", - events.get(0).type() == EDGE_PORT_ADDED); - assertTrue("The second element is of the wrong type.", - events.get(1).type() == EDGE_PORT_ADDED); + events.get(0).type() == EDGE_PORT_ADDED); testPoint = events.get(0).subject(); referencePoint = NetTestTools.connectPoint("a", 1); assertTrue("The port numbers of the first element are incorrect", - testPoint.port().toLong() == referencePoint.port().toLong()); + testPoint.port().toLong() == referencePoint.port().toLong()); assertTrue("The device id of the first element is incorrect.", - testPoint.deviceId().equals(referencePoint.deviceId())); + testPoint.deviceId().equals(referencePoint.deviceId())); testPoint = events.get(1).subject(); referencePoint = NetTestTools.connectPoint("b", 2); assertTrue("The port numbers of the second element are incorrect", - testPoint.port().toLong() == referencePoint.port().toLong()); + testPoint.port().toLong() == referencePoint.port().toLong()); assertTrue("The device id of the second element is incorrect.", - testPoint.deviceId().equals(referencePoint.deviceId())); + testPoint.deviceId().equals(referencePoint.deviceId())); //Rebroadcast event to ensure it results in no additional events - testTopologyManager.listener.event(event); + testLinkManager.listener.event(new LinkEvent(LINK_REMOVED, NetTestTools.link("a", 1, "b", 2))); assertTrue("The list contained an unexpected number of events", events.size() == 2); //Testing link adding when links to remove exist - eventsToAdd.clear(); events.clear(); - eventsToAdd.add(new LinkEvent(LINK_ADDED, NetTestTools.link("a", 1, "b", 2))); - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); - testTopologyManager.listener.event(event); + testLinkManager.listener.event(new LinkEvent(LINK_ADDED, NetTestTools.link("a", 1, "b", 2))); assertTrue("The list contained an unexpected number of events", events.size() == 2); assertTrue("The first element is of the wrong type.", - events.get(0).type() == EDGE_PORT_REMOVED); + events.get(0).type() == EDGE_PORT_REMOVED); assertTrue("The second element is of the wrong type.", - events.get(1).type() == EDGE_PORT_REMOVED); + events.get(1).type() == EDGE_PORT_REMOVED); testPoint = events.get(0).subject(); referencePoint = NetTestTools.connectPoint("a", 1); assertTrue("The port numbers of the first element are incorrect", - testPoint.port().toLong() == referencePoint.port().toLong()); + testPoint.port().toLong() == referencePoint.port().toLong()); assertTrue("The device id of the first element is incorrect.", - testPoint.deviceId().equals(referencePoint.deviceId())); + testPoint.deviceId().equals(referencePoint.deviceId())); testPoint = events.get(1).subject(); referencePoint = NetTestTools.connectPoint("b", 2); assertTrue("The port numbers of the second element are incorrect", - testPoint.port().toLong() == referencePoint.port().toLong()); + testPoint.port().toLong() == referencePoint.port().toLong()); assertTrue("The device id of the second element is incorrect.", - testPoint.deviceId().equals(referencePoint.deviceId())); + testPoint.deviceId().equals(referencePoint.deviceId())); //Apparent duplicate of previous method tests removal when the elements have already been removed - eventsToAdd.clear(); events.clear(); - eventsToAdd.add(new LinkEvent(LINK_ADDED, NetTestTools.link("a", 1, "b", 2))); - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); - testTopologyManager.listener.event(event); - + testLinkManager.listener.event(new LinkEvent(LINK_ADDED, NetTestTools.link("a", 1, "b", 2))); assertTrue("The list should contain no events, the removed elements don't exist.", events.size() == 0); } @@ -192,8 +185,7 @@ public class EdgeManagerTest { //Setup Device referenceDevice; - TopologyEvent event; - List eventsToAdd = Lists.newArrayList(); + DeviceEvent event; int numDevices = 10; int numInfraPorts = 5; totalPorts = 10; @@ -201,14 +193,13 @@ public class EdgeManagerTest { //Test response to device added events referenceDevice = NetTestTools.device("1"); - eventsToAdd.add(new DeviceEvent(DEVICE_ADDED, referenceDevice, - new DefaultPort(referenceDevice, PortNumber.portNumber(1), true))); - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); - testTopologyManager.listener.event(event); + event = new DeviceEvent(DEVICE_ADDED, referenceDevice, + new DefaultPort(referenceDevice, PortNumber.portNumber(1), true)); + testDeviceManager.listener.event(event); //Check that ports were populated correctly assertTrue("Unexpected number of new ports added", - mgr.deviceService.getPorts(NetTestTools.did("1")).size() == 10); + mgr.deviceService.getPorts(NetTestTools.did("1")).size() == 10); //Check that of the ten ports the half that are infrastructure ports aren't added assertEquals("Unexpected number of new edge ports added", (totalPorts - numInfraPorts), events.size()); @@ -219,15 +210,15 @@ public class EdgeManagerTest { //Names here are irrelevant, the first 5 ports are populated as infrastructure, 6-10 are edge for (int index = 0; index < events.size(); index++) { assertEquals("Port added had unexpected port number.", - events.get(index).subject().port(), - NetTestTools.connectPoint("a", index + numInfraPorts + 1).port()); + events.get(index).subject().port(), + NetTestTools.connectPoint("a", index + numInfraPorts + 1).port()); } events.clear(); //Repost the event to test repeated posts - testTopologyManager.listener.event(event); + testDeviceManager.listener.event(event); assertEquals("The redundant notification should not have created additional notifications.", - 0, events.size()); + 0, events.size()); //Calculate the size of the returned iterable of edge points. Iterable pts = mgr.getEdgePoints(); Iterator pointIterator = pts.iterator(); @@ -238,45 +229,41 @@ public class EdgeManagerTest { assertEquals("Unexpected number of edge points", totalPorts - numInfraPorts, count); //Testing device removal events.clear(); - eventsToAdd.clear(); - eventsToAdd.add(new DeviceEvent(DEVICE_REMOVED, referenceDevice, - new DefaultPort(referenceDevice, PortNumber.portNumber(1), true))); - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); - testTopologyManager.listener.event(event); + event = (new DeviceEvent(DEVICE_REMOVED, referenceDevice, + new DefaultPort(referenceDevice, PortNumber.portNumber(1), true))); + testDeviceManager.listener.event(event); assertEquals("There should be five new events from removal of edge points", - totalPorts - numInfraPorts, events.size()); + totalPorts - numInfraPorts, events.size()); for (int index = 0; index < events.size(); index++) { //Assert that the correct port numbers were removed in the correct order assertEquals("Port removed had unexpected port number.", - events.get(index).subject().port(), - (NetTestTools.connectPoint("a", index + numInfraPorts + 1).port())); + events.get(index).subject().port(), + (NetTestTools.connectPoint("a", index + numInfraPorts + 1).port())); //Assert that the events are of the correct type assertEquals("Unexpected type of event", events.get(index).type(), EDGE_PORT_REMOVED); } events.clear(); //Rebroadcast event to check that it triggers no new behavior - testTopologyManager.listener.event(event); + testDeviceManager.listener.event(event); assertEquals("Rebroadcast of removal event should not produce additional events", - 0, events.size()); + 0, events.size()); //Testing device status change, changed from unavailable to available events.clear(); - eventsToAdd.clear(); //Make sure that the devicemanager shows the device as available. addDevice(referenceDevice, "1", 5); devices.put(referenceDevice.id(), referenceDevice); - eventsToAdd.add(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, referenceDevice)); - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); - testTopologyManager.listener.event(event); + event = new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, referenceDevice); + testDeviceManager.listener.event(event); //An earlier setup set half of the reference device ports to infrastructure assertEquals("An unexpected number of events were generated.", totalPorts - numInfraPorts, events.size()); for (int i = 0; i < 5; i++) { assertEquals("The event was not of the right type", events.get(i).type(), EDGE_PORT_ADDED); } events.clear(); - testTopologyManager.listener.event(event); + testDeviceManager.listener.event(event); assertEquals("No events should have been generated for a set of existing ports.", 0, events.size()); //Test removal when state changes when the device becomes unavailable @@ -288,21 +275,20 @@ public class EdgeManagerTest { no events will be generated since no ports will be provided in getPorts() to EdgeManager. */ alwaysReturnPorts = true; - testTopologyManager.listener.event(event); + testDeviceManager.listener.event(event); alwaysReturnPorts = false; assertEquals("An unexpected number of events were created.", totalPorts - numInfraPorts, events.size()); for (int i = 0; i < 5; i++) { EdgePortEvent edgeEvent = events.get(i); assertEquals("The event is of an unexpected type.", - EdgePortEvent.Type.EDGE_PORT_REMOVED, edgeEvent.type()); + EdgePortEvent.Type.EDGE_PORT_REMOVED, edgeEvent.type()); assertEquals("The event pertains to an unexpected port", PortNumber.portNumber(i + numInfraPorts + 1), - edgeEvent.subject().port()); + edgeEvent.subject().port()); } } @Test public void testInternalCache() { - List eventsToAdd = Lists.newArrayList(); int numDevices = 10; //Number of infrastructure ports per device int numPorts = 5; @@ -312,11 +298,8 @@ public class EdgeManagerTest { for (int i = 0; i < numDevices; i++) { Device newDevice = NetTestTools.device(Integer.toString(i)); devices.put(newDevice.id(), newDevice); - eventsToAdd.add(new DeviceEvent(DEVICE_ADDED, newDevice)); + testDeviceManager.listener.event(new DeviceEvent(DEVICE_ADDED, newDevice)); } - TopologyEvent event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); - testTopologyManager.listener.event(event); - //Check all ports have correct designations ConnectPoint testPoint; for (int deviceNum = 0; deviceNum < numDevices; deviceNum++) { @@ -334,7 +317,7 @@ public class EdgeManagerTest { count++; } assertEquals("There are an unexpeceted number of edge points returned.", - (totalPorts - numPorts) * numDevices, count); + (totalPorts - numPorts) * numDevices, count); for (int deviceNumber = 0; deviceNumber < numDevices; deviceNumber++) { count = 0; for (ConnectPoint ignored : mgr.getEdgePoints(NetTestTools.did("1"))) { @@ -349,8 +332,7 @@ public class EdgeManagerTest { public void testEmit() { byte[] arr = new byte[10]; Device referenceDevice; - TopologyEvent event; - List eventsToAdd = Lists.newArrayList(); + DeviceEvent event; int numDevices = 10; int numInfraPorts = 5; totalPorts = 10; @@ -360,16 +342,16 @@ public class EdgeManagerTest { } for (int i = 0; i < numDevices; i++) { referenceDevice = NetTestTools.device(Integer.toString(i)); - eventsToAdd.add(new DeviceEvent(DEVICE_ADDED, referenceDevice, - new DefaultPort(referenceDevice, PortNumber.portNumber(1), true))); + testDeviceManager.listener.event(new DeviceEvent(DEVICE_ADDED, referenceDevice, + new DefaultPort(referenceDevice, + PortNumber.portNumber(1), + true))); } - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); - testTopologyManager.listener.event(event); mgr.emitPacket(ByteBuffer.wrap(arr), Optional.empty()); assertEquals("There were an unexpected number of emitted packets", - (totalPorts - numInfraPorts) * numDevices, packets.size()); + (totalPorts - numInfraPorts) * numDevices, packets.size()); Iterator packetIter = packets.iterator(); OutboundPacket packet; while (packetIter.hasNext()) { @@ -381,7 +363,7 @@ public class EdgeManagerTest { mgr.emitPacket(NetTestTools.did(Integer.toString(1)), ByteBuffer.wrap(arr), Optional.empty()); assertEquals("Unexpected number of outbound packets were emitted.", - totalPorts - numInfraPorts, packets.size()); + totalPorts - numInfraPorts, packets.size()); packetIter = packets.iterator(); while (packetIter.hasNext()) { packet = packetIter.next(); @@ -455,6 +437,7 @@ public class EdgeManagerTest { } private class TestDeviceManager extends DeviceServiceAdapter { + private DeviceListener listener; private Map devices; @@ -490,6 +473,17 @@ public class EdgeManagerTest { public Iterable getAvailableDevices() { return devices.values(); } + + + @Override + public void addListener(DeviceListener listener) { + this.listener = listener; + } + + @Override + public void removeListener(DeviceListener listener) { + this.listener = null; + } } private class TestPacketManager extends PacketServiceAdapter { @@ -499,6 +493,15 @@ public class EdgeManagerTest { } } + private class TestLinkManager extends LinkServiceAdapter { + private LinkListener listener; + + @Override + public void addListener(LinkListener listener) { + this.listener = listener; + } + } + private class TestListener implements EdgePortListener { private List events; diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java index eb7f2ccd..7cee0d0e 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java @@ -29,8 +29,10 @@ import org.onlab.junit.TestUtils.TestUtilsException; import org.onosproject.core.IdGenerator; import org.onosproject.event.Event; import org.onosproject.net.Device; +import org.onosproject.net.DeviceId; import org.onosproject.net.Link; import org.onosproject.net.NetworkResource; +import org.onosproject.net.PortNumber; import org.onosproject.net.device.DeviceEvent; import org.onosproject.net.device.DeviceListener; import org.onosproject.net.intent.Intent; @@ -52,7 +54,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; -import static org.onosproject.net.LinkKey.linkKey; import static org.onosproject.net.newresource.ResourceEvent.Type.*; import static org.onosproject.net.NetTestTools.APP_ID; import static org.onosproject.net.NetTestTools.device; @@ -231,7 +232,7 @@ public class ObjectiveTrackerTest { @Test public void testResourceEvent() throws Exception { ResourceEvent event = new ResourceEvent(RESOURCE_ADDED, - ResourcePath.discrete(linkKey(link("a", 1, "b", 1)))); + ResourcePath.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1))); resourceListener.event(event); assertThat( -- cgit 1.2.3-korg