Move PCE label handling from APP to protocol.
Change-Id: I26ae21b27ac2dc9ae3302030f6860e0e371c342c
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/BasicPceccHandler.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/BasicPceccHandler.java
deleted file mode 100644
index e30b966..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/BasicPceccHandler.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pceservice;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.LinkedList;
-
-import org.onlab.packet.MplsLabel;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.pce.pcestore.api.PceStore;
-import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
-import org.onosproject.pce.pcestore.PceccTunnelInfo;
-import org.onosproject.pce.pcestore.DefaultLspLocalLabelInfo;
-import org.onosproject.net.Link;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
-/**
- * Basic PCECC handler.
- * In Basic PCECC, after path computation will configure IN and OUT label to nodes.
- * [X]OUT---link----IN[Y]OUT---link-----IN[Z] where X, Y and Z are nodes.
- * For generating labels, will go thorough links in the path from Egress to Ingress.
- * In each link, will take label from destination node local pool as IN label,
- * and assign this label as OUT label to source node.
- */
-public final class BasicPceccHandler {
- private static final Logger log = LoggerFactory.getLogger(BasicPceccHandler.class);
-
- private static final String LABEL_RESOURCE_SERVICE_NULL = "Label Resource Service cannot be null";
- private static final String PCE_STORE_NULL = "PCE Store cannot be null";
- private static BasicPceccHandler crHandlerInstance = null;
- private LabelResourceService labelRsrcService;
- private PceStore pceStore;
- private FlowObjectiveService flowObjectiveService;
- private ApplicationId appId;
-
- /**
- * Initializes default values.
- */
- private BasicPceccHandler() {
- }
-
- /**
- * Returns single instance of this class.
- *
- * @return this class single instance
- */
- public static BasicPceccHandler getInstance() {
- if (crHandlerInstance == null) {
- crHandlerInstance = new BasicPceccHandler();
- }
- return crHandlerInstance;
- }
-
- /**
- * Initialization of label manager and pce store.
- *
- * @param labelRsrcService label resource service
- * @param flowObjectiveService flow objective service to push device label information
- * @param appId applicaton id
- * @param pceStore pce label store
- */
- public void initialize(LabelResourceService labelRsrcService, FlowObjectiveService flowObjectiveService,
- ApplicationId appId, PceStore pceStore) {
- this.labelRsrcService = labelRsrcService;
- this.flowObjectiveService = flowObjectiveService;
- this.appId = appId;
- this.pceStore = pceStore;
- }
-
- /**
- * Allocates labels from local resource pool and configure these (IN and OUT) labels into devices.
- *
- * @param tunnel tunnel between ingress to egress
- * @return success or failure
- */
- public boolean allocateLabel(Tunnel tunnel) {
- long applyNum = 1;
- boolean isLastLabelToPush = false;
- Collection<LabelResource> labelRscList;
-
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
-
- List<Link> linkList = tunnel.path().links();
- if ((linkList != null) && (linkList.size() > 0)) {
- // Sequence through reverse order to push local labels into devices
- // Generation of labels from egress to ingress
- for (ListIterator<Link> iterator = linkList.listIterator(linkList.size()); iterator.hasPrevious();) {
- Link link = iterator.previous();
- DeviceId dstDeviceId = link.dst().deviceId();
- DeviceId srcDeviceId = link.src().deviceId();
- labelRscList = labelRsrcService.applyFromDevicePool(dstDeviceId, applyNum);
- if ((labelRscList != null) && (labelRscList.size() > 0)) {
- // Link label value is taken from destination device local pool.
- // [X]OUT---link----IN[Y]OUT---link-----IN[Z] where X, Y and Z are nodes.
- // Link label value is used as OUT and IN for both ends
- // (source and destination devices) of the link.
- // Currently only one label is allocated to a device (destination device).
- // So, no need to iterate through list
- Iterator<LabelResource> labelIterator = labelRscList.iterator();
- DefaultLabelResource defaultLabelResource = (DefaultLabelResource) labelIterator.next();
- LabelResourceId labelId = defaultLabelResource.labelResourceId();
- log.debug("Allocated local label: " + labelId.toString()
- + "to device: " + defaultLabelResource.deviceId().toString());
- PortNumber dstPort = link.dst().port();
-
- // Check whether this is last link label to push
- if (!iterator.hasPrevious()) {
- isLastLabelToPush = true;
- }
-
- // Push into destination device
- // Destination device IN port is link.dst().port()
- installLocalLabelRule(dstDeviceId, labelId, dstPort, tunnel.tunnelId(), false,
- Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.ADD);
-
- // Push into source device
- // Source device OUT port will be link.dst().port(). Means its remote port used to send packet.
- installLocalLabelRule(srcDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush,
- Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.ADD);
-
- // Add or update pcecc tunnel info in pce store.
- updatePceccTunnelInfoInStore(srcDeviceId, dstDeviceId, labelId, dstPort,
- tunnel, isLastLabelToPush);
- } else {
- log.error("Unable to allocate label to device id {}.", dstDeviceId.toString());
- releaseLabel(tunnel);
- return false;
- }
- }
- } else {
- log.error("Tunnel {} is having empty links.", tunnel.toString());
- return false;
- }
-
- return true;
- }
-
- /**
- * Updates list of local labels of PCECC tunnel info in pce store.
- *
- * @param srcDeviceId source device in a link
- * @param dstDeviceId destination device in a link
- * @param labelId label id of a link
- * @param dstPort destination device port number of a link
- * @param tunnel tunnel
- * @param isLastLabelToPush indicates this is the last label to push in Basic PCECC case
- */
- public void updatePceccTunnelInfoInStore(DeviceId srcDeviceId, DeviceId dstDeviceId, LabelResourceId labelId,
- PortNumber dstPort, Tunnel tunnel, boolean isLastLabelToPush) {
- // First try to retrieve device from store and update its label id if it is exists,
- // otherwise add it
- boolean dstDeviceUpdated = false;
- boolean srcDeviceUpdated = false;
-
- PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId());
- List<LspLocalLabelInfo> lspLabelInfoList;
- if (pceccTunnelInfo != null) {
- lspLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList();
- if ((lspLabelInfoList != null) && (lspLabelInfoList.size() > 0)) {
- for (int i = 0; i < lspLabelInfoList.size(); ++i) {
- LspLocalLabelInfo lspLocalLabelInfo =
- lspLabelInfoList.get(i);
- LspLocalLabelInfo.Builder lspLocalLabelInfoBuilder = null;
- if (dstDeviceId.equals(lspLocalLabelInfo.deviceId())) {
- lspLocalLabelInfoBuilder = DefaultLspLocalLabelInfo.builder(lspLocalLabelInfo);
- lspLocalLabelInfoBuilder.inLabelId(labelId);
- // Destination device IN port will be link destination port
- lspLocalLabelInfoBuilder.inPort(dstPort);
- dstDeviceUpdated = true;
- } else if (srcDeviceId.equals(lspLocalLabelInfo.deviceId())) {
- lspLocalLabelInfoBuilder = DefaultLspLocalLabelInfo.builder(lspLocalLabelInfo);
- lspLocalLabelInfoBuilder.outLabelId(labelId);
- // Source device OUT port will be link destination (remote) port
- lspLocalLabelInfoBuilder.outPort(dstPort);
- srcDeviceUpdated = true;
- }
-
- // Update
- if ((lspLocalLabelInfoBuilder != null) && (dstDeviceUpdated || srcDeviceUpdated)) {
- lspLabelInfoList.set(i, lspLocalLabelInfoBuilder.build());
- }
- }
- }
- }
-
- // If it is not found in store then add it to store
- if (!dstDeviceUpdated || !srcDeviceUpdated) {
- // If tunnel info itself not available then create new one, otherwise add node to list.
- if (pceccTunnelInfo == null) {
- pceccTunnelInfo = new PceccTunnelInfo();
- lspLabelInfoList = new LinkedList<>();
- } else {
- lspLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList();
- if (lspLabelInfoList == null) {
- lspLabelInfoList = new LinkedList<>();
- }
- }
-
- if (!dstDeviceUpdated) {
- LspLocalLabelInfo lspLocalLabelInfo = DefaultLspLocalLabelInfo.builder()
- .deviceId(dstDeviceId)
- .inLabelId(labelId)
- .outLabelId(null)
- .inPort(dstPort) // Destination device IN port will be link destination port
- .outPort(null)
- .build();
- lspLabelInfoList.add(lspLocalLabelInfo);
- }
-
- if (!srcDeviceUpdated) {
- LspLocalLabelInfo lspLocalLabelInfo = DefaultLspLocalLabelInfo.builder()
- .deviceId(srcDeviceId)
- .inLabelId(null)
- .outLabelId(labelId)
- .inPort(null)
- .outPort(dstPort) // Source device OUT port will be link destination (remote) port
- .build();
- lspLabelInfoList.add(lspLocalLabelInfo);
- }
-
- pceccTunnelInfo.lspLocalLabelInfoList(lspLabelInfoList);
- pceStore.addTunnelInfo(tunnel.tunnelId(), pceccTunnelInfo);
- }
- }
-
- /**
- * Deallocates unused labels to device pools.
- *
- * @param tunnel tunnel between ingress to egress
- */
- public void releaseLabel(Tunnel tunnel) {
-
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
-
- Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create();
- PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId());
- if (pceccTunnelInfo != null) {
- List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList();
- if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) {
- for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) {
- LspLocalLabelInfo lspLocalLabelInfo = iterator.next();
- DeviceId deviceId = lspLocalLabelInfo.deviceId();
- LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId();
- LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId();
- PortNumber inPort = lspLocalLabelInfo.inPort();
- PortNumber outPort = lspLocalLabelInfo.outPort();
-
- // Push into device
- if ((inLabelId != null) && (inPort != null)) {
- installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), false,
- Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE);
- }
-
- if ((outLabelId != null) && (outPort != null)) {
- installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), false,
- Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE);
- }
-
- // List is stored from egress to ingress. So, using IN label id to release.
- // Only one local label is assigned to device (destination node)
- // and that is used as OUT label for source node.
- // No need to release label for last node in the list from pool because label was not allocated to
- // ingress node (source node).
- if ((iterator.hasNext()) && (inLabelId != null)) {
- LabelResource labelRsc = new DefaultLabelResource(deviceId, inLabelId);
- release.put(deviceId, labelRsc);
- }
- }
- }
-
- // Release from label pool
- if (!release.isEmpty()) {
- labelRsrcService.releaseToDevicePool(release);
- }
-
- // Remove tunnel info only if tunnel consumer id is not saved.
- // If tunnel consumer id is saved, this tunnel info will be removed during releasing bandwidth.
- if (pceccTunnelInfo.tunnelConsumerId() == null) {
- pceStore.removeTunnelInfo(tunnel.tunnelId());
- }
- } else {
- log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString());
- }
- }
-
- // Install a rule for pushing local labels to the device which is specific to path.
- private synchronized void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId,
- PortNumber portNum, TunnelId tunnelId,
- Boolean isBos, Long labelType,
- Objective.Operation type) {
- checkNotNull(flowObjectiveService);
- checkNotNull(appId);
- TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
-
- selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
- selectorBuilder.matchInPort(portNum);
- selectorBuilder.matchTunnelId(Long.parseLong(tunnelId.id()));
- selectorBuilder.matchMplsBos(isBos);
- selectorBuilder.matchMetadata(labelType);
-
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
-
- ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder()
- .withSelector(selectorBuilder.build())
- .withTreatment(treatment)
- .withFlag(ForwardingObjective.Flag.VERSATILE)
- .fromApp(appId)
- .makePermanent();
-
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, forwardingObjective.add());
- } else {
- flowObjectiveService.forward(deviceId, forwardingObjective.remove());
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/LabelType.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/LabelType.java
deleted file mode 100644
index 78e57f0..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/LabelType.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pceservice;
-
-/**
- * Describes about Label type.
- */
-public enum LabelType {
- /**
- * Signifies in label id of a device.
- */
- OUT_LABEL(0),
-
- /**
- * Signifies out label id of a device.
- */
- IN_LABEL(1);
-
- int value;
-
- /**
- * Assign val with the value as the Label type.
- *
- * @param val Label type
- */
- LabelType(int val) {
- value = val;
- }
-
- /**
- * Returns value of Label type.
- *
- * @return label type
- */
- public byte type() {
- return (byte) value;
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
index f777d4f..a4c2aa6 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
@@ -19,19 +19,11 @@
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
-import java.util.Map.Entry;
import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -39,18 +31,12 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.TCP;
import org.onlab.util.Bandwidth;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
import org.onosproject.core.IdGenerator;
import org.onosproject.incubator.net.tunnel.DefaultTunnel;
import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.LabelStack;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
import org.onosproject.incubator.net.tunnel.TunnelEvent;
@@ -59,8 +45,6 @@
import org.onosproject.incubator.net.tunnel.TunnelName;
import org.onosproject.incubator.net.tunnel.TunnelService;
import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultAnnotations.Builder;
@@ -68,16 +52,10 @@
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.Objective;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
-import org.onosproject.net.link.LinkListener;
import org.onosproject.net.link.LinkEvent;
-import org.onosproject.net.link.LinkService;
import org.onosproject.net.MastershipRole;
import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
import org.onosproject.pce.pceservice.constraint.CapabilityConstraint.CapabilityType;
@@ -97,7 +75,6 @@
import org.onosproject.net.topology.TopologyService;
import org.onosproject.pce.pceservice.api.PceService;
import org.onosproject.pce.pcestore.PcePathInfo;
-import org.onosproject.pce.pcestore.PceccTunnelInfo;
import org.onosproject.pce.pcestore.api.PceStore;
import org.onosproject.pcep.api.DeviceCapability;
import org.onosproject.store.serializers.KryoNamespaces;
@@ -110,14 +87,10 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.ACTIVE;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT;
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING;
-import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING;
-import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.pce.pceservice.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LSP_SIG_TYPE;
@@ -127,11 +100,6 @@
import static org.onosproject.pce.pceservice.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.pce.pceservice.PcepAnnotationKeys.COST_TYPE;
-import org.onosproject.net.packet.InboundPacket;
-import org.onosproject.net.packet.PacketContext;
-import org.onosproject.net.packet.PacketProcessor;
-import org.onosproject.net.packet.PacketService;
-
/**
* Implementation of PCE service.
*/
@@ -142,13 +110,10 @@
public static final long GLOBAL_LABEL_SPACE_MIN = 4097;
public static final long GLOBAL_LABEL_SPACE_MAX = 5121;
- private static final String DEVICE_NULL = "Device-cannot be null";
- private static final String LINK_NULL = "Link-cannot be null";
public static final String PCE_SERVICE_APP = "org.onosproject.pce";
private static final String LOCAL_LSP_ID_GEN_TOPIC = "pcep-local-lsp-id";
public static final String DEVICE_TYPE = "type";
public static final String L3_DEVICE = "L3";
- private static final int PREFIX_LENGTH = 32;
private static final String TUNNEL_CONSUMER_ID_GEN_TOPIC = "pcep-tunnel-consumer-id";
private IdGenerator tunnelConsumerIdGen;
@@ -156,16 +121,11 @@
private static final String LSRID = "lsrId";
private static final String TRUE = "true";
private static final String FALSE = "false";
- private static final String END_OF_SYNC_IP_PREFIX = "0.0.0.0/32";
public static final int PCEP_PORT = 4189;
private IdGenerator localLspIdIdGen;
protected DistributedSet<Short> localLspIdFreeList;
- // LSR-id and device-id mapping for checking capability if L3 device is not
- // having its capability
- private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
-
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -185,46 +145,24 @@
protected TunnelService tunnelService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected PacketService packetService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LinkService linkService;
+ protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected NetworkConfigService netCfgService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LabelResourceAdminService labelRsrcAdminService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LabelResourceService labelRsrcService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowObjectiveService flowObjectiveService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipService mastershipService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected TopologyService topologyService;
private TunnelListener listener = new InnerTunnelListener();
- private DeviceListener deviceListener = new InternalDeviceListener();
- private LinkListener linkListener = new InternalLinkListener();
- private InternalConfigListener cfgListener = new InternalConfigListener();
- private BasicPceccHandler crHandler;
- private PceccSrTeBeHandler srTeHandler;
private ApplicationId appId;
- private final PcepPacketProcessor processor = new PcepPacketProcessor();
private final TopologyListener topologyListener = new InternalTopologyListener();
- private ScheduledExecutorService executor;
public static final int INITIAL_DELAY = 30;
public static final int PERIODIC_DELAY = 30;
@@ -238,17 +176,8 @@
@Activate
protected void activate() {
appId = coreService.registerApplication(PCE_SERVICE_APP);
- crHandler = BasicPceccHandler.getInstance();
- crHandler.initialize(labelRsrcService, flowObjectiveService, appId, pceStore);
-
- srTeHandler = PceccSrTeBeHandler.getInstance();
- srTeHandler.initialize(labelRsrcAdminService, labelRsrcService, flowObjectiveService, appId, pceStore,
- deviceService);
tunnelService.addListener(listener);
- deviceService.addListener(deviceListener);
- linkService.addListener(linkListener);
- netCfgService.addListener(cfgListener);
tunnelConsumerIdGen = coreService.getIdGenerator(TUNNEL_CONSUMER_ID_GEN_TOPIC);
localLspIdIdGen = coreService.getIdGenerator(LOCAL_LSP_ID_GEN_TOPIC);
@@ -259,24 +188,14 @@
.build()
.asDistributedSet();
- packetService.addProcessor(processor, PacketProcessor.director(4));
topologyService.addListener(topologyListener);
- // Reserve global node pool
- if (!srTeHandler.reserveGlobalPool(GLOBAL_LABEL_SPACE_MIN, GLOBAL_LABEL_SPACE_MAX)) {
- log.debug("Global node pool was already reserved.");
- }
-
log.info("Started");
}
@Deactivate
protected void deactivate() {
tunnelService.removeListener(listener);
- deviceService.removeListener(deviceListener);
- linkService.removeListener(linkListener);
- netCfgService.removeListener(cfgListener);
- packetService.removeProcessor(processor);
topologyService.removeListener(topologyListener);
log.info("Stopped");
}
@@ -401,16 +320,6 @@
annotationBuilder.set(DELEGATE, TRUE);
Path computedPath = computedPathSet.iterator().next();
- LabelStack labelStack = null;
-
- if (lspType == SR_WITHOUT_SIGNALLING) {
- labelStack = srTeHandler.computeLabelStack(computedPath);
- // Failed to form a label stack.
- if (labelStack == null) {
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType));
- return false;
- }
- }
if (lspType != WITH_SIGNALLING) {
/*
@@ -423,7 +332,7 @@
// For SR-TE tunnels, call SR manager for label stack and put it inside tunnel.
Tunnel tunnel = new DefaultTunnel(null, srcEndPoint, dstEndPoint, MPLS, INIT, null, null,
TunnelName.tunnelName(tunnelName), computedPath,
- labelStack, annotationBuilder.build());
+ annotationBuilder.build());
// Allocate bandwidth.
TunnelConsumerId consumerId = null;
@@ -445,9 +354,8 @@
}
if (consumerId != null) {
- // Store tunnel consumer id in LSP-Label store.
- PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId);
- pceStore.addTunnelInfo(tunnelId, pceccTunnelInfo);
+ // Store tunnel consumer id in LSP store.
+ pceStore.addTunnelInfo(tunnelId, consumerId);
}
return true;
}
@@ -553,7 +461,6 @@
annotationBuilder.set(PCC_TUNNEL_ID, tunnel.annotations().value(PCC_TUNNEL_ID));
Path computedPath = computedPathSet.iterator().next();
- LabelStack labelStack = null;
TunnelConsumerId consumerId = null;
LspType lspType = LspType.valueOf(lspSigType);
long localLspId = 0;
@@ -564,19 +471,11 @@
*/
localLspId = getNextLocalLspId();
annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(localLspId));
-
- if (lspType == SR_WITHOUT_SIGNALLING) {
- labelStack = srTeHandler.computeLabelStack(computedPath);
- // Failed to form a label stack.
- if (labelStack == null) {
- return false;
- }
- }
}
Tunnel updatedTunnel = new DefaultTunnel(null, tunnel.src(), tunnel.dst(), MPLS, INIT, null, null,
tunnel.tunnelName(), computedPath,
- labelStack, annotationBuilder.build());
+ annotationBuilder.build());
// Allocate shared bandwidth.
if (bwConstraintValue != 0) {
@@ -597,20 +496,8 @@
}
if (consumerId != null) {
- // Store tunnel consumer id in LSP-Label store.
- PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId);
- pceStore.addTunnelInfo(updatedTunnelId, pceccTunnelInfo);
- }
-
- // For CR cases, download labels and send update message.
- if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) {
- Tunnel tunnelForlabelDownload = new DefaultTunnel(null, tunnel.src(), tunnel.dst(), MPLS, INIT, null,
- updatedTunnelId, tunnel.tunnelName(), computedPath,
- labelStack, annotationBuilder.build());
-
- if (!crHandler.allocateLabel(tunnelForlabelDownload)) {
- log.error("Unable to allocate labels for the tunnel {}.", tunnel.toString());
- }
+ // Store tunnel consumer id in LSP store.
+ pceStore.addTunnelInfo(updatedTunnelId, consumerId);
}
return true;
@@ -626,12 +513,6 @@
return false;
}
- LspType lspType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
- // Release basic PCECC labels.
- if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) {
- crHandler.releaseLabel(tunnel);
- }
-
// 2. Call tunnel service.
return tunnelService.downTunnel(appId, tunnel.tunnelId());
}
@@ -845,19 +726,19 @@
}
}
+ ResourceConsumer tunnelConsumerId = pceStore.getTunnelInfo(tunnel.tunnelId());
+ if (tunnelConsumerId == null) {
+ //If bandwidth for old tunnel is not allocated i,e 0 then no need to release
+ log.debug("Bandwidth not allocated (0 bandwidth) for old LSP.");
+ return;
+ }
+
if (isLinkShared) {
releaseSharedBandwidth(newTunnel, tunnel);
return;
}
- PceccTunnelInfo tunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId());
- if (tunnelInfo == null || tunnelInfo.tunnelConsumerId() == null) {
- //If bandwidth for old tunnel is not allocated i,e 0 then no need to release
- return;
- }
- resourceService.release(tunnelInfo.tunnelConsumerId());
- return;
-
+ resourceService.release(tunnelConsumerId);
/*
* Note: Storing of tunnel consumer id is done by caller of bandwidth reservation function. So deleting tunnel
* consumer id should be done by caller of bandwidth releasing function. This will prevent ambiguities related
@@ -871,16 +752,15 @@
*/
private synchronized void releaseSharedBandwidth(Tunnel newTunnel, Tunnel oldTunnel) {
// 1. Release old tunnel's bandwidth.
- resourceService.release(pceStore.getTunnelInfo(oldTunnel.tunnelId()).tunnelConsumerId());
+ resourceService.release(pceStore.getTunnelInfo(oldTunnel.tunnelId()));
// 2. Release new tunnel's bandwidth, if new tunnel bandwidth is allocated
- PceccTunnelInfo tunnelInfo = pceStore.getTunnelInfo(newTunnel.tunnelId());
- if (tunnelInfo == null || tunnelInfo.tunnelConsumerId() == null) {
+ ResourceConsumer consumer = pceStore.getTunnelInfo(newTunnel.tunnelId());
+ if (consumer == null) {
//If bandwidth for new tunnel is not allocated i,e 0 then no need to allocate
return;
}
- ResourceConsumer consumer = tunnelInfo.tunnelConsumerId();
resourceService.release(consumer);
// 3. Allocate new tunnel's complete bandwidth.
@@ -895,245 +775,6 @@
}
}
- /**
- * Allocates node label to specific device.
- *
- * @param specificDevice device to which node label needs to be allocated
- */
- public void allocateNodeLabel(Device specificDevice) {
- checkNotNull(specificDevice, DEVICE_NULL);
-
- DeviceId deviceId = specificDevice.id();
-
- // Retrieve lsrId of a specific device
- if (specificDevice.annotations() == null) {
- log.debug("Device {} does not have annotations.", specificDevice.toString());
- return;
- }
-
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId == null) {
- log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());
- return;
- }
-
- // Get capability config from netconfig
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capability for a lsrd {} from NetConfig.", lsrId);
- // Save info. When PCEP session is comes up then allocate node-label
- lsrIdDeviceIdMap.put(lsrId, specificDevice.id());
- return;
- }
-
- // Check whether device has SR-TE Capability
- if (cfg.labelStackCap()) {
- srTeHandler.allocateNodeLabel(deviceId, lsrId);
- }
- }
-
- /**
- * Releases node label of a specific device.
- *
- * @param specificDevice this device label and lsr-id information will be
- * released in other existing devices
- */
- public void releaseNodeLabel(Device specificDevice) {
- checkNotNull(specificDevice, DEVICE_NULL);
-
- DeviceId deviceId = specificDevice.id();
-
- // Retrieve lsrId of a specific device
- if (specificDevice.annotations() == null) {
- log.debug("Device {} does not have annotations.", specificDevice.toString());
- return;
- }
-
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId == null) {
- log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());
- return;
- }
-
- // Get capability config from netconfig
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capabilty for a lsrd {} from NetConfig.", lsrId);
- return;
- }
-
- // Check whether device has SR-TE Capability
- if (cfg.labelStackCap()) {
- if (!srTeHandler.releaseNodeLabel(deviceId, lsrId)) {
- log.error("Unable to release node label for a device id {}.", deviceId.toString());
- }
- }
- }
-
- /**
- * Allocates adjacency label for a link.
- *
- * @param link link
- */
- public void allocateAdjacencyLabel(Link link) {
- checkNotNull(link, LINK_NULL);
-
- Device specificDevice = deviceService.getDevice(link.src().deviceId());
- DeviceId deviceId = specificDevice.id();
-
- // Retrieve lsrId of a specific device
- if (specificDevice.annotations() == null) {
- log.debug("Device {} does not have annotations.", specificDevice.toString());
- return;
- }
-
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId == null) {
- log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());
- return;
- }
-
- // Get capability config from netconfig
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capabilty for a lsrd {} from NetConfig.", lsrId);
- // Save info. When PCEP session comes up then allocate adjacency
- // label
- if (lsrIdDeviceIdMap.get(lsrId) != null) {
- lsrIdDeviceIdMap.put(lsrId, specificDevice.id());
- }
- return;
- }
-
- // Check whether device has SR-TE Capability
- if (cfg.labelStackCap()) {
- srTeHandler.allocateAdjacencyLabel(link);
- }
-
- return;
- }
-
- /**
- * Releases allocated adjacency label of a link.
- *
- * @param link link
- */
- public void releaseAdjacencyLabel(Link link) {
- checkNotNull(link, LINK_NULL);
-
- Device specificDevice = deviceService.getDevice(link.src().deviceId());
- DeviceId deviceId = specificDevice.id();
-
- // Retrieve lsrId of a specific device
- if (specificDevice.annotations() == null) {
- log.debug("Device {} does not have annotations.", specificDevice.toString());
- return;
- }
-
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId == null) {
- log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());
- return;
- }
-
- // Get capability config from netconfig
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capabilty for a lsrd {} from NetConfig.", lsrId);
- return;
- }
-
- // Check whether device has SR-TE Capability
- if (cfg.labelStackCap()) {
- if (!srTeHandler.releaseAdjacencyLabel(link)) {
- log.error("Unable to release adjacency labels for a link {}.", link.toString());
- return;
- }
- }
-
- return;
- }
-
- /*
- * Handle device events.
- */
- private class InternalDeviceListener implements DeviceListener {
- @Override
- public void event(DeviceEvent event) {
- Device specificDevice = (Device) event.subject();
- if (specificDevice == null) {
- log.error("Unable to find device from device event.");
- return;
- }
-
- switch (event.type()) {
-
- case DEVICE_ADDED:
- // Node-label allocation is being done during Label DB Sync.
- // So, when device is detected, no need to do node-label
- // allocation.
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId != null) {
- pceStore.addLsrIdDevice(lsrId, specificDevice.id());
-
- // Search in failed DB sync store. If found, trigger label DB sync.
- DeviceId pccDeviceId = DeviceId.deviceId(lsrId);
- if (pceStore.hasPccLsr(pccDeviceId)) {
- log.debug("Continue to perform label DB sync for device {}.", pccDeviceId.toString());
- syncLabelDb(pccDeviceId);
- pceStore.removePccLsr(pccDeviceId);
- }
- }
- break;
-
- case DEVICE_REMOVED:
- // Release node-label
- if (mastershipService.getLocalRole(specificDevice.id()) == MastershipRole.MASTER) {
- releaseNodeLabel(specificDevice);
- }
-
- if (specificDevice.annotations().value(LSRID) != null) {
- pceStore.removeLsrIdDevice(specificDevice.annotations().value(LSRID));
- }
-
- break;
-
- default:
- break;
- }
- }
- }
-
- /*
- * Handle link events.
- */
- private class InternalLinkListener implements LinkListener {
- @Override
- public void event(LinkEvent event) {
- Link link = (Link) event.subject();
-
- switch (event.type()) {
-
- case LINK_ADDED:
- // Allocate adjacency label
- if (mastershipService.getLocalRole(link.src().deviceId()) == MastershipRole.MASTER) {
- allocateAdjacencyLabel(link);
- }
- break;
-
- case LINK_REMOVED:
- // Release adjacency label
- if (mastershipService.getLocalRole(link.src().deviceId()) == MastershipRole.MASTER) {
- releaseAdjacencyLabel(link);
- }
- break;
-
- default:
- break;
- }
- }
- }
-
// Listens on tunnel events.
private class InnerTunnelListener implements TunnelListener {
@Override
@@ -1155,37 +796,16 @@
case TUNNEL_ADDED:
// Allocate bandwidth for non-initiated, delegated LSPs with non-zero bandwidth (learned LSPs).
String pceInit = tunnel.annotations().value(PCE_INIT);
- if (FALSE.equalsIgnoreCase(pceInit)
- && bwConstraintValue != 0) {
- reserveBandwidth(tunnel.path(), bwConstraintValue, null);
+ if (FALSE.equalsIgnoreCase(pceInit) && bwConstraintValue != 0) {
+ TunnelConsumerId consumerId = reserveBandwidth(tunnel.path(), bwConstraintValue, null);
+ if (consumerId != null) {
+ // Store tunnel consumer id in LSP store.
+ pceStore.addTunnelInfo(tunnel.tunnelId(), consumerId);
+ }
}
break;
case TUNNEL_UPDATED:
- // Allocate/send labels for basic PCECC tunnels.
- if ((tunnel.state() == ESTABLISHED) && (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR)
- && (mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER)) {
- if (!crHandler.allocateLabel(tunnel)) {
- log.error("Unable to allocate labels for a tunnel {}.", tunnel.toString());
- }
- }
-
- //In CR case, release labels when new tunnel for it is updated.
- if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR && tunnel.state() == ACTIVE
- && mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) {
- Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst());
-
- for (Tunnel t : tunnels) {
- if (tunnel.annotations().value(PLSP_ID).equals(t.annotations().value(PLSP_ID))
- && !tunnel.annotations().value(LOCAL_LSP_ID)
- .equals(t.annotations().value(LOCAL_LSP_ID))) {
- // Release basic PCECC labels.
- crHandler.releaseLabel(t);
- break;
- }
- }
- }
-
if (tunnel.state() == UNSTABLE) {
/*
* During LSP DB sync if PCC doesn't report LSP which was PCE initiated, it's state is turned into
@@ -1241,164 +861,6 @@
}
}
- private class InternalConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
-
- if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED)
- && event.configClass().equals(DeviceCapability.class)) {
-
- DeviceId deviceIdLsrId = (DeviceId) event.subject();
- String lsrId = deviceIdLsrId.toString();
- DeviceId deviceId = lsrIdDeviceIdMap.get(lsrId);
- if (deviceId == null) {
- log.debug("Unable to find device id for a lsr-id {} from lsr-id and device-id map.", lsrId);
- return;
- }
-
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capabilty for a lsrd {}.", lsrId);
- return;
- }
-
- if (cfg.labelStackCap()) {
- if (mastershipService.getLocalRole(deviceId) == MastershipRole.MASTER) {
- // Allocate node-label
- srTeHandler.allocateNodeLabel(deviceId, lsrId);
-
- // Allocate adjacency label to links which are
- // originated from this specific device id
- Set<Link> links = linkService.getDeviceEgressLinks(deviceId);
- for (Link link : links) {
- if (!srTeHandler.allocateAdjacencyLabel(link)) {
- return;
- }
- }
- }
- }
-
- // Remove lsrId info from map
- lsrIdDeviceIdMap.remove(lsrId);
- }
- }
- }
-
- private boolean syncLabelDb(DeviceId deviceId) {
- checkNotNull(deviceId);
-
- DeviceId actualDevcieId = pceStore.getLsrIdDevice(deviceId.toString());
- if (actualDevcieId == null) {
- log.error("Device not available {}.", deviceId.toString());
- pceStore.addPccLsr(deviceId);
- return false;
- }
-
- Device specificDevice = deviceService.getDevice(actualDevcieId);
- if (specificDevice == null) {
- log.error("Unable to find device for specific device id {}.", actualDevcieId.toString());
- return false;
- }
-
- if (pceStore.getGlobalNodeLabel(actualDevcieId) != null) {
- Map<DeviceId, LabelResourceId> globalNodeLabelMap = pceStore.getGlobalNodeLabels();
-
- for (Entry<DeviceId, LabelResourceId> entry : globalNodeLabelMap.entrySet()) {
-
- // Convert from DeviceId to TunnelEndPoint
- Device srcDevice = deviceService.getDevice(entry.getKey());
-
- /*
- * If there is a slight difference in timing such that if device subsystem has removed the device but
- * PCE store still has it, just ignore such devices.
- */
- if (srcDevice == null) {
- continue;
- }
-
- String srcLsrId = srcDevice.annotations().value(LSRID);
- if (srcLsrId == null) {
- continue;
- }
-
- srTeHandler.advertiseNodeLabelRule(actualDevcieId,
- entry.getValue(),
- IpPrefix.valueOf(IpAddress.valueOf(srcLsrId), PREFIX_LENGTH),
- Objective.Operation.ADD, false);
- }
-
- Map<Link, LabelResourceId> adjLabelMap = pceStore.getAdjLabels();
- for (Entry<Link, LabelResourceId> entry : adjLabelMap.entrySet()) {
- if (entry.getKey().src().deviceId().equals(actualDevcieId)) {
- srTeHandler.installAdjLabelRule(actualDevcieId,
- entry.getValue(),
- entry.getKey().src().port(),
- entry.getKey().dst().port(),
- Objective.Operation.ADD);
- }
- }
- }
-
- srTeHandler.advertiseNodeLabelRule(actualDevcieId,
- LabelResourceId.labelResourceId(0),
- IpPrefix.valueOf(END_OF_SYNC_IP_PREFIX),
- Objective.Operation.ADD, true);
-
- log.debug("End of label DB sync for device {}", actualDevcieId);
-
- if (mastershipService.getLocalRole(specificDevice.id()) == MastershipRole.MASTER) {
- // Allocate node-label to this specific device.
- allocateNodeLabel(specificDevice);
-
- // Allocate adjacency label
- Set<Link> links = linkService.getDeviceEgressLinks(specificDevice.id());
- if (links != null) {
- for (Link link : links) {
- allocateAdjacencyLabel(link);
- }
- }
- }
-
- return true;
- }
-
- // Process the packet received.
- private class PcepPacketProcessor implements PacketProcessor {
- // Process the packet received and in our case initiates the label DB sync.
- @Override
- public void process(PacketContext context) {
- // Stop processing if the packet has been handled, since we
- // can't do any more to it.
- log.debug("Received trigger for label DB sync.");
- if (context.isHandled()) {
- return;
- }
-
- InboundPacket pkt = context.inPacket();
- if (pkt == null) {
- return;
- }
-
- Ethernet ethernet = pkt.parsed();
- if (ethernet == null || ethernet.getEtherType() != Ethernet.TYPE_IPV4) {
- return;
- }
-
- IPv4 ipPacket = (IPv4) ethernet.getPayload();
- if (ipPacket == null || ipPacket.getProtocol() != IPv4.PROTOCOL_TCP) {
- return;
- }
-
- TCP tcp = (TCP) ipPacket.getPayload();
- if (tcp == null || tcp.getDestinationPort() != PCEP_PORT) {
- return;
- }
-
- syncLabelDb(pkt.receivedFrom().deviceId());
- }
- }
-
//Computes path from tunnel store and also path failed to setup.
private void callForOptimization() {
//Recompute the LSPs which it was delegated [LSPs stored in PCE store (failed paths)]
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java
deleted file mode 100644
index 0a79716..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pceservice;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MplsLabel;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
-import org.onosproject.incubator.net.tunnel.LabelStack;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.pce.pcestore.api.PceStore;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.Objective;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
-/**
- * PCE SR-BE and SR-TE functionality.
- * SR-BE: Each node (PCC) is allocated a node-SID (label) by the PCECC. The PCECC sends PCLabelUpd to
- * update the label map of each node to all the nodes in the domain.
- * SR-TE: apart from node-SID, Adj-SID is used where each adjacency is allocated an Adj-SID (label) by the PCECC.
- * The PCECC sends PCLabelUpd to update the label map of each Adj to the corresponding nodes in the domain.
- */
-public final class PceccSrTeBeHandler {
- private static final Logger log = LoggerFactory.getLogger(PceccSrTeBeHandler.class);
-
- private static final String LABEL_RESOURCE_ADMIN_SERVICE_NULL = "Label Resource Admin Service cannot be null";
- private static final String LABEL_RESOURCE_SERVICE_NULL = "Label Resource Service cannot be null";
- private static final String PCE_STORE_NULL = "PCE Store cannot be null";
- private static final String DEVICE_ID_NULL = "Device-Id cannot be null";
- private static final String LSR_ID_NULL = "LSR-Id cannot be null";
- private static final String LINK_NULL = "Link cannot be null";
- private static final String PATH_NULL = "Path cannot be null";
- private static final String LSR_ID = "lsrId";
- private static final int PREFIX_LENGTH = 32;
- private static PceccSrTeBeHandler srTeHandlerInstance = null;
- private LabelResourceAdminService labelRsrcAdminService;
- private LabelResourceService labelRsrcService;
- private FlowObjectiveService flowObjectiveService;
- private DeviceService deviceService;
- private PceStore pceStore;
- private ApplicationId appId;
-
- /**
- * Initializes default values.
- */
- private PceccSrTeBeHandler() {
- }
-
- /**
- * Returns single instance of this class.
- *
- * @return this class single instance
- */
- public static PceccSrTeBeHandler getInstance() {
- if (srTeHandlerInstance == null) {
- srTeHandlerInstance = new PceccSrTeBeHandler();
- }
- return srTeHandlerInstance;
- }
-
- /**
- * Initialization of label manager interfaces and pce store.
- *
- * @param labelRsrcAdminService label resource admin service
- * @param labelRsrcService label resource service
- * @param flowObjectiveService flow objective service to push device label information
- * @param appId application id
- * @param pceStore PCE label store
- * @param deviceService device service
- */
- public void initialize(LabelResourceAdminService labelRsrcAdminService, LabelResourceService labelRsrcService,
- FlowObjectiveService flowObjectiveService, ApplicationId appId, PceStore pceStore,
- DeviceService deviceService) {
- this.labelRsrcAdminService = labelRsrcAdminService;
- this.labelRsrcService = labelRsrcService;
- this.flowObjectiveService = flowObjectiveService;
- this.pceStore = pceStore;
- this.appId = appId;
- this.deviceService = deviceService;
- }
-
- /**
- * Reserves the global label pool.
- *
- * @param beginLabel minimum value of global label space
- * @param endLabel maximum value of global label space
- * @return success or failure
- */
- public boolean reserveGlobalPool(long beginLabel, long endLabel) {
- checkNotNull(labelRsrcAdminService, LABEL_RESOURCE_ADMIN_SERVICE_NULL);
- return labelRsrcAdminService.createGlobalPool(LabelResourceId.labelResourceId(beginLabel),
- LabelResourceId.labelResourceId(endLabel));
- }
-
- /**
- * Retrieve lsr-id from device annotation.
- *
- * @param deviceId specific device id from which lsr-id needs to be retrieved
- * @return lsr-id of a device
- */
- public String getLsrId(DeviceId deviceId) {
- checkNotNull(deviceId, DEVICE_ID_NULL);
- Device device = deviceService.getDevice(deviceId);
- if (device == null) {
- log.debug("Device is not available for device id {} in device service.", deviceId.toString());
- return null;
- }
-
- // Retrieve lsr-id from device
- if (device.annotations() == null) {
- log.debug("Device {} does not have annotation.", device.toString());
- return null;
- }
-
- String lsrId = device.annotations().value(LSR_ID);
- if (lsrId == null) {
- log.debug("The lsr-id of device {} is null.", device.toString());
- return null;
- }
- return lsrId;
- }
-
- /**
- * Allocates node label from global node label pool to specific device.
- * Configure this device with labels and lsrid mapping of all other devices and vice versa.
- *
- * @param specificDeviceId node label needs to be allocated to specific device
- * @param specificLsrId lsrid of specific device
- * @return success or failure
- */
- public boolean allocateNodeLabel(DeviceId specificDeviceId, String specificLsrId) {
- long applyNum = 1; // For each node only one node label
- LabelResourceId specificLabelId = null;
-
- checkNotNull(specificDeviceId, DEVICE_ID_NULL);
- checkNotNull(specificLsrId, LSR_ID_NULL);
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
-
- // Check whether node-label was already configured for this specific device.
- if (pceStore.getGlobalNodeLabel(specificDeviceId) != null) {
- log.debug("Node label was already configured for device {}.", specificDeviceId.toString());
- return false;
- }
-
- // The specificDeviceId is the new device and is not there in the pce store.
- // So, first generate its label and configure label and its lsr-id to it.
- Collection<LabelResource> result = labelRsrcService.applyFromGlobalPool(applyNum);
- if (result.size() > 0) {
- // Only one element (label-id) to retrieve
- Iterator<LabelResource> iterator = result.iterator();
- DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator.next();
- specificLabelId = defaultLabelResource.labelResourceId();
- if (specificLabelId == null) {
- log.error("Unable to retrieve global node label for a device id {}.", specificDeviceId.toString());
- return false;
- }
- } else {
- log.error("Unable to allocate global node label for a device id {}.", specificDeviceId.toString());
- return false;
- }
-
- // store it
- pceStore.addGlobalNodeLabel(specificDeviceId, specificLabelId);
-
- // Push its label information into specificDeviceId
- advertiseNodeLabelRule(specificDeviceId, specificLabelId,
- IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH),
- Objective.Operation.ADD, false);
-
- // Configure (node-label, lsr-id) mapping of each devices into specific device and vice versa.
- for (Map.Entry<DeviceId, LabelResourceId> element : pceStore.getGlobalNodeLabels().entrySet()) {
- DeviceId otherDevId = element.getKey();
- LabelResourceId otherLabelId = element.getValue();
-
- // Get lsr-id of a device
- String otherLsrId = getLsrId(otherDevId);
- if (otherLsrId == null) {
- log.error("The lsr-id of device id {} is null.", otherDevId.toString());
- releaseNodeLabel(specificDeviceId, specificLsrId);
- return false;
- }
-
- // Push to device
- // Push label information of specificDeviceId to otherDevId in list and vice versa.
- if (!otherDevId.equals(specificDeviceId)) {
- advertiseNodeLabelRule(otherDevId, specificLabelId,
- IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH),
- Objective.Operation.ADD, false);
-
- advertiseNodeLabelRule(specificDeviceId, otherLabelId,
- IpPrefix.valueOf(IpAddress.valueOf(otherLsrId), PREFIX_LENGTH),
- Objective.Operation.ADD, false);
- }
- }
-
- return true;
- }
-
- /**
- * Releases assigned node label of specific device from global node label pool and pce store.
- * and remove configured this node label from all other devices.
- *
- * @param specificDeviceId node label needs to be released for specific device
- * @param specificLsrId lsrid of specific device
- * @return success or failure
- */
- public boolean releaseNodeLabel(DeviceId specificDeviceId, String specificLsrId) {
- checkNotNull(specificDeviceId, DEVICE_ID_NULL);
- checkNotNull(specificLsrId, LSR_ID_NULL);
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
- boolean retValue = true;
-
- // Release node label entry of this specific device from all other devices
- // Retrieve node label of this specific device from store
- LabelResourceId labelId = pceStore.getGlobalNodeLabel(specificDeviceId);
- if (labelId == null) {
- log.error("Unable to retrieve label of a device id {} from store.", specificDeviceId.toString());
- return false;
- }
-
- // Go through all devices in the pce store and remove label entry from device
- for (Map.Entry<DeviceId, LabelResourceId> element : pceStore.getGlobalNodeLabels().entrySet()) {
- DeviceId otherDevId = element.getKey();
-
- // Remove this specific device label information from all other nodes except
- // this specific node where connection already lost.
- if (!specificDeviceId.equals(otherDevId)) {
- advertiseNodeLabelRule(otherDevId, labelId,
- IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH),
- Objective.Operation.REMOVE, false);
- }
- }
-
- // Release from label manager
- Set<LabelResourceId> release = new HashSet<>();
- release.add(labelId);
- if (!labelRsrcService.releaseToGlobalPool(release)) {
- log.error("Unable to release label id {} from label manager.", labelId.toString());
- retValue = false;
- }
-
- // Remove from store
- if (!pceStore.removeGlobalNodeLabel(specificDeviceId)) {
- log.error("Unable to remove global node label id {} from store.", labelId.toString());
- retValue = false;
- }
-
- return retValue;
- }
-
- /**
- * Allocates adjacency label to a link from local resource pool by a specific device id.
- *
- * @param link between devices
- * @return success or failure
- */
- public boolean allocateAdjacencyLabel(Link link) {
- long applyNum = 1; // Single label to each link.
- DeviceId srcDeviceId = link.src().deviceId();
- Collection<LabelResource> labelList;
-
- checkNotNull(link, LINK_NULL);
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
-
- // Checks whether adjacency label was already allocated
- LabelResourceId labelId = pceStore.getAdjLabel(link);
- if (labelId != null) {
- log.debug("Adjacency label {} was already allocated for a link {}.", labelId.toString(), link.toString());
- return false;
- }
-
- // Allocate adjacency label to a link from label manager.
- // Take label from source device pool to allocate.
- labelList = labelRsrcService.applyFromDevicePool(srcDeviceId, applyNum);
- if (labelList.size() <= 0) {
- log.error("Unable to allocate label to a device id {}.", srcDeviceId.toString());
- return false;
- }
-
- // Currently only one label to a device. So, no need to iterate through list
- Iterator<LabelResource> iterator = labelList.iterator();
- DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator.next();
- labelId = defaultLabelResource.labelResourceId();
- if (labelId == null) {
- log.error("Unable to allocate label to a device id {}.", srcDeviceId.toString());
- return false;
- }
- log.debug("Allocated adjacency label {} to a link {}.", labelId.toString(), link.toString());
-
- // Push adjacency label to device
- installAdjLabelRule(srcDeviceId, labelId, link.src().port(), link.dst().port(), Objective.Operation.ADD);
-
- // Save in store
- pceStore.addAdjLabel(link, labelId);
- return true;
- }
-
- /**
- * Releases unused adjacency labels from device pools.
- *
- * @param link between devices
- * @return success or failure
- */
- public boolean releaseAdjacencyLabel(Link link) {
- checkNotNull(link, LINK_NULL);
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
- boolean retValue = true;
-
- // Retrieve link label from store
- LabelResourceId labelId = pceStore.getAdjLabel(link);
- if (labelId == null) {
- log.error("Unabel to retrieve label for a link {} from store.", link.toString());
- return false;
- }
-
- // Device
- DeviceId srcDeviceId = link.src().deviceId();
-
- // Release adjacency label from device
- installAdjLabelRule(srcDeviceId, labelId, link.src().port(), link.dst().port(), Objective.Operation.REMOVE);
-
- // Release link label from label manager
- Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create();
- DefaultLabelResource defaultLabelResource = new DefaultLabelResource(srcDeviceId, labelId);
- release.put(srcDeviceId, defaultLabelResource);
- if (!labelRsrcService.releaseToDevicePool(release)) {
- log.error("Unable to release label id {} from label manager.", labelId.toString());
- retValue = false;
- }
-
- // Remove adjacency label from store
- if (!pceStore.removeAdjLabel(link)) {
- log.error("Unable to remove adjacency label id {} from store.", labelId.toString());
- retValue = false;
- }
- return retValue;
- }
-
- /**
- * Computes label stack for a path.
- *
- * @param path lsp path
- * @return label stack
- */
- public LabelStack computeLabelStack(Path path) {
- checkNotNull(path, PATH_NULL);
- // Label stack is linked list to make labels in order.
- List<LabelResourceId> labelStack = new LinkedList<>();
- List<Link> linkList = path.links();
- if ((linkList != null) && (linkList.size() > 0)) {
- // Path: [x] ---- [y] ---- [z]
- // For other than last link, add only source[x] device label.
- // For the last link, add both source[y] and destination[z] device labels.
- // For all links add adjacency label
- Link link = null;
- LabelResourceId nodeLabelId = null;
- LabelResourceId adjLabelId = null;
- DeviceId deviceId = null;
- for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) {
- link = iterator.next();
- // Add adjacency label for this link
- adjLabelId = pceStore.getAdjLabel(link);
- if (adjLabelId == null) {
- log.error("Adjacency label id is null for a link {}.", link.toString());
- return null;
- }
- labelStack.add(adjLabelId);
-
- deviceId = link.dst().deviceId();
- nodeLabelId = pceStore.getGlobalNodeLabel(deviceId);
- if (nodeLabelId == null) {
- log.error("Unable to find node label for a device id {} in store.", deviceId.toString());
- return null;
- }
- labelStack.add(nodeLabelId);
- }
- } else {
- log.debug("Empty link in path.");
- return null;
- }
- return new DefaultLabelStack(labelStack);
- }
-
- /**
- * Install a rule for pushing unique global labels to the device.
- *
- * @param deviceId device to which flow should be pushed
- * @param labelId label for the device
- * @param type type of operation
- */
- private void installNodeLabelRule(DeviceId deviceId, LabelResourceId labelId, Objective.Operation type) {
- checkNotNull(flowObjectiveService);
- checkNotNull(appId);
- TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
-
- selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
-
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
-
- ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder()
- .withSelector(selectorBuilder.build()).withTreatment(treatment)
- .withFlag(ForwardingObjective.Flag.VERSATILE).fromApp(appId).makePermanent();
-
- if (type.equals(Objective.Operation.ADD)) {
-
- flowObjectiveService.forward(deviceId, forwardingObjective.add());
- } else {
- flowObjectiveService.forward(deviceId, forwardingObjective.remove());
- }
- }
-
- /**
- * Install a rule for pushing node labels to the device of other nodes.
- *
- * @param deviceId device to which flow should be pushed
- * @param labelId label for the device
- * @param ipPrefix device for which label is pushed
- * @param type type of operation
- * @param bBos is this the end of sync push
- */
- public void advertiseNodeLabelRule(DeviceId deviceId, LabelResourceId labelId, IpPrefix ipPrefix,
- Objective.Operation type, boolean bBos) {
- checkNotNull(flowObjectiveService);
- checkNotNull(appId);
- TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
-
- selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
- selectorBuilder.matchIPSrc(ipPrefix);
-
- if (bBos) {
- selectorBuilder.matchMplsBos(bBos);
- }
-
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
-
- ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder()
- .withSelector(selectorBuilder.build()).withTreatment(treatment)
- .withFlag(ForwardingObjective.Flag.VERSATILE).fromApp(appId).makePermanent();
-
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, forwardingObjective.add());
- } else {
- flowObjectiveService.forward(deviceId, forwardingObjective.remove());
- }
- }
-
- /**
- * Install a rule for pushing Adjacency labels to the device.
- *
- * @param deviceId device to which flow should be pushed
- * @param labelId label for the adjacency
- * @param srcPortNum local port of the adjacency
- * @param dstPortNum remote port of the adjacency
- * @param type type of operation
- */
- public void installAdjLabelRule(DeviceId deviceId, LabelResourceId labelId, PortNumber srcPortNum,
- PortNumber dstPortNum, Objective.Operation type) {
- checkNotNull(flowObjectiveService);
- checkNotNull(appId);
- TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
-
- selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
- selectorBuilder.matchIPSrc(IpPrefix.valueOf((int) srcPortNum.toLong(), 32));
- selectorBuilder.matchIPDst(IpPrefix.valueOf((int) dstPortNum.toLong(), 32));
-
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
-
- ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder()
- .withSelector(selectorBuilder.build()).withTreatment(treatment)
- .withFlag(ForwardingObjective.Flag.VERSATILE).fromApp(appId).makePermanent();
-
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, forwardingObjective.add());
- } else {
- flowObjectiveService.forward(deviceId, forwardingObjective.remove());
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DefaultLspLocalLabelInfo.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DefaultLspLocalLabelInfo.java
deleted file mode 100644
index cdad3b2..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DefaultLspLocalLabelInfo.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pcestore;
-
-import com.google.common.base.MoreObjects;
-
-import java.util.Objects;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
-
-/**
- * Local node details including IN and OUT labels as well as IN and OUT port details.
- */
-public final class DefaultLspLocalLabelInfo implements LspLocalLabelInfo {
-
- private final DeviceId deviceId;
-
- private final LabelResourceId inLabelId;
-
- private final LabelResourceId outLabelId;
-
- private final PortNumber inPort;
-
- private final PortNumber outPort;
-
- /**
- * Initialization of member variables.
- *
- * @param deviceId device id
- * @param inLabelId in label id of a node
- * @param outLabelId out label id of a node
- * @param inPort input port
- * @param outPort remote port
- */
- private DefaultLspLocalLabelInfo(DeviceId deviceId,
- LabelResourceId inLabelId,
- LabelResourceId outLabelId,
- PortNumber inPort,
- PortNumber outPort) {
- this.deviceId = deviceId;
- this.inLabelId = inLabelId;
- this.outLabelId = outLabelId;
- this.inPort = inPort;
- this.outPort = outPort;
- }
-
- /**
- * Initialization of member variables for serialization.
- */
- private DefaultLspLocalLabelInfo() {
- this.deviceId = null;
- this.inLabelId = null;
- this.outLabelId = null;
- this.inPort = null;
- this.outPort = null;
- }
-
- @Override
- public DeviceId deviceId() {
- return deviceId;
- }
-
- @Override
- public LabelResourceId inLabelId() {
- return inLabelId;
- }
-
- @Override
- public LabelResourceId outLabelId() {
- return outLabelId;
- }
-
- @Override
- public PortNumber inPort() {
- return inPort;
- }
-
- @Override
- public PortNumber outPort() {
- return outPort;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(deviceId, inLabelId, outLabelId, inPort, outPort);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LspLocalLabelInfo) {
- final DefaultLspLocalLabelInfo other = (DefaultLspLocalLabelInfo) obj;
- return Objects.equals(this.deviceId, other.deviceId) &&
- Objects.equals(this.inLabelId, other.inLabelId) &&
- Objects.equals(this.outLabelId, other.outLabelId) &&
- Objects.equals(this.inPort, other.inPort) &&
- Objects.equals(this.outPort, other.outPort);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("DeviceId", deviceId)
- .add("InLabelId", inLabelId)
- .add("OutLabelId", outLabelId)
- .add("InPort", inPort)
- .add("OutPort", outPort)
- .toString();
- }
-
- /**
- * Creates and returns a new builder instance that clones an existing object.
- *
- * @param deviceLabelInfo device label information
- * @return new builder
- */
- public static Builder builder(LspLocalLabelInfo deviceLabelInfo) {
- return new Builder(deviceLabelInfo);
- }
-
- /**
- * Creates and returns a new builder instance.
- *
- * @return new builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder.
- */
- public static final class Builder implements LspLocalLabelInfo.Builder {
-
- private DeviceId deviceId;
-
- private LabelResourceId inLabelId;
-
- private LabelResourceId outLabelId;
-
- private PortNumber inPort;
-
- private PortNumber outPort;
-
- /**
- * Constructs default builder.
- */
- private Builder() {
- }
-
- /**
- * Initializes member variables with existing object.
- */
- private Builder(LspLocalLabelInfo deviceLabelInfo) {
- this.deviceId = deviceLabelInfo.deviceId();
- this.inLabelId = deviceLabelInfo.inLabelId();
- this.outLabelId = deviceLabelInfo.outLabelId();
- this.inPort = deviceLabelInfo.inPort();
- this.outPort = deviceLabelInfo.outPort();
- }
-
- @Override
- public Builder deviceId(DeviceId id) {
- this.deviceId = id;
- return this;
- }
-
- @Override
- public Builder inLabelId(LabelResourceId id) {
- this.inLabelId = id;
- return this;
- }
-
- @Override
- public Builder outLabelId(LabelResourceId id) {
- this.outLabelId = id;
- return this;
- }
-
- @Override
- public Builder inPort(PortNumber port) {
- this.inPort = port;
- return this;
- }
-
- @Override
- public Builder outPort(PortNumber port) {
- this.outPort = port;
- return this;
- }
-
- @Override
- public LspLocalLabelInfo build() {
- return new DefaultLspLocalLabelInfo(deviceId, inLabelId, outLabelId, inPort, outPort);
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
index 47f1c46..9b2941f 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
@@ -19,9 +19,6 @@
import com.google.common.collect.ImmutableSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -34,18 +31,13 @@
import org.onlab.util.KryoNamespace;
import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
import org.onosproject.net.resource.ResourceConsumer;
import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
import org.onosproject.pce.pceservice.constraint.CostConstraint;
import org.onosproject.pce.pceservice.TunnelConsumerId;
import org.onosproject.pce.pceservice.LspType;
import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint;
-import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
import org.onosproject.pce.pcestore.api.PceStore;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.ConsistentMap;
@@ -62,42 +54,21 @@
@Component(immediate = true)
@Service
public class DistributedPceStore implements PceStore {
-
- private static final String DEVICE_ID_NULL = "Device ID cannot be null";
- private static final String DEVICE_LABEL_STORE_INFO_NULL = "Device Label Store cannot be null";
- private static final String LABEL_RESOURCE_ID_NULL = "Label Resource Id cannot be null";
- private static final String LABEL_RESOURCE_LIST_NULL = "Label Resource List cannot be null";
- private static final String LABEL_RESOURCE_NULL = "Label Resource cannot be null";
- private static final String LINK_NULL = "LINK cannot be null";
- private static final String LSP_LOCAL_LABEL_INFO_NULL = "LSP Local Label Info cannot be null";
private static final String PATH_INFO_NULL = "Path Info cannot be null";
private static final String PCECC_TUNNEL_INFO_NULL = "PCECC Tunnel Info cannot be null";
private static final String TUNNEL_ID_NULL = "Tunnel Id cannot be null";
- private static final String TUNNEL_CONSUMER_ID_NULL = "Tunnel consumer Id cannot be null";
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
- // Mapping device with global node label
- private ConsistentMap<DeviceId, LabelResourceId> globalNodeLabelMap;
-
- // Mapping link with adjacency label
- private ConsistentMap<Link, LabelResourceId> adjLabelMap;
-
// Mapping tunnel with device local info with tunnel consumer id
- private ConsistentMap<TunnelId, PceccTunnelInfo> tunnelInfoMap;
+ private ConsistentMap<TunnelId, ResourceConsumer> tunnelInfoMap;
// List of Failed path info
private DistributedSet<PcePathInfo> failedPathSet;
- // Locally maintain LSRID to device id mapping for better performance.
- private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
-
- // List of PCC LSR ids whose BGP device information was not available to perform
- // label db sync.
- private HashSet<DeviceId> pendinglabelDbSyncPccMap = new HashSet();
private static final Serializer SERIALIZER = Serializer
.using(new KryoNamespace.Builder().register(KryoNamespaces.API)
.register(PcePathInfo.class)
@@ -112,36 +83,13 @@
@Activate
protected void activate() {
- globalNodeLabelMap = storageService.<DeviceId, LabelResourceId>consistentMapBuilder()
- .withName("onos-pce-globalnodelabelmap")
- .withSerializer(Serializer.using(
- new KryoNamespace.Builder()
- .register(KryoNamespaces.API)
- .register(LabelResourceId.class)
- .build()))
- .build();
-
- adjLabelMap = storageService.<Link, LabelResourceId>consistentMapBuilder()
- .withName("onos-pce-adjlabelmap")
- .withSerializer(Serializer.using(
- new KryoNamespace.Builder()
- .register(KryoNamespaces.API)
- .register(Link.class,
- LabelResource.class,
- LabelResourceId.class)
- .build()))
- .build();
-
- tunnelInfoMap = storageService.<TunnelId, PceccTunnelInfo>consistentMapBuilder()
+ tunnelInfoMap = storageService.<TunnelId, ResourceConsumer>consistentMapBuilder()
.withName("onos-pce-tunnelinfomap")
.withSerializer(Serializer.using(
new KryoNamespace.Builder()
.register(KryoNamespaces.API)
.register(TunnelId.class,
- PceccTunnelInfo.class,
- DefaultLspLocalLabelInfo.class,
- TunnelConsumerId.class,
- LabelResourceId.class)
+ TunnelConsumerId.class)
.build()))
.build();
@@ -160,18 +108,6 @@
}
@Override
- public boolean existsGlobalNodeLabel(DeviceId id) {
- checkNotNull(id, DEVICE_ID_NULL);
- return globalNodeLabelMap.containsKey(id);
- }
-
- @Override
- public boolean existsAdjLabel(Link link) {
- checkNotNull(link, LINK_NULL);
- return adjLabelMap.containsKey(link);
- }
-
- @Override
public boolean existsTunnelInfo(TunnelId tunnelId) {
checkNotNull(tunnelId, TUNNEL_ID_NULL);
return tunnelInfoMap.containsKey(tunnelId);
@@ -184,16 +120,6 @@
}
@Override
- public int getGlobalNodeLabelCount() {
- return globalNodeLabelMap.size();
- }
-
- @Override
- public int getAdjLabelCount() {
- return adjLabelMap.size();
- }
-
- @Override
public int getTunnelInfoCount() {
return tunnelInfoMap.size();
}
@@ -204,21 +130,9 @@
}
@Override
- public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
- return globalNodeLabelMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> (LabelResourceId) e.getValue().value()));
- }
-
- @Override
- public Map<Link, LabelResourceId> getAdjLabels() {
- return adjLabelMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> (LabelResourceId) e.getValue().value()));
- }
-
- @Override
- public Map<TunnelId, PceccTunnelInfo> getTunnelInfos() {
+ public Map<TunnelId, ResourceConsumer> getTunnelInfos() {
return tunnelInfoMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> (PceccTunnelInfo) e.getValue().value()));
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
}
@Override
@@ -227,45 +141,17 @@
}
@Override
- public LabelResourceId getGlobalNodeLabel(DeviceId id) {
- checkNotNull(id, DEVICE_ID_NULL);
- return globalNodeLabelMap.get(id) == null ? null : globalNodeLabelMap.get(id).value();
- }
-
- @Override
- public LabelResourceId getAdjLabel(Link link) {
- checkNotNull(link, LINK_NULL);
- return adjLabelMap.get(link) == null ? null : adjLabelMap.get(link).value();
- }
-
- @Override
- public PceccTunnelInfo getTunnelInfo(TunnelId tunnelId) {
+ public ResourceConsumer getTunnelInfo(TunnelId tunnelId) {
checkNotNull(tunnelId, TUNNEL_ID_NULL);
return tunnelInfoMap.get(tunnelId) == null ? null : tunnelInfoMap.get(tunnelId).value();
}
@Override
- public void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId) {
- checkNotNull(deviceId, DEVICE_ID_NULL);
- checkNotNull(labelId, LABEL_RESOURCE_ID_NULL);
-
- globalNodeLabelMap.put(deviceId, labelId);
- }
-
- @Override
- public void addAdjLabel(Link link, LabelResourceId labelId) {
- checkNotNull(link, LINK_NULL);
- checkNotNull(labelId, LABEL_RESOURCE_ID_NULL);
-
- adjLabelMap.put(link, labelId);
- }
-
- @Override
- public void addTunnelInfo(TunnelId tunnelId, PceccTunnelInfo pceccTunnelInfo) {
+ public void addTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId) {
checkNotNull(tunnelId, TUNNEL_ID_NULL);
- checkNotNull(pceccTunnelInfo, PCECC_TUNNEL_INFO_NULL);
+ checkNotNull(tunnelConsumerId, PCECC_TUNNEL_INFO_NULL);
- tunnelInfoMap.put(tunnelId, pceccTunnelInfo);
+ tunnelInfoMap.put(tunnelId, tunnelConsumerId);
}
@Override
@@ -275,62 +161,6 @@
}
@Override
- public boolean updateTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
- checkNotNull(tunnelId, TUNNEL_ID_NULL);
- checkNotNull(lspLocalLabelInfoList, LSP_LOCAL_LABEL_INFO_NULL);
-
- if (!tunnelInfoMap.containsKey((tunnelId))) {
- log.debug("Tunnel info does not exist whose tunnel id is {}.", tunnelId.toString());
- return false;
- }
-
- PceccTunnelInfo tunnelInfo = tunnelInfoMap.get(tunnelId).value();
- tunnelInfo.lspLocalLabelInfoList(lspLocalLabelInfoList);
- tunnelInfoMap.put(tunnelId, tunnelInfo);
-
- return true;
- }
-
- @Override
- public boolean updateTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId) {
- checkNotNull(tunnelId, TUNNEL_ID_NULL);
- checkNotNull(tunnelConsumerId, TUNNEL_CONSUMER_ID_NULL);
-
- if (!tunnelInfoMap.containsKey((tunnelId))) {
- log.debug("Tunnel info does not exist whose tunnel id is {}.", tunnelId.toString());
- return false;
- }
-
- PceccTunnelInfo tunnelInfo = tunnelInfoMap.get(tunnelId).value();
- tunnelInfo.tunnelConsumerId(tunnelConsumerId);
- tunnelInfoMap.put(tunnelId, tunnelInfo);
-
- return true;
- }
-
- @Override
- public boolean removeGlobalNodeLabel(DeviceId id) {
- checkNotNull(id, DEVICE_ID_NULL);
-
- if (globalNodeLabelMap.remove(id) == null) {
- log.error("SR-TE node label deletion for device {} has failed.", id.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeAdjLabel(Link link) {
- checkNotNull(link, LINK_NULL);
-
- if (adjLabelMap.remove(link) == null) {
- log.error("Adjacency label deletion for link {} hash failed.", link.toString());
- return false;
- }
- return true;
- }
-
- @Override
public boolean removeTunnelInfo(TunnelId tunnelId) {
checkNotNull(tunnelId, TUNNEL_ID_NULL);
@@ -351,50 +181,4 @@
}
return true;
}
-
- @Override
- public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
- checkNotNull(lsrId);
- checkNotNull(deviceId);
-
- lsrIdDeviceIdMap.put(lsrId, deviceId);
- return true;
- }
-
- @Override
- public boolean removeLsrIdDevice(String lsrId) {
- checkNotNull(lsrId);
-
- lsrIdDeviceIdMap.remove(lsrId);
- return true;
- }
-
- @Override
- public DeviceId getLsrIdDevice(String lsrId) {
- checkNotNull(lsrId);
-
- return lsrIdDeviceIdMap.get(lsrId);
-
- }
-
- @Override
- public boolean addPccLsr(DeviceId lsrId) {
- checkNotNull(lsrId);
- pendinglabelDbSyncPccMap.add(lsrId);
- return true;
- }
-
- @Override
- public boolean removePccLsr(DeviceId lsrId) {
- checkNotNull(lsrId);
- pendinglabelDbSyncPccMap.remove(lsrId);
- return true;
- }
-
- @Override
- public boolean hasPccLsr(DeviceId lsrId) {
- checkNotNull(lsrId);
- return pendinglabelDbSyncPccMap.contains(lsrId);
-
- }
}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PceccTunnelInfo.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PceccTunnelInfo.java
deleted file mode 100644
index e41947d..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PceccTunnelInfo.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pcestore;
-
-import com.google.common.base.MoreObjects;
-
-import java.util.Objects;
-import java.util.List;
-
-import org.onosproject.net.resource.ResourceConsumer;
-import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
-
-/**
- * PCECC tunnel information is used to store
- * list of links label information of a path containing IN, OUT label and destination port of a link
- * to release label allocation in devices.
- * Also storing resource consumer id to release bandwdith of a tunnel.
- * The first entry is created with TunnelId and resource consumer id,
- * later this entry may be updated to store label information on basic PCECC case.
- */
-public final class PceccTunnelInfo {
-
- private List<LspLocalLabelInfo> lspLocalLabelInfoList;
-
- private ResourceConsumer tunnelConsumerId;
-
- /**
- * Initialization of member variables.
- *
- * @param lspLocalLabelInfoList list of devices local label info
- * @param tunnelConsumerId tunnel consumer id
- */
- public PceccTunnelInfo(List<LspLocalLabelInfo> lspLocalLabelInfoList,
- ResourceConsumer tunnelConsumerId) {
- this.lspLocalLabelInfoList = lspLocalLabelInfoList;
- this.tunnelConsumerId = tunnelConsumerId;
- }
-
- /**
- * Initialization for serialization.
- */
- public PceccTunnelInfo() {
- this.lspLocalLabelInfoList = null;
- this.tunnelConsumerId = null;
- }
-
- /**
- * Retrieves list of devices local label info.
- *
- * @return list of devices local label info
- */
- public List<LspLocalLabelInfo> lspLocalLabelInfoList() {
- return this.lspLocalLabelInfoList;
- }
-
- /**
- * Retrieves tunnel consumer id.
- *
- * @return tunnel consumer id
- */
- public ResourceConsumer tunnelConsumerId() {
- return this.tunnelConsumerId;
- }
-
- /**
- * Sets list of local label info of a path.
- *
- * @param lspLocalLabelInfoList list of devices local label info
- */
- public void lspLocalLabelInfoList(List<LspLocalLabelInfo> lspLocalLabelInfoList) {
- this.lspLocalLabelInfoList = lspLocalLabelInfoList;
- }
-
- /**
- * Sets tunnel consumer id.
- *
- * @param id tunnel consumer id
- */
- public void tunnelConsumerId(ResourceConsumer id) {
- this.tunnelConsumerId = id;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(lspLocalLabelInfoList, tunnelConsumerId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PceccTunnelInfo) {
- final PceccTunnelInfo other = (PceccTunnelInfo) obj;
- return Objects.equals(this.lspLocalLabelInfoList, other.lspLocalLabelInfoList) &&
- Objects.equals(this.tunnelConsumerId, other.tunnelConsumerId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("DeviceLabelInfoList", lspLocalLabelInfoList)
- .add("TunnelConsumerId", tunnelConsumerId)
- .toString();
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/LspLocalLabelInfo.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/LspLocalLabelInfo.java
deleted file mode 100644
index 07b61be..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/LspLocalLabelInfo.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pcestore.api;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-
-/**
- * Abstraction of an entity providing LSP local label information.
- */
-public interface LspLocalLabelInfo {
-
- /**
- * Returns device id.
- *
- * @return device id
- */
- DeviceId deviceId();
-
- /**
- * Returns in label id of a device.
- *
- * @return in label resource id
- */
- LabelResourceId inLabelId();
-
- /**
- * Returns out label id of a device.
- *
- * @return node out label resource id
- */
- LabelResourceId outLabelId();
-
- /**
- * Returns in port of an incoming label.
- *
- * @return in port
- */
- PortNumber inPort();
-
- /**
- * Returns next hop of an outgoing label.
- *
- * @return out port
- */
- PortNumber outPort();
-
- /**
- * LspLocalLabelInfo Builder.
- */
- interface Builder {
-
- /**
- * Returns builder object of a device id.
- *
- * @param id device id
- * @return builder object of device id
- */
- Builder deviceId(DeviceId id);
-
- /**
- * Returns builder object of in label.
- *
- * @param id in label id
- * @return builder object of in label id
- */
- Builder inLabelId(LabelResourceId id);
-
- /**
- * Returns builder object of out label.
- *
- * @param id out label id
- * @return builder object of out label id
- */
- Builder outLabelId(LabelResourceId id);
-
- /**
- * Returns builder object of in port of an incoming label.
- *
- * @param port in port
- * @return builder object of in port
- */
- Builder inPort(PortNumber port);
-
- /**
- * Returns builder object of next hop of an outgoing label.
- *
- * @param port out port
- * @return builder object of out port
- */
- Builder outPort(PortNumber port);
-
- /**
- * Builds object of device local label info.
- *
- * @return object of device local label info.
- */
- LspLocalLabelInfo build();
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
index 3c9ceb7..3fdef15 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
@@ -15,14 +15,8 @@
*/
package org.onosproject.pce.pcestore.api;
-import java.util.List;
-
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
import org.onosproject.net.resource.ResourceConsumer;
-import org.onosproject.pce.pcestore.PceccTunnelInfo;
import org.onosproject.pce.pcestore.PcePathInfo;
import java.util.Map;
@@ -32,22 +26,6 @@
*/
public interface PceStore {
/**
- * Checks whether device id is present in global node label store.
- *
- * @param id device id
- * @return success of failure
- */
- boolean existsGlobalNodeLabel(DeviceId id);
-
- /**
- * Checks whether link is present in adjacency label store.
- *
- * @param link link between devices
- * @return success of failure
- */
- boolean existsAdjLabel(Link link);
-
- /**
* Checks whether tunnel id is present in tunnel info store.
*
* @param tunnelId tunnel id
@@ -64,20 +42,6 @@
boolean existsFailedPathInfo(PcePathInfo failedPathInfo);
/**
- * Retrieves the node label count.
- *
- * @return node label count
- */
- int getGlobalNodeLabelCount();
-
- /**
- * Retrieves the adjacency label count.
- *
- * @return adjacency label count
- */
- int getAdjLabelCount();
-
- /**
* Retrieves the tunnel info count.
*
* @return tunnel info count
@@ -92,25 +56,11 @@
int getFailedPathInfoCount();
/**
- * Retrieves device id and label pairs collection from global node label store.
- *
- * @return collection of device id and label pairs
- */
- Map<DeviceId, LabelResourceId> getGlobalNodeLabels();
-
- /**
- * Retrieves link and label pairs collection from adjacency label store.
- *
- * @return collection of link and label pairs
- */
- Map<Link, LabelResourceId> getAdjLabels();
-
- /**
* Retrieves tunnel id and pcecc tunnel info pairs collection from tunnel info store.
*
- * @return collection of tunnel id and pcecc tunnel info pairs
+ * @return collection of tunnel id and resource consumer pairs
*/
- Map<TunnelId, PceccTunnelInfo> getTunnelInfos();
+ Map<TunnelId, ResourceConsumer> getTunnelInfos();
/**
* Retrieves path info collection from failed path info store.
@@ -120,52 +70,20 @@
Iterable<PcePathInfo> getFailedPathInfos();
/**
- * Retrieves node label for specified device id.
- *
- * @param id device id
- * @return node label
- */
- LabelResourceId getGlobalNodeLabel(DeviceId id);
-
- /**
- * Retrieves adjacency label for specified link.
- *
- * @param link between devices
- * @return adjacency label
- */
- LabelResourceId getAdjLabel(Link link);
-
- /**
* Retrieves local label info with tunnel consumer id from tunnel info store.
*
* @param tunnelId tunnel id
- * @return pcecc tunnel info
+ * @return resource consumer
*/
- PceccTunnelInfo getTunnelInfo(TunnelId tunnelId);
-
- /**
- * Stores node label into global node label store.
- *
- * @param deviceId device id
- * @param labelId node label id
- */
- void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId);
-
- /**
- * Stores adjacency label into adjacency label store.
- *
- * @param link link between nodes
- * @param labelId link label id
- */
- void addAdjLabel(Link link, LabelResourceId labelId);
+ ResourceConsumer getTunnelInfo(TunnelId tunnelId);
/**
* Stores local label info with tunnel consumer id into tunnel info store for specified tunnel id.
*
* @param tunnelId tunnel id
- * @param pceccTunnelInfo local label info
+ * @param tunnelConsumerId tunnel consumer id
*/
- void addTunnelInfo(TunnelId tunnelId, PceccTunnelInfo pceccTunnelInfo);
+ void addTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId);
/**
* Stores path information into failed path info store.
@@ -175,41 +93,6 @@
void addFailedPathInfo(PcePathInfo failedPathInfo);
/**
- * Updates local label info. The first entry is created with TunnelId and TunnelConsumerId.
- * Later this entry may be updated to store label information if it is basic PCECC case.
- *
- * @param tunnelId tunnel id
- * @param lspLocalLabelInfoList list of local labels
- * @return success or failure
- */
- boolean updateTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList);
-
- /**
- * Updates tunnel info map with tunnel consumer id.
- *
- * @param tunnelId tunnel id
- * @param tunnelConsumerId tunnel consumer id
- * @return success or failure
- */
- boolean updateTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId);
-
- /**
- * Removes device label from global node label store for specified device id.
- *
- * @param id device id
- * @return success or failure
- */
- boolean removeGlobalNodeLabel(DeviceId id);
-
- /**
- * Removes adjacency label from adjacency label store for specified link information.
- *
- * @param link between nodes
- * @return success or failure
- */
- boolean removeAdjLabel(Link link);
-
- /**
* Removes local label info with tunnel consumer id from tunnel info store for specified tunnel id.
*
* @param tunnelId tunnel id
@@ -224,54 +107,4 @@
* @return success or failure
*/
boolean removeFailedPathInfo(PcePathInfo failedPathInfo);
-
- /**
- * Adds lsrid to device id mapping.
- *
- * @param lsrId lsrId of the device
- * @param deviceId device id
- * @return success or failure
- */
- boolean addLsrIdDevice(String lsrId, DeviceId deviceId);
-
- /**
- * Removes lsrid to device id mapping.
- *
- * @param lsrId lsrId of the device
- * @return success or failure
- */
- boolean removeLsrIdDevice(String lsrId);
-
- /**
- * Gets lsrid to device id mapping.
- *
- * @param lsrId lsrId of the device
- * @return device id of the lsrId
- */
- DeviceId getLsrIdDevice(String lsrId);
-
- /**
- * Adds lsrId of the PCC in form of device id for the PCC for which sync is pending due to non-availability of BGP.
- * device.
- *
- * @param lsrId LSR id of the PCC in form of device id
- * @return success or failure
- */
- public boolean addPccLsr(DeviceId lsrId);
-
- /**
- * Removes lsrId of the PCC in form of device id for the PCC for which pending sync is done.
- *
- * @param lsrId LSR id of the PCC in form of device id
- * @return success or failure
- */
- public boolean removePccLsr(DeviceId lsrId);
-
- /**
- * Gets lsrId of the PCC in form of device id.
- *
- * @param lsrId LSR id of the PCC in form of device id
- * @return success or failure
- */
- public boolean hasPccLsr(DeviceId lsrId);
}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BasicPceccHandlerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BasicPceccHandlerTest.java
deleted file mode 100644
index cd28f9e..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BasicPceccHandlerTest.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pceservice;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.onosproject.net.Link.Type.DIRECT;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.LinkedList;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.DefaultGroupId;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.Path;
-import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
-import org.onosproject.pce.pcestore.api.PceStore;
-import org.onosproject.pce.pcestore.PceccTunnelInfo;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pce.util.LabelResourceAdapter;
-import org.onosproject.pce.util.PceStoreAdapter;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.Link;
-
-/**
- * Unit tests for BasicPceccHandler class.
- */
-public class BasicPceccHandlerTest {
-
- public static final long LOCAL_LABEL_SPACE_MIN = 5122;
- public static final long LOCAL_LABEL_SPACE_MAX = 9217;
-
- private BasicPceccHandler pceccHandler;
- protected LabelResourceService labelRsrcService;
- protected PceStore pceStore;
- private FlowObjectiveService flowObjectiveService;
- private CoreService coreService;
- private ApplicationId appId;
- private TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
- private TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
- private DefaultGroupId groupId = new DefaultGroupId(92034);
- private TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
- private TunnelId tunnelId = TunnelId.valueOf("41654654");
- private ProviderId producerName = new ProviderId("producer1", "13");
- private Path path;
- private Tunnel tunnel;
- private PceccTunnelInfo pceccTunnelInfo;
- private DeviceId deviceId1;
- private DeviceId deviceId2;
- private DeviceId deviceId3;
- private DeviceId deviceId4;
- private DeviceId deviceId5;
- private PortNumber port1;
- private PortNumber port2;
- private PortNumber port3;
- private PortNumber port4;
- private PortNumber port5;
-
- @Before
- public void setUp() throws Exception {
- pceccHandler = BasicPceccHandler.getInstance();
- labelRsrcService = new LabelResourceAdapter();
- pceStore = new PceStoreAdapter();
- flowObjectiveService = new PceManagerTest.MockFlowObjService();
- coreService = new PceManagerTest.MockCoreService();
- appId = coreService.registerApplication("org.onosproject.pce");
- pceccHandler.initialize(labelRsrcService, flowObjectiveService, appId, pceStore);
-
- // Cretae tunnel test
- // Link
- ProviderId providerId = new ProviderId("of", "foo");
- deviceId1 = DeviceId.deviceId("of:A");
- deviceId2 = DeviceId.deviceId("of:B");
- deviceId3 = DeviceId.deviceId("of:C");
- deviceId4 = DeviceId.deviceId("of:D");
- deviceId5 = DeviceId.deviceId("of:E");
- port1 = PortNumber.portNumber(1);
- port2 = PortNumber.portNumber(2);
- port3 = PortNumber.portNumber(3);
- port4 = PortNumber.portNumber(4);
- port5 = PortNumber.portNumber(5);
- List<Link> linkList = new LinkedList<>();
-
- Link l1 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build())
- .src(new ConnectPoint(deviceId1, port1))
- .dst(new ConnectPoint(deviceId2, port2))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l1);
- Link l2 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key2", "yahoo").build())
- .src(new ConnectPoint(deviceId2, port2))
- .dst(new ConnectPoint(deviceId3, port3))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l2);
- Link l3 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key3", "yahoo").build())
- .src(new ConnectPoint(deviceId3, port3))
- .dst(new ConnectPoint(deviceId4, port4))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l3);
- Link l4 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key4", "yahoo").build())
- .src(new ConnectPoint(deviceId4, port4))
- .dst(new ConnectPoint(deviceId5, port5))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l4);
-
- // Path
- path = new DefaultPath(providerId, linkList, 10);
-
- // Tunnel
- tunnel = new DefaultTunnel(producerName, src, dst, Tunnel.Type.VXLAN,
- Tunnel.State.ACTIVE, groupId, tunnelId,
- tunnelName, path);
- }
-
- @After
- public void tearDown() throws Exception {
- PceManagerTest.flowsDownloaded = 0;
- }
-
- /**
- * Checks the operation of getInstance() method.
- */
- @Test
- public void testGetInstance() {
- assertThat(pceccHandler, is(notNullValue()));
- }
-
- /**
- * Checks the operation of allocateLabel() method.
- */
- @Test
- public void testAllocateLabel() {
- List<LspLocalLabelInfo> lspLocalLabelInfoList;
- Iterator<LspLocalLabelInfo> iterator;
- LspLocalLabelInfo lspLocalLabelInfo;
- DeviceId deviceId;
- LabelResourceId inLabelId;
- LabelResourceId outLabelId;
- PortNumber inPort;
- PortNumber outPort;
-
- // check allocation result
- assertThat(pceccHandler.allocateLabel(tunnel), is(true));
-
- // Check list of devices with IN and OUT labels whether stored properly in store
- pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId());
- lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList();
- iterator = lspLocalLabelInfoList.iterator();
-
- // Retrieve values and check device5
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId5));
- assertThat(inLabelId, is(notNullValue()));
- assertThat(outLabelId, is(nullValue()));
- assertThat(inPort, is(port5));
- assertThat(outPort, is(nullValue()));
-
- // Next element check
- // Retrieve values and check device4
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId4));
- assertThat(inLabelId, is(notNullValue()));
- assertThat(outLabelId, is(notNullValue()));
- assertThat(inPort, is(port4));
- assertThat(outPort, is(port5));
-
- // Next element check
- // Retrieve values and check device3
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId3));
- assertThat(inLabelId, is(notNullValue()));
- assertThat(outLabelId, is(notNullValue()));
- assertThat(inPort, is(port3));
- assertThat(outPort, is(port4));
-
- // Next element check
- // Retrieve values and check device2
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId2));
- assertThat(inLabelId, is(notNullValue()));
- assertThat(outLabelId, is(notNullValue()));
- assertThat(inPort, is(port2));
- assertThat(outPort, is(port3));
-
- // Next element check
- // Retrieve values and check device1
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId1));
- assertThat(inLabelId, is(nullValue()));
- assertThat(outLabelId, is(notNullValue()));
- assertThat(inPort, is(nullValue()));
- assertThat(outPort, is(port2));
- }
-
- /**
- * Checks the operation of releaseLabel() method.
- */
- @Test
- public void testReleaseLabel() {
- // Release tunnels
- assertThat(pceccHandler.allocateLabel(tunnel), is(true));
- pceccHandler.releaseLabel(tunnel);
-
- // Retrieve from store. Store should not contain this tunnel info.
- pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId());
- assertThat(pceccTunnelInfo, is(nullValue()));
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
index 6962b49..fa52fa0 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
@@ -1,14 +1,10 @@
package org.onosproject.pce.pceservice;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.onlab.graph.GraphPathSearch.ALL_PATHS;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
-import static org.onosproject.net.Link.State.ACTIVE;
-import static org.onosproject.net.Link.Type.DIRECT;
import static org.onosproject.net.MastershipRole.MASTER;
import static org.onosproject.net.resource.Resources.continuous;
import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING;
@@ -22,13 +18,11 @@
import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE2;
import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE3;
import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE4;
-import static org.onosproject.pce.pceservice.PceManager.PCEP_PORT;
import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.pce.pceservice.PcepAnnotationKeys.PLSP_ID;
import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.COST;
import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.TE_COST;
-import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -44,9 +38,6 @@
import org.onlab.graph.GraphPathSearch;
import org.onlab.junit.TestUtils;
import org.onlab.junit.TestUtils.TestUtilsException;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.TCP;
import org.onlab.util.Bandwidth;
import org.onosproject.common.DefaultTopologyGraph;
import org.onosproject.core.ApplicationId;
@@ -54,9 +45,6 @@
import org.onosproject.core.DefaultApplicationId;
import org.onosproject.core.IdGenerator;
import org.onosproject.event.Event;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
import org.onosproject.incubator.net.tunnel.DefaultTunnel;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.Tunnel.State;
@@ -67,34 +55,20 @@
import org.onosproject.mastership.MastershipServiceAdapter;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultAnnotations.Builder;
import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultLink;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.ElementId;
import org.onosproject.net.Link;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.link.LinkEvent;
-import org.onosproject.net.link.LinkListener;
-import org.onosproject.net.packet.DefaultInboundPacket;
-import org.onosproject.net.packet.DefaultPacketContext;
-import org.onosproject.net.packet.InboundPacket;
-import org.onosproject.net.packet.OutboundPacket;
-import org.onosproject.net.packet.PacketProcessor;
-import org.onosproject.net.packet.PacketService;
-import org.onosproject.net.packet.PacketServiceAdapter;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.Resource;
import org.onosproject.net.topology.DefaultTopologyEdge;
@@ -112,10 +86,7 @@
import org.onosproject.pce.pceservice.PathComputationTest.MockPathResourceService;
import org.onosproject.pce.pceservice.constraint.CostConstraint;
import org.onosproject.pce.pcestore.api.PceStore;
-import org.onosproject.pce.util.FlowObjServiceAdapter;
-import org.onosproject.pce.util.LabelResourceAdapter;
import org.onosproject.pce.util.MockDeviceService;
-import org.onosproject.pce.util.MockLinkService;
import org.onosproject.pce.util.PceStoreAdapter;
import org.onosproject.pce.util.TunnelServiceAdapter;
import org.onosproject.pcep.api.DeviceCapability;
@@ -137,14 +108,9 @@
private MockCoreService coreService = new MockCoreService();
private MockTunnelServiceAdapter tunnelService = new MockTunnelServiceAdapter();
private TestStorageService storageService = new TestStorageService();
- private PacketService packetService = new MockPacketService();
private MockDeviceService deviceService = new MockDeviceService();
private MockNetConfigRegistryAdapter netConfigRegistry = new PathComputationTest.MockNetConfigRegistryAdapter();
- private MockLinkService linkService = new MockLinkService();
- private MockFlowObjService flowObjectiveService = new MockFlowObjService();
private PceStore pceStore = new PceStoreAdapter();
- private LabelResourceService labelResourceService = new LabelResourceAdapter();
- private LabelResourceAdminService labelRsrcAdminService = new LabelResourceAdapter();
public static ProviderId providerId = new ProviderId("pce", "foo");
private static final String L3 = "L3";
@@ -173,13 +139,8 @@
pceManager.tunnelService = tunnelService;
pceManager.coreService = coreService;
pceManager.storageService = storageService;
- pceManager.packetService = packetService;
pceManager.deviceService = deviceService;
- pceManager.linkService = linkService;
pceManager.netCfgService = netConfigRegistry;
- pceManager.labelRsrcAdminService = labelRsrcAdminService;
- pceManager.labelRsrcService = labelResourceService;
- pceManager.flowObjectiveService = flowObjectiveService;
pceManager.pceStore = pceStore;
pceManager.mastershipService = mastershipService;
pceManager.activate();
@@ -452,29 +413,6 @@
}
/**
- * Tests path setup without failure for LSP with signalling and with bandwidth reservation.
- */
- @Test
- public void setupPathTest11() {
- build4RouterTopo(false, true, true, true, 15);
- List<Constraint> constraints = new LinkedList<Constraint>();
- BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
- CostConstraint costConstraint = new CostConstraint(TE_COST);
-
- constraints.add(costConstraint);
- constraints.add(bwConstraint);
-
- LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
- LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
-
- pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
- pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, SR_WITHOUT_SIGNALLING);
- assertThat(result, is(false));
- }
-
- /**
* Tests path setup without signalling and with bandwidth reservation.
*/
@Test
@@ -487,24 +425,6 @@
constraints.add(costConstraint);
constraints.add(bwConstraint);
- LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
- LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
-
- pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
- pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
-
- LabelResourceId link1Label = LabelResourceId.labelResourceId(5202);
- pceManager.pceStore.addAdjLabel(link1, link1Label);
-
- LabelResourceId link2Label = LabelResourceId.labelResourceId(5203);
- pceManager.pceStore.addAdjLabel(link2, link2Label);
-
- LabelResourceId link3Label = LabelResourceId.labelResourceId(5204);
- pceManager.pceStore.addAdjLabel(link3, link3Label);
-
- LabelResourceId link4Label = LabelResourceId.labelResourceId(5205);
- pceManager.pceStore.addAdjLabel(link4, link4Label);
-
boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, SR_WITHOUT_SIGNALLING);
assertThat(result, is(true));
}
@@ -572,24 +492,6 @@
CostConstraint costConstraint = new CostConstraint(TE_COST);
constraints.add(costConstraint);
- LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
- LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
-
- pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
- pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
-
- LabelResourceId link1Label = LabelResourceId.labelResourceId(5202);
- pceManager.pceStore.addAdjLabel(link1, link1Label);
-
- LabelResourceId link2Label = LabelResourceId.labelResourceId(5203);
- pceManager.pceStore.addAdjLabel(link2, link2Label);
-
- LabelResourceId link3Label = LabelResourceId.labelResourceId(5204);
- pceManager.pceStore.addAdjLabel(link3, link3Label);
-
- LabelResourceId link4Label = LabelResourceId.labelResourceId(5205);
- pceManager.pceStore.addAdjLabel(link4, link4Label);
-
boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, SR_WITHOUT_SIGNALLING);
assertThat(result, is(true));
@@ -685,89 +587,6 @@
}
/**
- * Tests packet in to trigger label DB sync.
- */
- @Test
- public void packetProcessingTest1() throws URISyntaxException {
-
- build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc.
-
- LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
- LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
-
- pceManager.pceStore.addLsrIdDevice(deviceD1.annotations().value(LSRID), deviceD1.id());
- pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
- pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
-
- ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1));
- ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2));
-
- Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT)
- .providerId(new ProviderId("eth", "1")).build();
-
- LabelResourceId link1Label = LabelResourceId.labelResourceId(5204);
- pceManager.pceStore.addAdjLabel(link1, link1Label);
-
- TCP tcp = new TCP();
- tcp.setDestinationPort(PCEP_PORT);
-
- IPv4 ipv4 = new IPv4();
- ipv4.setProtocol(IPv4.PROTOCOL_TCP);
- ipv4.setPayload(tcp);
-
- Ethernet eth = new Ethernet();
- eth.setEtherType(Ethernet.TYPE_IPV4);
- eth.setPayload(ipv4);
-
- InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(DeviceId.deviceId("1.1.1.1"),
- PortNumber.portNumber(PCEP_PORT)),
- eth, null);
-
- pktProcessor.process(new MockPcepPacketContext(inPkt, null));
- assertThat(flowsDownloaded, is(4));
- }
-
- /**
- * Tests faulty packet in to trigger label DB sync.
- */
- @Test
- public void packetProcessingTest2() throws URISyntaxException {
-
- build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc.
-
- LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
- LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
-
- pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
- pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
-
- ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1));
- ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2));
-
- Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT)
- .providerId(new ProviderId("eth", "1")).build();
-
- LabelResourceId link1Label = LabelResourceId.labelResourceId(5204);
- pceManager.pceStore.addAdjLabel(link1, link1Label);
-
- TCP tcp = new TCP(); // Not set the pcep port.
- IPv4 ipv4 = new IPv4();
- ipv4.setProtocol(IPv4.PROTOCOL_TCP);
- ipv4.setPayload(tcp);
-
- Ethernet eth = new Ethernet();
- eth.setEtherType(Ethernet.TYPE_IPV4);
- eth.setPayload(ipv4);
-
- InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(),
- PortNumber.portNumber(PCEP_PORT)),
- eth, null);
-
- pktProcessor.process(new MockPcepPacketContext(inPkt, null));
- assertThat(flowsDownloaded, is(0));
- }
-
- /**
* Tests tunnel events added and removed.
*/
@Test
@@ -780,24 +599,6 @@
constraints.add(costConstraint);
constraints.add(bwConstraint);
- LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
- LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
-
- pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
- pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
-
- LabelResourceId link1Label = LabelResourceId.labelResourceId(5202);
- pceManager.pceStore.addAdjLabel(link1, link1Label);
-
- LabelResourceId link2Label = LabelResourceId.labelResourceId(5203);
- pceManager.pceStore.addAdjLabel(link2, link2Label);
-
- LabelResourceId link3Label = LabelResourceId.labelResourceId(5204);
- pceManager.pceStore.addAdjLabel(link3, link3Label);
-
- LabelResourceId link4Label = LabelResourceId.labelResourceId(5205);
- pceManager.pceStore.addAdjLabel(link4, link4Label);
-
pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T1", constraints, SR_WITHOUT_SIGNALLING);
assertThat(pceStore.getTunnelInfoCount(), is(1));
@@ -1276,86 +1077,6 @@
assertThat(pathService.paths().iterator().next().cost(), is((double) 180));
}
- /*
- * Tests node label allocation/removal in SR-TE case based on device event.
- */
- @Test
- public void deviceEventTest() {
- // Make four router topology with SR-TE capabilities.
- build4RouterTopo(true, false, true, true, 0);
-
- // Add new L3 device
- DefaultAnnotations.Builder builderDev5 = DefaultAnnotations.builder();
- builderDev5.set(AnnotationKeys.TYPE, L3);
- builderDev5.set(LSRID, "5.5.5.5");
-
- Device dev5 = new MockDevice(DeviceId.deviceId("P005"), builderDev5.build());
- deviceService.addDevice(dev5);
-
- // Add capability
- DeviceCapability device5Cap = netConfigRegistry.addConfig(DeviceId.deviceId("5.5.5.5"), DeviceCapability.class);
- device5Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- // Get listener
- DeviceListener listener = deviceService.getListener();
-
- // Generate Remove events
- deviceService.removeDevice(dev5);
- DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_REMOVED, dev5);
- listener.event(event);
-
- assertThat(pceStore.getGlobalNodeLabel(dev5.id()), is(nullValue()));
- }
-
- /**
- * Tests adjacency label allocation/removal in SR-TE case based on link event.
- */
- @Test
- public void linkEventTest() {
- // Make four router topology with SR-TE capabilities.
- build4RouterTopo(true, false, true, true, 0);
-
- // Get listener
- LinkListener listener = linkService.getListener();
-
- // Adding link3
- linkService.addLink(link3);
-
- // Generate events
- LinkEvent event = new LinkEvent(LinkEvent.Type.LINK_ADDED, link3);
- listener.event(event);
-
- assertThat(pceStore.getAdjLabel(link3), is(notNullValue()));
-
- // Adding link4
- linkService.addLink(link4);
-
- event = new LinkEvent(LinkEvent.Type.LINK_ADDED, link4);
- listener.event(event);
-
- assertThat(pceStore.getAdjLabel(link4), is(notNullValue()));
-
- // Remove link3
- linkService.removeLink(link3);
-
- // Generate events
- event = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link3);
- listener.event(event);
-
- assertThat(pceStore.getAdjLabel(link3), is(nullValue()));
-
- // Remove link4
- linkService.removeLink(link4);
-
- event = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
- listener.event(event);
-
- assertThat(pceStore.getAdjLabel(link4), is(nullValue()));
- }
-
@After
public void tearDown() {
pceManager.deactivate();
@@ -1364,13 +1085,8 @@
pceManager.tunnelService = null;
pceManager.coreService = null;
pceManager.storageService = null;
- pceManager.packetService = null;
pceManager.deviceService = null;
- pceManager.linkService = null;
pceManager.netCfgService = null;
- pceManager.labelRsrcAdminService = null;
- pceManager.labelRsrcService = null;
- pceManager.flowObjectiveService = null;
pceManager.pceStore = null;
pceManager.topologyService = null;
pceManager.mastershipService = null;
@@ -1588,31 +1304,4 @@
super(null, id, null, null, null, null, null, null, annotations);
}
}
-
- private PacketProcessor pktProcessor = null;
-
- private class MockPacketService extends PacketServiceAdapter {
- @Override
- public void addProcessor(PacketProcessor processor, int priority) {
- pktProcessor = processor;
- }
- }
-
- // Minimal PacketContext to make core and applications happy.
- final class MockPcepPacketContext extends DefaultPacketContext {
- private MockPcepPacketContext(InboundPacket inPkt, OutboundPacket outPkt) {
- super(System.currentTimeMillis(), inPkt, outPkt, false);
- }
-
- @Override
- public void send() {
- }
- }
-
- public static class MockFlowObjService extends FlowObjServiceAdapter {
- @Override
- public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
- ++flowsDownloaded;
- }
- }
}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java
deleted file mode 100644
index be5cd2e..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pceservice;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.onosproject.net.Link.Type.DIRECT;
-import static org.onosproject.pce.pceservice.PathComputationTest.D1;
-import static org.onosproject.pce.pceservice.PathComputationTest.D2;
-import static org.onosproject.pce.pceservice.PathComputationTest.D3;
-import static org.onosproject.pce.pceservice.PathComputationTest.D4;
-import static org.onosproject.pce.pceservice.PathComputationTest.D5;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.LinkedList;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.incubator.net.tunnel.LabelStack;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.Path;
-import org.onosproject.pce.pceservice.PathComputationTest.MockNetConfigRegistryAdapter;
-import org.onosproject.pce.pcestore.api.PceStore;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pce.util.LabelResourceAdapter;
-import org.onosproject.pce.util.PceStoreAdapter;
-import org.onosproject.pce.util.MockDeviceService;
-import org.onosproject.pcep.api.DeviceCapability;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.Link;
-
-/**
- * Unit tests for PceccSrTeBeHandler class.
- */
-public class PceccSrTeBeHandlerTest {
-
- public static final long GLOBAL_LABEL_SPACE_MIN = 4097;
- public static final long GLOBAL_LABEL_SPACE_MAX = 5121;
- private static final String L3 = "L3";
- private static final String LSRID = "lsrId";
-
- private PceccSrTeBeHandler srTeHandler;
- private CoreService coreService;
- private LabelResourceAdminService labelRsrcAdminService;
- private LabelResourceService labelRsrcService;
- private PceStore pceStore;
- private MockDeviceService deviceService;
- private FlowObjectiveService flowObjectiveService;
- private MockNetConfigRegistryAdapter netCfgService = new PathComputationTest.MockNetConfigRegistryAdapter();
- private ApplicationId appId;
- private ProviderId providerId;
- private Device deviceD1;
- private Device deviceD2;
- private Device deviceD3;
- private Device deviceD4;
- private Device deviceD5;
- private PortNumber port1;
- private PortNumber port2;
- private PortNumber port3;
- private PortNumber port4;
- private PortNumber port5;
- private Link link1;
- private Link link2;
- private Link link3;
- private Link link4;
- private Path path1;
- LabelResourceId labelId;
-
- @Before
- public void setUp() throws Exception {
- // Initialization of member variables
- srTeHandler = PceccSrTeBeHandler.getInstance();
- labelRsrcService = new LabelResourceAdapter();
- labelRsrcAdminService = new LabelResourceAdapter();
- flowObjectiveService = new PceManagerTest.MockFlowObjService();
- coreService = new PceManagerTest.MockCoreService();
- appId = coreService.registerApplication("org.onosproject.pce");
- pceStore = new PceStoreAdapter();
- deviceService = new MockDeviceService();
- srTeHandler.initialize(labelRsrcAdminService, labelRsrcService, flowObjectiveService, appId, pceStore,
- deviceService);
-
- // Creates path
- // Creates list of links
- providerId = new ProviderId("of", "foo");
-
- // Devices
- DefaultAnnotations.Builder builderDev1 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev2 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev3 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev4 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev5 = DefaultAnnotations.builder();
-
- builderDev1.set(AnnotationKeys.TYPE, L3);
- builderDev1.set(LSRID, "1.1.1.1");
-
- builderDev2.set(AnnotationKeys.TYPE, L3);
- builderDev2.set(LSRID, "2.2.2.2");
-
- builderDev3.set(AnnotationKeys.TYPE, L3);
- builderDev3.set(LSRID, "3.3.3.3");
-
- builderDev4.set(AnnotationKeys.TYPE, L3);
- builderDev4.set(LSRID, "4.4.4.4");
-
- builderDev5.set(AnnotationKeys.TYPE, L3);
- builderDev5.set(LSRID, "5.5.5.5");
-
- deviceD1 = new MockDevice(D1.deviceId(), builderDev1.build());
- deviceD2 = new MockDevice(D2.deviceId(), builderDev2.build());
- deviceD3 = new MockDevice(D3.deviceId(), builderDev3.build());
- deviceD4 = new MockDevice(D4.deviceId(), builderDev4.build());
- deviceD5 = new MockDevice(D5.deviceId(), builderDev5.build());
-
- deviceService.addDevice(deviceD1);
- deviceService.addDevice(deviceD2);
- deviceService.addDevice(deviceD3);
- deviceService.addDevice(deviceD4);
- deviceService.addDevice(deviceD5);
-
- DeviceCapability device1Cap = netCfgService.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
- device1Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- DeviceCapability device2Cap = netCfgService.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
- device2Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- DeviceCapability device3Cap = netCfgService.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class);
- device3Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- DeviceCapability device4Cap = netCfgService.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
- device4Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- DeviceCapability device5Cap = netCfgService.addConfig(DeviceId.deviceId("5.5.5.5"), DeviceCapability.class);
- device5Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- // Port Numbers
- port1 = PortNumber.portNumber(1);
- port2 = PortNumber.portNumber(2);
- port3 = PortNumber.portNumber(3);
- port4 = PortNumber.portNumber(4);
- port5 = PortNumber.portNumber(5);
- List<Link> linkList = new LinkedList<>();
-
- link1 = DefaultLink.builder().providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build())
- .src(new ConnectPoint(deviceD1.id(), port1)).dst(new ConnectPoint(deviceD2.id(), port2)).type(DIRECT)
- .state(Link.State.ACTIVE).build();
- linkList.add(link1);
- link2 = DefaultLink.builder().providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key2", "yahoo").build())
- .src(new ConnectPoint(deviceD2.id(), port2)).dst(new ConnectPoint(deviceD3.id(), port3)).type(DIRECT)
- .state(Link.State.ACTIVE).build();
- linkList.add(link2);
- link3 = DefaultLink.builder().providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key3", "yahoo").build())
- .src(new ConnectPoint(deviceD3.id(), port3)).dst(new ConnectPoint(deviceD4.id(), port4)).type(DIRECT)
- .state(Link.State.ACTIVE).build();
- linkList.add(link3);
- link4 = DefaultLink.builder().providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key4", "yahoo").build())
- .src(new ConnectPoint(deviceD4.id(), port4)).dst(new ConnectPoint(deviceD5.id(), port5)).type(DIRECT)
- .state(Link.State.ACTIVE).build();
- linkList.add(link4);
-
- // Path
- path1 = new DefaultPath(providerId, linkList, 10);
- }
-
- @After
- public void tearDown() throws Exception {
- PceManagerTest.flowsDownloaded = 0;
- }
-
- /**
- * Checks the operation of getInstance() method.
- */
- @Test
- public void testGetInstance() {
- assertThat(srTeHandler, is(notNullValue()));
- }
-
- /**
- * Checks the operation of reserveGlobalPool() method.
- */
- @Test
- public void testReserveGlobalPool() {
- assertThat(srTeHandler.reserveGlobalPool(GLOBAL_LABEL_SPACE_MIN, GLOBAL_LABEL_SPACE_MAX), is(true));
- }
-
- /**
- * Checks the operation of allocateNodeLabel() method on node label.
- */
- @Test
- public void testAllocateNodeLabel() {
- // Specific device D1.deviceId
-
- //device 1
- String lsrId1 = "11.1.1.1";
- // Allocate node label for specific device D1deviceId
- assertThat(srTeHandler.allocateNodeLabel(D1.deviceId(), lsrId1), is(true));
- // Retrieve label from store
- LabelResourceId labelId = pceStore.getGlobalNodeLabel(D1.deviceId());
- // Check whether label is generated for this device D1.deviceId()
- assertThat(labelId, is(notNullValue()));
-
- // device 2
- String lsrId2 = "12.1.1.1";
- // Allocate node label for specific device D2.deviceId()
- assertThat(srTeHandler.allocateNodeLabel(D2.deviceId(), lsrId2), is(true));
- // Retrieve label from store
- labelId = pceStore.getGlobalNodeLabel(D2.deviceId());
- // Check whether label is generated for this device D2.deviceId()
- assertThat(labelId, is(notNullValue()));
-
- // device 3
- String lsrId3 = "13.1.1.1";
- // Allocate node label for specific device D3.deviceId()
- assertThat(srTeHandler.allocateNodeLabel(D3.deviceId(), lsrId3), is(true));
- // Retrieve label from store
- labelId = pceStore.getGlobalNodeLabel(D3.deviceId());
- // Check whether label is generated for this device D3.deviceId()
- assertThat(labelId, is(notNullValue()));
-
- // device 4
- String lsrId4 = "14.1.1.1";
- // Allocate node label for specific device D4.deviceId()
- assertThat(srTeHandler.allocateNodeLabel(D4.deviceId(), lsrId4), is(true));
- // Retrieve label from store
- labelId = pceStore.getGlobalNodeLabel(D4.deviceId());
- // Check whether label is generated for this device D4.deviceId()
- assertThat(labelId, is(notNullValue()));
-
- // device 5
- String lsrId5 = "15.1.1.1";
- // Allocate node label for specific device D5.deviceId()
- assertThat(srTeHandler.allocateNodeLabel(D5.deviceId(), lsrId5), is(true));
- // Retrieve label from store
- labelId = pceStore.getGlobalNodeLabel(D5.deviceId());
- // Check whether label is generated for this device D5.deviceId()
- assertThat(labelId, is(notNullValue()));
- }
-
- /**
- * Checks the operation of releaseNodeLabel() method on node label.
- */
- @Test
- public void testReleaseNodeLabelSuccess() {
- testAllocateNodeLabel();
- // Specific device D1.deviceId()
-
- //device 1
- String lsrId1 = "11.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(D1.deviceId(), lsrId1), is(true));
- // Check whether successfully removed label from store
- LabelResourceId labelId = pceStore.getGlobalNodeLabel(D1.deviceId());
- assertThat(labelId, is(nullValue()));
-
- //device 2
- String lsrId2 = "12.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(D2.deviceId(), lsrId2), is(true));
- // Check whether successfully removed label from store
- labelId = pceStore.getGlobalNodeLabel(D2.deviceId());
- assertThat(labelId, is(nullValue()));
-
- //device 3
- String lsrId3 = "13.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(D3.deviceId(), lsrId3), is(true));
- // Check whether successfully removed label from store
- labelId = pceStore.getGlobalNodeLabel(D3.deviceId());
- assertThat(labelId, is(nullValue()));
-
- //device 4
- String lsrId4 = "14.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(D4.deviceId(), lsrId4), is(true));
- // Check whether successfully removed label from store
- labelId = pceStore.getGlobalNodeLabel(D4.deviceId());
- assertThat(labelId, is(nullValue()));
-
- //device 5
- String lsrId5 = "15.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(D5.deviceId(), lsrId5), is(true));
- // Check whether successfully removed label from store
- labelId = pceStore.getGlobalNodeLabel(D5.deviceId());
- assertThat(labelId, is(nullValue()));
- }
-
- @Test
- public void testReleaseNodeLabelFailure() {
- testAllocateNodeLabel();
-
- //device 6
- String lsrId6 = "16.1.1.1";
- // Check whether successfully released node label
- DeviceId deviceId6 = DeviceId.deviceId("foo6");
- assertThat(srTeHandler.releaseNodeLabel(deviceId6, lsrId6), is(false));
- }
-
- /**
- * Checks the operation of allocateAdjacencyLabel() method on adjacency label.
- */
- @Test
- public void testAllocateAdjacencyLabel() {
- // test link1
- // Check whether adjacency label is allocated successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link1), is(true));
- // Retrieve from store and check whether adjacency label is generated successfully for this device.
- LabelResourceId labelId = pceStore.getAdjLabel(link1);
- assertThat(labelId, is(notNullValue()));
-
- // test link2
- // Check whether adjacency label is allocated successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link2), is(true));
- // Retrieve from store and check whether adjacency label is generated successfully for this device.
- labelId = pceStore.getAdjLabel(link2);
- assertThat(labelId, is(notNullValue()));
-
- // test link3
- // Check whether adjacency label is allocated successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link3), is(true));
- // Retrieve from store and check whether adjacency label is generated successfully for this device.
- labelId = pceStore.getAdjLabel(link3);
- assertThat(labelId, is(notNullValue()));
-
- // test link4
- // Check whether adjacency label is allocated successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link4), is(true));
- // Retrieve from store and check whether adjacency label is generated successfully for this device.
- labelId = pceStore.getAdjLabel(link4);
- assertThat(labelId, is(notNullValue()));
- }
-
- /**
- * Checks the operation of releaseAdjacencyLabel() method on adjacency label.
- */
- @Test
- public void testReleaseAdjacencyLabel() {
- // Test link1
- // Check whether adjacency label is released successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link1), is(true));
- assertThat(srTeHandler.releaseAdjacencyLabel(link1), is(true));
- // Retrieve from store and check whether adjacency label is removed successfully for this device.
- LabelResourceId labelId = pceStore.getAdjLabel(link1);
- assertThat(labelId, is(nullValue()));
-
- // Test link2
- // Check whether adjacency label is released successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link2), is(true));
- assertThat(srTeHandler.releaseAdjacencyLabel(link2), is(true));
- // Retrieve from store and check whether adjacency label is removed successfully for this device.
- labelId = pceStore.getAdjLabel(link2);
- assertThat(labelId, is(nullValue()));
- }
-
- /**
- * Checks the operation of computeLabelStack() method.
- */
- @Test
- public void testComputeLabelStack() {
- // Allocate node labels to each devices
- labelId = LabelResourceId.labelResourceId(4097);
- pceStore.addGlobalNodeLabel(D1.deviceId(), labelId);
- labelId = LabelResourceId.labelResourceId(4098);
- pceStore.addGlobalNodeLabel(D2.deviceId(), labelId);
- labelId = LabelResourceId.labelResourceId(4099);
- pceStore.addGlobalNodeLabel(D3.deviceId(), labelId);
- labelId = LabelResourceId.labelResourceId(4100);
- pceStore.addGlobalNodeLabel(D4.deviceId(), labelId);
- labelId = LabelResourceId.labelResourceId(4101);
- pceStore.addGlobalNodeLabel(D5.deviceId(), labelId);
-
- // Allocate adjacency labels to each devices
- labelId = LabelResourceId.labelResourceId(5122);
- pceStore.addAdjLabel(link1, labelId);
- labelId = LabelResourceId.labelResourceId(5123);
- pceStore.addAdjLabel(link2, labelId);
- labelId = LabelResourceId.labelResourceId(5124);
- pceStore.addAdjLabel(link3, labelId);
- labelId = LabelResourceId.labelResourceId(5125);
- pceStore.addAdjLabel(link4, labelId);
-
- // Compute label stack
- LabelStack labelStack = srTeHandler.computeLabelStack(path1);
-
- List<LabelResourceId> labelList = labelStack.labelResources();
- Iterator<LabelResourceId> iterator = labelList.iterator();
-
- // check adjacency label of D1.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(5122)));
-
- // check node-label of D2.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(4098)));
-
- // check adjacency label of D2.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(5123)));
-
- // check node-label of D3.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(4099)));
-
- // check adjacency label of D3.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(5124)));
-
- // check node-label of D4.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(4100)));
-
- // check adjacency label of D4.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(5125)));
-
- // check node-label of D5.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(4101)));
- }
-
- private class MockDevice extends DefaultDevice {
- MockDevice(DeviceId id, Annotations annotations) {
- super(null, id, null, null, null, null, null, null, annotations);
- }
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DefaultLspLocalLabelInfoTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DefaultLspLocalLabelInfoTest.java
deleted file mode 100644
index b4012ac..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DefaultLspLocalLabelInfoTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pcestore;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
-
-/**
- * Unit tests for DefaultLspLocalLabelInfo class.
- */
-public class DefaultLspLocalLabelInfoTest {
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // create same two objects.
- DeviceId deviceId1 = DeviceId.deviceId("foo");
- LabelResourceId inLabelId1 = LabelResourceId.labelResourceId(1);
- LabelResourceId outLabelId1 = LabelResourceId.labelResourceId(2);
- PortNumber inPort1 = PortNumber.portNumber(5122);
- PortNumber outPort1 = PortNumber.portNumber(5123);
-
- LspLocalLabelInfo lspLocalLabel1 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId1)
- .inLabelId(inLabelId1)
- .outLabelId(outLabelId1)
- .inPort(inPort1)
- .outPort(outPort1)
- .build();
-
- // create same object as above object
- LspLocalLabelInfo sameLocalLabel1 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId1)
- .inLabelId(inLabelId1)
- .outLabelId(outLabelId1)
- .inPort(inPort1)
- .outPort(outPort1)
- .build();
-
- // Create different object.
- DeviceId deviceId2 = DeviceId.deviceId("goo");
- LabelResourceId inLabelId2 = LabelResourceId.labelResourceId(3);
- LabelResourceId outLabelId2 = LabelResourceId.labelResourceId(4);
- PortNumber inPort2 = PortNumber.portNumber(5124);
- PortNumber outPort2 = PortNumber.portNumber(5125);
-
- LspLocalLabelInfo lspLocalLabel2 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId2)
- .inLabelId(inLabelId2)
- .outLabelId(outLabelId2)
- .inPort(inPort2)
- .outPort(outPort2)
- .build();
-
- new EqualsTester().addEqualityGroup(lspLocalLabel1, sameLocalLabel1)
- .addEqualityGroup(lspLocalLabel2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a DefaultLspLocalLabelInfo object.
- */
- @Test
- public void testConstruction() {
- DeviceId deviceId = DeviceId.deviceId("foo");
- LabelResourceId inLabelId = LabelResourceId.labelResourceId(1);
- LabelResourceId outLabelId = LabelResourceId.labelResourceId(2);
- PortNumber inPort = PortNumber.portNumber(5122);
- PortNumber outPort = PortNumber.portNumber(5123);
-
- LspLocalLabelInfo lspLocalLabel = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId)
- .inLabelId(inLabelId)
- .outLabelId(outLabelId)
- .inPort(inPort)
- .outPort(outPort)
- .build();
-
- assertThat(deviceId, is(lspLocalLabel.deviceId()));
- assertThat(inLabelId, is(lspLocalLabel.inLabelId()));
- assertThat(outLabelId, is(lspLocalLabel.outLabelId()));
- assertThat(inPort, is(lspLocalLabel.inPort()));
- assertThat(outPort, is(lspLocalLabel.outPort()));
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java
index e1ca650..e0916a8 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java
@@ -30,15 +30,12 @@
import org.junit.Test;
import org.onlab.util.DataRateUnit;
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.ElementId;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.Link;
@@ -46,7 +43,6 @@
import org.onosproject.net.resource.ResourceConsumer;
import org.onosproject.pce.pceservice.LspType;
import org.onosproject.pce.pceservice.TunnelConsumerId;
-import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.store.service.TestStorageService;
@@ -68,24 +64,18 @@
private PortNumber portNumber2 = PortNumber.portNumber(2);
private PortNumber portNumber3 = PortNumber.portNumber(3);
private PortNumber portNumber4 = PortNumber.portNumber(4);
- private ConnectPoint srcConnectionPoint1 = new ConnectPoint((ElementId) deviceId1, portNumber1);
- private ConnectPoint dstConnectionPoint2 = new ConnectPoint((ElementId) deviceId2, portNumber2);
- private ConnectPoint srcConnectionPoint3 = new ConnectPoint((ElementId) deviceId3, portNumber3);
- private ConnectPoint dstConnectionPoint4 = new ConnectPoint((ElementId) deviceId4, portNumber4);
- private LabelResource labelResource1 = new DefaultLabelResource(deviceId1, labelId1);
- private LabelResource labelResource2 = new DefaultLabelResource(deviceId2, labelId2);
- private LabelResource labelResource3 = new DefaultLabelResource(deviceId3, labelId3);
- private LabelResource labelResource4 = new DefaultLabelResource(deviceId4, labelId4);
+ private ConnectPoint srcConnectionPoint1 = new ConnectPoint(deviceId1, portNumber1);
+ private ConnectPoint dstConnectionPoint2 = new ConnectPoint(deviceId2, portNumber2);
+ private ConnectPoint srcConnectionPoint3 = new ConnectPoint(deviceId3, portNumber3);
+ private ConnectPoint dstConnectionPoint4 = new ConnectPoint(deviceId4, portNumber4);
private Link link1;
private Link link2;
- private List<LabelResource> labelList1 = new LinkedList<>();
- private List<LabelResource> labelList2 = new LinkedList<>();
private TunnelId tunnelId1 = TunnelId.valueOf("1");
private TunnelId tunnelId2 = TunnelId.valueOf("2");
private TunnelId tunnelId3 = TunnelId.valueOf("3");
private TunnelId tunnelId4 = TunnelId.valueOf("4");
- private PceccTunnelInfo pceccTunnelInfo1;
- private PceccTunnelInfo pceccTunnelInfo2;
+ private ResourceConsumer tunnelConsumerId1 = TunnelConsumerId.valueOf(10);
+ private ResourceConsumer tunnelConsumerId2 = TunnelConsumerId.valueOf(20);
private PcePathInfo failedPathInfo1;
private PcePathInfo failedPathInfo2;
private PcePathInfo failedPathInfo3;
@@ -120,44 +110,6 @@
.type(Link.Type.DIRECT)
.state(Link.State.ACTIVE)
.build();
- labelList1.add(labelResource1);
- labelList1.add(labelResource2);
- labelList2.add(labelResource3);
- labelList2.add(labelResource4);
-
- // Create pceccTunnelInfo1
- List<LspLocalLabelInfo> lspLocalLabelInfoList1 = new LinkedList<>();
- ResourceConsumer tunnelConsumerId1 = TunnelConsumerId.valueOf(10);
-
- DeviceId deviceId1 = DeviceId.deviceId("foo");
- LabelResourceId inLabelId1 = LabelResourceId.labelResourceId(1);
- LabelResourceId outLabelId1 = LabelResourceId.labelResourceId(2);
-
- LspLocalLabelInfo lspLocalLabel1 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId1)
- .inLabelId(inLabelId1)
- .outLabelId(outLabelId1)
- .build();
- lspLocalLabelInfoList1.add(lspLocalLabel1);
-
- pceccTunnelInfo1 = new PceccTunnelInfo(lspLocalLabelInfoList1, tunnelConsumerId1);
-
- // Create pceccTunnelInfo2
- List<LspLocalLabelInfo> lspLocalLabelInfoList2 = new LinkedList<>();
- ResourceConsumer tunnelConsumerId2 = TunnelConsumerId.valueOf(20);
-
- DeviceId deviceId2 = DeviceId.deviceId("foo");
- LabelResourceId inLabelId2 = LabelResourceId.labelResourceId(3);
- LabelResourceId outLabelId2 = LabelResourceId.labelResourceId(4);
-
- LspLocalLabelInfo lspLocalLabel2 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId2)
- .inLabelId(inLabelId2)
- .outLabelId(outLabelId2)
- .build();
- lspLocalLabelInfoList2.add(lspLocalLabel2);
-
- pceccTunnelInfo2 = new PceccTunnelInfo(lspLocalLabelInfoList2, tunnelConsumerId2);
// Creates failedPathInfo1
DeviceId src1 = DeviceId.deviceId("foo1");
@@ -209,42 +161,6 @@
}
/**
- * Checks the operation of addGlobalNodeLabel() method.
- */
- @Test
- public void testAddGlobalNodeLabel() {
- // initialization
- distrPceStore.storageService = new TestStorageService();
- distrPceStore.activate();
-
- // add device with label
- distrPceStore.addGlobalNodeLabel(deviceId1, labelId1);
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId1), is(true));
- assertThat(distrPceStore.getGlobalNodeLabel(deviceId1), is(labelId1));
- distrPceStore.addGlobalNodeLabel(deviceId2, labelId2);
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId2), is(true));
- assertThat(distrPceStore.getGlobalNodeLabel(deviceId2), is(labelId2));
- }
-
- /**
- * Checks the operation of addAdjLabel() method.
- */
- @Test
- public void testAddAdjLabel() {
- // initialization
- distrPceStore.storageService = new TestStorageService();
- distrPceStore.activate();
-
- // link with list of labels
- distrPceStore.addAdjLabel(link1, labelId1);
- assertThat(distrPceStore.existsAdjLabel(link1), is(true));
- assertThat(distrPceStore.getAdjLabel(link1), is(labelId1));
- distrPceStore.addAdjLabel(link2, labelId2);
- assertThat(distrPceStore.existsAdjLabel(link2), is(true));
- assertThat(distrPceStore.getAdjLabel(link2), is(labelId2));
- }
-
- /**
* Checks the operation of addTunnelInfo() method.
*/
@Test
@@ -254,12 +170,12 @@
distrPceStore.activate();
// TunnelId with device label store information
- distrPceStore.addTunnelInfo(tunnelId1, pceccTunnelInfo1);
+ distrPceStore.addTunnelInfo(tunnelId1, tunnelConsumerId1);
assertThat(distrPceStore.existsTunnelInfo(tunnelId1), is(true));
- assertThat(distrPceStore.getTunnelInfo(tunnelId1), is(pceccTunnelInfo1));
- distrPceStore.addTunnelInfo(tunnelId2, pceccTunnelInfo2);
+ assertThat(distrPceStore.getTunnelInfo(tunnelId1), is(tunnelConsumerId1));
+ distrPceStore.addTunnelInfo(tunnelId2, tunnelConsumerId2);
assertThat(distrPceStore.existsTunnelInfo(tunnelId2), is(true));
- assertThat(distrPceStore.getTunnelInfo(tunnelId2), is(pceccTunnelInfo2));
+ assertThat(distrPceStore.getTunnelInfo(tunnelId2), is(tunnelConsumerId2));
}
/**
@@ -279,30 +195,6 @@
}
/**
- * Checks the operation of existsGlobalNodeLabel() method.
- */
- @Test
- public void testExistsGlobalNodeLabel() {
- testAddGlobalNodeLabel();
-
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId1), is(true));
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId2), is(true));
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId3), is(false));
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId4), is(false));
- }
-
- /**
- * Checks the operation of existsAdjLabel() method.
- */
- @Test
- public void testExistsAdjLabel() {
- testAddAdjLabel();
-
- assertThat(distrPceStore.existsAdjLabel(link1), is(true));
- assertThat(distrPceStore.existsAdjLabel(link2), is(true));
- }
-
- /**
* Checks the operation of existsTunnelInfo() method.
*/
@Test
@@ -329,26 +221,6 @@
}
/**
- * Checks the operation of getGlobalNodeLabelCount() method.
- */
- @Test
- public void testGetGlobalNodeLabelCount() {
- testAddGlobalNodeLabel();
-
- assertThat(distrPceStore.getGlobalNodeLabelCount(), is(2));
- }
-
- /**
- * Checks the operation of getAdjLabelCount() method.
- */
- @Test
- public void testGetAdjLabelCount() {
- testAddAdjLabel();
-
- assertThat(distrPceStore.getAdjLabelCount(), is(2));
- }
-
- /**
* Checks the operation of getTunnelInfoCount() method.
*/
@Test
@@ -369,39 +241,13 @@
}
/**
- * Checks the operation of getGlobalNodeLabels() method.
- */
- @Test
- public void testGetGlobalNodeLabels() {
- testAddGlobalNodeLabel();
-
- Map<DeviceId, LabelResourceId> nodeLabelMap = distrPceStore.getGlobalNodeLabels();
- assertThat(nodeLabelMap, is(notNullValue()));
- assertThat(nodeLabelMap.isEmpty(), is(false));
- assertThat(nodeLabelMap.size(), is(2));
- }
-
- /**
- * Checks the operation of getAdjLabels() method.
- */
- @Test
- public void testGetAdjLabels() {
- testAddAdjLabel();
-
- Map<Link, LabelResourceId> adjLabelMap = distrPceStore.getAdjLabels();
- assertThat(adjLabelMap, is(notNullValue()));
- assertThat(adjLabelMap.isEmpty(), is(false));
- assertThat(adjLabelMap.size(), is(2));
- }
-
- /**
* Checks the operation of getTunnelInfos() method.
*/
@Test
public void testGetTunnelInfos() {
testAddTunnelInfo();
- Map<TunnelId, PceccTunnelInfo> tunnelInfoMap = distrPceStore.getTunnelInfos();
+ Map<TunnelId, ResourceConsumer> tunnelInfoMap = distrPceStore.getTunnelInfos();
assertThat(tunnelInfoMap, is(notNullValue()));
assertThat(tunnelInfoMap.isEmpty(), is(false));
assertThat(tunnelInfoMap.size(), is(2));
@@ -420,38 +266,6 @@
}
/**
- * Checks the operation of getGlobalNodeLabel() method.
- */
- @Test
- public void testGetGlobalNodeLabel() {
- testAddGlobalNodeLabel();
-
- // deviceId1 with labelId1
- assertThat(deviceId1, is(notNullValue()));
- assertThat(distrPceStore.getGlobalNodeLabel(deviceId1), is(labelId1));
-
- // deviceId2 with labelId2
- assertThat(deviceId2, is(notNullValue()));
- assertThat(distrPceStore.getGlobalNodeLabel(deviceId2), is(labelId2));
- }
-
- /**
- * Checks the operation of getAdjLabel() method.
- */
- @Test
- public void testGetAdjLabel() {
- testAddAdjLabel();
-
- // link1 with labels
- assertThat(link1, is(notNullValue()));
- assertThat(distrPceStore.getAdjLabel(link1), is(labelId1));
-
- // link2 with labels
- assertThat(link2, is(notNullValue()));
- assertThat(distrPceStore.getAdjLabel(link2), is(labelId2));
- }
-
- /**
* Checks the operation of getTunnelInfo() method.
*/
@Test
@@ -460,88 +274,11 @@
// tunnelId1 with device label store info
assertThat(tunnelId1, is(notNullValue()));
- assertThat(distrPceStore.getTunnelInfo(tunnelId1), is(pceccTunnelInfo1));
+ assertThat(distrPceStore.getTunnelInfo(tunnelId1), is(tunnelConsumerId1));
// tunnelId2 with device label store info
assertThat(tunnelId2, is(notNullValue()));
- assertThat(distrPceStore.getTunnelInfo(tunnelId2), is(pceccTunnelInfo2));
- }
-
- /**
- * Checks the operation of updateTunnelInfo() method.
- */
- @Test
- public void testUpdateTunnelInfo() {
- // add tunnel info
- testAddTunnelInfo();
-
- // new updates
- // Create pceccTunnelInfo3
- List<LspLocalLabelInfo> lspLocalLabelInfoList3 = new LinkedList<>();
- ResourceConsumer tunnelConsumerId3 = TunnelConsumerId.valueOf(30);
-
- DeviceId deviceId3 = DeviceId.deviceId("goo");
- LabelResourceId inLabelId3 = LabelResourceId.labelResourceId(3);
- LabelResourceId outLabelId3 = LabelResourceId.labelResourceId(4);
-
- LspLocalLabelInfo lspLocalLabel3 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId3)
- .inLabelId(inLabelId3)
- .outLabelId(outLabelId3)
- .build();
- lspLocalLabelInfoList3.add(lspLocalLabel3);
-
- PceccTunnelInfo pceccTunnelInfo3 = new PceccTunnelInfo(lspLocalLabelInfoList3, tunnelConsumerId3);
-
- // Create pceccTunnelInfo4
- List<LspLocalLabelInfo> lspLocalLabelInfoList4 = new LinkedList<>();
- ResourceConsumer tunnelConsumerId4 = TunnelConsumerId.valueOf(40);
-
- DeviceId deviceId4 = DeviceId.deviceId("goo");
- LabelResourceId inLabelId4 = LabelResourceId.labelResourceId(4);
- LabelResourceId outLabelId4 = LabelResourceId.labelResourceId(5);
-
- LspLocalLabelInfo lspLocalLabel4 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId4)
- .inLabelId(inLabelId4)
- .outLabelId(outLabelId4)
- .build();
- lspLocalLabelInfoList4.add(lspLocalLabel4);
-
- PceccTunnelInfo pceccTunnelInfo4 = new PceccTunnelInfo(lspLocalLabelInfoList4, tunnelConsumerId4);
-
- // update only lspLocalLabelInfoList
- assertThat(distrPceStore.updateTunnelInfo(tunnelId1, lspLocalLabelInfoList3), is(true));
- assertThat(distrPceStore.updateTunnelInfo(tunnelId2, lspLocalLabelInfoList4), is(true));
-
- // update only tunnelConsumerId
- assertThat(distrPceStore.updateTunnelInfo(tunnelId1, tunnelConsumerId3), is(true));
- assertThat(distrPceStore.updateTunnelInfo(tunnelId2, tunnelConsumerId4), is(true));
-
- assertThat(distrPceStore.getTunnelInfo(tunnelId1), is(pceccTunnelInfo3));
- assertThat(distrPceStore.getTunnelInfo(tunnelId2), is(pceccTunnelInfo4));
- }
-
- /**
- * Checks the operation of removeGlobalNodeLabel() method.
- */
- @Test
- public void testRemoveGlobalNodeLabel() {
- testAddGlobalNodeLabel();
-
- assertThat(distrPceStore.removeGlobalNodeLabel(deviceId1), is(true));
- assertThat(distrPceStore.removeGlobalNodeLabel(deviceId2), is(true));
- }
-
- /**
- * Checks the operation of removeAdjLabel() method.
- */
- @Test
- public void testRemoveAdjLabel() {
- testAddAdjLabel();
-
- assertThat(distrPceStore.removeAdjLabel(link1), is(true));
- assertThat(distrPceStore.removeAdjLabel(link2), is(true));
+ assertThat(distrPceStore.getTunnelInfo(tunnelId2), is(tunnelConsumerId2));
}
/**
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/PceccTunnelInfoTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/PceccTunnelInfoTest.java
deleted file mode 100644
index 6d9bcd3..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/PceccTunnelInfoTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.pcestore;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.resource.ResourceConsumer;
-import org.onosproject.pce.pceservice.TunnelConsumerId;
-import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
-
-/**
- * Unit tests for PceccTunnelInfo class.
- */
-public class PceccTunnelInfoTest {
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // create same two objects.
- List<LspLocalLabelInfo> lspLocalLabelList1 = new LinkedList<>();
- ResourceConsumer tunnelConsumerId1 = TunnelConsumerId.valueOf(10);
-
- // create object of DefaultLspLocalLabelInfo
- DeviceId deviceId1 = DeviceId.deviceId("foo");
- LabelResourceId inLabelId1 = LabelResourceId.labelResourceId(1);
- LabelResourceId outLabelId1 = LabelResourceId.labelResourceId(2);
- PortNumber inPort1 = PortNumber.portNumber(5122);
- PortNumber outPort1 = PortNumber.portNumber(5123);
-
- LspLocalLabelInfo lspLocalLabel1 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId1)
- .inLabelId(inLabelId1)
- .outLabelId(outLabelId1)
- .inPort(inPort1)
- .outPort(outPort1)
- .build();
- lspLocalLabelList1.add(lspLocalLabel1);
-
- PceccTunnelInfo pceccTunnelInfo1 = new PceccTunnelInfo(lspLocalLabelList1, tunnelConsumerId1);
-
- // create same as above object
- PceccTunnelInfo samePceccTunnelInfo1 = new PceccTunnelInfo(lspLocalLabelList1, tunnelConsumerId1);
-
- // Create different object.
- List<LspLocalLabelInfo> lspLocalLabelInfoList2 = new LinkedList<>();
- ResourceConsumer tunnelConsumerId2 = TunnelConsumerId.valueOf(20);
-
- // create object of DefaultLspLocalLabelInfo
- DeviceId deviceId2 = DeviceId.deviceId("goo");
- LabelResourceId inLabelId2 = LabelResourceId.labelResourceId(3);
- LabelResourceId outLabelId2 = LabelResourceId.labelResourceId(4);
- PortNumber inPort2 = PortNumber.portNumber(5124);
- PortNumber outPort2 = PortNumber.portNumber(5125);
-
- LspLocalLabelInfo lspLocalLabel2 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId2)
- .inLabelId(inLabelId2)
- .outLabelId(outLabelId2)
- .inPort(inPort2)
- .outPort(outPort2)
- .build();
- lspLocalLabelInfoList2.add(lspLocalLabel2);
-
- PceccTunnelInfo pceccTunnelInfo2 = new PceccTunnelInfo(lspLocalLabelInfoList2, tunnelConsumerId2);
-
- new EqualsTester().addEqualityGroup(pceccTunnelInfo1, samePceccTunnelInfo1)
- .addEqualityGroup(pceccTunnelInfo2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a PceccTunnelInfo object.
- */
- @Test
- public void testConstruction() {
- List<LspLocalLabelInfo> lspLocalLabelInfoList = new LinkedList<>();
- ResourceConsumer tunnelConsumerId = TunnelConsumerId.valueOf(10);
-
- // create object of DefaultLspLocalLabelInfo
- DeviceId deviceId = DeviceId.deviceId("foo");
- LabelResourceId inLabelId = LabelResourceId.labelResourceId(1);
- LabelResourceId outLabelId = LabelResourceId.labelResourceId(2);
- PortNumber inPort = PortNumber.portNumber(5122);
- PortNumber outPort = PortNumber.portNumber(5123);
-
- LspLocalLabelInfo lspLocalLabelInfo = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId)
- .inLabelId(inLabelId)
- .outLabelId(outLabelId)
- .inPort(inPort)
- .outPort(outPort)
- .build();
- lspLocalLabelInfoList.add(lspLocalLabelInfo);
-
- PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(lspLocalLabelInfoList, tunnelConsumerId);
-
- assertThat(lspLocalLabelInfoList, is(pceccTunnelInfo.lspLocalLabelInfoList()));
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/util/FlowObjServiceAdapter.java b/apps/pce/app/src/test/java/org/onosproject/pce/util/FlowObjServiceAdapter.java
deleted file mode 100644
index 4d32eb7..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/util/FlowObjServiceAdapter.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2016-present 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.pce.util;
-
-import java.util.List;
-import com.google.common.collect.ImmutableList;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flowobjective.FilteringObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.NextObjective;
-
-/**
- * Test implementation of FlowObjectiveService.
- */
-public class FlowObjServiceAdapter implements FlowObjectiveService {
-
- private ForwardingObjective forwardingObjective;
- @Override
- public void filter(DeviceId deviceId, FilteringObjective filteringObjective) {
-
- }
-
- @Override
- public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
- this.forwardingObjective = forwardingObjective;
- }
-
- @Override
- public void next(DeviceId deviceId, NextObjective nextObjective) {
-
- }
-
- @Override
- public int allocateNextId() {
- return 0;
- }
-
- @Override
- public void initPolicy(String policy) {
-
- }
-
- public ForwardingObjective forwardingObjective() {
- return forwardingObjective;
- }
-
- @Override
- public List<String> getNextMappings() {
- return ImmutableList.of();
- }
-
- @Override
- public List<String> getPendingNexts() {
- return ImmutableList.of();
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java b/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java
index 48120ad..80f62a5 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java
@@ -22,19 +22,14 @@
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
import org.onosproject.net.resource.ResourceConsumer;
-import org.onosproject.pce.pcestore.PceccTunnelInfo;
import org.onosproject.pce.pcestore.PcePathInfo;
-import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
import org.onosproject.pce.pcestore.api.PceStore;
/**
@@ -42,14 +37,8 @@
*/
public class PceStoreAdapter implements PceStore {
- // Mapping device with global node label
- private ConcurrentMap<DeviceId, LabelResourceId> globalNodeLabelMap = new ConcurrentHashMap<>();
-
- // Mapping link with adjacency label
- private ConcurrentMap<Link, LabelResourceId> adjLabelMap = new ConcurrentHashMap<>();
-
// Mapping tunnel with device local info with tunnel consumer id
- private ConcurrentMap<TunnelId, PceccTunnelInfo> tunnelInfoMap = new ConcurrentHashMap<>();
+ private ConcurrentMap<TunnelId, ResourceConsumer> tunnelInfoMap = new ConcurrentHashMap<>();
// Set of Path info
private Set<PcePathInfo> failedPathInfoSet = new HashSet<>();
@@ -58,16 +47,6 @@
private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
@Override
- public boolean existsGlobalNodeLabel(DeviceId id) {
- return globalNodeLabelMap.containsKey(id);
- }
-
- @Override
- public boolean existsAdjLabel(Link link) {
- return adjLabelMap.containsKey(link);
- }
-
- @Override
public boolean existsTunnelInfo(TunnelId tunnelId) {
return tunnelInfoMap.containsKey(tunnelId);
}
@@ -78,16 +57,6 @@
}
@Override
- public int getGlobalNodeLabelCount() {
- return globalNodeLabelMap.size();
- }
-
- @Override
- public int getAdjLabelCount() {
- return adjLabelMap.size();
- }
-
- @Override
public int getTunnelInfoCount() {
return tunnelInfoMap.size();
}
@@ -98,21 +67,9 @@
}
@Override
- public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
- return globalNodeLabelMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> (LabelResourceId) e.getValue()));
- }
-
- @Override
- public Map<Link, LabelResourceId> getAdjLabels() {
- return adjLabelMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> (LabelResourceId) e.getValue()));
- }
-
- @Override
- public Map<TunnelId, PceccTunnelInfo> getTunnelInfos() {
+ public Map<TunnelId, ResourceConsumer> getTunnelInfos() {
return tunnelInfoMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> (PceccTunnelInfo) e.getValue()));
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
}
@Override
@@ -121,33 +78,13 @@
}
@Override
- public LabelResourceId getGlobalNodeLabel(DeviceId id) {
- return globalNodeLabelMap.get(id);
- }
-
- @Override
- public LabelResourceId getAdjLabel(Link link) {
- return adjLabelMap.get(link);
- }
-
- @Override
- public PceccTunnelInfo getTunnelInfo(TunnelId tunnelId) {
+ public ResourceConsumer getTunnelInfo(TunnelId tunnelId) {
return tunnelInfoMap.get(tunnelId);
}
@Override
- public void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId) {
- globalNodeLabelMap.put(deviceId, labelId);
- }
-
- @Override
- public void addAdjLabel(Link link, LabelResourceId labelId) {
- adjLabelMap.put(link, labelId);
- }
-
- @Override
- public void addTunnelInfo(TunnelId tunnelId, PceccTunnelInfo pceccTunnelInfo) {
- tunnelInfoMap.put(tunnelId, pceccTunnelInfo);
+ public void addTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId) {
+ tunnelInfoMap.put(tunnelId, tunnelConsumerId);
}
@Override
@@ -156,48 +93,6 @@
}
@Override
- public boolean updateTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
- if (!tunnelInfoMap.containsKey((tunnelId))) {
- return false;
- }
-
- PceccTunnelInfo labelStoreInfo = tunnelInfoMap.get(tunnelId);
- labelStoreInfo.lspLocalLabelInfoList(lspLocalLabelInfoList);
- tunnelInfoMap.put(tunnelId, labelStoreInfo);
- return true;
- }
-
- @Override
- public boolean updateTunnelInfo(TunnelId tunnelId, ResourceConsumer tunnelConsumerId) {
- if (!tunnelInfoMap.containsKey((tunnelId))) {
- return false;
- }
-
- PceccTunnelInfo tunnelInfo = tunnelInfoMap.get(tunnelId);
- tunnelInfo.tunnelConsumerId(tunnelConsumerId);
- tunnelInfoMap.put(tunnelId, tunnelInfo);
- return true;
- }
-
- @Override
- public boolean removeGlobalNodeLabel(DeviceId id) {
- globalNodeLabelMap.remove(id);
- if (globalNodeLabelMap.containsKey(id)) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeAdjLabel(Link link) {
- adjLabelMap.remove(link);
- if (adjLabelMap.containsKey(link)) {
- return false;
- }
- return true;
- }
-
- @Override
public boolean removeTunnelInfo(TunnelId tunnelId) {
tunnelInfoMap.remove(tunnelId);
if (tunnelInfoMap.containsKey(tunnelId)) {
@@ -213,39 +108,4 @@
}
return true;
}
-
- @Override
- public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
- lsrIdDeviceIdMap.put(lsrId, deviceId);
- return true;
- }
-
- @Override
- public boolean removeLsrIdDevice(String lsrId) {
- lsrIdDeviceIdMap.remove(lsrId);
- return true;
- }
-
- @Override
- public DeviceId getLsrIdDevice(String lsrId) {
- return lsrIdDeviceIdMap.get(lsrId);
- }
-
- @Override
- public boolean addPccLsr(DeviceId lsrId) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean removePccLsr(DeviceId lsrId) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean hasPccLsr(DeviceId lsrId) {
- // TODO Auto-generated method stub
- return false;
- }
}