summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--service/src/main/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/HttpsRest.java26
-rw-r--r--service/src/main/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapterMgrService.java35
2 files changed, 25 insertions, 36 deletions
diff --git a/service/src/main/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/HttpsRest.java b/service/src/main/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/HttpsRest.java
index 7190c56..fa006c1 100644
--- a/service/src/main/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/HttpsRest.java
+++ b/service/src/main/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/HttpsRest.java
@@ -43,7 +43,7 @@ public class HttpsRest extends HttpBaseRest {
try {
client.start();
} catch(Exception e) {
- e.printStackTrace();
+ LOG.error("Exception: ",e);
}
}
@@ -167,7 +167,7 @@ public class HttpsRest extends HttpBaseRest {
try {
client.send(exchange);
} catch(IOException e) {
- e.printStackTrace();
+ LOG.error("IOException: ",e);
}
try {
int exchangeState = exchange.waitForDone();
@@ -186,10 +186,10 @@ public class HttpsRest extends HttpBaseRest {
throw new ServiceException(
"request is expierd: " + RestHttpContentExchange.toState(HttpExchange.STATUS_EXPIRED));
}
- } catch(InterruptedException e) {
- e.printStackTrace();
} catch(UnsupportedEncodingException e) {
- e.printStackTrace();
+ LOG.error("UnsupportedEncodingException: ",e);
+ } catch(Exception e) {//if not specific handling, no use of InterruptedException
+ LOG.error("InterruptedException: ",e);
}
return null;
}
@@ -208,7 +208,7 @@ public class HttpsRest extends HttpBaseRest {
try {
client.send(exchange);
} catch(IOException e) {
- e.printStackTrace();
+ LOG.error("IOException: ",e);
}
try {
@@ -228,10 +228,10 @@ public class HttpsRest extends HttpBaseRest {
throw new ServiceException(
"request is expierd: " + RestHttpContentExchange.toState(HttpExchange.STATUS_EXPIRED));
}
- } catch(InterruptedException e) {
- e.printStackTrace();
} catch(UnsupportedEncodingException e) {
- e.printStackTrace();
+ LOG.error("UnsupportedEncodingException: ",e);
+ } catch(Exception e) {
+ LOG.error("Exception: ",e);
}
return null;
}
@@ -258,7 +258,7 @@ public class HttpsRest extends HttpBaseRest {
try {
client.send(exchange);
} catch(IOException e) {
- e.printStackTrace();
+ LOG.error("IOException: ",e);
}
try {
@@ -278,10 +278,10 @@ public class HttpsRest extends HttpBaseRest {
throw new ServiceException(
"request is expierd: " + RestHttpContentExchange.toState(HttpExchange.STATUS_EXPIRED));
}
- } catch(InterruptedException e) {
- e.printStackTrace();
} catch(UnsupportedEncodingException e) {
- e.printStackTrace();
+ LOG.error("UnsupportedEncodingException: ",e);
+ } catch(Exception e) {
+ LOG.error("Exception: ",e);
}
return null;
}
diff --git a/service/src/main/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapterMgrService.java b/service/src/main/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapterMgrService.java
index bb4ec3a..57aafc2 100644
--- a/service/src/main/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapterMgrService.java
+++ b/service/src/main/java/org/onap/vfc/nfvo/multivimproxy/service/adapter/impl/MultivimProxyAdapterMgrService.java
@@ -83,17 +83,15 @@ public class MultivimProxyAdapterMgrService implements IMultivimProxyAdapterMgrS
* @throws IOException
*/
public static String readVimAdapterInfoFromJson() throws IOException {
- InputStream ins = null;
- BufferedInputStream bins = null;
String fileContent = "";
String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty("file.separator")
+ "etc" + System.getProperty("file.separator") + "adapterInfo" + System.getProperty("file.separator")
+ RESMGRADAPTERINFO;
- try {
- ins = new FileInputStream(fileName);
- bins = new BufferedInputStream(ins);
+ try (
+ InputStream ins = new FileInputStream(fileName);
+ BufferedInputStream bins = new BufferedInputStream(ins)){
byte[] contentByte = new byte[ins.available()];
int num = bins.read(contentByte);
@@ -103,14 +101,7 @@ public class MultivimProxyAdapterMgrService implements IMultivimProxyAdapterMgrS
}
} catch(FileNotFoundException e) {
LOG.error(fileName + "is not found!", e);
- } finally {
- if(ins != null) {
- ins.close();
- }
- if(bins != null) {
- bins.close();
- }
- }
+ }
return fileContent;
}
@@ -145,13 +136,13 @@ public class MultivimProxyAdapterMgrService implements IMultivimProxyAdapterMgrS
// catch Runtime Exception
try {
sendRequest(paramsMap, adapterInfo);
- } catch(RuntimeException e) {
+ } catch(Exception e) {
LOG.error(e.getMessage(), e);
}
}
- private void sendRequest(Map<String, String> paramsMap, JSONObject driverInfo) {
+ private void sendRequest(Map<String, String> paramsMap, JSONObject driverInfo)throws InterruptedException {
JSONObject resultObj = adapter2MSBMgr.registerProxy(paramsMap, driverInfo);
if(Integer.valueOf(resultObj.get("retCode").toString()) == HttpConstant.HTTP_CREATED) {
@@ -161,16 +152,14 @@ public class MultivimProxyAdapterMgrService implements IMultivimProxyAdapterMgrS
+ resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString());
// if registration fails,wait one minute and try again
- try {
- synchronized(lockObject) {
+ synchronized(lockObject) {
+ while(Integer.valueOf(resultObj.get("retCode").toString()) != Constant.HTTP_CREATED){
lockObject.wait(Constant.REPEAT_REG_TIME);
+ resultObj = adapter2MSBMgr.registerProxy(this.paramsMap, this.adapterInfo);
+ }
}
- } catch(InterruptedException e) {
- LOG.error(e.getMessage(), e);
- }
-
- sendRequest(this.paramsMap, this.adapterInfo);
- }
+ LOG.info("Resmgr has now Successfully Registered to the Microservice BUS!");
+ }
}