added javadocs and comments
diff --git a/src/main/java/org.onosproject.xran/wrapper/CellMap.java b/src/main/java/org.onosproject.xran/wrapper/CellMap.java
index ea4fc77..6685189 100644
--- a/src/main/java/org.onosproject.xran/wrapper/CellMap.java
+++ b/src/main/java/org.onosproject.xran/wrapper/CellMap.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-present Open Networking Laboratory
+ * Copyright 2015-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,20 +19,22 @@
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import io.netty.channel.ChannelHandlerContext;
-import org.onosproject.net.DeviceId;
import org.onosproject.xran.XranStore;
import org.onosproject.xran.codecs.api.ECGI;
import org.onosproject.xran.codecs.api.PCIARFCN;
import org.onosproject.xran.entities.RnibCell;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+/**
+ * CELL wrapper to help put/get/remove.
+ */
public class CellMap {
+ // map to get the context channel based on ecgi
private ConcurrentMap<ECGI, ChannelHandlerContext> ecgiCtx = new ConcurrentHashMap<>();
+ // pci-arfcn to ecgi bimap
private BiMap<PCIARFCN, ECGI> pciarfcnMap = HashBiMap.create();
private XranStore xranStore;
@@ -40,13 +42,22 @@
this.xranStore = xranStore;
}
+ /**
+ * Put the PCI-ARFCN to ECGI map from new cell.
+ *
+ * @param value CELL entity
+ */
public void putPciArfcn(RnibCell value) {
- PCIARFCN pciarfcn = new PCIARFCN();
- pciarfcn.setPci(value.getConf().getPci());
- pciarfcn.setEarfcnDl(value.getConf().getEarfcnDl());
+ PCIARFCN pciarfcn = PCIARFCN.valueOf(value.getConf().getPci(), value.getConf().getEarfcnDl());
pciarfcnMap.put(pciarfcn, value.getEcgi());
}
+ /**
+ * Put inside ECGI to CTX map.
+ *
+ * @param value CELL entity to get ECGI from
+ * @param ctx context channel
+ */
public void put(RnibCell value, ChannelHandlerContext ctx) {
if (value.getEcgi() != null) {
ecgiCtx.put(value.getEcgi(), ctx);
@@ -54,8 +65,14 @@
}
}
+ /**
+ * Get cell based on PCI-ARFCN.
+ *
+ * @param id PCI-ARFCN
+ * @return CELL entity if found
+ */
public RnibCell get(PCIARFCN id) {
- ECGI ecgi = null;
+ ECGI ecgi;
ecgi = pciarfcnMap.get(id);
if (ecgi != null) {
@@ -64,6 +81,12 @@
return null;
}
+ /**
+ * Get cell based on ECGI.
+ *
+ * @param ecgi CELL ECGI
+ * @return CELL entity if found
+ */
public RnibCell get(ECGI ecgi) {
if (ecgi != null) {
return xranStore.getCell(ecgi);
@@ -71,6 +94,12 @@
return null;
}
+ /**
+ * Remove cell from three maps based on ECGI or PCI-ARFCN.
+ *
+ * @param key ecgECGIi or pci-arfcn of cell to remove
+ * @return true if remove succeeded
+ */
public boolean remove(Object key) {
ECGI ecgi = null;
if (key instanceof ECGI) {
@@ -87,6 +116,12 @@
return ecgi != null && xranStore.removeCell(ecgi);
}
+ /**
+ * Get context handler for specified ECGI.
+ *
+ * @param id CELL ECGI
+ * @return context handler if found
+ */
public ChannelHandlerContext getCtx(ECGI id) {
return ecgiCtx.get(id);
}
diff --git a/src/main/java/org.onosproject.xran/wrapper/LinkMap.java b/src/main/java/org.onosproject.xran/wrapper/LinkMap.java
index ed7b4f1..543879d 100644
--- a/src/main/java/org.onosproject.xran/wrapper/LinkMap.java
+++ b/src/main/java/org.onosproject.xran/wrapper/LinkMap.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-present Open Networking Laboratory
+ * Copyright 2015-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,9 @@
import static org.slf4j.LoggerFactory.getLogger;
+/**
+ * LINK wrapper to help put/get/remove.
+ */
public class LinkMap {
private static final Logger log = getLogger(LinkMap.class);
@@ -41,14 +44,28 @@
this.ueMap = ueMap;
}
+ /**
+ * Put a new primary link between a CELL and a UE.
+ *
+ * @param cell CELL entity
+ * @param ue UE entity
+ */
public void putPrimaryLink(RnibCell cell, RnibUe ue) {
RnibLink link = new RnibLink(cell, ue);
+ // set link to primary before storing
link.setType(RnibLink.Type.SERVING_PRIMARY);
xranStore.storeLink(link);
ueMap.putCrnti(cell, ue);
}
+ /**
+ * Put non-serving link based on CELL and CRNTI.
+ *
+ * @param cell CELL entity
+ * @param crnti CRNTI
+ * @return new link after creation
+ */
public RnibLink putNonServingLink(RnibCell cell, CRNTI crnti) {
RnibLink link = null;
RnibUe ue = ueMap.get(cell.getEcgi(), crnti);
@@ -62,6 +79,13 @@
return link;
}
+ /**
+ * Put non-serving link based on CELL and UE id.
+ *
+ * @param cell CELL entity
+ * @param ueId UE id
+ * @return new link after creation
+ */
public RnibLink putNonServingLink(RnibCell cell, Long ueId) {
RnibLink link = null;
RnibUe ue = ueMap.get(ueId);
@@ -75,6 +99,13 @@
return link;
}
+ /**
+ * Get link based on ECGI and UE id.
+ *
+ * @param src CELL ECGI
+ * @param dst UE ID
+ * @return link if found
+ */
public RnibLink get(ECGI src, Long dst) {
if (src != null && dst != null) {
return xranStore.getLink(src, dst);
@@ -82,6 +113,13 @@
return null;
}
+ /**
+ * Get link based on ECGI and CRNTI.
+ *
+ * @param src CELL ECGI
+ * @param dst CELL unique CRNTI
+ * @return link if found
+ */
public RnibLink get(ECGI src, CRNTI dst) {
RnibUe ue = ueMap.get(src, dst);
@@ -91,12 +129,27 @@
return null;
}
+ /**
+ * Get CRNTI based on UE id.
+ *
+ * @param ueId UE id
+ * @return UE if found
+ */
public CRNTI getCrnti(Long ueId) {
return ueMap.getCrntUe().inverse().get(ueId).getValue();
}
+ /**
+ * Get primary CELL for specified UE.
+ *
+ * @param ue UE entity
+ * @return primary CELL if found
+ */
public RnibCell getPrimaryCell(RnibUe ue) {
- List<RnibLink> linksByUeId = xranStore.getLinksByUeId(ue.getId());
+ List<RnibLink> linksByUeId = xranStore.getlinksbyueid(ue.getId());
+
+ // TODO: search for primary link from crntUe in UeMap because it has the primary links only!
+ // search all links for this UE and find PRIMARY.
Optional<RnibLink> primary = linksByUeId.stream()
.filter(l -> l.getType().equals(RnibLink.Type.SERVING_PRIMARY))
.findFirst();
diff --git a/src/main/java/org.onosproject.xran/wrapper/UeMap.java b/src/main/java/org.onosproject.xran/wrapper/UeMap.java
index 8b2110d..6ebab70 100644
--- a/src/main/java/org.onosproject.xran/wrapper/UeMap.java
+++ b/src/main/java/org.onosproject.xran/wrapper/UeMap.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-present Open Networking Laboratory
+ * Copyright 2015-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,12 +21,15 @@
import org.onosproject.xran.XranStore;
import org.onosproject.xran.codecs.api.CRNTI;
import org.onosproject.xran.codecs.api.ECGI;
-import org.onosproject.xran.codecs.api.MMEUES1APID;
import org.onosproject.xran.entities.RnibCell;
import org.onosproject.xran.entities.RnibUe;
import org.onosproject.xran.identifiers.EcgiCrntiPair;
+/**
+ * UE wrapper to help put/get/remove.
+ */
public class UeMap {
+ // ECGI, CRNTI pair of primary cell for specified UE.
private BiMap<EcgiCrntiPair, Long> crntUe = HashBiMap.create();
private XranStore xranStore;
@@ -35,30 +38,58 @@
this.xranStore = xranStore;
}
+ /**
+ * Get the ECGI, CRNTI to UE bimap.
+ *
+ * @return BiMap of EcgiCrntiPair to Long
+ */
public BiMap<EcgiCrntiPair, Long> getCrntUe() {
return crntUe;
}
+ /**
+ * Put new ECGI, CRNTI pair of primary link to UE and remove old one.
+ *
+ * @param cell new primary CELL
+ * @param ue UE
+ */
public void putCrnti(RnibCell cell, RnibUe ue) {
- CRNTI ranId = ue.getCrnti();
+ CRNTI crnti = ue.getCrnti();
ECGI ecgi = cell.getEcgi();
- if (ranId != null && ecgi != null) {
+
+ if (crnti != null && ecgi != null) {
+ // check if there is an ecgi, crnti pair for this UE id.
EcgiCrntiPair oldPair = crntUe.inverse().get(ue.getId()),
newPair = EcgiCrntiPair.valueOf(cell.getEcgi(), ue.getCrnti());
if (oldPair == null) {
crntUe.put(newPair, ue.getId());
} else {
+ // remove old pair and add the new pair which corresponds to the primary cell.
crntUe.inverse().remove(ue.getId());
crntUe.put(newPair, ue.getId());
}
}
}
+ /**
+ * Put new UE to the store and update the ECGI, CRNTI pair.
+ *
+ * @param cell new primary CELL
+ * @param ue UE
+ */
public void put(RnibCell cell, RnibUe ue) {
xranStore.storeUe(ue);
+ // after adding new primary cell update the bimap as well.
putCrnti(cell, ue);
}
+ /**
+ * Get UE based on ECGI and CRNTI.
+ *
+ * @param ecgi CELL ECGI
+ * @param crnti CELL unique CRNTI
+ * @return UE entity if found
+ */
public RnibUe get(ECGI ecgi, CRNTI crnti) {
Long aLong = crntUe.get(EcgiCrntiPair.valueOf(ecgi, crnti));
if (aLong != null) {
@@ -67,10 +98,22 @@
return null;
}
+ /**
+ * Get UE based on its id.
+ *
+ * @param ueId UE id
+ * @return UE entity if found
+ */
public RnibUe get(Long ueId) {
return xranStore.getUe(ueId);
}
+ /**
+ * Remove UE based on its id.
+ *
+ * @param ueId UE id
+ * @return true if remove succeeded
+ */
public boolean remove(Long ueId) {
crntUe.inverse().remove(ueId);
return xranStore.removeUe(ueId);
diff --git a/src/main/java/org.onosproject.xran/wrapper/package-info.java b/src/main/java/org.onosproject.xran/wrapper/package-info.java
index c724c32..7718d8e 100644
--- a/src/main/java/org.onosproject.xran/wrapper/package-info.java
+++ b/src/main/java/org.onosproject.xran/wrapper/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-present Open Networking Laboratory
+ * Copyright 2015-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,4 +14,7 @@
* limitations under the License.
*/
+/**
+ * Created by dimitris on 7/20/17.
+ */
package org.onosproject.xran.wrapper;
\ No newline at end of file