[ONOS-4743] - DB sync is suspended if PCEP session is formed before BGP devices are learnt
Change-Id: I543201c54883e06182c1c83c4c64dd16a18e096c
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
index 6afdb30..0cda281 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
@@ -19,6 +19,8 @@
import com.google.common.collect.ImmutableSet;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -89,6 +91,13 @@
// List of Failed path info
private DistributedSet<PcePathInfo> failedPathSet;
+ // Locally maintain LSRID to device id mapping for better performance.
+ private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
+
+ // List of PCC LSR ids whose BGP device information was not available to perform
+ // label db sync.
+ private HashSet<DeviceId> pendinglabelDbSyncPccMap = new HashSet();
+
@Activate
protected void activate() {
globalNodeLabelMap = storageService.<DeviceId, LabelResourceId>consistentMapBuilder()
@@ -341,4 +350,50 @@
}
return true;
}
+
+ @Override
+ public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
+ checkNotNull(lsrId);
+ checkNotNull(deviceId);
+
+ lsrIdDeviceIdMap.put(lsrId, deviceId);
+ return true;
+ }
+
+ @Override
+ public boolean removeLsrIdDevice(String lsrId) {
+ checkNotNull(lsrId);
+
+ lsrIdDeviceIdMap.remove(lsrId);
+ return true;
+ }
+
+ @Override
+ public DeviceId getLsrIdDevice(String lsrId) {
+ checkNotNull(lsrId);
+
+ return lsrIdDeviceIdMap.get(lsrId);
+
+ }
+
+ @Override
+ public boolean addPccLsr(DeviceId lsrId) {
+ checkNotNull(lsrId);
+ pendinglabelDbSyncPccMap.add(lsrId);
+ return true;
+ }
+
+ @Override
+ public boolean removePccLsr(DeviceId lsrId) {
+ checkNotNull(lsrId);
+ pendinglabelDbSyncPccMap.remove(lsrId);
+ return true;
+ }
+
+ @Override
+ public boolean hasPccLsr(DeviceId lsrId) {
+ checkNotNull(lsrId);
+ return pendinglabelDbSyncPccMap.contains(lsrId);
+
+ }
}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
index 02ffcf6..3c9ceb7 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
@@ -224,4 +224,54 @@
* @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);
}