cherry pick [ONOS-4986] [ONOS-4985] Json defect fix to master
Change-Id: Ia9ead1babf3de43e6f492f4f3b6f4d6b9377b042
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java
index 284f776..09a396e 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java
@@ -80,7 +80,8 @@
"constraints: \n" +
" cost : %s \n" +
" bandwidth : %s",
- tunnel.tunnelId().id(), tunnel.src().toString(), tunnel.dst().toString(),
+ tunnel.tunnelId().id(), tunnel.path().src().deviceId().toString(),
+ tunnel.path().dst().deviceId().toString(),
tunnel.type().name(), tunnel.tunnelName(), tunnel.annotations().value(COST_TYPE),
tunnel.annotations().value(AnnotationKeys.BANDWIDTH));
}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java
index 058a17f..97a6913 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java
@@ -47,7 +47,7 @@
@Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost (1) or TE cost (2).",
required = false, multiValued = false)
- int cost = -1;
+ Integer cost = null;
@Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. "
+ "Data rate unit is in Bps.", required = false, multiValued = false)
@@ -66,7 +66,7 @@
}
// Cost validation
- if (cost != -1) {
+ if (cost != null) {
if ((cost < 1) || (cost > 2)) {
error("The cost attribute value is either IGP cost(1) or TE cost(2).");
return;
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java
index 42ee274..f0472aa 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java
@@ -162,13 +162,14 @@
@Override
public String toString() {
return toStringHelper(this)
+ .omitNullValues()
.add("id", id())
.add("source", source)
.add("destination", destination)
.add("lsptype", lspType)
.add("name", name)
- .add("costConstraint", costConstraint.toString())
- .add("bandwidthConstraint", bandwidthConstraint.toString())
+ .add("costConstraint", costConstraint)
+ .add("bandwidthConstraint", bandwidthConstraint)
.toString();
}
@@ -241,8 +242,8 @@
@Override
public Builder of(Tunnel tunnel) {
this.id = TunnelId.valueOf(tunnel.tunnelId().id());
- this.source = tunnel.src().toString();
- this.destination = tunnel.dst().toString();
+ this.source = tunnel.path().src().deviceId().toString();
+ this.destination = tunnel.path().dst().deviceId().toString();
this.name = tunnel.tunnelName().toString();
// LSP type
String lspType = tunnel.annotations().value(PcepAnnotationKeys.LSP_SIG_TYPE);
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
index 4a0b3ac..c622f0e 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
@@ -509,7 +509,7 @@
}
if (existingBwValue != null) {
- if (bwConstraintValue == 0 && bwConstraint != null) {
+ if (bwConstraint == null) {
bwConstraintValue = existingBwValue.bps();
}
//If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation
@@ -526,6 +526,11 @@
constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspSigType)));
if (costConstraint != null) {
constraints.add(costConstraint);
+ } else {
+ //Take cost constraint from old tunnel if it is not specified in update flow
+ costType = tunnel.annotations().value(COST_TYPE);
+ costConstraint = CostConstraint.of(CostConstraint.Type.valueOf(costType));
+ constraints.add(costConstraint);
}
computedPathSet = computePath(links.get(0).src().deviceId(), links.get(links.size() - 1).dst().deviceId(),
@@ -845,6 +850,10 @@
return;
}
+ if (pceStore.getTunnelInfo(tunnel.tunnelId()) == null) {
+ //If bandwidth for old tunnel is not allocated i,e 0 then no need to release
+ return;
+ }
resourceService.release(pceStore.getTunnelInfo(tunnel.tunnelId()).tunnelConsumerId());
return;
@@ -1211,7 +1220,7 @@
localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID)));
}
// If not zero bandwidth, and delegated (initiated LSPs will also be delegated).
- if (Float.parseFloat(tunnel.annotations().value(BANDWIDTH)) != 0
+ if (bwConstraintValue != 0
&& mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) {
releaseBandwidth(tunnel);
}
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 ea5dca0..47f1c46 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
@@ -98,6 +98,17 @@
// List of PCC LSR ids whose BGP device information was not available to perform
// label db sync.
private HashSet<DeviceId> pendinglabelDbSyncPccMap = new HashSet();
+ private static final Serializer SERIALIZER = Serializer
+ .using(new KryoNamespace.Builder().register(KryoNamespaces.API)
+ .register(PcePathInfo.class)
+ .register(CostConstraint.class)
+ .register(CostConstraint.Type.class)
+ .register(BandwidthConstraint.class)
+ .register(SharedBandwidthConstraint.class)
+ .register(CapabilityConstraint.class)
+ .register(CapabilityConstraint.CapabilityType.class)
+ .register(LspType.class)
+ .build());
@Activate
protected void activate() {
@@ -136,19 +147,7 @@
failedPathSet = storageService.<PcePathInfo>setBuilder()
.withName("failed-path-info")
- .withSerializer(Serializer.using(
- new KryoNamespace.Builder()
- .register(KryoNamespaces.API)
- .register(PcePathInfo.class,
- CostConstraint.class,
- CostConstraint.Type.class,
- BandwidthConstraint.class,
- SharedBandwidthConstraint.class,
- CapabilityConstraint.class,
- CapabilityConstraint.CapabilityType.class,
- LspType.class)
- .build()))
-
+ .withSerializer(SERIALIZER)
.build()
.asDistributedSet();