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 --- .../impl/compiler/MplsPathIntentCompiler.java | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java') 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) { -- cgit 1.2.3-korg