diff options
author | 2018-03-27 14:34:18 +0530 | |
---|---|---|
committer | 2018-03-27 14:34:18 +0530 | |
commit | ba241158fb4b5acc66f23f0f80712cb971d64d07 (patch) | |
tree | 2e8ec61b0eee2bb400cabaab12413ffbe9f7d938 /juju | |
parent | 3064d937a6300d5f354d83471a520b4e26d2daaa (diff) |
spurious wakeup in juju-vnfmadapter
internalsvc/impl/JujuAdapter2DriverMgrService.java
file name:JujuAdapterMgrService.java
Change-Id: I7219a9ba5548b09418eb91a6dc8923a1e2182b3f
Issue-ID: VFC-854
Signed-off-by: ajay priyadarshi <ajay.priyadarshi@ril.com>
Diffstat (limited to 'juju')
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 |