diff options
author | 2019-03-15 20:17:20 +0900 | |
---|---|---|
committer | 2019-03-15 20:25:52 +0900 | |
commit | b3a50f47c377b1cbd7ab03927a622f24ddb1c1d3 (patch) | |
tree | 41827c18314226ca1870047a18592533953b27ec /nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java | |
parent | cd12f7c1f7290858027822502c37296bdcef14e9 (diff) |
Fix sonar issue vfc-adaptor
Issue-ID: VFC-1277
Change-Id: I0d764fab50972d0a9ba5d67ada0c9c1045412211
Signed-off-by: arind.mondal <arind.mondal@samsung.com>
Diffstat (limited to 'nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java')
2 files changed, 122 insertions, 51 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TerminateVnfContinueRunnable.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TerminateVnfContinueRunnable.java index e152c4b5..80959d12 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TerminateVnfContinueRunnable.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TerminateVnfContinueRunnable.java @@ -59,21 +59,88 @@ public class TerminateVnfContinueRunnable implements Runnable { private VnfcResourceInfoMapper vnfcDbMgmr; private Driver2CbamRequestConverter requestConverter; - - public TerminateVnfContinueRunnable(String vnfmId, TerminateVnfRequest driverRequest, String vnfInstanceId, String jobId, - NslcmMgmrInf nslcmMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionMapper dbManager, VnfcResourceInfoMapper vnfcDbMgmr) + + + ////////////////////////// Builder class + + public static class TerminateVnfContinueRunnableBuilder { + private String vnfmId; + private TerminateVnfRequest driverRequest; + private String vnfInstanceId; + private String jobId; + private NslcmMgmrInf nslcmMgmr; + private CbamMgmrInf cbamMgmr; + private Driver2CbamRequestConverter requestConverter; + private VnfmJobExecutionMapper dbManager; + private VnfcResourceInfoMapper vnfcDbMgmr; + + public TerminateVnfContinueRunnableBuilder setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + return this; + } + + public TerminateVnfContinueRunnableBuilder setDriverRequest(TerminateVnfRequest driverRequest) { + this.driverRequest = driverRequest; + return this; + } + + public TerminateVnfContinueRunnableBuilder setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + return this; + } + + public TerminateVnfContinueRunnableBuilder setJobId(String jobId) { + this.jobId = jobId; + return this; + } + + public TerminateVnfContinueRunnableBuilder setNslcmMgmr(NslcmMgmrInf nslcmMgmr) { + this.nslcmMgmr = nslcmMgmr; + return this; + } + + public TerminateVnfContinueRunnableBuilder setCbamMgmr(CbamMgmrInf cbamMgmr) { + this.cbamMgmr = cbamMgmr; + return this; + } + + public TerminateVnfContinueRunnableBuilder setRequestConverter(Driver2CbamRequestConverter requestConverter) { + this.requestConverter = requestConverter; + return this; + } + + public TerminateVnfContinueRunnableBuilder setDbManager(VnfmJobExecutionMapper dbManager) { + this.dbManager = dbManager; + return this; + } + + public TerminateVnfContinueRunnableBuilder setVnfcDbMgmr(VnfcResourceInfoMapper vnfcDbMgmr) { + this.vnfcDbMgmr = vnfcDbMgmr; + return this; + } + + public TerminateVnfContinueRunnable build(){ + return new TerminateVnfContinueRunnable(this); + } + + + } + + + public TerminateVnfContinueRunnable(TerminateVnfContinueRunnableBuilder builder) { - this.driverRequest = driverRequest; - this.vnfInstanceId = vnfInstanceId; - this.nslcmMgmr = nslcmMgmr; - this.cbamMgmr = cbamMgmr; - this.requestConverter = requestConverter; - this.jobId = jobId; - this.jobDbMgmr = dbManager; - this.vnfmId = vnfmId; - this.vnfcDbMgmr = vnfcDbMgmr; + this.driverRequest = builder.driverRequest; + this.vnfInstanceId = builder.vnfInstanceId; + this.nslcmMgmr = builder.nslcmMgmr; + this.cbamMgmr = builder.cbamMgmr; + this.requestConverter = builder.requestConverter; + this.jobId = builder.jobId; + this.jobDbMgmr = builder.dbManager; + this.vnfmId = builder.vnfmId; + this.vnfcDbMgmr = builder.vnfcDbMgmr; } - + + private void handleGrant(){ try { NslcmGrantVnfRequest grantRequest = buildNslcmGrantVnfRequest(); @@ -89,27 +156,27 @@ public class TerminateVnfContinueRunnable implements Runnable { handleDelete(); } - private void handleDelete() { - try { - boolean vnfAllowDelete = false; - int i = 0; - while(!vnfAllowDelete) { - CBAMQueryVnfResponse queryResponse = cbamMgmr.queryVnf(vnfInstanceId); - if(CommonEnum.InstantiationState.NOT_INSTANTIATED == queryResponse.getInstantiationState()) - { - vnfAllowDelete = true; - break; - } - i++; - logger.info(i + ": The vnf's current status is " + queryResponse.getInstantiationState().name() + " is not ready for deleting, please wait ... "); - Thread.sleep(30000); - } - prepareDelete(jobId); - cbamMgmr.deleteVnf(vnfInstanceId); - } catch (Exception e) { - logger.error("TerminateVnfContinueRunnable --> handleDelete error.", e); - } - } + private void handleDelete() { + try { + boolean vnfAllowDelete = false; + int i = 0; + while (!vnfAllowDelete) { + CBAMQueryVnfResponse queryResponse = cbamMgmr.queryVnf(vnfInstanceId); + if (CommonEnum.InstantiationState.NOT_INSTANTIATED == queryResponse.getInstantiationState()) { + vnfAllowDelete = true; + break; + } + i++; + logger.info(i + ": The vnf's current status is " + queryResponse.getInstantiationState().name() + + " is not ready for deleting, please wait ... "); + Thread.sleep(30000); + } + prepareDelete(jobId); + cbamMgmr.deleteVnf(vnfInstanceId); + } catch (Exception e) { + logger.error("TerminateVnfContinueRunnable --> handleDelete error.", e); + } + } private void prepareDelete(String jobId) { long nowTime = System.currentTimeMillis(); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java index b9fb3e81..79df78da 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java @@ -18,11 +18,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.impl; import java.util.concurrent.Executors; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.Driver2CbamRequestConverter; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.HealVnfContinueRunnable; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.InstantiateVnfContinueRunnable; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.ScaleVnfContinueRunnable; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.TerminateVnfContinueRunnable; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.*; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfcResourceInfoMapper; @@ -39,20 +35,28 @@ import org.springframework.stereotype.Component; public class VnfContinueProcessorImpl implements VnfContinueProcessorInf{ @Override - public void continueInstantiateVnf(String vnfmId, InstantiateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CatalogMgmrInf catalogMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionMapper jobDbManager, VnfcResourceInfoMapper vnfcDbMgmr) { - InstantiateVnfContinueRunnable task = new InstantiateVnfContinueRunnable(vnfmId, driverRequest, vnfInstanceId, jobId, - nslcmMgmr, catalogMgmr, cbamMgmr, requestConverter, jobDbManager, vnfcDbMgmr); - - Executors.newSingleThreadExecutor().submit(task); - } + public void continueInstantiateVnf(String vnfmId, InstantiateVnfRequest driverRequest, String vnfInstanceId, + String jobId, NslcmMgmrInf nslcmMgmr, CatalogMgmrInf catalogMgmr, CbamMgmrInf cbamMgmr, + Driver2CbamRequestConverter requestConverter, VnfmJobExecutionMapper jobDbManager, + VnfcResourceInfoMapper vnfcDbMgmr) { + InstantiateVnfContinueRunnable task = new InstantiateVnfContinueRunnable(vnfmId, driverRequest, vnfInstanceId, + jobId, nslcmMgmr, catalogMgmr, cbamMgmr, requestConverter, jobDbManager, vnfcDbMgmr); + + Executors.newSingleThreadExecutor().submit(task); + } @Override - public void continueTerminateVnf(String vnfmId, TerminateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionMapper jobDbManager, VnfcResourceInfoMapper vnfcDbMgmr) { - TerminateVnfContinueRunnable task = new TerminateVnfContinueRunnable(vnfmId, driverRequest, vnfInstanceId, jobId, - nslcmMgmr, cbamMgmr, requestConverter, jobDbManager, vnfcDbMgmr); - - Executors.newSingleThreadExecutor().submit(task); - } + public void continueTerminateVnf(String vnfmId, TerminateVnfRequest driverRequest, String vnfInstanceId, + String jobId, NslcmMgmrInf nslcmMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, + VnfmJobExecutionMapper jobDbManager, VnfcResourceInfoMapper vnfcDbMgmr) { + + TerminateVnfContinueRunnable task = new TerminateVnfContinueRunnable.TerminateVnfContinueRunnableBuilder() + .setVnfmId(vnfmId).setDriverRequest(driverRequest).setVnfInstanceId(vnfInstanceId).setJobId(jobId) + .setNslcmMgmr(nslcmMgmr).setCbamMgmr(cbamMgmr).setRequestConverter(requestConverter) + .setDbManager(jobDbManager).setVnfcDbMgmr(vnfcDbMgmr).build(); + + Executors.newSingleThreadExecutor().submit(task); + } @Override public void continueScaleVnf(String vnfmId, ScaleVnfRequest driverRequest, String vnfInstanceId, String jobId, |