Pce Load Balancing
Change-Id: I417e7473db86fa26f7a2dc46122dcacdeb584108
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 eb6fadd..18d291e 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
@@ -16,6 +16,7 @@
package org.onosproject.pce.pcestore;
import com.google.common.collect.ImmutableSet;
+import java.util.Arrays;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -23,6 +24,7 @@
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.pce.pceservice.ExplicitPathInfo;
import org.onosproject.pce.pceservice.LspType;
import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
@@ -57,6 +59,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
+ //Mapping tunnel name with Disjoint paths
+ private ConsistentMap<String, List<TunnelId>> tunnelNameDisjoinTunnelIdInfo;
+
// List of Failed path info
private DistributedSet<PcePathInfo> failedPathSet;
@@ -96,6 +101,15 @@
.build()))
.build();
+ tunnelNameDisjoinTunnelIdInfo = storageService.<String, List<TunnelId>>consistentMapBuilder()
+ .withName("onos-pce-disjointTunnelIds")
+ .withSerializer(Serializer.using(
+ new KryoNamespace.Builder()
+ .register(KryoNamespaces.API)
+ .register(TunnelId.class)
+ .build()))
+ .build();
+
log.info("Started");
}
@@ -157,4 +171,51 @@
return null;
}
+/* @Override
+ public DisjointPath getDisjointPaths(String tunnelName) {
+ if (tunnelNameDisjointPathInfo.get(tunnelName) != null) {
+ return tunnelNameDisjointPathInfo.get(tunnelName).value();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean addDisjointPathInfo(String tunnelName, DisjointPath path) {
+ checkNotNull(tunnelName);
+ checkNotNull(path);
+ return tunnelNameDisjointPathInfo.put(tunnelName, path) != null ? true : false;
+ }*/
+
+ @Override
+ public boolean addLoadBalancingTunnelIdsInfo(String tunnelName, TunnelId... tunnelIds) {
+ checkNotNull(tunnelName);
+ checkNotNull(tunnelIds);
+ return tunnelNameDisjoinTunnelIdInfo.put(tunnelName, Arrays.asList(tunnelIds)) != null ? true : false;
+ }
+
+ @Override
+ public List<TunnelId> getLoadBalancingTunnelIds(String tunnelName) {
+ if (tunnelNameDisjoinTunnelIdInfo.get(tunnelName) != null) {
+ return tunnelNameDisjoinTunnelIdInfo.get(tunnelName).value();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean removeLoadBalancingTunnelIdsInfo(String tunnelName) {
+ if (tunnelNameDisjoinTunnelIdInfo.remove(tunnelName) == null) {
+ log.error("Failed to remove entry {} for this tunnelName in DisjointTunnelIdsInfoMap" + tunnelName);
+ return false;
+ }
+ return true;
+ }
+
+ /* @Override
+ public boolean removeDisjointPathInfo(String tunnelName) {
+ if (tunnelNameDisjointPathInfo.remove(tunnelName) == null) {
+ log.error("Failed to remove entry {} for this tunnelName in DisjointPathInfoMap", tunnelName);
+ return false;
+ }
+ return true;
+ }*/
}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java
index 6497e36..3f38ddd 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java
@@ -43,6 +43,8 @@
private List<ExplicitPathInfo> explicitPathInfo; //Explicit path info to compute explicit path
+ private boolean loadBalancing; //load balancing option
+
/**
* Initialization of member variables.
*
@@ -52,19 +54,22 @@
* @param constraints list of constraints
* @param lspType lsp type
* @param explicitPathInfo explicit path info
+ * @param loadBalancing load balancing option
*/
public PcePathInfo(DeviceId src,
DeviceId dst,
String name,
List<Constraint> constraints,
LspType lspType,
- List<ExplicitPathInfo> explicitPathInfo) {
+ List<ExplicitPathInfo> explicitPathInfo,
+ boolean loadBalancing) {
this.src = src;
this.dst = dst;
this.name = name;
this.constraints = constraints;
this.lspType = lspType;
this.explicitPathInfo = explicitPathInfo;
+ this.loadBalancing = loadBalancing;
}
/**
@@ -77,6 +82,7 @@
this.constraints = null;
this.lspType = null;
this.explicitPathInfo = null;
+ this.loadBalancing = false;
}
/**
@@ -187,9 +193,27 @@
this.explicitPathInfo = explicitPathInfo;
}
+ /**
+ * Returns whether stored path has enabled load balancing.
+ *
+ * @return load balancing option is enable
+ */
+ public boolean isLoadBalancing() {
+ return loadBalancing;
+ }
+
+ /**
+ * Sets load balancing option is enable.
+ *
+ * @param loadBalancing load balancing option is enable
+ */
+ public void loadBalancing(boolean loadBalancing) {
+ this.loadBalancing = loadBalancing;
+ }
+
@Override
public int hashCode() {
- return Objects.hash(src, dst, name, constraints, lspType, explicitPathInfo);
+ return Objects.hash(src, dst, name, constraints, lspType, explicitPathInfo, loadBalancing);
}
@Override
@@ -204,7 +228,8 @@
Objects.equals(this.name, other.name) &&
Objects.equals(this.constraints, other.constraints) &&
Objects.equals(this.lspType, other.lspType) &&
- Objects.equals(this.explicitPathInfo, other.explicitPathInfo);
+ Objects.equals(this.explicitPathInfo, other.explicitPathInfo) &&
+ Objects.equals(this.loadBalancing, other.loadBalancing);
}
return false;
}
@@ -219,6 +244,7 @@
.add("Constraints", constraints)
.add("explicitPathInfo", explicitPathInfo)
.add("LspType", lspType)
+ .add("loadBalancing", loadBalancing)
.toString();
}
}
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 61f7fda..9ca38cb 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.pce.pcestore.api;
+import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.pce.pceservice.ExplicitPathInfo;
import org.onosproject.pce.pcestore.PcePathInfo;
@@ -79,4 +80,35 @@
* @return list of explicit path info
*/
List<ExplicitPathInfo> getTunnelNameExplicitPathInfoMap(String tunnelName);
+
+ //DisjointPath getDisjointPaths(String tunnelName);
+
+ //boolean addDisjointPathInfo(String tunnelName, DisjointPath path);
+
+ /**
+ * Stores load balancing tunnels by load balance path name.
+ *
+ * @param loadBalancingPathName load balancing path name
+ * @param tunnelIds list load balancing tunnels
+ * @return success or failure
+ */
+ boolean addLoadBalancingTunnelIdsInfo(String loadBalancingPathName, TunnelId... tunnelIds);
+
+ /**
+ * Query load balancing tunnels by load balance path name.
+ *
+ * @param loadBalancingPathName load balancing path name
+ * @return list of load balancing tunnels
+ */
+ List<TunnelId> getLoadBalancingTunnelIds(String loadBalancingPathName);
+
+ /**
+ * Removes load balancing tunnel info.
+ *
+ * @param loadBalancingPathName load balancing path name
+ * @return success or failure
+ */
+ boolean removeLoadBalancingTunnelIdsInfo(String loadBalancingPathName);
+
+ //boolean removeDisjointPathInfo(String tunnelName);
}