slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.xran.rest; |
| 17 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 18 | import com.fasterxml.jackson.annotation.JsonInclude; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 19 | import com.fasterxml.jackson.databind.JsonNode; |
| 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 21 | import com.google.common.collect.Lists; |
| 22 | import org.apache.commons.lang.exception.ExceptionUtils; |
| 23 | import org.onosproject.rest.AbstractWebResource; |
| 24 | import org.onosproject.xran.XranStore; |
| 25 | import org.onosproject.xran.annotations.Patch; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 26 | import org.onosproject.xran.controller.XranController; |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 27 | import org.onosproject.xran.entities.RnibCell; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 28 | import org.onosproject.xran.entities.RnibLink; |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 29 | import org.onosproject.xran.entities.RnibUe; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 30 | import org.onosproject.xran.codecs.ber.types.BerInteger; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 31 | import org.slf4j.Logger; |
| 32 | import org.slf4j.LoggerFactory; |
| 33 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 34 | import javax.ws.rs.Consumes; |
| 35 | import javax.ws.rs.DefaultValue; |
| 36 | import javax.ws.rs.GET; |
| 37 | import javax.ws.rs.POST; |
| 38 | import javax.ws.rs.Path; |
| 39 | import javax.ws.rs.PathParam; |
| 40 | import javax.ws.rs.Produces; |
| 41 | import javax.ws.rs.QueryParam; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 42 | import javax.ws.rs.core.MediaType; |
| 43 | import javax.ws.rs.core.Response; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 44 | import java.io.InputStream; |
| 45 | import java.util.List; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 46 | import java.util.Optional; |
| 47 | import java.util.concurrent.SynchronousQueue; |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 48 | import java.util.concurrent.TimeUnit; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * Link web resource. |
| 52 | */ |
| 53 | @Path("links") |
| 54 | public class LinkWebResource extends AbstractWebResource { |
| 55 | |
| 56 | private static final Logger log = |
| 57 | LoggerFactory.getLogger(LinkWebResource.class); |
| 58 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 59 | public LinkWebResource() { |
| 60 | |
| 61 | } |
| 62 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 63 | /** |
| 64 | * test. |
| 65 | * |
| 66 | * @param eciHex test |
| 67 | * @param ue test |
| 68 | * @return test |
| 69 | */ |
| 70 | @GET |
| 71 | @Produces(MediaType.APPLICATION_JSON) |
| 72 | public Response getLinksBetween(@DefaultValue("") @QueryParam("cell") String eciHex, |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 73 | @DefaultValue("-1") @QueryParam("ue") long ue) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 74 | List<RnibLink> list = Lists.newArrayList(); |
| 75 | if (!eciHex.isEmpty() && ue != -1) { |
| 76 | RnibLink link = get(XranStore.class).getLinkBetweenCellIdUeId(eciHex, ue); |
| 77 | if (link != null) { |
| 78 | list.add(link); |
| 79 | } |
| 80 | } else if (!eciHex.isEmpty()) { |
| 81 | list.addAll(get(XranStore.class).getLinksByCellId(eciHex)); |
| 82 | } else if (ue != -1) { |
| 83 | list.addAll(get(XranStore.class).getLinksByUeId(ue)); |
| 84 | } else { |
| 85 | list.addAll(get(XranStore.class).getLinks()); |
| 86 | } |
| 87 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 88 | if (list.size() > 0) { |
| 89 | try { |
| 90 | JsonNode jsonNode = mapper().valueToTree(list); |
| 91 | |
| 92 | return ResponseHelper.getResponse( |
| 93 | mapper(), |
| 94 | ResponseHelper.statusCode.OK, |
| 95 | jsonNode |
| 96 | ); |
| 97 | } catch (Exception e) { |
| 98 | String fullStackTrace = ExceptionUtils.getFullStackTrace(e); |
| 99 | log.error(fullStackTrace); |
| 100 | e.printStackTrace(); |
| 101 | |
| 102 | return ResponseHelper.getResponse( |
| 103 | mapper(), |
| 104 | ResponseHelper.statusCode.INTERNAL_SERVER_ERROR, |
| 105 | "Exception", |
| 106 | fullStackTrace |
| 107 | ); |
| 108 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 109 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 110 | |
| 111 | return ResponseHelper.getResponse( |
| 112 | mapper(), |
| 113 | ResponseHelper.statusCode.NOT_FOUND, |
| 114 | "Not Found", |
| 115 | "Specified links not found" |
| 116 | ); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | /** |
| 120 | * test. |
| 121 | * |
| 122 | * @param src test |
| 123 | * @param dst test |
| 124 | * @param stream test |
| 125 | * @return test |
| 126 | */ |
| 127 | @Patch |
| 128 | @Path("{src},{dst}") |
| 129 | @Consumes(MediaType.APPLICATION_JSON) |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 130 | @Produces(MediaType.APPLICATION_JSON) |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 131 | public Response patchLinks(@PathParam("src") String src, @PathParam("dst") long dst, InputStream stream) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 132 | RnibLink link = get(XranStore.class).getLinkBetweenCellIdUeId(src, dst); |
| 133 | if (link != null) { |
| 134 | try { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 135 | ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 136 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 137 | JsonNode type = jsonTree.path("type"); |
| 138 | if (!type.isMissingNode()) { |
| 139 | RnibLink.Type anEnum = RnibLink.Type.getEnum(type.asText()); |
| 140 | return handleTypeChange(link, anEnum); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 141 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 142 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 143 | JsonNode trafficpercent = jsonTree.path("trafficpercent"); |
| 144 | if (!trafficpercent.isMissingNode()) { |
| 145 | return handleTrafficChange(link, trafficpercent); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 146 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 147 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 148 | JsonNode rrmConf = jsonTree.path("RRMConf"); |
| 149 | if (!rrmConf.isMissingNode()) { |
| 150 | return handleRRMChange(link, rrmConf); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 151 | } |
| 152 | |
slowr | d19a83b | 2017-08-17 08:57:46 -0700 | [diff] [blame] | 153 | return ResponseHelper.getResponse( |
| 154 | mapper(), |
| 155 | ResponseHelper.statusCode.NOT_IMPLEMENTED, |
| 156 | "Not Implemented", |
| 157 | "The command you specified is not implemented or doesn't exist. We support " + |
| 158 | "type/RRMConf/traficpercent commands." |
| 159 | ); |
| 160 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 161 | } catch (Exception e) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 162 | String fullStackTrace = ExceptionUtils.getFullStackTrace(e); |
| 163 | log.error(fullStackTrace); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 164 | e.printStackTrace(); |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 165 | |
| 166 | return ResponseHelper.getResponse( |
| 167 | mapper(), |
| 168 | ResponseHelper.statusCode.INTERNAL_SERVER_ERROR, |
| 169 | "Exception", |
| 170 | fullStackTrace |
| 171 | ); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 172 | } |
| 173 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 174 | |
| 175 | return ResponseHelper.getResponse( |
| 176 | mapper(), |
| 177 | ResponseHelper.statusCode.NOT_FOUND, |
| 178 | "Not Found", |
| 179 | "Link not found use POST request" |
| 180 | ); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | /** |
| 184 | * test. |
| 185 | * |
| 186 | * @param src test |
| 187 | * @param dst test |
| 188 | * @param stream test |
| 189 | * @return test |
| 190 | */ |
| 191 | @POST |
| 192 | @Path("{src},{dst}") |
| 193 | @Consumes(MediaType.APPLICATION_JSON) |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 194 | @Produces(MediaType.APPLICATION_JSON) |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 195 | public Response postLinks(@PathParam("src") String src, @PathParam("dst") long dst, InputStream stream) { |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 196 | RnibCell cell = get(XranStore.class).getCell(src); |
| 197 | RnibUe ue = get(XranStore.class).getUe(dst); |
| 198 | |
| 199 | if (cell == null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 200 | return ResponseHelper.getResponse( |
| 201 | mapper(), |
| 202 | ResponseHelper.statusCode.NOT_FOUND, |
| 203 | "Not Found", |
| 204 | "Cell " + src + " was not found" |
| 205 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | if (ue == null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 209 | return ResponseHelper.getResponse( |
| 210 | mapper(), |
| 211 | ResponseHelper.statusCode.NOT_FOUND, |
| 212 | "Not Found", |
| 213 | "Ue with " + dst + " was not found" |
| 214 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | if (get(XranStore.class).getLink(cell.getEcgi(), ue.getMmeS1apId()) != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 218 | return ResponseHelper.getResponse( |
| 219 | mapper(), |
| 220 | ResponseHelper.statusCode.BAD_REQUEST, |
| 221 | "Bad Request", |
| 222 | "Link already exists use PATCH to modify" |
| 223 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 224 | } |
| 225 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 226 | try { |
| 227 | ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); |
| 228 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 229 | JsonNode type = jsonTree.path("type"); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 230 | |
slowr | 077957a | 2017-08-16 11:54:22 -0700 | [diff] [blame] | 231 | RnibLink link = new RnibLink(cell, ue); |
| 232 | // store it as non-serving when creating link |
| 233 | get(XranStore.class).storeLink(link); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 234 | if (!type.isMissingNode()) { |
slowr | 077957a | 2017-08-16 11:54:22 -0700 | [diff] [blame] | 235 | return handleTypeChange(link, RnibLink.Type.getEnum(type.asText())); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 236 | } |
slowr | 077957a | 2017-08-16 11:54:22 -0700 | [diff] [blame] | 237 | |
| 238 | JsonNode trafficpercent = jsonTree.path("trafficpercent"); |
| 239 | if (!trafficpercent.isMissingNode()) { |
| 240 | return handleTrafficChange(link, trafficpercent); |
| 241 | } |
| 242 | |
| 243 | JsonNode rrmConf = jsonTree.path("RRMConf"); |
| 244 | if (!rrmConf.isMissingNode()) { |
| 245 | return handleRRMChange(link, rrmConf); |
| 246 | } |
| 247 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 248 | } catch (Exception e) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 249 | String fullStackTrace = ExceptionUtils.getFullStackTrace(e); |
| 250 | log.error(fullStackTrace); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 251 | e.printStackTrace(); |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 252 | |
| 253 | return ResponseHelper.getResponse( |
| 254 | mapper(), |
| 255 | ResponseHelper.statusCode.INTERNAL_SERVER_ERROR, |
| 256 | "Exception", |
| 257 | fullStackTrace |
| 258 | ); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 259 | } |
| 260 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 261 | return ResponseHelper.getResponse( |
| 262 | mapper(), |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame^] | 263 | ResponseHelper.statusCode.BAD_REQUEST, |
| 264 | "Bad Request", |
slowr | d19a83b | 2017-08-17 08:57:46 -0700 | [diff] [blame] | 265 | "The command you specified is not implemented or doesn't exist. We support " + |
| 266 | "type/RRMConf/traficpercent commands." |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 267 | ); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 268 | } |
| 269 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 270 | private Response handleTypeChange(RnibLink link, RnibLink.Type newType) throws InterruptedException { |
| 271 | final SynchronousQueue<String>[] queue = new SynchronousQueue[1]; |
| 272 | |
| 273 | if (newType.equals(RnibLink.Type.SERVING_PRIMARY)) { |
slowr | 077957a | 2017-08-16 11:54:22 -0700 | [diff] [blame] | 274 | switch (link.getType()) { |
| 275 | case SERVING_PRIMARY: { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 276 | return ResponseHelper.getResponse( |
| 277 | mapper(), |
| 278 | ResponseHelper.statusCode.BAD_REQUEST, |
| 279 | "Bad Request", |
| 280 | "Link is already a primary link" |
| 281 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 282 | } |
slowr | 077957a | 2017-08-16 11:54:22 -0700 | [diff] [blame] | 283 | case SERVING_SECONDARY_CA: |
| 284 | case SERVING_SECONDARY_DC: |
| 285 | case NON_SERVING: { |
| 286 | List<RnibLink> linksByUeId = get(XranStore.class).getLinksByUeId(link.getLinkId().getMmeues1apid().longValue()); |
| 287 | |
| 288 | Optional<RnibLink> primary = linksByUeId.stream() |
| 289 | .filter(l -> l.getType().equals(RnibLink.Type.SERVING_PRIMARY)) |
| 290 | .findFirst(); |
| 291 | if (primary.isPresent()) { |
| 292 | queue[0] = get(XranController.class).sendHORequest(link, primary.get()); |
| 293 | String poll = queue[0].poll(5, TimeUnit.SECONDS); |
| 294 | |
| 295 | if (poll != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 296 | return ResponseHelper.getResponse( |
| 297 | mapper(), |
| 298 | ResponseHelper.statusCode.OK, |
| 299 | "Handoff Response", |
| 300 | poll |
| 301 | ); |
slowr | 077957a | 2017-08-16 11:54:22 -0700 | [diff] [blame] | 302 | } else { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 303 | return ResponseHelper.getResponse( |
| 304 | mapper(), |
| 305 | ResponseHelper.statusCode.REQUEST_TIMEOUT, |
| 306 | "Handoff Timeout", |
| 307 | "eNodeB did not send a HOComplete/HOFailure on time" |
| 308 | ); |
slowr | 077957a | 2017-08-16 11:54:22 -0700 | [diff] [blame] | 309 | } |
| 310 | } else { |
| 311 | link.setType(RnibLink.Type.SERVING_PRIMARY); |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 312 | return ResponseHelper.getResponse( |
| 313 | mapper(), |
| 314 | ResponseHelper.statusCode.OK, |
| 315 | "OK", |
| 316 | "Link set to primary" |
| 317 | ); |
slowr | 077957a | 2017-08-16 11:54:22 -0700 | [diff] [blame] | 318 | } |
| 319 | } |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 320 | } |
| 321 | } else if (newType.equals(RnibLink.Type.NON_SERVING)) { |
| 322 | switch (link.getType()) { |
| 323 | case NON_SERVING: |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 324 | return ResponseHelper.getResponse( |
| 325 | mapper(), |
| 326 | ResponseHelper.statusCode.BAD_REQUEST, |
| 327 | "Bad Request", |
| 328 | "Link is already a primary link" |
| 329 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 330 | case SERVING_PRIMARY: |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 331 | return ResponseHelper.getResponse( |
| 332 | mapper(), |
| 333 | ResponseHelper.statusCode.BAD_REQUEST, |
| 334 | "Bad Request", |
| 335 | "Cannot modify a primary link" |
| 336 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 337 | case SERVING_SECONDARY_CA: |
| 338 | case SERVING_SECONDARY_DC: |
| 339 | if (get(XranController.class).sendScellDelete(link)) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 340 | return ResponseHelper.getResponse( |
| 341 | mapper(), |
| 342 | ResponseHelper.statusCode.OK, |
| 343 | "OK", |
| 344 | "Link set to non-serving" |
| 345 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 346 | } else { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 347 | return ResponseHelper.getResponse( |
| 348 | mapper(), |
| 349 | ResponseHelper.statusCode.NOT_FOUND, |
| 350 | "Not Found", |
| 351 | "Could not find cell config report to construct Scell Delete" |
| 352 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 353 | } |
| 354 | } |
| 355 | } else if (newType.equals(RnibLink.Type.SERVING_SECONDARY_CA)) { |
| 356 | switch (link.getType()) { |
| 357 | case SERVING_PRIMARY: |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 358 | return ResponseHelper.getResponse( |
| 359 | mapper(), |
| 360 | ResponseHelper.statusCode.BAD_REQUEST, |
| 361 | "Bad Request", |
| 362 | "Cannot modify a primary link" |
| 363 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 364 | case SERVING_SECONDARY_DC: |
| 365 | case NON_SERVING: |
| 366 | queue[0] = get(XranController.class).sendScellAdd(link); |
| 367 | String poll = queue[0].poll(5, TimeUnit.SECONDS); |
| 368 | if (poll != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 369 | return ResponseHelper.getResponse( |
| 370 | mapper(), |
| 371 | ResponseHelper.statusCode.OK, |
| 372 | "ScellAdd Response", |
| 373 | poll |
| 374 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 375 | } else { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 376 | return ResponseHelper.getResponse( |
| 377 | mapper(), |
| 378 | ResponseHelper.statusCode.REQUEST_TIMEOUT, |
| 379 | "ScellAdd Timeout", |
| 380 | "eNodeB did not send a ScellAddStatus on time" |
| 381 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 382 | } |
| 383 | case SERVING_SECONDARY_CA: |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 384 | return ResponseHelper.getResponse( |
| 385 | mapper(), |
| 386 | ResponseHelper.statusCode.BAD_REQUEST, |
| 387 | "Bad Request", |
| 388 | "Link is already a secondary CA link" |
| 389 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 393 | return ResponseHelper.getResponse( |
| 394 | mapper(), |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame^] | 395 | ResponseHelper.statusCode.BAD_REQUEST, |
| 396 | "Bad Request", |
| 397 | "The command you specified is not implemented or doesn't exist." |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 398 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | private Response handleTrafficChange(RnibLink link, JsonNode trafficpercent) { |
| 402 | JsonNode jsonNode = trafficpercent.path("traffic-percent-dl"); |
| 403 | if (!jsonNode.isMissingNode()) { |
| 404 | link.getTrafficPercent().setTrafficPercentDl(new BerInteger(jsonNode.asInt())); |
| 405 | } |
| 406 | |
| 407 | jsonNode = trafficpercent.path("traffic-percent-ul"); |
| 408 | if (!jsonNode.isMissingNode()) { |
| 409 | link.getTrafficPercent().setTrafficPercentUl(new BerInteger(jsonNode.asInt())); |
| 410 | } |
| 411 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 412 | return ResponseHelper.getResponse( |
| 413 | mapper(), |
| 414 | ResponseHelper.statusCode.OK, |
| 415 | "OK", |
| 416 | "Traffic Percent changed" |
| 417 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | private Response handleRRMChange(RnibLink link, JsonNode rrmConf) throws InterruptedException { |
| 421 | final SynchronousQueue<String>[] queue = new SynchronousQueue[1]; |
| 422 | get(XranStore.class).modifyLinkRrmConf(link, rrmConf); |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame^] | 423 | boolean isxICIC = link.getLinkId().getCell().getVersion() <= 3; |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 424 | |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame^] | 425 | queue[0] = get(XranController.class).sendModifiedRRMConf(link.getRrmParameters(), |
| 426 | isxICIC); |
| 427 | |
| 428 | if (isxICIC) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 429 | return ResponseHelper.getResponse( |
| 430 | mapper(), |
| 431 | ResponseHelper.statusCode.OK, |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame^] | 432 | "OK", |
| 433 | "xICIC was sent successfully" |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 434 | ); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 435 | } else { |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame^] | 436 | String poll = queue[0].poll(5, TimeUnit.SECONDS); |
| 437 | |
| 438 | if (poll != null) { |
| 439 | return ResponseHelper.getResponse( |
| 440 | mapper(), |
| 441 | ResponseHelper.statusCode.OK, |
| 442 | "RRMConfig Response", |
| 443 | poll |
| 444 | ); |
| 445 | } else { |
| 446 | return ResponseHelper.getResponse( |
| 447 | mapper(), |
| 448 | ResponseHelper.statusCode.REQUEST_TIMEOUT, |
| 449 | "RRMConfig Timeout", |
| 450 | "eNodeB did not send a RRMConfingStatus on time" |
| 451 | ); |
| 452 | } |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 453 | } |
| 454 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 455 | } |