aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authormalar <malarvizhi.44@wipro.com>2021-09-01 15:09:10 +0000
committermalar <malarvizhi.44@wipro.com>2021-09-03 04:35:44 +0000
commitee82f3dc04665e8b86ce5c728a34f9701143e518 (patch)
treeb595a59cdf081320ce19b738b2fde37e92d759a0 /src/main/java
parentafb7bc0c146474e2492d29a70fa1c82689e8e3ed (diff)
Refactored code for standardizing configuration retrieval through common method2.1.4
Issue-ID: DCAEGEN2-2905 Signed-off-by: Malarvizhi Paramasivam <malarvizhi.44@wipro.com> Change-Id: Id268e066093d63f93ba3679831f2875e4afbaada
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java9
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java6
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java4
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java5
-rw-r--r--src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java8
5 files changed, 23 insertions, 9 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
index 8b05f8c..d0a8702 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
@@ -30,6 +30,8 @@ import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
+import org.onap.dcaegen2.services.sonhms.restclient.ConfigInterface;
+import org.onap.dcaegen2.services.sonhms.restclient.ConfigurationClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -463,6 +465,12 @@ public class Configuration {
Configuration.instance = instance;
}
+ public ConfigInterface getConfigurationClient()
+ {
+ ConfigInterface conf = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType());
+ return conf;
+ }
+
@Override
public String toString() {
return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword="
@@ -491,6 +499,7 @@ public class Configuration {
Type mapType = new TypeToken<Map<String, Object>>() {
}.getType();
+
JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes");
streamsSubscribes = new Gson().fromJson(subscribes, mapType);
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java
index 3964927..5e98eb4 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java
@@ -61,6 +61,7 @@ import org.onap.dcaegen2.services.sonhms.model.Flag;
import org.onap.dcaegen2.services.sonhms.model.HoDetails;
import org.onap.dcaegen2.services.sonhms.model.ThreadId;
import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody;
+import org.onap.dcaegen2.services.sonhms.restclient.ConfigInterface;
import org.onap.dcaegen2.services.sonhms.restclient.ConfigurationClient;
import org.onap.dcaegen2.services.sonhms.restclient.PciSolutions;
import org.onap.dcaegen2.services.sonhms.utils.BeanUtil;
@@ -82,6 +83,7 @@ public class ChildThread implements Runnable {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThread.class);
private static Timestamp startTime;
private static String networkId;
+ Configuration config = Configuration.getInstance();
/**
@@ -176,7 +178,7 @@ public class ChildThread implements Runnable {
FixedPciCellsRepository fixedPciCellsRepository = BeanUtil.getBean(FixedPciCellsRepository.class);
List<String> fixedPciCells = fixedPciCellsRepository.getFixedPciCells();
String cellId = fixedPciCells.get(0);
- JSONObject cellData = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getCellData(cellId);
+ JSONObject cellData = config.getConfigurationClient().getCellData(cellId);
networkId = cellData.getJSONObject("Cell").getString("networkId");
}
@@ -320,7 +322,7 @@ public class ChildThread implements Runnable {
for (PciSolutions pcisolutions : pciSolutionsList) {
String cellId = pcisolutions.getCellId();
- int oldPci = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPci(cellId);
+ int oldPci = config.getConfigurationClient().getPci(cellId);
int newPci = pcisolutions.getPci();
PciUpdate pciUpdate = new PciUpdate();
pciUpdate.setCellId(cellId);
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
index 5876d2b..6b60992 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
@@ -68,6 +68,7 @@ public class ChildThreadUtils {
private PnfUtils pnfUtils;
private PolicyDmaapClient policyDmaapClient;
private HoMetricsComponent hoMetricsComponent;
+ Configuration configuration = Configuration.getInstance();
/**
* Parameterized constructor.
@@ -98,7 +99,6 @@ public class ChildThreadUtils {
public Boolean triggerOrWait(Map<String, ArrayList<Integer>> collisionConfusionResult) {
// determine collision or confusion
- Configuration configuration = Configuration.getInstance();
int collisionSum = 0;
int confusionSum = 0;
@@ -226,7 +226,7 @@ public class ChildThreadUtils {
lteCell.setBlacklisted("true");
lteCell.setPlmnId(solutions.getNetworkId());
lteCell.setCid(removeableNeighbor);
- int pci = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPci(cellId);
+ int pci = configuration.getConfigurationClient().getPci(cellId);
lteCell.setPhyCellId(pci);
lteCell.setPnfName(pnfName);
lteCellList.add(lteCell);
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java
index 1787b3f..5a2eaa5 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java
@@ -45,6 +45,7 @@ import org.slf4j.Logger;
public class PnfUtils {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThreadUtils.class);
+ Configuration config = Configuration.getInstance();
/**
* get pnfs.
@@ -64,7 +65,7 @@ public class PnfUtils {
if (cellInfo.isPresent()) {
pnfName = cellInfo.get().getPnfName();
} else {
- pnfName = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPnfName(cellId);
+ pnfName = config.getConfigurationClient().getPnfName(cellId);
cellInfoRepository.save(new CellInfo(cellId, pnfName));
}
if (pnfs.containsKey(pnfName)) {
@@ -91,7 +92,7 @@ public class PnfUtils {
List<String> removeableNeighbors;
for (AnrSolutions anrSolution : anrSolutions) {
String cellId = anrSolution.getCellId();
- String pnfName = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPnfName(cellId);
+ String pnfName = config.getConfigurationClient().getPnfName(cellId);
removeableNeighbors = anrSolution.getRemoveableNeighbors();
Map<String, List<String>> cellRemNeighborsPair = new HashMap<>();
cellRemNeighborsPair.put(cellId, removeableNeighbors);
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java
index 7198fce..7ac3b9e 100644
--- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java
+++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java
@@ -45,6 +45,7 @@ import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
import org.onap.dcaegen2.services.sonhms.model.FapServiceList;
import org.onap.dcaegen2.services.sonhms.model.LteNeighborListInUseLteCell;
import org.onap.dcaegen2.services.sonhms.model.Notification;
+import org.onap.dcaegen2.services.sonhms.restclient.ConfigInterface;
import org.onap.dcaegen2.services.sonhms.restclient.ConfigurationClient;
import org.onap.dcaegen2.services.sonhms.restclient.CpsClient;
import org.onap.dcaegen2.services.sonhms.restclient.SdnrRestClient;
@@ -54,6 +55,7 @@ import org.slf4j.LoggerFactory;
public class ClusterUtils {
private static Logger log = LoggerFactory.getLogger(ClusterUtils.class);
+ Configuration config = Configuration.getInstance();
public List<ClusterDetails> getAllClusters() {
ClusterDetailsComponent clusterDetailsComponent = new ClusterDetailsComponent();
@@ -250,7 +252,7 @@ public class ClusterUtils {
val1.setPhysicalCellId(phy);
cluster.addEdge(val, val1);
- List<CellPciPair> nbrList = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getNbrList(cell);
+ List<CellPciPair> nbrList = config.getConfigurationClient().getNbrList(cell);
for (CellPciPair nbr : nbrList) {
String cid = nbr.getCellId();
@@ -303,12 +305,12 @@ public class ClusterUtils {
*/
public Map<CellPciPair, ArrayList<CellPciPair>> findClusterMap(String cellId) throws ConfigDbNotFoundException, CpsNotFoundException {
log.info("indide clusterMap");
- int phyCellId = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getPci(cellId);
+ int phyCellId = config.getConfigurationClient().getPci(cellId);
CellPciPair main = new CellPciPair();
main.setCellId(cellId);
main.setPhysicalCellId(phyCellId);
ArrayList<CellPciPair> cellPciPairs;
- cellPciPairs = (ArrayList<CellPciPair>) ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()).getNbrList(cellId);
+ cellPciPairs = (ArrayList<CellPciPair>) config.getConfigurationClient().getNbrList(cellId);
Map<CellPciPair, ArrayList<CellPciPair>> clusterMap = new HashMap<>();
clusterMap.put(main, cellPciPairs);
log.info("clusterMap{}", clusterMap);