primary to primary check added
diff --git a/src/main/java/org.onosproject.xran/rest/LinkWebResource.java b/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
index e3b2035..8a85941 100644
--- a/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
+++ b/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
@@ -168,13 +168,23 @@
JsonNode type = jsonTree.path("type");
+ RnibLink link = new RnibLink(cell, ue);
+ // store it as non-serving when creating link
+ get(XranStore.class).storeLink(link);
if (!type.isMissingNode()) {
- RnibLink link = new RnibLink(cell, ue);
- link.setType(RnibLink.Type.getEnum(type.asText()));
- get(XranStore.class).storeLink(link);
-
- // TODO: trigger the scell add
+ return handleTypeChange(link, RnibLink.Type.getEnum(type.asText()));
}
+
+ JsonNode trafficpercent = jsonTree.path("trafficpercent");
+ if (!trafficpercent.isMissingNode()) {
+ return handleTrafficChange(link, trafficpercent);
+ }
+
+ JsonNode rrmConf = jsonTree.path("RRMConf");
+ if (!rrmConf.isMissingNode()) {
+ return handleRRMChange(link, rrmConf);
+ }
+
} catch (Exception e) {
log.error(ExceptionUtils.getFullStackTrace(e));
e.printStackTrace();
@@ -192,29 +202,40 @@
final SynchronousQueue<String>[] queue = new SynchronousQueue[1];
if (newType.equals(RnibLink.Type.SERVING_PRIMARY)) {
- List<RnibLink> linksByUeId = get(XranStore.class).getLinksByUeId(link.getLinkId().getMmeues1apid().longValue());
-
- Optional<RnibLink> primary = linksByUeId.stream()
- .filter(l -> l.getType().equals(RnibLink.Type.SERVING_PRIMARY))
- .findFirst();
- if (primary.isPresent()) {
- queue[0] = get(XranController.class).sendHORequest(link, primary.get());
- String poll = queue[0].poll(5, TimeUnit.SECONDS);
-
- if (poll != null) {
- return Response.ok()
- .entity(poll)
- .build();
- } else {
+ switch (link.getType()) {
+ case SERVING_PRIMARY: {
return Response.serverError()
- .entity("did not receive response in time")
+ .entity("link already a primary")
.build();
}
- } else {
- link.setType(RnibLink.Type.SERVING_PRIMARY);
- return Response.ok()
- .entity("there was not another primary link")
- .build();
+ case SERVING_SECONDARY_CA:
+ case SERVING_SECONDARY_DC:
+ case NON_SERVING: {
+ List<RnibLink> linksByUeId = get(XranStore.class).getLinksByUeId(link.getLinkId().getMmeues1apid().longValue());
+
+ Optional<RnibLink> primary = linksByUeId.stream()
+ .filter(l -> l.getType().equals(RnibLink.Type.SERVING_PRIMARY))
+ .findFirst();
+ if (primary.isPresent()) {
+ queue[0] = get(XranController.class).sendHORequest(link, primary.get());
+ String poll = queue[0].poll(5, TimeUnit.SECONDS);
+
+ if (poll != null) {
+ return Response.ok()
+ .entity(poll)
+ .build();
+ } else {
+ return Response.serverError()
+ .entity("did not receive response in time")
+ .build();
+ }
+ } else {
+ link.setType(RnibLink.Type.SERVING_PRIMARY);
+ return Response.ok()
+ .entity("there was not another primary link")
+ .build();
+ }
+ }
}
} else if (newType.equals(RnibLink.Type.NON_SERVING)) {
switch (link.getType()) {