Avantika-Huawei
Committed by Gerrit Code Review

[ONOS-4170] PCEP provider changes for LSPDB sync

Change-Id: I9229fec9d97dd46343cc809e33c92b9722ab7ed3
......@@ -95,18 +95,32 @@ public interface PcepClient {
String channelId();
/**
* To set the status of state synchronization.
* Sets the status of LSP state synchronization.
*
* @param value to set the synchronization status
* @param syncStatus LSP synchronization status to be set
*/
void setIsSyncComplete(boolean value);
void setLspDbSyncStatus(PcepSyncStatus syncStatus);
/**
* Indicates the state synchronization status of this pcc.
* Indicates the LSP state synchronization status of this pcc.
*
* @return true/false if the synchronization is completed/not completed
* @return LSP state synchronization status.
*/
boolean isSyncComplete();
PcepSyncStatus lspDbSyncStatus();
/**
* Sets the status of label DB synchronization.
*
* @param syncStatus label DB synchronization status to be set
*/
void setLabelDbSyncStatus(PcepSyncStatus syncStatus);
/**
* Indicates the label DB synchronization status of this pcc.
*
* @return label DB synchronization status.
*/
PcepSyncStatus labelDbSyncStatus();
/**
* Sets capability negotiated during open message exchange.
......
/*
* 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.pcep.controller;
/**
* Representation of PCEP database sync status on session establishment.
*/
public enum PcepSyncStatus {
/**
* Specifies that the DB state is not synchronized.
*/
NOT_SYNCED(0),
/**
* Specifies that the DB state is currently undergoing synchronization.
*/
IN_SYNC(1),
/**
* Specifies that the DB state synchronization is completed.
*/
SYNCED(2);
int value;
/**
* Assign val with the value as the sync status.
*
* @param val sync status
*/
PcepSyncStatus(int val) {
value = val;
}
}
......@@ -169,6 +169,12 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
}
}
/*
* If MPLS LSR id and PCEP session socket IP addresses are not same,
* the MPLS LSR id will be encoded in separate TLV.
* We always maintain session information based on LSR ids.
* The socket IP is stored in channel.
*/
LinkedList<PcepValueType> optionalTlvs = pOpenmsg.getPcepOpenObject().getOptionalTlv();
for (PcepValueType optionalTlv : optionalTlvs) {
if (optionalTlv instanceof NodeAttributesTlv) {
......
......@@ -27,6 +27,7 @@ import org.onlab.packet.IpAddress;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepPacketStats;
import org.onosproject.pcep.controller.PcepSyncStatus;
import org.onosproject.pcep.controller.driver.PcepAgent;
import org.onosproject.pcep.controller.driver.PcepClientDriver;
import org.onosproject.pcepio.protocol.PcepFactories;
......@@ -52,9 +53,10 @@ public class PcepClientImpl implements PcepClientDriver {
protected String channelId;
private boolean connected;
protected boolean startDriverHandshakeCalled = false;
protected boolean isHandShakeComplete = false;
protected boolean isSyncComplete = false;
protected boolean startDriverHandshakeCalled;
protected boolean isHandShakeComplete;
private PcepSyncStatus lspDbSyncStatus;
private PcepSyncStatus labelDbSyncStatus;
private PccId pccId;
private PcepAgent agent;
......@@ -175,13 +177,23 @@ public class PcepClientImpl implements PcepClientDriver {
}
@Override
public void setIsSyncComplete(boolean value) {
this.isSyncComplete = value;
public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
this.lspDbSyncStatus = syncStatus;
}
@Override
public boolean isSyncComplete() {
return isSyncComplete;
public PcepSyncStatus lspDbSyncStatus() {
return lspDbSyncStatus;
}
@Override
public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
this.labelDbSyncStatus = syncStatus;
}
@Override
public PcepSyncStatus labelDbSyncStatus() {
return labelDbSyncStatus;
}
@Override
......
......@@ -48,7 +48,7 @@ public class PcepLspObjectVer1 implements PcepLspObject {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Object-Class | OT |Res|P|I| Object Length (bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| PLSP-ID | Flag C| O|A|R|S|D|
| PLSP-ID | Flag |C| O|A|R|S|D|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// TLVs //
| |
......@@ -116,6 +116,7 @@ public class PcepLspObjectVer1 implements PcepLspObject {
* @param bRFlag R flag
* @param bSFlag S flag
* @param bDFlag D flag
* @param bCFlag C flag
* @param llOptionalTlv list of optional tlv
*/
public PcepLspObjectVer1(PcepObjectHeader lspObjHeader, int iPlspId, byte yOFlag, boolean bAFlag, boolean bRFlag,
......@@ -294,6 +295,9 @@ public class PcepLspObjectVer1 implements PcepLspObject {
}
int iTemp = iPlspId << PLSPID_SHIFT_VALUE;
iTemp = iTemp | (((bCFlag) ? BIT_SET : BIT_RESET) << CFLAG_SHIFT_VALUE);
iTemp = iTemp | (yOFlag << OFLAG_SHIFT_VALUE);
byte bFlag;
iTemp = bAFlag ? (iTemp | AFLAG_TEMP_SHIFT_VALUE) : iTemp;
......
......@@ -51,4 +51,9 @@ public final class PcepAnnotationKeys {
* Annotation key for the LSP id assigned per tunnel.
*/
public static final String LOCAL_LSP_ID = "localLspId";
/**
* Annotation key for the identification of initiated LSP.
*/
public static final String PCE_INIT = "pceInit";
}
......
......@@ -18,7 +18,6 @@ package org.onosproject.provider.pcep.tunnel.impl;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.collections.map.MultiKeyMap;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.tunnel.TunnelProviderService;
import org.slf4j.Logger;
......@@ -40,8 +39,6 @@ public class PcepTunnelApiMapper {
private Map<Integer, PcepTunnelData> tunnelDB;
// Map to store the tunnel ids, given by core and given by pcc.
private Map<TunnelId, Integer> tunnelIdMap;
//Map to store all the learnt tunnels.
private MultiKeyMap pccTunnelDB = new MultiKeyMap();
TunnelProviderService tunnelApiMapperservice;
......@@ -193,14 +190,4 @@ public class PcepTunnelApiMapper {
boolean retValue = tunnelDB.containsKey((new Integer(value)));
return retValue;
}
/**
* Add Learnt tunnels to pcc tunnel DB.
*
* @param pcepTunnelData pcep tunnel data
*/
public void addPccTunnelDB(PcepTunnelData pcepTunnelData) {
pccTunnelDB.put(pcepTunnelData.statefulIpv4IndentifierTlv().getTunnelId() & 0xFFFFL,
pcepTunnelData.statefulIpv4IndentifierTlv().getIpv4IngressAddress(), pcepTunnelData);
}
}
......
......@@ -24,6 +24,7 @@ import org.jboss.netty.channel.Channel;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
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;
......@@ -42,7 +43,8 @@ public class PcepClientAdapter implements PcepClient {
private ClientCapability capability;
private PcepVersion pcepVersion;
private boolean syncCompleted;
private PcepSyncStatus lspDbSyncStatus;
private PcepSyncStatus labelDbSyncStatus;
/**
* Initialize instance with specified parameters.
......@@ -109,13 +111,23 @@ public class PcepClientAdapter implements PcepClient {
}
@Override
public final boolean isSyncComplete() {
return syncCompleted;
public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
this.lspDbSyncStatus = syncStatus;
}
@Override
public final void setIsSyncComplete(boolean value) {
syncCompleted = value;
public PcepSyncStatus lspDbSyncStatus() {
return lspDbSyncStatus;
}
@Override
public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
this.labelDbSyncStatus = syncStatus;
}
@Override
public PcepSyncStatus labelDbSyncStatus() {
return labelDbSyncStatus;
}
@Override
......