aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-openstack-adapters/src/main')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java37
2 files changed, 25 insertions, 16 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java
index 02aa0843ae..a9aa50f654 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java
@@ -22,6 +22,8 @@ package org.onap.so.adapters.openstack;
import java.util.concurrent.Executor;
+import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -38,6 +40,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@EntityScan({ "org.onap.so.db.catalog.beans", "org.onap.so.db.request.beans"})
public class MsoOpenstackAdaptersApplication {
+
@Value("${mso.async.core-pool-size}")
private int corePoolSize;
@@ -63,6 +66,7 @@ public class MsoOpenstackAdaptersApplication {
@Bean
public Executor asyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ executor.setTaskDecorator(new MDCTaskDecorator());
executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity);
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
index 5cce4dd35f..2f688dbf48 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
@@ -50,6 +50,8 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
+import org.springframework.http.client.BufferingClientHttpRequestFactory;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
import org.springframework.stereotype.Component;
@@ -108,13 +110,11 @@ public class ValetClient {
URI uri = builder.build();
ValetCreateRequest vcr = this.createValetCreateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest);
- RestTemplate restTemplate = new RestTemplate();
String body = mapper.writeValueAsString(vcr);
HttpHeaders headers = generateHeaders(requestId);
- HttpEntity<String> entity = new HttpEntity<>(body, headers);
- LOGGER.debug("valet create req: " + uri.toString() + HEADERS + headers.toString() + BODY + body);
+ HttpEntity<String> entity = new HttpEntity<>(body, headers);
- response = restTemplate.exchange(uri, HttpMethod.POST, entity, ValetCreateResponse.class);
+ response = getRestTemplate().exchange(uri, HttpMethod.POST, entity, ValetCreateResponse.class);
gvr = this.getGVRFromResponse(response);
} catch (Exception e) {
LOGGER.error("An exception occurred in callValetCreateRequest", e);
@@ -123,6 +123,12 @@ public class ValetClient {
return gvr;
}
+ private RestTemplate getRestTemplate(){
+ RestTemplate restTemplate = new RestTemplate();
+ restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()));
+ return restTemplate;
+ }
+
/*
* This method will be invoked to send an Update request to Valet.
*/
@@ -135,14 +141,13 @@ public class ValetClient {
UriBuilder builder = UriBuilder.fromPath(baseUrl).path(basePath).queryParam(REQUEST_ID, requestId);
URI uri = builder.build();
- ValetUpdateRequest vur = this.createValetUpdateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest);
- RestTemplate restTemplate = new RestTemplate();
+ ValetUpdateRequest vur = this.createValetUpdateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest);
String body = mapper.writeValueAsString(vur);
HttpHeaders headers = generateHeaders(requestId);
HttpEntity<String> entity = new HttpEntity<>(body, headers);
- LOGGER.debug("valet update req: " + uri.toString() + HEADERS + headers.toString() + BODY + body);
+
- response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetUpdateResponse.class);
+ response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetUpdateResponse.class);
gvr = this.getGVRFromResponse(response);
} catch (Exception e) {
LOGGER.error("An exception occurred in callValetUpdateRequest", e);
@@ -163,13 +168,13 @@ public class ValetClient {
URI uri = builder.build();
ValetDeleteRequest vdr = this.createValetDeleteRequest(regionId, tenantId, vfModuleId, vfModuleName);
- RestTemplate restTemplate = new RestTemplate();
+
String body = mapper.writeValueAsString(vdr);
HttpHeaders headers = generateHeaders(requestId);
HttpEntity<String> entity = new HttpEntity<>(body, headers);
- LOGGER.debug("valet delete req: " + uri.toString() + HEADERS + headers.toString() + ", body=" + body);
- response = restTemplate.exchange(uri, HttpMethod.DELETE, entity, ValetDeleteResponse.class);
+
+ response = getRestTemplate().exchange(uri, HttpMethod.DELETE, entity, ValetDeleteResponse.class);
gvr = this.getGVRFromResponse(response);
} catch (Exception e) {
LOGGER.error("An exception occurred in callValetDeleteRequest", e);
@@ -190,13 +195,13 @@ public class ValetClient {
URI uri = builder.build(requestId);
ValetConfirmRequest vcr = this.createValetConfirmRequest(stackId);
- RestTemplate restTemplate = new RestTemplate();
+
String body = mapper.writeValueAsString(vcr);
HttpHeaders headers = generateHeaders(requestId);
HttpEntity<String> entity = new HttpEntity<>(body, headers);
LOGGER.debug("valet confirm req: " + uri.toString() + HEADERS + headers.toString() + BODY + body);
- response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetConfirmResponse.class);
+ response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetConfirmResponse.class);
gvr = this.getGVRFromResponse(response);
} catch (Exception e) {
LOGGER.error("An exception occurred in callValetConfirmRequest", e);
@@ -217,13 +222,13 @@ public class ValetClient {
URI uri = builder.build(requestId);
ValetRollbackRequest vrr = this.createValetRollbackRequest(stackId, suppressRollback, errorMessage);
- RestTemplate restTemplate = new RestTemplate();
+
String body = mapper.writeValueAsString(vrr);
HttpHeaders headers = generateHeaders(requestId);
HttpEntity<String> entity = new HttpEntity<>(body, headers);
- LOGGER.debug("valet rollback req: " + uri.toString() + HEADERS + headers.toString() + BODY + body);
- response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetRollbackResponse.class);
+
+ response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetRollbackResponse.class);
gvr = this.getGVRFromResponse(response);
} catch (Exception e) {
LOGGER.error("An exception occurred in callValetRollbackRequest", e);