Avantika-Huawei
Committed by Gerrit Code Review

Move PCE label handling from APP to protocol.

Change-Id: I26ae21b27ac2dc9ae3302030f6860e0e371c342c
Showing 60 changed files with 3085 additions and 852 deletions
/*
* 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();
}
}
......@@ -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 @@ import java.util.Map;
*/
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 @@ public interface PceStore {
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 @@ public interface PceStore {
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 @@ public interface PceStore {
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
*/
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
* @return resource consumer
*/
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 @@ public interface PceStore {
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 @@ public interface PceStore {
* @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);
}
......
/*
* 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()));
}
}
......@@ -22,19 +22,14 @@ import java.util.concurrent.ConcurrentMap;
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 @@ import org.onosproject.pce.pcestore.api.PceStore;
*/
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 @@ public class PceStoreAdapter implements PceStore {
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 @@ public class PceStoreAdapter implements PceStore {
}
@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 @@ public class PceStoreAdapter implements PceStore {
}
@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 @@ public class PceStoreAdapter implements PceStore {
}
@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 @@ public class PceStoreAdapter implements PceStore {
}
@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 @@ public class PceStoreAdapter implements PceStore {
}
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;
}
}
......
......@@ -16,8 +16,14 @@
package org.onosproject.pcep.controller;
import java.util.Collection;
import java.util.LinkedList;
import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
import org.onosproject.incubator.net.tunnel.LabelStack;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.net.Path;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.types.PcepValueType;
/**
* Abstraction of an Pcep client controller. Serves as a one stop
......@@ -85,20 +91,6 @@ public interface PcepClientController {
void removeNodeListener(PcepNodeListener listener);
/**
* Register a listener for packet events.
*
* @param listener the listener to notify
*/
void addPacketListener(PcepPacketListener listener);
/**
* Unregister a packet listener.
*
* @param listener the listener to unregister
*/
void removePacketListener(PcepPacketListener listener);
/**
* Send a message to a particular pcc client.
*
* @param pccId the id of the client to send message.
......@@ -118,4 +110,29 @@ public interface PcepClientController {
* Close all connected PCC clients.
*/
void closeConnectedClients();
/**
* Create label stack from the given path.
*
* @param path from which label stack is to be computed
* @return the label stack
*/
public LabelStack computeLabelStack(Path path);
/**
* Allocates and downloads local labels for the given LSP.
*
* @param tunnel for which local labels have to be assigned and downloaded
* @return success or failure
*/
public boolean allocateLocalLabel(Tunnel tunnel);
/**
* Creates label stack for ERO object from network resource.
*
* @param labelStack
* @param path (hop list)
* @return list of ERO sub-objects
*/
public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path);
}
......
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//incubator/api:onos-incubator-api',
'//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
'//protocols/pcep/api:onos-protocols-pcep-api',
'//incubator/api:onos-incubator-api',
'//core/store/serializers:onos-core-serializers',
'//apps/pcep-api:onos-apps-pcep-api',
]
......
......@@ -50,6 +50,11 @@
<groupId>org.onosproject</groupId>
<artifactId>onlab-misc</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-core-serializers</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.pcestore;
package org.onosproject.pcelabelstore;
import com.google.common.base.MoreObjects;
......@@ -21,8 +21,8 @@ import java.util.Objects;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
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.
......@@ -30,13 +30,9 @@ import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
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;
/**
......@@ -152,15 +148,10 @@ public final class DefaultLspLocalLabelInfo implements LspLocalLabelInfo {
* Builder.
*/
public static final class Builder implements LspLocalLabelInfo.Builder {
private DeviceId deviceId;
private LabelResourceId inLabelId;
private LabelResourceId outLabelId;
private PortNumber inPort;
private PortNumber outPort;
/**
......
/*
* 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.pcelabelstore;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
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.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
import org.onosproject.pcelabelstore.api.PceLabelStore;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Manages the pool of available labels to devices, links and tunnels.
*/
@Component(immediate = true)
@Service
public class DistributedPceLabelStore implements PceLabelStore {
private static final String DEVICE_ID_NULL = "Device ID cannot be null";
private static final String LABEL_RESOURCE_ID_NULL = "Label Resource Id cannot be null";
private static final String LINK_NULL = "LINK 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 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 id with local labels.
private ConsistentMap<TunnelId, List<LspLocalLabelInfo>> tunnelLabelInfoMap;
// 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<>();
@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();
tunnelLabelInfoMap = storageService.<TunnelId, List<LspLocalLabelInfo>>consistentMapBuilder()
.withName("onos-pce-tunnellabelinfomap")
.withSerializer(Serializer.using(
new KryoNamespace.Builder()
.register(KryoNamespaces.API)
.register(TunnelId.class,
DefaultLspLocalLabelInfo.class,
LabelResourceId.class,
DeviceId.class)
.build()))
.build();
log.info("Started");
}
@Deactivate
protected void deactivate() {
log.info("Stopped");
}
@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 tunnelLabelInfoMap.containsKey(tunnelId);
}
@Override
public int getGlobalNodeLabelCount() {
return globalNodeLabelMap.size();
}
@Override
public int getAdjLabelCount() {
return adjLabelMap.size();
}
@Override
public int getTunnelInfoCount() {
return tunnelLabelInfoMap.size();
}
@Override
public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
return globalNodeLabelMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
}
@Override
public Map<Link, LabelResourceId> getAdjLabels() {
return adjLabelMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
}
@Override
public Map<TunnelId, List<LspLocalLabelInfo>> getTunnelInfos() {
return tunnelLabelInfoMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
}
@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 List<LspLocalLabelInfo> getTunnelInfo(TunnelId tunnelId) {
checkNotNull(tunnelId, TUNNEL_ID_NULL);
return tunnelLabelInfoMap.get(tunnelId) == null ? null : tunnelLabelInfoMap.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, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
checkNotNull(tunnelId, TUNNEL_ID_NULL);
checkNotNull(lspLocalLabelInfoList, PCECC_TUNNEL_INFO_NULL);
tunnelLabelInfoMap.put(tunnelId, lspLocalLabelInfoList);
}
@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);
if (tunnelLabelInfoMap.remove(tunnelId) == null) {
log.error("Tunnel info deletion for tunnel id {} has failed.", tunnelId.toString());
return false;
}
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);
}
}
package org.onosproject.pcelabelstore;
/**
* Representation of label operation over PCEP.
*/
public enum PcepLabelOp {
/**
* Signifies that the label operation is addition.
*/
ADD,
/**
* Signifies that the label operation is modification. This is reserved for future.
*/
MODIFY,
/**
* Signifies that the label operation is deletion.
*/
REMOVE
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.pcestore.api;
package org.onosproject.pcelabelstore.api;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
......
/*
* 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.pcelabelstore.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 java.util.Map;
/**
* Abstraction of an entity providing pool of available labels to devices, links and tunnels.
*/
public interface PceLabelStore {
/**
* 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
* @return success of failure
*/
boolean existsTunnelInfo(TunnelId tunnelId);
/**
* 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
*/
int getTunnelInfoCount();
/**
* 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
*/
Map<TunnelId, List<LspLocalLabelInfo>> getTunnelInfos();
/**
* 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
*/
List<LspLocalLabelInfo> 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);
/**
* Stores local label info with tunnel consumer id into tunnel info store for specified tunnel id.
*
* @param tunnelId tunnel id
* @param lspLocalLabelInfoList local label info
*/
void addTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList);
/**
* 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
* @return success or failure
*/
boolean removeTunnelInfo(TunnelId tunnelId);
/**
* 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);
}
......@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*Provider that uses PCEP controller as a means to send packets.
* PCE store service API.
*/
package org.onosproject.provider.pcep.packet.impl;
\ No newline at end of file
package org.onosproject.pcelabelstore.api;
......
......@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcep.controller;
public interface PcepPacketListener {
void sendPacketIn(PccId pccId);
}
/**
* PCE store application.
*/
package org.onosproject.pcelabelstore;
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.onosproject.pce.pceservice;
package org.onosproject.pcep.controller.impl;
/**
* Describes about Label type.
......
......@@ -111,13 +111,13 @@ public class PcepControllerImpl implements PcepController {
@Override
public Boolean deleteTunnel(String id) {
// TODO Auto-generated method stub
return null;
return false;
}
@Override
public Boolean updateTunnelBandwidth(String id, long bandwidth) {
// TODO Auto-generated method stub
return null;
return false;
}
@Override
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.pcestore;
package org.onosproject.pcelabelstore;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
......@@ -24,7 +24,7 @@ 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;
import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
/**
* Unit tests for DefaultLspLocalLabelInfo class.
......
......@@ -13,14 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.pceservice;
package org.onosproject.pcelabelstore.label;
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;
......@@ -29,8 +28,6 @@ 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;
......@@ -40,19 +37,24 @@ 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.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.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.pcelabelstore.api.LspLocalLabelInfo;
import org.onosproject.pcelabelstore.api.PceLabelStore;
import org.onosproject.pcelabelstore.util.LabelResourceAdapter;
import org.onosproject.pcelabelstore.util.MockDeviceService;
import org.onosproject.pcelabelstore.util.PceLabelStoreAdapter;
import org.onosproject.pcep.controller.impl.BasicPceccHandler;
import org.onosproject.pcep.controller.impl.PcepClientControllerImpl;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.Link;
......@@ -63,13 +65,13 @@ public class BasicPceccHandlerTest {
public static final long LOCAL_LABEL_SPACE_MIN = 5122;
public static final long LOCAL_LABEL_SPACE_MAX = 9217;
private static final String L3 = "L3";
private static final String LSRID = "lsrId";
private BasicPceccHandler pceccHandler;
protected LabelResourceService labelRsrcService;
protected PceStore pceStore;
private FlowObjectiveService flowObjectiveService;
private CoreService coreService;
private ApplicationId appId;
protected MockDeviceService deviceService;
protected PceLabelStore pceStore;
private TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
private TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
private DefaultGroupId groupId = new DefaultGroupId(92034);
......@@ -78,7 +80,8 @@ public class BasicPceccHandlerTest {
private ProviderId producerName = new ProviderId("producer1", "13");
private Path path;
private Tunnel tunnel;
private PceccTunnelInfo pceccTunnelInfo;
List<LspLocalLabelInfo> lspLocalLabelInfoList;
private Device deviceD1, deviceD2, deviceD3, deviceD4, deviceD5;
private DeviceId deviceId1;
private DeviceId deviceId2;
private DeviceId deviceId3;
......@@ -94,13 +97,14 @@ public class BasicPceccHandlerTest {
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);
pceStore = new PceLabelStoreAdapter();
deviceService = new MockDeviceService();
pceccHandler.initialize(labelRsrcService,
deviceService,
pceStore,
new PcepClientControllerImpl());
// Cretae tunnel test
// Create tunnel test
// Link
ProviderId providerId = new ProviderId("of", "foo");
deviceId1 = DeviceId.deviceId("of:A");
......@@ -115,6 +119,41 @@ public class BasicPceccHandlerTest {
port5 = PortNumber.portNumber(5);
List<Link> linkList = new LinkedList<>();
// Making L3 devices
DefaultAnnotations.Builder builderDev1 = DefaultAnnotations.builder();
builderDev1.set(AnnotationKeys.TYPE, L3);
builderDev1.set(LSRID, "1.1.1.1");
deviceD1 = new MockDevice(deviceId1, builderDev1.build());
deviceService.addDevice(deviceD1);
// Making L3 devices
DefaultAnnotations.Builder builderDev2 = DefaultAnnotations.builder();
builderDev2.set(AnnotationKeys.TYPE, L3);
builderDev2.set(LSRID, "2.2.2.2");
deviceD2 = new MockDevice(deviceId2, builderDev2.build());
deviceService.addDevice(deviceD2);
// Making L3 devices
DefaultAnnotations.Builder builderDev3 = DefaultAnnotations.builder();
builderDev3.set(AnnotationKeys.TYPE, L3);
builderDev3.set(LSRID, "3.3.3.3");
deviceD3 = new MockDevice(deviceId3, builderDev3.build());
deviceService.addDevice(deviceD3);
// Making L3 devices
DefaultAnnotations.Builder builderDev4 = DefaultAnnotations.builder();
builderDev4.set(AnnotationKeys.TYPE, L3);
builderDev4.set(LSRID, "4.4.4.4");
deviceD4 = new MockDevice(deviceId4, builderDev4.build());
deviceService.addDevice(deviceD4);
// Making L3 devices
DefaultAnnotations.Builder builderDev5 = DefaultAnnotations.builder();
builderDev5.set(AnnotationKeys.TYPE, L3);
builderDev5.set(LSRID, "5.5.5.5");
deviceD5 = new MockDevice(deviceId5, builderDev5.build());
deviceService.addDevice(deviceD5);
Link l1 = DefaultLink.builder()
.providerId(providerId)
.annotations(DefaultAnnotations.builder().set("key1", "yahoo").build())
......@@ -163,7 +202,6 @@ public class BasicPceccHandlerTest {
@After
public void tearDown() throws Exception {
PceManagerTest.flowsDownloaded = 0;
}
/**
......@@ -179,7 +217,6 @@ public class BasicPceccHandlerTest {
*/
@Test
public void testAllocateLabel() {
List<LspLocalLabelInfo> lspLocalLabelInfoList;
Iterator<LspLocalLabelInfo> iterator;
LspLocalLabelInfo lspLocalLabelInfo;
DeviceId deviceId;
......@@ -192,8 +229,7 @@ public class BasicPceccHandlerTest {
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();
lspLocalLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
iterator = lspLocalLabelInfoList.iterator();
// Retrieve values and check device5
......@@ -281,7 +317,13 @@ public class BasicPceccHandlerTest {
pceccHandler.releaseLabel(tunnel);
// Retrieve from store. Store should not contain this tunnel info.
pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId());
assertThat(pceccTunnelInfo, is(nullValue()));
lspLocalLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
assertThat(lspLocalLabelInfoList, is(nullValue()));
}
private class MockDevice extends DefaultDevice {
MockDevice(DeviceId id, Annotations annotations) {
super(null, id, null, null, null, null, null, null, annotations);
}
}
}
......
/*
* Copyright 2015-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.pcelabelstore.util;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.DistributedPrimitive;
import org.onosproject.store.service.MapEventListener;
import org.onosproject.store.service.Versioned;
/**
* Testing adapter for the consistent map.
*/
public class ConsistentMapAdapter<K, V> implements ConsistentMap<K, V> {
@Override
public String name() {
return null;
}
@Override
public DistributedPrimitive.Type primitiveType() {
return DistributedPrimitive.Type.CONSISTENT_MAP;
}
@Override
public int size() {
return 0;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean containsKey(K key) {
return false;
}
@Override
public boolean containsValue(V value) {
return false;
}
@Override
public Versioned<V> get(K key) {
return null;
}
@Override
public Versioned<V> computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
return null;
}
@Override
public Versioned<V> compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
return null;
}
@Override
public Versioned<V> computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
return null;
}
@Override
public Versioned<V> computeIf(K key, Predicate<? super V> condition,
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
return null;
}
@Override
public Versioned<V> put(K key, V value) {
return null;
}
@Override
public Versioned<V> putAndGet(K key, V value) {
return null;
}
@Override
public Versioned<V> remove(K key) {
return null;
}
@Override
public void clear() {
}
@Override
public Set<K> keySet() {
return null;
}
@Override
public Collection<Versioned<V>> values() {
return null;
}
@Override
public Set<Map.Entry<K, Versioned<V>>> entrySet() {
return null;
}
@Override
public Versioned<V> putIfAbsent(K key, V value) {
return null;
}
@Override
public boolean remove(K key, V value) {
return false;
}
@Override
public boolean remove(K key, long version) {
return false;
}
@Override
public Versioned replace(K key, V value) {
return null;
}
@Override
public boolean replace(K key, V oldValue, V newValue) {
return false;
}
@Override
public boolean replace(K key, long oldVersion, V newValue) {
return false;
}
@Override
public void addListener(MapEventListener<K, V> listener, Executor executor) {
}
@Override
public void removeListener(MapEventListener<K, V> listener) {
}
@Override
public Map<K, V> asJavaMap() {
return null;
}
}
/*
* 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.pcelabelstore.util;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import org.onosproject.store.service.AsyncDistributedSet;
import org.onosproject.store.service.SetEventListener;
/**
* Testing adapter for the distributed set.
*/
public class DistributedSetAdapter<E> implements AsyncDistributedSet<E> {
@Override
public CompletableFuture<Void> addListener(SetEventListener<E> listener) {
return null;
}
@Override
public CompletableFuture<Void> removeListener(SetEventListener<E> listener) {
return null;
}
@Override
public CompletableFuture<Boolean> add(E element) {
return null;
}
@Override
public CompletableFuture<Boolean> remove(E element) {
return null;
}
@Override
public CompletableFuture<Integer> size() {
return null;
}
@Override
public CompletableFuture<Boolean> isEmpty() {
return null;
}
@Override
public CompletableFuture<Void> clear() {
return null;
}
@Override
public CompletableFuture<Boolean> contains(E element) {
return null;
}
@Override
public CompletableFuture<Boolean> addAll(Collection<? extends E> c) {
return null;
}
@Override
public CompletableFuture<Boolean> containsAll(Collection<? extends E> c) {
return null;
}
@Override
public CompletableFuture<Boolean> retainAll(Collection<? extends E> c) {
return null;
}
@Override
public CompletableFuture<Boolean> removeAll(Collection<? extends E> c) {
return null;
}
@Override
public CompletableFuture<? extends Set<E>> getAsImmutableSet() {
return null;
}
@Override
public String name() {
return null;
}
}
/*
* Copyright 2015-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.pcelabelstore.util;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiFunction;
import org.onosproject.store.service.EventuallyConsistentMap;
import org.onosproject.store.service.EventuallyConsistentMapListener;
/**
* Testing adapter for EventuallyConsistentMap.
*/
public class EventuallyConsistentMapAdapter<K, V> implements EventuallyConsistentMap<K, V> {
@Override
public String name() {
return null;
}
@Override
public Type primitiveType() {
return Type.EVENTUALLY_CONSISTENT_MAP;
}
@Override
public int size() {
return 0;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean containsKey(K key) {
return false;
}
@Override
public boolean containsValue(V value) {
return false;
}
@Override
public V get(K key) {
return null;
}
@Override
public void put(K key, V value) {
}
@Override
public V remove(K key) {
return null;
}
@Override
public void remove(K key, V value) {
}
@Override
public V compute(K key, BiFunction<K, V, V> recomputeFunction) {
return null;
}
@Override
public void putAll(Map<? extends K, ? extends V> m) {
}
@Override
public void clear() {
}
@Override
public Set<K> keySet() {
return null;
}
@Override
public Collection<V> values() {
return null;
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
return null;
}
@Override
public void addListener(EventuallyConsistentMapListener<K, V> listener) {
}
@Override
public void removeListener(EventuallyConsistentMapListener<K, V> listener) {
}
@Override
public CompletableFuture<Void> destroy() {
return CompletableFuture.completedFuture(null);
}
}
/*
* 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.pcelabelstore.util;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Random;
import java.util.Set;
import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
import org.onosproject.incubator.net.resource.label.LabelResource;
import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
import org.onosproject.incubator.net.resource.label.LabelResourceDelegate;
import org.onosproject.incubator.net.resource.label.LabelResourceEvent;
import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.incubator.net.resource.label.LabelResourceListener;
import org.onosproject.incubator.net.resource.label.LabelResourcePool;
import org.onosproject.incubator.net.resource.label.LabelResourceProvider;
import org.onosproject.incubator.net.resource.label.LabelResourceProviderRegistry;
import org.onosproject.incubator.net.resource.label.LabelResourceProviderService;
import org.onosproject.incubator.net.resource.label.LabelResourceService;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceEvent.Type;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.provider.AbstractListenerProviderRegistry;
import org.onosproject.net.provider.AbstractProviderService;
import com.google.common.collect.Multimap;
/**
* Provides test implementation of class LabelResourceService.
*/
public class LabelResourceAdapter
extends AbstractListenerProviderRegistry<LabelResourceEvent, LabelResourceListener,
LabelResourceProvider, LabelResourceProviderService>
implements LabelResourceService, LabelResourceAdminService, LabelResourceProviderRegistry {
public static final long GLOBAL_LABEL_SPACE_MIN = 4097;
public static final long GLOBAL_LABEL_SPACE_MAX = 5121;
public static final long LOCAL_LABEL_SPACE_MIN = 5122;
public static final long LOCAL_LABEL_SPACE_MAX = 9217;
private Random random = new Random();
@Override
public boolean createDevicePool(DeviceId deviceId,
LabelResourceId beginLabel,
LabelResourceId endLabel) {
return true;
}
@Override
public boolean createGlobalPool(LabelResourceId beginLabel,
LabelResourceId endLabel) {
return true;
}
@Override
public boolean destroyDevicePool(DeviceId deviceId) {
return true;
}
@Override
public boolean destroyGlobalPool() {
return true;
}
public long getLabelId(long min, long max) {
return random.nextInt((int) max - (int) min + 1) + (int) min;
}
@Override
public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
long applyNum) {
Collection<LabelResource> labelList = new LinkedList<>();
LabelResource label = new DefaultLabelResource(deviceId,
LabelResourceId.labelResourceId(
getLabelId(LOCAL_LABEL_SPACE_MIN, LOCAL_LABEL_SPACE_MAX)));
labelList.add(label);
return labelList;
}
@Override
public Collection<LabelResource> applyFromGlobalPool(long applyNum) {
Collection<LabelResource> labelList = new LinkedList<>();
LabelResource label = new DefaultLabelResource(DeviceId.deviceId("foo"),
LabelResourceId.labelResourceId(
getLabelId(GLOBAL_LABEL_SPACE_MIN, GLOBAL_LABEL_SPACE_MAX)));
labelList.add(label);
return labelList;
}
@Override
public boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release) {
return true;
}
@Override
public boolean releaseToGlobalPool(Set<LabelResourceId> release) {
return true;
}
@Override
public boolean isDevicePoolFull(DeviceId deviceId) {
return false;
}
@Override
public boolean isGlobalPoolFull() {
return false;
}
@Override
public long getFreeNumOfDevicePool(DeviceId deviceId) {
return 4;
}
@Override
public long getFreeNumOfGlobalPool() {
return 4;
}
@Override
public LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId) {
return null;
}
@Override
public LabelResourcePool getGlobalLabelResourcePool() {
return null;
}
private class InternalLabelResourceDelegate implements LabelResourceDelegate {
@Override
public void notify(LabelResourceEvent event) {
post(event);
}
}
private class InternalDeviceListener implements DeviceListener {
@Override
public void event(DeviceEvent event) {
Device device = event.subject();
if (Type.DEVICE_REMOVED.equals(event.type())) {
destroyDevicePool(device.id());
}
}
}
private class InternalLabelResourceProviderService
extends AbstractProviderService<LabelResourceProvider>
implements LabelResourceProviderService {
protected InternalLabelResourceProviderService(LabelResourceProvider provider) {
super(provider);
}
@Override
public void deviceLabelResourcePoolDetected(DeviceId deviceId,
LabelResourceId beginLabel,
LabelResourceId endLabel) {
checkNotNull(deviceId, "deviceId is not null");
checkNotNull(beginLabel, "beginLabel is not null");
checkNotNull(endLabel, "endLabel is not null");
createDevicePool(deviceId, beginLabel, endLabel);
}
@Override
public void deviceLabelResourcePoolDestroyed(DeviceId deviceId) {
checkNotNull(deviceId, "deviceId is not null");
destroyDevicePool(deviceId);
}
}
@Override
protected LabelResourceProviderService createProviderService(LabelResourceProvider provider) {
return null;
}
}
/*
* 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.pcelabelstore.util;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.device.PortStatistics;
import org.onosproject.net.Device;
import org.onosproject.net.Device.Type;
import org.onosproject.net.DeviceId;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceService;
/**
* Test fixture for the device service.
*/
public class MockDeviceService implements DeviceService {
private List<Device> devices = new LinkedList<>();
private DeviceListener listener;
/**
* Adds a new device.
*
* @param dev device to be added
*/
public void addDevice(Device dev) {
devices.add(dev);
}
/**
* Removes the specified device.
*
* @param dev device to be removed
*/
public void removeDevice(Device dev) {
devices.remove(dev);
}
@Override
public Device getDevice(DeviceId deviceId) {
for (Device dev : devices) {
if (dev.id().equals(deviceId)) {
return dev;
}
}
return null;
}
@Override
public Iterable<Device> getAvailableDevices() {
return devices;
}
@Override
public void addListener(DeviceListener listener) {
this.listener = listener;
}
/**
* Get the listener.
*/
public DeviceListener getListener() {
return listener;
}
@Override
public void removeListener(DeviceListener listener) {
// TODO Auto-generated method stub
}
@Override
public int getDeviceCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Iterable<Device> getDevices() {
// TODO Auto-generated method stub
return null;
}
@Override
public Iterable<Device> getDevices(Type type) {
// TODO Auto-generated method stub
return null;
}
@Override
public Iterable<Device> getAvailableDevices(Type type) {
// TODO Auto-generated method stub
return null;
}
@Override
public MastershipRole getRole(DeviceId deviceId) {
// TODO Auto-generated method stub
return null;
}
@Override
public List<Port> getPorts(DeviceId deviceId) {
// TODO Auto-generated method stub
return null;
}
@Override
public List<PortStatistics> getPortStatistics(DeviceId deviceId) {
// TODO Auto-generated method stub
return null;
}
@Override
public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
// TODO Auto-generated method stub
return null;
}
@Override
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isAvailable(DeviceId deviceId) {
// TODO Auto-generated method stub
return false;
}
}
package org.onosproject.pcelabelstore.util;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.onosproject.net.DeviceId;
import org.onosproject.net.config.Config;
import org.onosproject.net.config.ConfigApplyDelegate;
import org.onosproject.net.config.ConfigFactory;
import org.onosproject.net.config.NetworkConfigListener;
import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.config.SubjectFactory;
import org.onosproject.pcep.api.DeviceCapability;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
/* Mock test for network config registry. */
public class MockNetConfigRegistryAdapter implements NetworkConfigService, NetworkConfigRegistry {
private ConfigFactory cfgFactory;
private Map<DeviceId, DeviceCapability> classConfig = new HashMap<>();
@Override
public void registerConfigFactory(ConfigFactory configFactory) {
cfgFactory = configFactory;
}
@Override
public void unregisterConfigFactory(ConfigFactory configFactory) {
cfgFactory = null;
}
@Override
public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) {
if (configClass == DeviceCapability.class) {
DeviceCapability devCap = new DeviceCapability();
classConfig.put((DeviceId) subject, devCap);
JsonNode node = new ObjectNode(new MockJsonNode());
ObjectMapper mapper = new ObjectMapper();
ConfigApplyDelegate delegate = new InternalApplyDelegate();
devCap.init((DeviceId) subject, null, node, mapper, delegate);
return (C) devCap;
}
return null;
}
@Override
public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) {
classConfig.remove(subject);
}
@Override
public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
if (configClass == DeviceCapability.class) {
return (C) classConfig.get(subject);
}
return null;
}
private class MockJsonNode extends JsonNodeFactory {
}
// Auxiliary delegate to receive notifications about changes applied to
// the network configuration - by the apps.
private class InternalApplyDelegate implements ConfigApplyDelegate {
@Override
public void onApply(Config config) {
//configs.put(config.subject(), config.node());
}
}
@Override
public void addListener(NetworkConfigListener listener) {
// TODO Auto-generated method stub
}
@Override
public void removeListener(NetworkConfigListener listener) {
// TODO Auto-generated method stub
}
@Override
public Set<ConfigFactory> getConfigFactories() {
// TODO Auto-generated method stub
return null;
}
@Override
public <S, C extends Config<S>> Set<ConfigFactory<S, C>> getConfigFactories(Class<S> subjectClass) {
// TODO Auto-generated method stub
return null;
}
@Override
public <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass) {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<Class> getSubjectClasses() {
// TODO Auto-generated method stub
return null;
}
@Override
public SubjectFactory getSubjectFactory(String subjectClassKey) {
// TODO Auto-generated method stub
return null;
}
@Override
public SubjectFactory getSubjectFactory(Class subjectClass) {
// TODO Auto-generated method stub
return null;
}
@Override
public Class<? extends Config> getConfigClass(String subjectClassKey, String configKey) {
// TODO Auto-generated method stub
return null;
}
@Override
public <S> Set<S> getSubjects(Class<S> subjectClass) {
// TODO Auto-generated method stub
return null;
}
@Override
public <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass) {
// TODO Auto-generated method stub
return null;
}
@Override
public <S> Set<? extends Config<S>> getConfigs(S subject) {
// TODO Auto-generated method stub
return null;
}
@Override
public <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass, JsonNode json) {
// TODO Auto-generated method stub
return null;
}
@Override
public <S, C extends Config<S>> C applyConfig(String subjectClassKey, S subject, String configKey, JsonNode json) {
// TODO Auto-generated method stub
return null;
}
@Override
public <S> void removeConfig(String subjectClassKey, S subject, String configKey) {
// TODO Auto-generated method stub
}
@Override
public <S> void removeConfig(S subject) {
// TODO Auto-generated method stub
}
@Override
public <S> void removeConfig() {
// TODO Auto-generated method stub
}
}
package org.onosproject.pcelabelstore.util;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
import org.onosproject.incubator.net.tunnel.LabelStack;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.net.Path;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepClientController;
import org.onosproject.pcep.controller.PcepClientListener;
import org.onosproject.pcep.controller.PcepEventListener;
import org.onosproject.pcep.controller.PcepNodeListener;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.types.PcepValueType;
public class MockPcepClientController implements PcepClientController {
Map<PccId, PcepClient> clientMap = new HashMap<>();
@Override
public Collection<PcepClient> getClients() {
// TODO Auto-generated method stub
return null;
}
public void addClient(PccId pccId, PcepClient pc) {
clientMap.put(pccId, pc);
return;
}
@Override
public PcepClient getClient(PccId pccId) {
return clientMap.get(pccId);
}
@Override
public void addListener(PcepClientListener listener) {
// TODO Auto-generated method stub
}
@Override
public void removeListener(PcepClientListener listener) {
// TODO Auto-generated method stub
}
@Override
public void addEventListener(PcepEventListener listener) {
// TODO Auto-generated method stub
}
@Override
public void removeEventListener(PcepEventListener listener) {
// TODO Auto-generated method stub
}
@Override
public void addNodeListener(PcepNodeListener listener) {
// TODO Auto-generated method stub
}
@Override
public void removeNodeListener(PcepNodeListener listener) {
// TODO Auto-generated method stub
}
@Override
public void writeMessage(PccId pccId, PcepMessage msg) {
// TODO Auto-generated method stub
}
@Override
public void processClientMessage(PccId pccId, PcepMessage msg) {
// TODO Auto-generated method stub
}
@Override
public void closeConnectedClients() {
// TODO Auto-generated method stub
}
@Override
public LabelStack computeLabelStack(Path path) {
// TODO Auto-generated method stub
return null;
}
@Override
public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean allocateLocalLabel(Tunnel tunnel) {
// TODO Auto-generated method stub
return false;
}
}
/*
* 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.pcelabelstore.util;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.pcelabelstore.api.LspLocalLabelInfo;
import org.onosproject.pcelabelstore.api.PceLabelStore;
/**
* Provides test implementation of PceStore.
*/
public class PceLabelStoreAdapter implements PceLabelStore {
// 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, List<LspLocalLabelInfo>> tunnelInfoMap = new ConcurrentHashMap<>();
// Locally maintain LSRID to device id mapping for better performance.
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);
}
@Override
public int getGlobalNodeLabelCount() {
return globalNodeLabelMap.size();
}
@Override
public int getAdjLabelCount() {
return adjLabelMap.size();
}
@Override
public int getTunnelInfoCount() {
return tunnelInfoMap.size();
}
@Override
public boolean removeTunnelInfo(TunnelId tunnelId) {
tunnelInfoMap.remove(tunnelId);
if (tunnelInfoMap.containsKey(tunnelId)) {
return false;
}
return true;
}
@Override
public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
return globalNodeLabelMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
}
@Override
public Map<Link, LabelResourceId> getAdjLabels() {
return adjLabelMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
}
@Override
public LabelResourceId getGlobalNodeLabel(DeviceId id) {
return globalNodeLabelMap.get(id);
}
@Override
public LabelResourceId getAdjLabel(Link link) {
return adjLabelMap.get(link);
}
@Override
public List<LspLocalLabelInfo> 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, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
tunnelInfoMap.put(tunnelId, lspLocalLabelInfoList);
}
@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 addLsrIdDevice(String lsrId, DeviceId deviceId) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean removeLsrIdDevice(String lsrId) {
// TODO Auto-generated method stub
return false;
}
@Override
public DeviceId getLsrIdDevice(String lsrId) {
// TODO Auto-generated method stub
return null;
}
@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;
}
@Override
public Map<TunnelId, List<LspLocalLabelInfo>> getTunnelInfos() {
return tunnelInfoMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
}
}
/*
* 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.pcelabelstore.util;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import org.jboss.netty.channel.Channel;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepSyncStatus;
import org.onosproject.pcepio.protocol.PcepFactories;
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepStateReport;
import org.onosproject.pcepio.protocol.PcepVersion;
/**
* Representation of PCEP client adapter.
*/
public class PcepClientAdapter implements PcepClient {
private Channel channel;
protected String channelId;
private boolean connected;
private PccId pccId;
private ClientCapability capability;
private PcepVersion pcepVersion;
private PcepSyncStatus lspDbSyncStatus;
private PcepSyncStatus labelDbSyncStatus;
private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
/**
* Initialize instance with specified parameters.
*
* @param pccId PCC id
* @param pcepVersion PCEP message version
*/
public void init(PccId pccId, PcepVersion pcepVersion) {
this.pccId = pccId;
this.pcepVersion = pcepVersion;
}
@Override
public final void disconnectClient() {
this.channel.close();
}
@Override
public final void sendMessage(PcepMessage m) {
}
@Override
public final void sendMessage(List<PcepMessage> msgs) {
try {
PcepMessage pcepMsg = msgs.get(0);
assertNotNull("PCEP MSG should be created.", pcepMsg);
} catch (RejectedExecutionException e) {
throw e;
}
}
@Override
public final boolean isConnected() {
return this.connected;
}
@Override
public String channelId() {
return channelId;
}
@Override
public final PccId getPccId() {
return this.pccId;
};
@Override
public final String getStringId() {
return this.pccId.toString();
}
@Override
public final void handleMessage(PcepMessage m) {
}
@Override
public boolean isOptical() {
return false;
}
@Override
public PcepFactory factory() {
return PcepFactories.getFactory(pcepVersion);
}
@Override
public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
this.lspDbSyncStatus = syncStatus;
}
@Override
public PcepSyncStatus lspDbSyncStatus() {
return lspDbSyncStatus;
}
@Override
public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
this.labelDbSyncStatus = syncStatus;
}
@Override
public PcepSyncStatus labelDbSyncStatus() {
return labelDbSyncStatus;
}
@Override
public void setCapability(ClientCapability capability) {
this.capability = capability;
}
@Override
public ClientCapability capability() {
return capability;
}
@Override
public void addNode(PcepClient pc) {
}
@Override
public void deleteNode(PccId pccId) {
}
@Override
public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
lspDelegationInfo.put(lspKey, dFlag);
}
@Override
public Boolean delegationInfo(LspKey lspKey) {
return lspDelegationInfo.get(lspKey);
}
@Override
public void initializeSyncMsgList(PccId pccId) {
// TODO Auto-generated method stub
}
@Override
public List<PcepStateReport> getSyncMsgList(PccId pccId) {
// TODO Auto-generated method stub
return null;
}
@Override
public void removeSyncMsgList(PccId pccId) {
// TODO Auto-generated method stub
}
@Override
public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
// TODO Auto-generated method stub
}
}
/*
* Copyright 2015-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.pcelabelstore.util;
import org.onosproject.store.service.AtomicCounterBuilder;
import org.onosproject.store.service.AtomicValueBuilder;
import org.onosproject.store.service.ConsistentMapBuilder;
import org.onosproject.store.service.ConsistentTreeMapBuilder;
import org.onosproject.store.service.DistributedSetBuilder;
import org.onosproject.store.service.EventuallyConsistentMapBuilder;
import org.onosproject.store.service.LeaderElectorBuilder;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.Topic;
import org.onosproject.store.service.TransactionContextBuilder;
import org.onosproject.store.service.WorkQueue;
/**
* Adapter for the storage service.
*/
public class StorageServiceAdapter implements StorageService {
@Override
public <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder() {
return null;
}
@Override
public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() {
return null;
}
@Override
public <E> DistributedSetBuilder<E> setBuilder() {
return null;
}
@Override
public AtomicCounterBuilder atomicCounterBuilder() {
return null;
}
@Override
public <V> AtomicValueBuilder<V> atomicValueBuilder() {
return null;
}
@Override
public TransactionContextBuilder transactionContextBuilder() {
return null;
}
@Override
public LeaderElectorBuilder leaderElectorBuilder() {
return null;
}
@Override
public <E> WorkQueue<E> getWorkQueue(String name, Serializer serializer) {
return null;
}
@Override
public <T> Topic<T> getTopic(String name, Serializer serializer) {
// TODO Auto-generated method stub
return null;
}
@Override
public <V> ConsistentTreeMapBuilder<V> consistentTreeMapBuilder() {
// TODO Auto-generated method stub
return null;
}
}
/*
* Copyright 2015-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.pcelabelstore.util;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicLong;
import org.onosproject.store.service.AsyncAtomicCounter;
import org.onosproject.store.service.AtomicCounterBuilder;
/**
* Test implementation of atomic counter.
*/
public final class TestAtomicCounter implements AsyncAtomicCounter {
final AtomicLong value;
@Override
public String name() {
return null;
}
private TestAtomicCounter() {
value = new AtomicLong();
}
@Override
public CompletableFuture<Long> incrementAndGet() {
return CompletableFuture.completedFuture(value.incrementAndGet());
}
@Override
public CompletableFuture<Long> getAndIncrement() {
return CompletableFuture.completedFuture(value.getAndIncrement());
}
@Override
public CompletableFuture<Long> getAndAdd(long delta) {
return CompletableFuture.completedFuture(value.getAndAdd(delta));
}
@Override
public CompletableFuture<Long> addAndGet(long delta) {
return CompletableFuture.completedFuture(value.addAndGet(delta));
}
@Override
public CompletableFuture<Void> set(long value) {
this.value.set(value);
return CompletableFuture.completedFuture(null);
}
@Override
public CompletableFuture<Boolean> compareAndSet(long expectedValue, long updateValue) {
return CompletableFuture.completedFuture(value.compareAndSet(expectedValue, updateValue));
}
@Override
public CompletableFuture<Long> get() {
return CompletableFuture.completedFuture(value.get());
}
public static AtomicCounterBuilder builder() {
return new Builder();
}
public static class Builder extends AtomicCounterBuilder {
@Override
public AsyncAtomicCounter build() {
return new TestAtomicCounter();
}
}
}
/*
* Copyright 2015-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.pcelabelstore.util;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.onosproject.store.primitives.ConsistentMapBackedJavaMap;
import org.onosproject.store.service.AsyncConsistentMap;
import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.ConsistentMapBuilder;
import org.onosproject.store.service.MapEvent;
import org.onosproject.store.service.MapEventListener;
import org.onosproject.store.service.Versioned;
import com.google.common.base.Objects;
/**
* Test implementation of the consistent map.
*/
public final class TestConsistentMap<K, V> extends ConsistentMapAdapter<K, V> {
private final List<MapEventListener<K, V>> listeners;
private final Map<K, Versioned<V>> map;
private final String mapName;
private final AtomicLong counter = new AtomicLong(0);
private TestConsistentMap(String mapName) {
map = new HashMap<>();
listeners = new LinkedList<>();
this.mapName = mapName;
}
private Versioned<V> version(V v) {
return new Versioned<>(v, counter.incrementAndGet(), System.currentTimeMillis());
}
/**
* Notify all listeners of an event.
*/
private void notifyListeners(String mapName,
K key, Versioned<V> newvalue, Versioned<V> oldValue) {
MapEvent<K, V> event = new MapEvent<>(mapName, key, newvalue, oldValue);
listeners.forEach(
listener -> listener.event(event)
);
}
@Override
public int size() {
return map.size();
}
@Override
public boolean isEmpty() {
return map.isEmpty();
}
@Override
public boolean containsKey(K key) {
return map.containsKey(key);
}
@Override
public boolean containsValue(V value) {
return map.containsValue(value);
}
@Override
public Versioned<V> get(K key) {
return map.get(key);
}
@Override
public Versioned<V> computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
AtomicBoolean updated = new AtomicBoolean(false);
Versioned<V> result = map.compute(key, (k, v) -> {
if (v == null) {
updated.set(true);
return version(mappingFunction.apply(key));
}
return v;
});
if (updated.get()) {
notifyListeners(mapName, key, result, null);
}
return result;
}
@Override
public Versioned<V> compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
AtomicBoolean updated = new AtomicBoolean(false);
AtomicReference<Versioned<V>> previousValue = new AtomicReference<>();
Versioned<V> result = map.compute(key, (k, v) -> {
updated.set(true);
previousValue.set(v);
return version(remappingFunction.apply(k, Versioned.valueOrNull(v)));
});
if (updated.get()) {
notifyListeners(mapName, key, result, previousValue.get());
}
return result;
}
@Override
public Versioned<V> computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
AtomicBoolean updated = new AtomicBoolean(false);
AtomicReference<Versioned<V>> previousValue = new AtomicReference<>();
Versioned<V> result = map.compute(key, (k, v) -> {
if (v != null) {
updated.set(true);
previousValue.set(v);
return version(remappingFunction.apply(k, v.value()));
}
return v;
});
if (updated.get()) {
notifyListeners(mapName, key, result, previousValue.get());
}
return result;
}
@Override
public Versioned<V> computeIf(K key, Predicate<? super V> condition,
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
AtomicBoolean updated = new AtomicBoolean(false);
AtomicReference<Versioned<V>> previousValue = new AtomicReference<>();
Versioned<V> result = map.compute(key, (k, v) -> {
if (condition.test(Versioned.valueOrNull(v))) {
previousValue.set(v);
updated.set(true);
return version(remappingFunction.apply(k, Versioned.valueOrNull(v)));
}
return v;
});
if (updated.get()) {
notifyListeners(mapName, key, result, previousValue.get());
}
return result;
}
@Override
public Versioned<V> put(K key, V value) {
Versioned<V> newValue = version(value);
Versioned<V> previousValue = map.put(key, newValue);
notifyListeners(mapName, key, newValue, previousValue);
return previousValue;
}
@Override
public Versioned<V> putAndGet(K key, V value) {
Versioned<V> newValue = version(value);
Versioned<V> previousValue = map.put(key, newValue);
notifyListeners(mapName, key, newValue, previousValue);
return newValue;
}
@Override
public Versioned<V> remove(K key) {
Versioned<V> result = map.remove(key);
notifyListeners(mapName, key, null, result);
return result;
}
@Override
public void clear() {
map.keySet().forEach(this::remove);
}
@Override
public Set<K> keySet() {
return map.keySet();
}
@Override
public Collection<Versioned<V>> values() {
return map.values()
.stream()
.collect(Collectors.toList());
}
@Override
public Set<Map.Entry<K, Versioned<V>>> entrySet() {
return map.entrySet();
}
@Override
public Versioned<V> putIfAbsent(K key, V value) {
Versioned<V> newValue = version(value);
Versioned<V> result = map.putIfAbsent(key, newValue);
if (result == null) {
notifyListeners(mapName, key, newValue, result);
}
return result;
}
@Override
public boolean remove(K key, V value) {
Versioned<V> existingValue = map.get(key);
if (Objects.equal(Versioned.valueOrNull(existingValue), value)) {
map.remove(key);
notifyListeners(mapName, key, null, existingValue);
return true;
}
return false;
}
@Override
public boolean remove(K key, long version) {
Versioned<V> existingValue = map.get(key);
if (existingValue == null) {
return false;
}
if (existingValue.version() == version) {
map.remove(key);
notifyListeners(mapName, key, null, existingValue);
return true;
}
return false;
}
@Override
public Versioned<V> replace(K key, V value) {
Versioned<V> existingValue = map.get(key);
if (existingValue == null) {
return null;
}
Versioned<V> newValue = version(value);
Versioned<V> result = map.put(key, newValue);
notifyListeners(mapName, key, newValue, result);
return result;
}
@Override
public boolean replace(K key, V oldValue, V newValue) {
Versioned<V> existingValue = map.get(key);
if (existingValue == null || !existingValue.value().equals(oldValue)) {
return false;
}
Versioned<V> value = version(newValue);
Versioned<V> result = map.put(key, value);
notifyListeners(mapName, key, value, result);
return true;
}
@Override
public boolean replace(K key, long oldVersion, V newValue) {
Versioned<V> existingValue = map.get(key);
if (existingValue == null || existingValue.version() != oldVersion) {
return false;
}
Versioned<V> value = version(newValue);
Versioned<V> result = map.put(key, value);
notifyListeners(mapName, key, value, result);
return true;
}
@Override
public void addListener(MapEventListener<K, V> listener) {
listeners.add(listener);
}
@Override
public void removeListener(MapEventListener<K, V> listener) {
listeners.remove(listener);
}
@Override
public Map<K, V> asJavaMap() {
return new ConsistentMapBackedJavaMap<>(this);
}
public static Builder builder() {
return new Builder();
}
public static class Builder<K, V> extends ConsistentMapBuilder<K, V> {
@Override
public ConsistentMap<K, V> build() {
return new TestConsistentMap<>(name());
}
@Override
public AsyncConsistentMap<K, V> buildAsyncMap() {
return null;
}
}
}
/*
* 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.pcelabelstore.util;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import org.onosproject.store.primitives.DefaultDistributedSet;
import org.onosproject.store.service.AsyncDistributedSet;
import org.onosproject.store.service.DistributedSet;
import org.onosproject.store.service.DistributedSetBuilder;
import org.onosproject.store.service.SetEvent;
import org.onosproject.store.service.SetEventListener;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
/**
* Test implementation of the distributed set.
*/
public final class TestDistributedSet<E> extends DistributedSetAdapter<E> {
private final List<SetEventListener<E>> listeners;
private final Set<E> set;
private final String setName;
/**
* Public constructor.
*
* @param setName name to be assigned to this set
*/
public TestDistributedSet(String setName) {
set = new HashSet<>();
listeners = new LinkedList<>();
this.setName = setName;
}
/**
* Notify all listeners of a set event.
*
* @param event the SetEvent
*/
private void notifyListeners(SetEvent<E> event) {
listeners.forEach(
listener -> listener.event(event)
);
}
@Override
public CompletableFuture<Void> addListener(SetEventListener<E> listener) {
listeners.add(listener);
return CompletableFuture.completedFuture(null);
}
@Override
public CompletableFuture<Void> removeListener(SetEventListener<E> listener) {
listeners.remove(listener);
return CompletableFuture.completedFuture(null);
}
@Override
public CompletableFuture<Boolean> add(E element) {
SetEvent<E> event =
new SetEvent<>(setName, SetEvent.Type.ADD, element);
notifyListeners(event);
return CompletableFuture.completedFuture(set.add(element));
}
@Override
public CompletableFuture<Boolean> remove(E element) {
SetEvent<E> event =
new SetEvent<>(setName, SetEvent.Type.REMOVE, element);
notifyListeners(event);
return CompletableFuture.completedFuture(set.remove(element));
}
@Override
public CompletableFuture<Integer> size() {
return CompletableFuture.completedFuture(set.size());
}
@Override
public CompletableFuture<Boolean> isEmpty() {
return CompletableFuture.completedFuture(set.isEmpty());
}
@Override
public CompletableFuture<Void> clear() {
removeAll(ImmutableSet.copyOf(set));
return CompletableFuture.completedFuture(null);
}
@Override
public CompletableFuture<Boolean> contains(E element) {
return CompletableFuture.completedFuture(set.contains(element));
}
@Override
public CompletableFuture<Boolean> addAll(Collection<? extends E> c) {
c.forEach(this::add);
return CompletableFuture.completedFuture(true);
}
@Override
public CompletableFuture<Boolean> containsAll(Collection<? extends E> c) {
return CompletableFuture.completedFuture(set.containsAll(c));
}
@Override
public CompletableFuture<Boolean> retainAll(Collection<? extends E> c) {
Set notInSet2;
notInSet2 = Sets.difference(set, (Set<?>) c);
return removeAll(ImmutableSet.copyOf(notInSet2));
}
@Override
public CompletableFuture<Boolean> removeAll(Collection<? extends E> c) {
c.forEach(this::remove);
return CompletableFuture.completedFuture(true);
}
@Override
public CompletableFuture<? extends Set<E>> getAsImmutableSet() {
return CompletableFuture.completedFuture(ImmutableSet.copyOf(set));
}
@Override
public String name() {
return this.setName;
}
@Override
public DistributedSet<E> asDistributedSet() {
return new DefaultDistributedSet<>(this, 0);
}
@Override
public DistributedSet<E> asDistributedSet(long timeoutMillis) {
return new DefaultDistributedSet<>(this, timeoutMillis);
}
/**
* Returns a new Builder instance.
*
* @return Builder
**/
public static Builder builder() {
return new Builder();
}
/**
* Builder constructor that instantiates a TestDistributedSet.
*
* @param <E>
*/
public static class Builder<E> extends DistributedSetBuilder<E> {
@Override
public AsyncDistributedSet<E> build() {
return new TestDistributedSet(name());
}
}
}
/*
* Copyright 2015-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.pcelabelstore.util;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import org.onlab.util.KryoNamespace;
import org.onosproject.cluster.NodeId;
import org.onosproject.store.Timestamp;
import org.onosproject.store.service.EventuallyConsistentMap;
import org.onosproject.store.service.EventuallyConsistentMapBuilder;
import org.onosproject.store.service.EventuallyConsistentMapEvent;
import org.onosproject.store.service.EventuallyConsistentMapListener;
import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;
import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE;
/**
* Testing version of an Eventually Consistent Map.
*/
public final class TestEventuallyConsistentMap<K, V> extends EventuallyConsistentMapAdapter<K, V> {
private final HashMap<K, V> map;
private final String mapName;
private final List<EventuallyConsistentMapListener<K, V>> listeners;
private final BiFunction<K, V, Collection<NodeId>> peerUpdateFunction;
private TestEventuallyConsistentMap(String mapName,
BiFunction<K, V, Collection<NodeId>> peerUpdateFunction) {
map = new HashMap<>();
listeners = new LinkedList<>();
this.mapName = mapName;
this.peerUpdateFunction = peerUpdateFunction;
}
/**
* Notify all listeners of an event.
*/
private void notifyListeners(EventuallyConsistentMapEvent<K, V> event) {
listeners.forEach(
listener -> listener.event(event)
);
}
@Override
public int size() {
return map.size();
}
@Override
public boolean isEmpty() {
return map.isEmpty();
}
@Override
public boolean containsKey(K key) {
return map.containsKey(key);
}
@Override
public boolean containsValue(V value) {
return map.containsValue(value);
}
@Override
public V get(K key) {
return map.get(key);
}
@Override
public void put(K key, V value) {
map.put(key, value);
EventuallyConsistentMapEvent<K, V> addEvent =
new EventuallyConsistentMapEvent<>(mapName, PUT, key, value);
notifyListeners(addEvent);
if (peerUpdateFunction != null) {
peerUpdateFunction.apply(key, value);
}
}
@Override
public V remove(K key) {
V result = map.remove(key);
if (result != null) {
EventuallyConsistentMapEvent<K, V> removeEvent =
new EventuallyConsistentMapEvent<>(mapName, REMOVE,
key, map.get(key));
notifyListeners(removeEvent);
}
return result;
}
@Override
public void remove(K key, V value) {
boolean removed = map.remove(key, value);
if (removed) {
EventuallyConsistentMapEvent<K, V> removeEvent =
new EventuallyConsistentMapEvent<>(mapName, REMOVE, key, value);
notifyListeners(removeEvent);
}
}
@Override
public V compute(K key, BiFunction<K, V, V> recomputeFunction) {
return map.compute(key, recomputeFunction);
}
@Override
public void putAll(Map<? extends K, ? extends V> m) {
map.putAll(m);
}
@Override
public void clear() {
map.clear();
}
@Override
public Set<K> keySet() {
return map.keySet();
}
@Override
public Collection<V> values() {
return map.values();
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
return map.entrySet();
}
public static <K, V> Builder<K, V> builder() {
return new Builder<>();
}
@Override
public void addListener(EventuallyConsistentMapListener<K, V> listener) {
listeners.add(listener);
}
@Override
public void removeListener(EventuallyConsistentMapListener<K, V> listener) {
listeners.remove(listener);
}
public static class Builder<K, V> implements EventuallyConsistentMapBuilder<K, V> {
private String name;
private BiFunction<K, V, Collection<NodeId>> peerUpdateFunction;
@Override
public EventuallyConsistentMapBuilder<K, V> withName(String name) {
this.name = name;
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V> withSerializer(KryoNamespace.Builder serializerBuilder) {
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V> withSerializer(KryoNamespace serializer) {
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V>
withTimestampProvider(BiFunction<K, V, Timestamp> timestampProvider) {
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V> withEventExecutor(ExecutorService executor) {
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V> withCommunicationExecutor(ExecutorService executor) {
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V> withBackgroundExecutor(ScheduledExecutorService executor) {
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V>
withPeerUpdateFunction(BiFunction<K, V, Collection<NodeId>> peerUpdateFunction) {
this.peerUpdateFunction = peerUpdateFunction;
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V> withTombstonesDisabled() {
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V> withAntiEntropyPeriod(long period, TimeUnit unit) {
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V> withFasterConvergence() {
return this;
}
@Override
public EventuallyConsistentMapBuilder<K, V> withPersistence() {
return this;
}
@Override
public EventuallyConsistentMap<K, V> build() {
if (name == null) {
name = "test";
}
return new TestEventuallyConsistentMap<>(name, peerUpdateFunction);
}
}
}
/*
* Copyright 2016-present Open Networking Laboratory
* Copyright 2015-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.
......@@ -13,58 +13,45 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.util;
package org.onosproject.pcelabelstore.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;
import org.onosproject.store.service.AtomicCounterBuilder;
import org.onosproject.store.service.AtomicValueBuilder;
import org.onosproject.store.service.ConsistentMapBuilder;
import org.onosproject.store.service.DistributedSetBuilder;
import org.onosproject.store.service.EventuallyConsistentMapBuilder;
import org.onosproject.store.service.TransactionContextBuilder;
/**
* Test implementation of FlowObjectiveService.
*/
public class FlowObjServiceAdapter implements FlowObjectiveService {
private ForwardingObjective forwardingObjective;
@Override
public void filter(DeviceId deviceId, FilteringObjective filteringObjective) {
public class TestStorageService extends StorageServiceAdapter {
}
@Override
public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
this.forwardingObjective = forwardingObjective;
public <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder() {
return TestEventuallyConsistentMap.builder();
}
@Override
public void next(DeviceId deviceId, NextObjective nextObjective) {
public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() {
return TestConsistentMap.builder();
}
@Override
public int allocateNextId() {
return 0;
public <E> DistributedSetBuilder<E> setBuilder() {
return TestDistributedSet.builder();
}
@Override
public void initPolicy(String policy) {
}
public ForwardingObjective forwardingObjective() {
return forwardingObjective;
public AtomicCounterBuilder atomicCounterBuilder() {
return TestAtomicCounter.builder();
}
@Override
public List<String> getNextMappings() {
return ImmutableList.of();
public <V> AtomicValueBuilder<V> atomicValueBuilder() {
throw new UnsupportedOperationException("atomicValueBuilder");
}
@Override
public List<String> getPendingNexts() {
return ImmutableList.of();
public TransactionContextBuilder transactionContextBuilder() {
throw new UnsupportedOperationException("transactionContextBuilder");
}
}
......
......@@ -366,7 +366,6 @@ public class PcepLspObjectVer1 implements PcepLspObject {
default:
// Skip the unknown TLV.
cb.skipBytes(hLength);
tlv = null;
log.info("Received unsupported TLV type :" + hType + " in LSP object.");
}
// Check for the padding
......
......@@ -22,6 +22,15 @@
<artifact>mvn:${project.groupId}/onos-bgpio/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcepio/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pcerest/${project.version}</artifact>
</app>
......
......@@ -21,7 +21,16 @@
<bundle>mvn:${project.groupId}/onos-bgpio/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcepio/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pce/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle>
</feature>
</features>
......
......@@ -46,5 +46,20 @@
<artifactId>onos-bgp-provider-topology</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pce</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pceweb</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pcerest</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
......
......@@ -10,7 +10,6 @@ BUNDLES = [
'//protocols/pcep/ctl:onos-protocols-pcep-ctl',
'//providers/pcep/topology:onos-providers-pcep-topology',
'//providers/pcep/tunnel:onos-providers-pcep-tunnel',
'//providers/pcep/packet:onos-providers-pcep-packet',
'//providers/bgpcep/flow:onos-providers-bgpcep-flow',
'//apps/pce/app:onos-apps-pce-app',
'//apps/pce/pceweb:onos-apps-pce-pceweb',
......
......@@ -30,7 +30,6 @@
<artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
......
......@@ -31,7 +31,6 @@
<bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pce/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle>
</feature>
......
......@@ -5,7 +5,6 @@ BUNDLES = [
'//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
'//protocols/pcep/ctl:onos-protocols-pcep-ctl',
'//apps/pcep-api:onos-apps-pcep-api',
'//providers/pcep/packet:onos-providers-pcep-packet',
]
onos_app (
......
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//protocols/pcep/api:onos-protocols-pcep-api',
]
osgi_jar_with_tests (
deps = COMPILE_DEPS,
)
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-providers</artifactId>
<version>1.7.0-SNAPSHOT</version>
</parent>
<artifactId>onos-pcep-provider-packet</artifactId>
<packaging>bundle</packaging>
<description>PCEP packet provider</description>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-controller-api</artifactId>
</dependency>
</dependencies>
</project>
package org.onosproject.provider.pcep.packet.impl;
import static org.slf4j.LoggerFactory.getLogger;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IPv4;
import org.onlab.packet.MacAddress;
import org.onlab.packet.TCP;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceService;
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.PacketProvider;
import org.onosproject.net.packet.PacketProviderRegistry;
import org.onosproject.net.packet.PacketProviderService;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClientController;
import org.onosproject.pcep.controller.PcepPacketListener;
import org.slf4j.Logger;
/**
* Provider which uses an PCEP controller to process packets.
*/
@Component(immediate = true)
@Service
public class PcepPacketProvider extends AbstractProvider implements PacketProvider {
private static final Logger log = getLogger(PcepPacketProvider.class);
static final String PROVIDER_ID = "org.onosproject.provider.packet.pcep";
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PacketProviderRegistry packetProviderRegistry;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PcepClientController pcepClientController;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
PacketProviderService packetProviderService;
private InnerPacketProvider listener = new InnerPacketProvider();
public static final String LSRID = "lsrId";
public static final int PCEP_PORT = 4189;
/**
* Creates a Packet provider.
*/
public PcepPacketProvider() {
super(new ProviderId("pcep", PROVIDER_ID));
}
@Activate
public void activate() {
packetProviderService = packetProviderRegistry.register(this);
pcepClientController.addPacketListener(listener);
log.info("Started");
}
@Deactivate
public void deactivate() {
packetProviderRegistry.unregister(this);
pcepClientController.removePacketListener(listener);
log.info("Stopped");
}
private class InnerPacketProvider implements PcepPacketListener {
@Override
public void sendPacketIn(PccId pccId) {
TCP tcp = new TCP();
// Set the well known PCEP port. To be used to decide to process/discard the packet while processing.
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.setDestinationMACAddress(MacAddress.NONE);
eth.setPayload(ipv4);
// Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
String lsrId = String.valueOf(pccId.ipAddress());
DeviceId pccDeviceId = DeviceId.deviceId(lsrId);
InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId,
PortNumber.portNumber(PCEP_PORT)),
eth, null);
packetProviderService.processPacket(new PcepPacketContext(inPkt, null));
}
}
// Minimal PacketContext to make core and applications happy.
private final class PcepPacketContext extends DefaultPacketContext {
private PcepPacketContext(InboundPacket inPkt, OutboundPacket outPkt) {
super(System.currentTimeMillis(), inPkt, outPkt, false);
}
@Override
public void send() {
// We don't send anything out.
}
}
@Override
public void emit(OutboundPacket packet) {
// Nothing to emit
}
}
......@@ -27,6 +27,5 @@
<module>topology</module>
<module>tunnel</module>
<module>app</module>
<module>packet</module>
</modules>
</project>
\ No newline at end of file
......
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//incubator/api:onos-incubator-api',
'//protocols/ovsdb/api:onos-protocols-ovsdb-api',
'//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
'//apps/pcep-api:onos-apps-pcep-api',
......
......@@ -25,6 +25,10 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.onlab.packet.IpAddress;
import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
import org.onosproject.incubator.net.tunnel.LabelStack;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.net.Path;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
......@@ -32,7 +36,6 @@ import org.onosproject.pcep.controller.PcepClientController;
import org.onosproject.pcep.controller.PcepClientListener;
import org.onosproject.pcep.controller.PcepEventListener;
import org.onosproject.pcep.controller.PcepNodeListener;
import org.onosproject.pcep.controller.PcepPacketListener;
import org.onosproject.pcep.controller.driver.PcepAgent;
import org.onosproject.pcepio.protocol.PcepError;
import org.onosproject.pcepio.protocol.PcepErrorInfo;
......@@ -41,6 +44,7 @@ import org.onosproject.pcepio.protocol.PcepErrorObject;
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.onosproject.pcepio.types.PcepValueType;
import com.google.common.collect.Sets;
......@@ -290,14 +294,20 @@ public class PcepClientControllerAdapter implements PcepClientController {
}
@Override
public void addPacketListener(PcepPacketListener listener) {
public LabelStack computeLabelStack(Path path) {
// TODO Auto-generated method stub
return null;
}
@Override
public void removePacketListener(PcepPacketListener listener) {
public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean allocateLocalLabel(Tunnel tunnel) {
// TODO Auto-generated method stub
return false;
}
}
......
......@@ -24,13 +24,16 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
import org.onosproject.incubator.net.tunnel.LabelStack;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.net.Path;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepClientController;
import org.onosproject.pcep.controller.PcepClientListener;
import org.onosproject.pcep.controller.PcepEventListener;
import org.onosproject.pcep.controller.PcepNodeListener;
import org.onosproject.pcep.controller.PcepPacketListener;
import org.onosproject.pcep.controller.driver.PcepAgent;
import org.onosproject.pcepio.protocol.PcepError;
import org.onosproject.pcepio.protocol.PcepErrorInfo;
......@@ -39,6 +42,7 @@ import org.onosproject.pcepio.protocol.PcepErrorObject;
import org.onosproject.pcepio.protocol.PcepFactory;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.onosproject.pcepio.types.PcepValueType;
import com.google.common.collect.Sets;
......@@ -58,7 +62,6 @@ public class PcepClientControllerAdapter implements PcepClientController {
protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
protected Set<PcepPacketListener> pcepPacketListener = Sets.newHashSet();
@Activate
public void activate() {
......@@ -118,16 +121,6 @@ public class PcepClientControllerAdapter implements PcepClientController {
}
@Override
public void addPacketListener(PcepPacketListener listener) {
pcepPacketListener.add(listener);
}
@Override
public void removePacketListener(PcepPacketListener listener) {
pcepPacketListener.remove(listener);
}
@Override
public void writeMessage(PccId pccId, PcepMessage msg) {
this.getClient(pccId).sendMessage(msg);
}
......@@ -292,4 +285,22 @@ public class PcepClientControllerAdapter implements PcepClientController {
return false;
}
}
@Override
public LabelStack computeLabelStack(Path path) {
// TODO Auto-generated method stub
return null;
}
@Override
public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean allocateLocalLabel(Tunnel tunnel) {
// TODO Auto-generated method stub
return false;
}
}
......