diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-01 05:49:27 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-01 05:49:27 -0800 |
commit | e63291850fd0795c5700e25e67e5dee89ba54c5f (patch) | |
tree | 9707289536ad95bb739c9856761ad43275e07d8c /framework/src/onos/core/net | |
parent | 671823e12bc13be9a8b87a5d7de33da1bb7a44e8 (diff) |
onos commit hash c2999f30c69e50df905a9d175ef80b3f23a98514
Change-Id: I2bb8562c4942b6d6a6d60b663db2e17540477b81
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/core/net')
8 files changed, 117 insertions, 37 deletions
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java index d09eb1f1..80a5ca77 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java @@ -237,12 +237,22 @@ public class ApplicationManager boolean changed = false; for (String name : app.features()) { Feature feature = featuresService.getFeature(name); + + // If we see an attempt at activation of a non-existent feature + // attempt to install the app artifacts first and then retry. + // This can be triggered by a race condition between different ONOS + // instances "installing" the apps from disk at their own pace. + // Perhaps there is a more elegant solution to be explored in the + // future. + if (feature == null) { + installAppArtifacts(app); + feature = featuresService.getFeature(name); + } + if (feature != null && !featuresService.isInstalled(feature)) { featuresService.installFeature(name); changed = true; - } else if (feature == null && !initializing) { - // Suppress feature-not-found reporting during startup since these - // can arise naturally from the staggered cluster install. + } else if (feature == null) { log.warn("Feature {} not found", name); } } 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 a76a298f..5ecdc7a2 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 @@ -54,6 +54,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ExecutorService; @@ -226,10 +227,11 @@ public class FlowObjectiveManager implements FlowObjectiveService { if (fwd.nextId() != null && flowObjectiveStore.getNextGroup(fwd.nextId()) == null) { log.trace("Queuing forwarding objective for nextId {}", fwd.nextId()); - if (pendingForwards.putIfAbsent(fwd.nextId(), - Sets.newHashSet(new PendingNext(deviceId, fwd))) != null) { - Set<PendingNext> pending = pendingForwards.get(fwd.nextId()); - pending.add(new PendingNext(deviceId, fwd)); + // TODO: change to computeIfAbsent + Set<PendingNext> pnext = pendingForwards.putIfAbsent(fwd.nextId(), + Sets.newHashSet(new PendingNext(deviceId, fwd))); + if (pnext != null) { + pnext.add(new PendingNext(deviceId, fwd)); } return true; } @@ -412,5 +414,26 @@ public class FlowObjectiveManager implements FlowObjectiveService { public ForwardingObjective forwardingObjective() { return fwd; } + + @Override + public int hashCode() { + return Objects.hash(deviceId, fwd); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof PendingNext)) { + return false; + } + final PendingNext other = (PendingNext) obj; + if (this.deviceId.equals(other.deviceId) && + this.fwd.equals(other.fwd)) { + return true; + } + return false; + } } } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java index 4dc93a51..5fb1dcf1 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java @@ -168,7 +168,9 @@ public class HostMonitor implements TimerTask { } } - this.timeout = Timer.getTimer().newTimeout(this, probeRate, TimeUnit.MILLISECONDS); + synchronized (this) { + this.timeout = Timer.getTimer().newTimeout(this, probeRate, TimeUnit.MILLISECONDS); + } } /** 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 a4ed551a..2941ddba 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 @@ -189,6 +189,7 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical List<ResourceAllocation> allocations = resourceService.allocate(intent.id(), lambdaResources); if (allocations.isEmpty()) { log.info("Resource allocation for {} failed (resource request: {})", intent, lambdaResources); + return null; } return minLambda; 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 066dd33e..4fb0d7ba 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 @@ -15,14 +15,23 @@ */ package org.onosproject.net.newresource.impl; +import com.google.common.collect.Lists; import org.onosproject.net.Device; import org.onosproject.net.Port; +import org.onosproject.net.OchPort; +import org.onosproject.net.TributarySlot; +import org.onosproject.net.OduSignalType; import org.onosproject.net.device.DeviceEvent; import org.onosproject.net.device.DeviceListener; import org.onosproject.net.newresource.ResourceAdminService; import org.onosproject.net.newresource.ResourcePath; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; import java.util.concurrent.ExecutorService; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import static com.google.common.base.Preconditions.checkNotNull; @@ -31,6 +40,13 @@ import static com.google.common.base.Preconditions.checkNotNull; */ final class ResourceDeviceListener implements DeviceListener { + private static final Logger log = LoggerFactory.getLogger(ResourceDeviceListener.class); + + private static final int TOTAL_ODU2_TRIBUTARY_SLOTS = 8; + private static final int TOTAL_ODU4_TRIBUTARY_SLOTS = 80; + private static final List<TributarySlot> ENTIRE_ODU2_TRIBUTARY_SLOTS = getEntireOdu2TributarySlots(); + private static final List<TributarySlot> ENTIRE_ODU4_TRIBUTARY_SLOTS = getEntireOdu4TributarySlots(); + private final ResourceAdminService adminService; private final ExecutorService executor; @@ -67,20 +83,56 @@ final class ResourceDeviceListener implements DeviceListener { } private void registerDeviceResource(Device device) { - executor.submit(() -> adminService.registerResources(ResourcePath.ROOT, device.id())); + executor.submit(() -> adminService.registerResources(ResourcePath.discrete(device.id()))); } private void unregisterDeviceResource(Device device) { - executor.submit(() -> adminService.unregisterResources(ResourcePath.ROOT, device.id())); + executor.submit(() -> adminService.unregisterResources(ResourcePath.discrete(device.id()))); } private void registerPortResource(Device device, Port port) { - ResourcePath parent = ResourcePath.discrete(device.id()); - executor.submit(() -> adminService.registerResources(parent, port.number())); + ResourcePath portPath = ResourcePath.discrete(device.id(), port.number()); + executor.submit(() -> { + adminService.registerResources(portPath); + + switch (port.type()) { + case OCH: + // register ODU TributarySlots against the OCH port + registerTributarySlotsResources(((OchPort) port).signalType(), portPath); + break; + default: + break; + } + }); + } + + private void registerTributarySlotsResources(OduSignalType oduSignalType, ResourcePath portPath) { + switch (oduSignalType) { + case ODU2: + adminService.registerResources(Lists.transform(ENTIRE_ODU2_TRIBUTARY_SLOTS, portPath::child)); + break; + case ODU4: + adminService.registerResources(Lists.transform(ENTIRE_ODU4_TRIBUTARY_SLOTS, portPath::child)); + break; + default: + break; + } } private void unregisterPortResource(Device device, Port port) { - ResourcePath parent = ResourcePath.discrete(device.id()); - executor.submit(() -> adminService.unregisterResources(parent, port.number())); + ResourcePath resource = ResourcePath.discrete(device.id(), port.number()); + executor.submit(() -> adminService.unregisterResources(resource)); } + + private static List<TributarySlot> getEntireOdu2TributarySlots() { + return IntStream.rangeClosed(1, TOTAL_ODU2_TRIBUTARY_SLOTS) + .mapToObj(x -> TributarySlot.of(x)) + .collect(Collectors.toList()); + } + private static List<TributarySlot> getEntireOdu4TributarySlots() { + return IntStream.rangeClosed(1, TOTAL_ODU4_TRIBUTARY_SLOTS) + .mapToObj(x -> TributarySlot.of(x)) + .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 index 68fd6612..9d2e06f5 100644 --- 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 @@ -15,6 +15,7 @@ */ 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; @@ -85,24 +86,24 @@ final class ResourceLinkListener implements LinkListener { executor.submit(() -> { // register the link LinkKey linkKey = LinkKey.linkKey(link); - adminService.registerResources(ResourcePath.ROOT, linkKey); + adminService.registerResources(ResourcePath.discrete(linkKey)); ResourcePath linkPath = ResourcePath.discrete(linkKey); // register VLAN IDs against the link if (isEnabled(link, this::isVlanEnabled)) { - adminService.registerResources(linkPath, ENTIRE_VLAN_IDS); + adminService.registerResources(Lists.transform(ENTIRE_VLAN_IDS, linkPath::child)); } // register MPLS labels against the link if (isEnabled(link, this::isMplsEnabled)) { - adminService.registerResources(linkPath, ENTIRE_MPLS_LABELS); + adminService.registerResources(Lists.transform(ENTIRE_MPLS_LABELS, linkPath::child)); } }); } private void unregisterLinkResource(Link link) { LinkKey linkKey = LinkKey.linkKey(link); - executor.submit(() -> adminService.unregisterResources(ResourcePath.ROOT, linkKey)); + executor.submit(() -> adminService.unregisterResources(ResourcePath.discrete(linkKey))); } private boolean isEnabled(Link link, Predicate<ConnectPoint> predicate) { diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java index 1c6930bb..3014951a 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java @@ -17,7 +17,6 @@ package org.onosproject.net.newresource.impl; import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -41,7 +40,6 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; /** @@ -164,23 +162,17 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent } @Override - public <T> boolean registerResources(ResourcePath parent, List<T> children) { - checkNotNull(parent); - checkNotNull(children); - checkArgument(!children.isEmpty()); + public boolean registerResources(List<ResourcePath> resources) { + checkNotNull(resources); - List<ResourcePath> resources = Lists.transform(children, parent::child); return store.register(resources); } @Override - public <T> boolean unregisterResources(ResourcePath parent, List<T> children) { - checkNotNull(parent); - checkNotNull(children); - checkArgument(!children.isEmpty()); + public boolean unregisterResources(List<ResourcePath> resources) { + checkNotNull(resources); - List<ResourcePath> resources = Lists.transform(children, parent::child); - return store.unregister(resources); + return store.register(resources); } private class InternalStoreDelegate implements ResourceStoreDelegate { diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java index e57d9dbe..5d7b5c8d 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java @@ -21,6 +21,7 @@ import org.onlab.util.Bandwidth; import org.onosproject.TestApplicationId; import org.onosproject.core.ApplicationId; import org.onosproject.net.ConnectPoint; +import org.onosproject.net.IndexedLambda; import org.onosproject.net.Link; import org.onosproject.net.Path; import org.onosproject.net.flow.TrafficSelector; @@ -34,8 +35,6 @@ import org.onosproject.net.intent.PointToPointIntent; import org.onosproject.net.intent.constraint.BandwidthConstraint; import org.onosproject.net.intent.constraint.LambdaConstraint; import org.onosproject.net.intent.impl.PathNotFoundException; -import org.onosproject.net.resource.link.BandwidthResource; -import org.onosproject.net.resource.link.LambdaResource; import org.onosproject.net.resource.link.LinkResourceService; import java.util.Collections; @@ -229,7 +228,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { final LinkResourceService resourceService = IntentTestsMocks.MockResourceService.makeBandwidthResourceService(1000.0); final List<Constraint> constraints = - Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); + Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0))); final PointToPointIntent intent = makeIntent("s1", "s3", constraints); @@ -251,7 +250,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { final LinkResourceService resourceService = IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); final List<Constraint> constraints = - Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); + Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0))); try { final PointToPointIntent intent = makeIntent("s1", "s3", constraints); @@ -275,7 +274,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { public void testLambdaConstrainedIntentSuccess() { final List<Constraint> constraints = - Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1))); + Collections.singletonList(new LambdaConstraint(new IndexedLambda(1))); final LinkResourceService resourceService = IntentTestsMocks.MockResourceService.makeLambdaResourceService(1); @@ -299,7 +298,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { public void testLambdaConstrainedIntentFailure() { final List<Constraint> constraints = - Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1))); + Collections.singletonList(new LambdaConstraint(new IndexedLambda(1))); final LinkResourceService resourceService = IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); try { |