slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | ///* |
| 2 | // * Copyright 2015-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 | // |
| 17 | //package org.onosproject.xran.impl; |
| 18 | // |
| 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.lang3.tuple.ImmutablePair; |
| 23 | //import org.apache.felix.scr.annotations.Activate; |
| 24 | //import org.apache.felix.scr.annotations.Deactivate; |
| 25 | //import org.apache.felix.scr.annotations.Reference; |
| 26 | //import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 27 | //import org.onlab.util.KryoNamespace; |
| 28 | //import org.onosproject.core.ApplicationId; |
| 29 | //import org.onosproject.core.CoreService; |
| 30 | //import org.onosproject.core.IdGenerator; |
| 31 | //import org.onosproject.store.AbstractStore; |
| 32 | //import org.onosproject.store.serializers.KryoNamespaces; |
| 33 | //import org.onosproject.store.service.ConsistentMap; |
| 34 | //import org.onosproject.store.service.Serializer; |
| 35 | //import org.onosproject.store.service.StorageService; |
| 36 | //import org.onosproject.store.service.Versioned; |
| 37 | //import org.onosproject.xran.XranStore; |
| 38 | //import org.onosproject.xran.codecs.api.ECGI; |
| 39 | //import org.onosproject.xran.codecs.api.ENBUES1APID; |
| 40 | //import org.onosproject.xran.codecs.api.MMEUES1APID; |
| 41 | //import org.onosproject.xran.codecs.pdu.CellConfigReport; |
| 42 | //import org.onosproject.xran.controller.XranController; |
| 43 | //import org.onosproject.xran.entities.RnibCell; |
| 44 | //import org.onosproject.xran.entities.RnibLink; |
| 45 | //import org.onosproject.xran.entities.RnibSlice; |
| 46 | //import org.onosproject.xran.entities.RnibUe; |
| 47 | //import org.onosproject.xran.identifiers.CellId; |
| 48 | //import org.onosproject.xran.identifiers.LinkId; |
| 49 | //import org.onosproject.xran.identifiers.SliceId; |
| 50 | //import org.onosproject.xran.identifiers.UeId; |
| 51 | //import org.slf4j.Logger; |
| 52 | // |
| 53 | //import java.util.List; |
| 54 | // |
| 55 | //import static org.slf4j.LoggerFactory.getLogger; |
| 56 | // |
| 57 | ///** |
| 58 | // * Created by dimitris on 7/22/17. |
| 59 | // */ |
| 60 | ////@Component(immediate = true) |
| 61 | ////@Service |
| 62 | //public class DistributedXranStore extends AbstractStore implements XranStore { |
| 63 | // private static final String XRAN_APP_ID = "org.onosproject.xran"; |
| 64 | // |
| 65 | // private final Logger log = getLogger(getClass()); |
| 66 | // |
| 67 | // private ConsistentMap<LinkId, RnibLink> linkMap; |
| 68 | // private ConsistentMap<CellId, RnibCell> cellMap; |
| 69 | // private ConsistentMap<UeId, RnibUe> ueMap; |
| 70 | // private ConsistentMap<SliceId, RnibSlice> sliceMap; |
| 71 | // |
| 72 | // @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 73 | // protected StorageService storageService; |
| 74 | // |
| 75 | // @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 76 | // protected CoreService coreService; |
| 77 | // |
| 78 | // private IdGenerator cellIdGenerator; |
| 79 | // private IdGenerator ueIdGenerator; |
| 80 | // private IdGenerator linkIdGenerator; |
| 81 | // private IdGenerator sliceIdGenerator; |
| 82 | // |
| 83 | // private XranController controller; |
| 84 | // |
| 85 | // private final String XRAN_CELL_ID = "xran-cell-ids"; |
| 86 | // private final String XRAN_UE_ID = "xran-eu-ids"; |
| 87 | // private final String XRAN_LINK_ID = "xran-link-ids"; |
| 88 | // private final String XRAN_SLICE_ID = "xran-slice-ids"; |
| 89 | // |
| 90 | // @Activate |
| 91 | // public void activate() { |
| 92 | // ApplicationId appId = coreService.getAppId(XRAN_APP_ID); |
| 93 | // |
| 94 | // cellIdGenerator = coreService.getIdGenerator(XRAN_CELL_ID); |
| 95 | // ueIdGenerator = coreService.getIdGenerator(XRAN_UE_ID); |
| 96 | // linkIdGenerator = coreService.getIdGenerator(XRAN_LINK_ID); |
| 97 | // sliceIdGenerator = coreService.getIdGenerator(XRAN_SLICE_ID); |
| 98 | // |
| 99 | // KryoNamespace.Builder serializer = KryoNamespace.newBuilder() |
| 100 | // .register(KryoNamespaces.API) |
| 101 | // .register(RnibCell.class) |
| 102 | // .register(RnibSlice.class) |
| 103 | // .register(RnibUe.class) |
| 104 | // .register(RnibLink.class) |
| 105 | // .register(LinkId.class) |
| 106 | // .register(CellId.class) |
| 107 | // .register(UeId.class) |
| 108 | // .register(SliceId.class) |
| 109 | // .register(ImmutablePair.class) |
| 110 | // .register(ENBUES1APID.class) |
| 111 | // .register(MMEUES1APID.class) |
| 112 | // .register(CellConfigReport.class) |
| 113 | // .register(ECGI.class); |
| 114 | // |
| 115 | // linkMap = storageService.<LinkId, RnibLink>consistentMapBuilder() |
| 116 | // .withSerializer(Serializer.using(serializer.build())) |
| 117 | // .withName("xran-link-map") |
| 118 | // .withApplicationId(appId) |
| 119 | // .withPurgeOnUninstall() |
| 120 | // .build(); |
| 121 | // |
| 122 | // cellMap = storageService.<CellId, RnibCell>consistentMapBuilder() |
| 123 | // .withSerializer(Serializer.using(serializer.build())) |
| 124 | // .withName("xran-cell-map") |
| 125 | // .withApplicationId(appId) |
| 126 | // .withPurgeOnUninstall() |
| 127 | // .build(); |
| 128 | // |
| 129 | // ueMap = storageService.<UeId, RnibUe>consistentMapBuilder() |
| 130 | // .withSerializer(Serializer.using(serializer.build())) |
| 131 | // .withName("xran-ue-map") |
| 132 | // .withApplicationId(appId) |
| 133 | // .withPurgeOnUninstall() |
| 134 | // .build(); |
| 135 | // |
| 136 | // sliceMap = storageService.<SliceId, RnibSlice>consistentMapBuilder() |
| 137 | // .withSerializer(Serializer.using(serializer.build())) |
| 138 | // .withName("xran-slice-map") |
| 139 | // .withApplicationId(appId) |
| 140 | // .withPurgeOnUninstall() |
| 141 | // .build(); |
| 142 | // |
| 143 | // log.info("XRAN Distributed Store Started"); |
| 144 | // } |
| 145 | // |
| 146 | // @Deactivate |
| 147 | // public void deactive() { |
| 148 | // log.info("XRAN Distributed Store Stopped"); |
| 149 | // } |
| 150 | // |
| 151 | // @Override |
| 152 | // public List<RnibLink> getLinksByCellId(long cellId) { |
| 153 | // List<RnibLink> list = Lists.newArrayList(); |
| 154 | // CellId cell = CellId.valueOf(cellId); |
| 155 | // linkMap.keySet().forEach( |
| 156 | // pair -> { |
| 157 | // if (pair.equals(cell)) { |
| 158 | // list.add(linkMap.get(pair).value()); |
| 159 | // } |
| 160 | // } |
| 161 | // ); |
| 162 | // return list; |
| 163 | // } |
| 164 | // |
| 165 | // @Override |
| 166 | // public List<RnibLink> getLinksByUeId(long euId) { |
| 167 | // List<RnibLink> list = Lists.newArrayList(); |
| 168 | // UeId ue = UeId.valueOf(euId); |
| 169 | // linkMap.keySet().forEach( |
| 170 | // pair -> { |
| 171 | // if (pair.equals(ue)) { |
| 172 | // list.add(linkMap.get(pair).value()); |
| 173 | // } |
| 174 | // } |
| 175 | // ); |
| 176 | // return list; |
| 177 | // } |
| 178 | // |
| 179 | // @Override |
| 180 | // public RnibLink getLinkBetweenCellIdUeId(long cellId, long euId) { |
| 181 | // LinkId linkId = LinkId.valueOf(cellId, euId); |
| 182 | // final Versioned<RnibLink> rnibLinkVersioned = linkMap.get(linkId); |
| 183 | // if (rnibLinkVersioned != null) { |
| 184 | // return rnibLinkVersioned.value(); |
| 185 | // } |
| 186 | // return null; |
| 187 | // } |
| 188 | // |
| 189 | // @Override |
| 190 | // public boolean modifyTypeOfLink(long cellId, long euId, String type) { |
| 191 | // final RnibLink link = getLinkBetweenCellIdUeId(cellId, euId); |
| 192 | // if (link != null) { |
| 193 | // link.setType(type); |
| 194 | // return true; |
| 195 | // } |
| 196 | // return false; |
| 197 | // } |
| 198 | // |
| 199 | // @Override |
| 200 | // public boolean modifyTrafficPercentOfLink(long cellId, long euId, long trafficPercent) { |
| 201 | // final RnibLink link = getLinkBetweenCellIdUeId(cellId, euId); |
| 202 | // if (link != null) { |
| 203 | // link.setTrafficPercent(trafficPercent); |
| 204 | // return true; |
| 205 | // } |
| 206 | // return false; |
| 207 | // } |
| 208 | // |
| 209 | // @Override |
| 210 | // public boolean createLinkBetweenCellIdUeId(long cellId, long euId, String type) { |
| 211 | // LinkId linkId = LinkId.valueOf(cellId, euId); |
| 212 | // if (linkMap.containsKey(linkId)) { |
| 213 | // return false; |
| 214 | // } |
| 215 | // RnibLink link = new RnibLink(linkId); |
| 216 | // link.setType(type); |
| 217 | // linkMap.putPrimaryLink(linkId, link); |
| 218 | // return true; |
| 219 | // } |
| 220 | // |
| 221 | // @Override |
| 222 | // public boolean deleteLink(long linkId) { |
| 223 | // return false; |
| 224 | // } |
| 225 | // |
| 226 | // @Override |
| 227 | // public List<Object> getNodes() { |
| 228 | // List<Object> list = Lists.newArrayList(); |
| 229 | // cellMap.values().forEach(v -> list.add(v.value())); |
| 230 | // ueMap.values().forEach(v -> list.add(v.value())); |
| 231 | // return list; |
| 232 | // } |
| 233 | // |
| 234 | // @Override |
| 235 | // public List<RnibCell> getCellNodes() { |
| 236 | // List<RnibCell> list = Lists.newArrayList(); |
| 237 | // cellMap.values().forEach(v -> list.add(v.value())); |
| 238 | // return list; |
| 239 | // } |
| 240 | // |
| 241 | // @Override |
| 242 | // public List<RnibUe> getUeNodes() { |
| 243 | // List<RnibUe> list = Lists.newArrayList(); |
| 244 | // ueMap.values().forEach(v -> list.add(v.value())); |
| 245 | // return list; |
| 246 | // } |
| 247 | // |
| 248 | // @Override |
| 249 | // public Object getByNodeId(long nodeId) { |
| 250 | // CellId cellId = CellId.valueOf(nodeId); |
| 251 | // if (cellMap.containsKey(cellId)) { |
| 252 | // return cellMap.get(cellId).value(); |
| 253 | // } |
| 254 | // UeId ueId = UeId.valueOf(nodeId); |
| 255 | // if (ueMap.containsKey(ueId)) { |
| 256 | // return ueMap.get(ueId).value(); |
| 257 | // } |
| 258 | // return null; |
| 259 | // } |
| 260 | // |
| 261 | // @Override |
| 262 | // public void storeCell(RnibCell cell) { |
| 263 | // final CellId cellId = CellId.valueOf(cellIdGenerator.getNewId()); |
| 264 | // cell.setCellId(cellId); |
| 265 | // cellMap.putIfAbsent(cellId, cell); |
| 266 | // } |
| 267 | // |
| 268 | // @Override |
| 269 | // public RnibCell getCell(long cellId) { |
| 270 | // CellId cell = CellId.valueOf(cellId); |
| 271 | // if (cellMap.containsKey(cell)) { |
| 272 | //// controller.sendMsg(cellMap.get(cell).value().getDevId(), "skata"); |
| 273 | // return cellMap.get(cell).value(); |
| 274 | // } |
| 275 | // return null; |
| 276 | // } |
| 277 | // |
| 278 | // @Override |
| 279 | // public boolean modifyCellRrmConf(JsonNode rrmConf) { |
| 280 | // return false; |
| 281 | // } |
| 282 | // |
| 283 | // @Override |
| 284 | // public RnibSlice getSlice(long sliceId) { |
| 285 | // SliceId slice = SliceId.valueOf(sliceId); |
| 286 | // if (sliceMap.containsKey(slice)) { |
| 287 | // return sliceMap.get(slice).value(); |
| 288 | // } |
| 289 | // return null; |
| 290 | // } |
| 291 | // |
| 292 | // @Override |
| 293 | // public boolean createSlice(ObjectNode attributes) { |
| 294 | // return false; |
| 295 | // } |
| 296 | // |
| 297 | // public XranController getController() { |
| 298 | // return controller; |
| 299 | // } |
| 300 | // |
| 301 | // @Override |
| 302 | // public void storeUe(RnibUe ue) { |
| 303 | // final UeId ueId = UeId.valueOf(ueIdGenerator.getNewId()); |
| 304 | // ue.setUeId(ueId); |
| 305 | // ueMap.putIfAbsent(ueId, ue); |
| 306 | // } |
| 307 | // |
| 308 | // public void setController(XranController controller) { |
| 309 | // this.controller = controller; |
| 310 | // } |
| 311 | //} |