blob: a42ecbd07cf4d3c90e09f0b0e01a26e7dd518002 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/*
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
17package org.onosproject.xran.wrapper;
18
19import com.google.common.collect.BiMap;
20import com.google.common.collect.HashBiMap;
21import io.netty.channel.ChannelHandlerContext;
22import org.onosproject.net.HostId;
23import org.onosproject.xran.XranStore;
24import org.onosproject.xran.codecs.api.CRNTI;
25import org.onosproject.xran.codecs.api.ENBUES1APID;
26import org.onosproject.xran.codecs.api.MMEUES1APID;
27import org.onosproject.xran.entities.RnibUe;
28
29import java.util.concurrent.ConcurrentHashMap;
30import java.util.concurrent.ConcurrentMap;
31
32public class UeMap {
33 private BiMap<CRNTI, MMEUES1APID> crntUe = HashBiMap.create();
34
35 private XranStore xranStore;
36
37 public UeMap(XranStore xranStore) {
38 this.xranStore = xranStore;
39 }
40
41 public void put(RnibUe ue) {
42
43 MMEUES1APID mmeS1apId = ue.getMmeS1apId();
44 if (mmeS1apId != null) {
45 xranStore.storeUe(ue);
46 }
47
48 CRNTI ranId = ue.getRanId();
49 if (ranId != null) {
50 crntUe.put(ranId, ue.getMmeS1apId());
51 }
52 }
53
54 public RnibUe get(CRNTI id) {
55 MMEUES1APID mme = crntUe.get(id);
56 if (mme != null) {
57 return xranStore.getUe(mme);
58 }
59 return null;
60 }
61
62 public RnibUe get(MMEUES1APID mme) {
63 if (mme != null) {
64 return xranStore.getUe(mme);
65 }
66 return null;
67 }
68
69 public boolean remove(MMEUES1APID id) {
70 crntUe.inverse().remove(id);
71 return xranStore.removeUe(id);
72 }
73}