diff options
author | Yan Yang <yangyanyj@chinamobile.com> | 2018-03-28 01:03:17 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-03-28 01:03:17 +0000 |
commit | f41dbe3ab432bdbec29bf87561220d0e2a4c19dd (patch) | |
tree | 58ff3badabf1afef3db26c4f2bd0d7d25d882a70 /juju | |
parent | 6532a50752b324de07655bd37692fe62be293dc6 (diff) | |
parent | ba241158fb4b5acc66f23f0f80712cb971d64d07 (diff) |
Merge "spurious wakeup in juju-vnfmadapter"
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 |