diff options
Diffstat (limited to 'a1-policy-management/src/main')
6 files changed, 19 insertions, 28 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java index 2b8c4fa6..ad2e221f 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java @@ -42,9 +42,7 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti import reactor.core.publisher.Mono; import reactor.netty.http.client.HttpClient; -import reactor.netty.resources.ConnectionProvider; -import reactor.netty.tcp.ProxyProvider.Proxy; -import reactor.netty.tcp.TcpClient; +import reactor.netty.transport.ProxyProvider; /** * Generic reactive REST client. @@ -200,32 +198,32 @@ public class AsyncRestClient { && !httpProxyConfig.httpProxyHost().isEmpty(); } - private TcpClient createTcpClient() { - TcpClient client = TcpClient.create(ConnectionProvider.newConnection()) // + private HttpClient buildHttpClient() { + HttpClient httpClient = HttpClient.create() // .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) // .doOnConnected(connection -> { connection.addHandlerLast(new ReadTimeoutHandler(30)); connection.addHandlerLast(new WriteTimeoutHandler(30)); }); + if (this.sslContext != null) { - client = client.secure(c -> c.sslContext(sslContext)); + httpClient = httpClient.secure(ssl -> ssl.sslContext(sslContext)); } + if (isHttpProxyConfigured()) { - client = client.proxy(proxy -> proxy.type(Proxy.HTTP).host(httpProxyConfig.httpProxyHost()) - .port(httpProxyConfig.httpProxyPort())); + httpClient = httpClient.proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP) + .host(httpProxyConfig.httpProxyHost()).port(httpProxyConfig.httpProxyPort())); } - return client; + return httpClient; } - private WebClient createWebClient(String baseUrl, TcpClient tcpClient) { - HttpClient httpClient = HttpClient.from(tcpClient); - - ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient); + private WebClient buildWebClient(String baseUrl) { + final HttpClient httpClient = buildHttpClient(); ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() // .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) // .build(); return WebClient.builder() // - .clientConnector(connector) // + .clientConnector(new ReactorClientHttpConnector(httpClient)) // .baseUrl(baseUrl) // .exchangeStrategies(exchangeStrategies) // .build(); @@ -233,15 +231,9 @@ public class AsyncRestClient { private Mono<WebClient> getWebClient() { if (this.webClient == null) { - try { - TcpClient tcpClient = createTcpClient(); - this.webClient = createWebClient(this.baseUrl, tcpClient); - } catch (Exception e) { - logger.error("Could not create WebClient {}", e.getMessage()); - return Mono.error(e); - } + this.webClient = buildWebClient(baseUrl); } - return Mono.just(this.webClient); + return Mono.just(buildWebClient(baseUrl)); } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientFactory.java index db3834a9..cde6647a 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientFactory.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientFactory.java @@ -72,7 +72,7 @@ public class AsyncRestClientFactory { return createRestClient(baseUrl, false); } - public AsyncRestClient createRestClient(String baseUrl) { + public AsyncRestClient createRestClientUseHttpProxy(String baseUrl) { return createRestClient(baseUrl, true); } @@ -190,5 +190,4 @@ public class AsyncRestClientFactory { } } - } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java index 7ded8ac9..78a418ab 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java @@ -120,7 +120,7 @@ public class OscA1Client implements A1Client { private final UriBuilder uri; public OscA1Client(RicConfig ricConfig, AsyncRestClientFactory restClientFactory) { - this(ricConfig, restClientFactory.createRestClient("")); + this(ricConfig, restClientFactory.createRestClientUseHttpProxy("")); } public OscA1Client(RicConfig ricConfig, AsyncRestClient restClient) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java index 130f5500..b158ad25 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java @@ -97,7 +97,7 @@ public class StdA1ClientVersion1 implements A1Client { private final UriBuilder uri; public StdA1ClientVersion1(RicConfig ricConfig, AsyncRestClientFactory restClientFactory) { - this(restClientFactory.createRestClient(""), ricConfig); + this(restClientFactory.createRestClientUseHttpProxy(""), ricConfig); } public StdA1ClientVersion1(AsyncRestClient restClient, RicConfig ricConfig) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java index d79b2e72..d0f4da28 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java @@ -124,7 +124,7 @@ public class StdA1ClientVersion2 implements A1Client { private final OranV2UriBuilder uriBuiler; public StdA1ClientVersion2(RicConfig ricConfig, AsyncRestClientFactory restClientFactory) { - this(ricConfig, restClientFactory.createRestClient("")); + this(ricConfig, restClientFactory.createRestClientUseHttpProxy("")); } public StdA1ClientVersion2(RicConfig ricConfig, AsyncRestClient restClient) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java index c3eff84a..3e6bda72 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java @@ -28,7 +28,7 @@ public class Consts { public static final String TRANSIENT_PARAM = "transient"; public static final String MANAGED_ELEMENT_ID_PARAM = "managed_element_id"; - public static final String V2_API_ROOT = "a1-policy/v2"; + public static final String V2_API_ROOT = "/a1-policy/v2"; public static final String V2_API_SERVICE_CALLBACKS_NAME = "Callbacks"; public static final String V2_API_SERVICE_CALLBACKS_DESCRIPTION = ""; |