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