summaryrefslogtreecommitdiffstats
path: root/rulemgt/src
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2018-07-30 13:00:52 +0900
committerONAP <arind.mondal@samsung.com>2018-08-14 10:04:01 +0900
commit8635bde272f6f2da05dd4dc274e0d91a640c0088 (patch)
treefc6da30479e0ee5fb092340a7261ebe5552a0eb6 /rulemgt/src
parentdf4bde91310a471a5489917e3a07359ef790d9cb (diff)
change to java 8 lambda
Issue-ID: HOLMES-152 Change-Id: I4687f0145b662185103d683be643342c8a9136e5 Signed-off-by: Arindam Mondal <arind.mondal@samsung.com>
Diffstat (limited to 'rulemgt/src')
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineIpList.java45
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/send/Ip4AddingRule.java2
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/send/RuleAllocation.java9
3 files changed, 21 insertions, 35 deletions
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineIpList.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineIpList.java
index 9b30705..2e91993 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineIpList.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineIpList.java
@@ -51,33 +51,24 @@ public class EngineIpList {
}
public List<String> getServiceCount()throws Exception{
- String response;
- CloseableHttpClient httpClient = null;
- HttpGet httpGet = new HttpGet(url);
- try {
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
- HttpResponse httpResponse = HttpsUtils
- .get(httpGet, new HashMap<>(), httpClient);
- response = HttpsUtils.extractResponseEntity(httpResponse);
- } catch (Exception e) {
- throw e;
- } finally {
- httpGet.releaseConnection();
- if (httpClient != null) {
- try {
- httpClient.close();
- } catch (IOException e) {
- log.warn("Failed to close http client!");
- }
- }
- }
- ServiceEntity service = GsonUtil.jsonToBean(response, ServiceEntity.class);
- List<ServiceNode4Query> nodesList = service.getNodes();
- List<String> ipList = new ArrayList<>();
- for(ServiceNode4Query node : nodesList){
- ipList.add(node.getIp());
- }
- return ipList;
+ String response;
+ HttpGet httpGet = new HttpGet(url);
+ try (CloseableHttpClient httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT)) {
+ HttpResponse httpResponse = HttpsUtils.get(httpGet, new HashMap<>(), httpClient);
+ response = HttpsUtils.extractResponseEntity(httpResponse);
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ httpGet.releaseConnection();
+
+ }
+ ServiceEntity service = GsonUtil.jsonToBean(response, ServiceEntity.class);
+ List<ServiceNode4Query> nodesList = service.getNodes();
+ List<String> ipList = new ArrayList<>();
+ for (ServiceNode4Query node : nodesList) {
+ ipList.add(node.getIp());
+ }
+ return ipList;
}
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/send/Ip4AddingRule.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/send/Ip4AddingRule.java
index e224bb5..4a2dba3 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/send/Ip4AddingRule.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/send/Ip4AddingRule.java
@@ -38,7 +38,7 @@ public class Ip4AddingRule {
public String getEngineIp4AddRule() {
List<CorrelationRule> ipRuleList = new ArrayList<>();
- LinkedHashMap<String,Integer> linkedHashMap = new LinkedHashMap();
+ LinkedHashMap<String,Integer> linkedHashMap = new LinkedHashMap<>();
try{
for(String ip : engineService){
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/send/RuleAllocation.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/send/RuleAllocation.java
index 75f0a08..9e7b5b2 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/send/RuleAllocation.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/send/RuleAllocation.java
@@ -193,13 +193,8 @@ public class RuleAllocation {
log.error("getEngineIp4AddRule failed !", e);
}
- List<Map.Entry<String, String>> list_Data = new ArrayList<Map.Entry<String, String>>(hashMap.entrySet());
- Collections.sort(list_Data, new Comparator<Map.Entry<String, String>>() {
- public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
- return o1.getValue().compareTo(o2.getValue());
- }
- });
-
+ List<Map.Entry<String, String>> list_Data = new ArrayList<>(hashMap.entrySet());
+ Collections.sort(list_Data,(o1,o2) -> o1.getValue().compareTo(o2.getValue()));
List<String> needList = new ArrayList<>();
for (Map.Entry<String, String> map : list_Data) {
String key = map.getKey();