diff options
author | tang peng <tang.peng5@zte.com.cn> | 2021-06-02 17:17:34 +0800 |
---|---|---|
committer | tang peng <tang.peng5@zte.com.cn> | 2021-06-04 08:46:47 +0800 |
commit | ff774a309d82c6d71064d32505492d7d0d8544cf (patch) | |
tree | 8ad5fa0e63a81155dc8aba330bd84c882ac54b45 /engine-d/src/main | |
parent | 240555b805b6b2f3195cd606952c8efd77693bbe (diff) |
Removed Dependency: httpclient
Issue-ID: HOLMES-414
Signed-off-by: tang peng <tang.peng5@zte.com.cn>
Change-Id: I30ce6a5ecbb6fa881d46ee78bc7fc2fb198b46db
Diffstat (limited to 'engine-d/src/main')
3 files changed, 15 insertions, 33 deletions
diff --git a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java index 245647d..2c9d88b 100644 --- a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java +++ b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java @@ -19,18 +19,13 @@ package org.onap.holmes.dsa.dmaappolling; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; import org.onap.holmes.common.api.stat.VesAlarm; import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder; import org.onap.holmes.common.exception.CorrelationException; -import org.onap.holmes.common.utils.GsonUtil; -import org.onap.holmes.common.utils.HttpsUtils; +import org.onap.holmes.common.utils.JerseyClient; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.UUID; @@ -83,27 +78,11 @@ public class Subscriber { } private List<String> getDMaaPData() throws Exception { - String response; - CloseableHttpClient closeableHttpClient = null; - HttpGet httpGet = new HttpGet(url + "/" + consumerGroup + "/" + consumer + "?timeout=" + period); - try { - closeableHttpClient = HttpsUtils.getConditionalHttpsClient(timeout); - HttpResponse httpResponse = HttpsUtils - .get(httpGet, new HashMap<>(), closeableHttpClient); - response = HttpsUtils.extractResponseEntity(httpResponse); - } catch (Exception e) { - throw e; - } finally { - httpGet.releaseConnection(); - if (closeableHttpClient != null) { - try { - closeableHttpClient.close(); - } catch (IOException e) { - log.warn("Failed to close http client!"); - } - } - } - return GsonUtil.jsonToBean(response, List.class); + return new JerseyClient() + .path(consumerGroup) + .path(consumer) + .queryParam("timeout", period) + .get(url, List.class); } private List<VesAlarm> extractVesAlarm(List<String> responseEntity) throws IOException { diff --git a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java index 135334a..37b5c07 100644 --- a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java +++ b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java @@ -1,5 +1,5 @@ /** - * Copyright 2017-2018 ZTE Corporation. + * Copyright 2017-2021 ZTE Corporation. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import io.dropwizard.setup.Environment; import lombok.extern.slf4j.Slf4j; import org.onap.holmes.common.config.MicroServiceConfig; import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication; +import org.onap.holmes.common.utils.CommonUtils; import org.onap.holmes.common.utils.transactionid.TransactionIdFilter; import org.onap.holmes.engine.dcae.DcaeConfigurationPolling; @@ -42,7 +43,7 @@ public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> { if (!"1".equals(System.getenv("TESTING"))) { ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); service.scheduleAtFixedRate( - new DcaeConfigurationPolling(MicroServiceConfig.getEnv(MicroServiceConfig.HOSTNAME)), 0, + new DcaeConfigurationPolling(CommonUtils.getEnv(MicroServiceConfig.HOSTNAME)), 0, DcaeConfigurationPolling.POLLING_PERIOD, TimeUnit.MILLISECONDS); } diff --git a/engine-d/src/main/java/org/onap/holmes/engine/Initializer.java b/engine-d/src/main/java/org/onap/holmes/engine/Initializer.java index 2e13be3..9eca2a6 100644 --- a/engine-d/src/main/java/org/onap/holmes/engine/Initializer.java +++ b/engine-d/src/main/java/org/onap/holmes/engine/Initializer.java @@ -18,7 +18,7 @@ package org.onap.holmes.engine; import org.jvnet.hk2.annotations.Service; import org.onap.holmes.common.exception.CorrelationException; -import org.onap.holmes.common.utils.HttpsUtils; +import org.onap.holmes.common.utils.CommonUtils; import org.onap.holmes.common.utils.MsbRegister; import org.onap.msb.sdk.discovery.entity.MicroServiceInfo; import org.onap.msb.sdk.discovery.entity.Node; @@ -30,7 +30,9 @@ import javax.inject.Inject; import java.util.HashSet; import java.util.Set; -import static org.onap.holmes.common.config.MicroServiceConfig.*; +import static org.onap.holmes.common.config.MicroServiceConfig.getMicroServiceIpAndPort; +import static org.onap.holmes.common.utils.CommonUtils.getEnv; +import static org.onap.holmes.common.utils.CommonUtils.isIpAddress; @Service public class Initializer { @@ -61,13 +63,13 @@ public class Initializer { msinfo.setProtocol("REST"); msinfo.setVisualRange("0|1"); msinfo.setLb_policy("round-robin"); - msinfo.setEnable_ssl(HttpsUtils.isHttpsEnabled()); + msinfo.setEnable_ssl(CommonUtils.isHttpsEnabled()); Set<Node> nodes = new HashSet<>(); Node node = new Node(); node.setIp(isIpAddress(serviceIpAndPort[0]) ? serviceIpAndPort[0] : getEnv("HOLMES_ENGINE_MGMT_SERVICE_HOST")); node.setPort("9102"); /* Following codes will cause an unregistration from MSB (due to MSB malfunction), comment them for now - String msbAddrTemplate = (HttpsUtils.isHttpsEnabled() ? "https" : "http") + String msbAddrTemplate = (CommonUtils.isHttpsEnabled() ? "https" : "http") + "://%s:%s/api/holmes-engine-mgmt/v1/healthcheck"; node.setCheckType("HTTP"); node.setCheckUrl(String.format(msbAddrTemplate, serviceAddrInfo[0], "9102")); |