diff options
Diffstat (limited to 'juju/juju-vnfmadapter')
2 files changed, 30 insertions, 16 deletions
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapter2DriverMgrService.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapter2DriverMgrService.java index 12ab241..fb592b5 100644 --- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapter2DriverMgrService.java +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapter2DriverMgrService.java @@ -135,23 +135,31 @@ public class JujuAdapter2DriverMgrService implements IJujuAdapter2DriverMgrServi // 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 = adapter2DriverMgr.registerDriver(paramsMap, driverInfo); - - if(Integer.valueOf(resultObj.get("retCode").toString()) == Constant.HTTP_CREATED) { - LOG.info("Vnfmadapter has now Successfully Registered to the Driver Manager!"); - } else { - LOG.error("Vnfmadapter failed to Register to the Driver Manager! Reason:" + + if(Integer.valueOf(resultObj.get("retCode").toString()) == Constant.HTTP_CREATED){ + LOG.info("Vnfmadapter has now Successfully Registered to the Driver Manager!"); + }else{ + LOG.error("Vnfmadapter failed to Register to the Driver Manager! Reason:" + resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString()); // if registration fails,wait one minute and try again - try { + synchronized(lockObject) { + while(Integer.valueOf(resultObj.get("retCode").toString()) != Constant.HTTP_CREATED){ + lockObject.wait(Constant.REPEAT_REG_TIME); + resultObj = adapter2DriverMgr.registerDriver(this.paramsMap, this.adapterInfo); + } + } + LOG.info("Vnfmadapter has now Successfully Registered to the Driver Manager!"); + + /*try { synchronized(lockObject) { lockObject.wait(Constant.REPEAT_REG_TIME); } @@ -160,12 +168,11 @@ public class JujuAdapter2DriverMgrService implements IJujuAdapter2DriverMgrServi } sendRequest(this.paramsMap, this.adapterInfo); - } - - } + */ + } } - +} @Override public void unregister() { // unregister diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrService.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrService.java index b7e6094..505b6ca 100644 --- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrService.java +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrService.java @@ -133,13 +133,13 @@ public class JujuAdapterMgrService implements IJujuAdapterMgrService { // 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.registerJujuAdapter(paramsMap, driverInfo); if(Integer.valueOf(resultObj.get("retCode").toString()) == Constant.HTTP_CREATED) { @@ -150,6 +150,14 @@ public class JujuAdapterMgrService implements IJujuAdapterMgrService { + resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString()); // if registration fails,wait one minute and try again + synchronized(lockObject) { + while(Integer.valueOf(resultObj.get("retCode").toString()) != Constant.HTTP_CREATED){ + lockObject.wait(Constant.REPEAT_REG_TIME); + resultObj = adapter2MSBMgr.registerJujuAdapter(paramsMap, driverInfo); + } + } + LOG.info("Vnfmadapter has now Successfully Registered to the Driver Manager!"); + /* try { synchronized(lockObject) { lockObject.wait(Constant.REPEAT_REG_TIME); @@ -159,10 +167,9 @@ public class JujuAdapterMgrService implements IJujuAdapterMgrService { } sendRequest(this.paramsMap, this.adapterInfo); + */ } - } - } @Override |