summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorromaingimbert <romain.gimbert@orange.com>2018-10-24 11:09:09 +0200
committerromaingimbert <romain.gimbert@orange.com>2018-10-24 11:09:09 +0200
commit740fa63f007b029f0e4d62b61c2b2c7156248adc (patch)
treed4a5ec8704e542a62df13dcfc66f3d19d90d7750 /src/main
parent4eecf9135e133a1a9a5f177fae3d0e7582d65190 (diff)
start up failed without msb
-fix code -fix log -add url log at nbi startup Change-Id: Iaf6dce3c0cd932f0c1067a43c46d36c24018b03c Issue-ID: EXTAPI-164 Signed-off-by: romaingimbert <romain.gimbert@orange.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/nbi/ServiceRegisterRunner.java20
-rw-r--r--src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java26
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java32
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java57
4 files changed, 94 insertions, 41 deletions
diff --git a/src/main/java/org/onap/nbi/ServiceRegisterRunner.java b/src/main/java/org/onap/nbi/ServiceRegisterRunner.java
index ed10a65..90ea9ac 100644
--- a/src/main/java/org/onap/nbi/ServiceRegisterRunner.java
+++ b/src/main/java/org/onap/nbi/ServiceRegisterRunner.java
@@ -16,6 +16,9 @@
package org.onap.nbi;
import com.google.common.base.Strings;
+import java.net.InetAddress;
+import java.util.HashSet;
+import java.util.Set;
import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;
import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
import org.onap.msb.sdk.discovery.entity.Node;
@@ -26,10 +29,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
-import java.net.InetAddress;
-import java.util.HashSet;
-import java.util.Set;
-
/**
* Register this NBI instance with MSB discovery when the app is fully started
*/
@@ -120,9 +119,8 @@ public class ServiceRegisterRunner implements CommandLineRunner {
+ " - enableSSL: [" + SERVICE_ENABLE_SSL + "]\n"
);
- int attempt = 0;
- while (attempt<RETRY) {
- attempt += 1;
+ int attempt = 1;
+ while (attempt<=RETRY) {
try {
logger.info("Registration with msb discovery (attempt {}/{})", attempt, RETRY);
MSBServiceClient msbClient = new MSBServiceClient(DISCOVERY_HOST, DISCOVERY_PORT);
@@ -130,9 +128,13 @@ public class ServiceRegisterRunner implements CommandLineRunner {
logger.debug("Registration with msb discovery done, microServiceFullInfo = {}", microServiceFullInfo.toString());
break;
} catch (Exception ex) {
- logger.info("Registration with msb discovery (attempt {}/{}) FAILED. Sleep {}ms", attempt, RETRY, RETRY_INTERVAL);
+ logger.warn("Registration with msb discovery (attempt {}/{}) FAILED.", attempt, RETRY);
+ attempt += 1;
+ if(attempt<=RETRY) {
+ logger.warn("Sleep {}ms", RETRY_INTERVAL);
+ Thread.sleep(RETRY_INTERVAL);
+ }
}
- Thread.sleep(RETRY_INTERVAL);
}
}
}
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java
index a4b8feb..1c4546b 100644
--- a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java
+++ b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java
@@ -21,6 +21,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import javax.annotation.PostConstruct;
import org.apache.commons.io.IOUtils;
import org.onap.nbi.OnapComponentsUrlPaths;
import org.onap.nbi.exceptions.BackendFunctionalException;
@@ -63,20 +64,35 @@ public class SdcClient {
private static final Logger LOGGER = LoggerFactory.getLogger(SdcClient.class);
+
+ private String sdcGetUrl;
+ private String sdcFindUrl;
+
+ @PostConstruct
+ private void setUpAndLogSDCUrl() {
+ sdcGetUrl= new StringBuilder().append(sdcHost).append(OnapComponentsUrlPaths.SDC_ROOT_URL+"/{id}"+OnapComponentsUrlPaths.SDC_GET_PATH).toString();
+ sdcFindUrl = new StringBuilder().append(sdcHost).append(OnapComponentsUrlPaths.SDC_ROOT_URL).toString();
+
+
+ LOGGER.info("SDC GET url : "+sdcGetUrl);
+ LOGGER.info("SDC FIND url : "+ sdcFindUrl);
+
+ }
+
+
public Map callGet(String id) {
- StringBuilder urlBuilder = new StringBuilder().append(sdcHost).append(OnapComponentsUrlPaths.SDC_ROOT_URL)
- .append("/").append(id).append(OnapComponentsUrlPaths.SDC_GET_PATH);
- UriComponentsBuilder callURI = UriComponentsBuilder.fromHttpUrl(urlBuilder.toString());
+ String callUrl = sdcGetUrl.replace("{id}", id);
+ UriComponentsBuilder callURLFormated = UriComponentsBuilder.fromHttpUrl(callUrl);
- ResponseEntity<Object> response = callSdc(callURI.build().encode().toUri());
+ ResponseEntity<Object> response = callSdc(callURLFormated.build().encode().toUri());
return (LinkedHashMap) response.getBody();
}
public List<LinkedHashMap> callFind(MultiValueMap<String, String> parametersMap) {
- UriComponentsBuilder callURI = UriComponentsBuilder.fromHttpUrl(sdcHost + OnapComponentsUrlPaths.SDC_ROOT_URL);
+ UriComponentsBuilder callURI = UriComponentsBuilder.fromHttpUrl(sdcFindUrl);
if (parametersMap != null) {
Map<String, String> stringStringMap = parametersMap.toSingleValueMap();
for (Entry<String, String> entry : stringStringMap.entrySet()) {
diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
index b9afe64..391cf41 100644
--- a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
+++ b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
@@ -17,6 +17,7 @@ package org.onap.nbi.apis.serviceinventory;
import java.util.LinkedHashMap;
import java.util.Map;
+import javax.annotation.PostConstruct;
import org.onap.nbi.OnapComponentsUrlPaths;
import org.onap.nbi.exceptions.BackendFunctionalException;
import org.slf4j.Logger;
@@ -49,6 +50,25 @@ public class AaiClient extends BaseClient {
private static final Logger LOGGER = LoggerFactory.getLogger(AaiClient.class);
private static final String X_TRANSACTION_ID = "X-TransactionId";
+
+ private String aaiServiceUrl;
+ private String aaiServicesUrl;
+ private String aaiServicesInstancesUrl;
+
+ @PostConstruct
+ private void setUpAndlogAAIUrl() {
+ aaiServiceUrl= new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_FOR_CUSTOMER_PATH).toString();
+ aaiServicesUrl= new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICES_FOR_CUSTOMER_PATH).toString();
+ aaiServicesInstancesUrl= new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_INSTANCES_PATH).toString();
+
+
+ LOGGER.info("AAI service url : "+aaiServiceUrl);
+ LOGGER.info("AAI services url : "+aaiServicesUrl);
+ LOGGER.info("AAI service instances url : "+aaiServicesInstancesUrl);
+
+ }
+
+
private HttpHeaders buildRequestHeaderForAAI() {
HttpHeaders httpHeaders = new HttpHeaders();
@@ -64,9 +84,7 @@ public class AaiClient extends BaseClient {
public Map getCatalogService(String customerId, String serviceSpecName, String serviceId) {
- StringBuilder callURL =
- new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_FOR_CUSTOMER_PATH);
- String callUrlFormated = callURL.toString().replace(CUSTOMER_ID, customerId);
+ String callUrlFormated = aaiServiceUrl.replace(CUSTOMER_ID, customerId);
callUrlFormated = callUrlFormated.replace("$serviceSpecName", serviceSpecName);
callUrlFormated = callUrlFormated.replace("$serviceId", serviceId);
@@ -91,9 +109,7 @@ public class AaiClient extends BaseClient {
}
public Map getServicesInAaiForCustomer(String customerId) {
- StringBuilder callURL =
- new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICES_FOR_CUSTOMER_PATH);
- String callUrlFormated = callURL.toString().replace(CUSTOMER_ID, customerId);
+ String callUrlFormated = aaiServicesUrl.replace(CUSTOMER_ID, customerId);
try{
ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
return (LinkedHashMap) response.getBody();
@@ -104,9 +120,7 @@ public class AaiClient extends BaseClient {
}
public Map getServiceInstancesInAaiForCustomer(String customerId, String serviceType) {
- StringBuilder callURL =
- new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_INSTANCES_PATH);
- String callUrlFormated = callURL.toString().replace(CUSTOMER_ID, customerId);
+ String callUrlFormated = aaiServicesInstancesUrl.replace(CUSTOMER_ID, customerId);
callUrlFormated = callUrlFormated.replace("$serviceSpecName", serviceType);
try{
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java b/src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java
index 67421ba..21bfbcd 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java
@@ -12,6 +12,7 @@
*/
package org.onap.nbi.apis.serviceorder;
+import javax.annotation.PostConstruct;
import org.onap.nbi.OnapComponentsUrlPaths;
import org.onap.nbi.apis.serviceorder.model.consumer.CreateE2EServiceInstanceResponse;
import org.onap.nbi.apis.serviceorder.model.consumer.CreateServiceInstanceResponse;
@@ -59,6 +60,32 @@ public class SoClient {
private static final Logger LOGGER = LoggerFactory.getLogger(SoClient.class);
+ private String createSoUrl;
+ private String createE2ESoUrl;
+ private String getSoStatus;
+ private String getE2ESoStatus;
+ private String deleteE2ESoUrl;
+ private String deleteSoUrl;
+
+
+ @PostConstruct
+ private void setUpAndLogSOUrl() {
+ createSoUrl = new StringBuilder().append(soHostname).append(OnapComponentsUrlPaths.MSO_CREATE_SERVICE_INSTANCE_PATH).toString();
+ createE2ESoUrl = new StringBuilder().append(soHostname).append(OnapComponentsUrlPaths.MSO_CREATE_E2ESERVICE_INSTANCE_PATH).toString();
+ deleteSoUrl= new StringBuilder().append(soHostname).append(OnapComponentsUrlPaths.MSO_DELETE_REQUEST_STATUS_PATH).toString();
+ deleteE2ESoUrl= new StringBuilder().append(soHostname).append(OnapComponentsUrlPaths.MSO_DELETE_E2ESERVICE_INSTANCE_PATH).toString();
+ getSoStatus= new StringBuilder().append(soHostname).append(OnapComponentsUrlPaths.MSO_GET_REQUEST_STATUS_PATH).toString();
+ getE2ESoStatus= new StringBuilder().append(soHostname).append(OnapComponentsUrlPaths.MSO_GET_E2EREQUEST_STATUS_PATH).toString();
+
+ LOGGER.info("SO create service url : "+ createSoUrl);
+ LOGGER.info("SO create e2e service url : "+ createE2ESoUrl);
+ LOGGER.info("SO delete service url : "+deleteSoUrl);
+ LOGGER.info("SO delete e2e service url : "+deleteE2ESoUrl);
+ LOGGER.info("SO get so status url : "+getSoStatus);
+ LOGGER.info("SO get e2e so status url : "+getE2ESoStatus);
+
+ }
+
public ResponseEntity<CreateServiceInstanceResponse> callCreateServiceInstance(MSOPayload msoPayload) {
@@ -66,20 +93,18 @@ public class SoClient {
LOGGER.debug("Calling SO CreateServiceInstance with msoPayload : " + msoPayload.toString());
}
- String url = soHostname + OnapComponentsUrlPaths.MSO_CREATE_SERVICE_INSTANCE_PATH;
-
try {
- ResponseEntity<CreateServiceInstanceResponse> response = restTemplate.exchange(url, HttpMethod.POST,
+ ResponseEntity<CreateServiceInstanceResponse> response = restTemplate.exchange(createSoUrl, HttpMethod.POST,
new HttpEntity<>(msoPayload, buildRequestHeader()), CreateServiceInstanceResponse.class);
- logResponsePost(url, response);
+ logResponsePost(createSoUrl, response);
return response;
} catch (BackendFunctionalException e) {
- LOGGER.error(ERROR_ON_CALLING + url + " ," + e);
+ LOGGER.error(ERROR_ON_CALLING + createSoUrl + " ," + e);
return new ResponseEntity(e.getBodyResponse(),e.getHttpStatus());
} catch (ResourceAccessException e) {
- LOGGER.error(ERROR_ON_CALLING + url + " ," + e);
+ LOGGER.error(ERROR_ON_CALLING + createSoUrl + " ," + e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@@ -90,20 +115,18 @@ public class SoClient {
LOGGER.debug("Calling SO CreateServiceInstanceE2E with msoPayload : " + msoPayloadE2E.toString());
}
- String url = soHostname + OnapComponentsUrlPaths.MSO_CREATE_E2ESERVICE_INSTANCE_PATH;
-
try {
- ResponseEntity<CreateE2EServiceInstanceResponse> response = restTemplate.exchange(url, HttpMethod.POST,
+ ResponseEntity<CreateE2EServiceInstanceResponse> response = restTemplate.exchange(createE2ESoUrl, HttpMethod.POST,
new HttpEntity<>(msoPayloadE2E, buildRequestHeader()), CreateE2EServiceInstanceResponse.class);
- logE2EResponsePost(url, response);
+ logE2EResponsePost(createE2ESoUrl, response);
return response;
} catch (BackendFunctionalException e) {
- LOGGER.error(ERROR_ON_CALLING + url + " ," + e);
+ LOGGER.error(ERROR_ON_CALLING + createE2ESoUrl + " ," + e);
return new ResponseEntity(e.getBodyResponse(),e.getHttpStatus());
} catch (ResourceAccessException e) {
- LOGGER.error(ERROR_ON_CALLING + url + " ," + e);
+ LOGGER.error(ERROR_ON_CALLING + createE2ESoUrl + " ," + e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@@ -114,7 +137,7 @@ public class SoClient {
LOGGER.debug("Calling SO DeleteServiceInstance with msoPayload : " + msoPayload.toString());
}
- String url = soHostname + OnapComponentsUrlPaths.MSO_DELETE_REQUEST_STATUS_PATH + serviceId;
+ String url = deleteSoUrl + serviceId;
try {
ResponseEntity<CreateServiceInstanceResponse> response = restTemplate.exchange(url, HttpMethod.DELETE,
@@ -136,7 +159,7 @@ public class SoClient {
public ResponseEntity<CreateE2EServiceInstanceResponse> callE2EDeleteServiceInstance(String globalSubscriberId, String serviceType,
String serviceInstanceId) {
- String url = soHostname + OnapComponentsUrlPaths.MSO_DELETE_E2ESERVICE_INSTANCE_PATH + serviceInstanceId;
+ String url = deleteE2ESoUrl + serviceInstanceId;
MSODeleteE2EPayload msoDeleteE2EPayload = new MSODeleteE2EPayload();
msoDeleteE2EPayload.setGlobalSubscriberId(globalSubscriberId);
msoDeleteE2EPayload.setServiceType(serviceType);
@@ -195,7 +218,7 @@ public class SoClient {
}
public GetRequestStatusResponse callGetRequestStatus(String requestId) {
- String url = soHostname + OnapComponentsUrlPaths.MSO_GET_REQUEST_STATUS_PATH + requestId;
+ String url = getSoStatus + requestId;
try {
@@ -215,9 +238,7 @@ public class SoClient {
public GetE2ERequestStatusResponse callE2EGetRequestStatus(String operationId, String serviceId) {
- StringBuilder callURL =
- new StringBuilder().append(soHostname).append(OnapComponentsUrlPaths.MSO_GET_E2EREQUEST_STATUS_PATH);
- String callUrlFormated = callURL.toString().replace("$serviceId", serviceId);
+ String callUrlFormated = getE2ESoStatus.replace("$serviceId", serviceId);
callUrlFormated = callUrlFormated.replace("$operationId", operationId);
if (LOGGER.isDebugEnabled()) {