From a215f9704e4f17ec5b00664e83d843b45884fd3e Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Thu, 21 Sep 2017 20:39:57 +0800 Subject: reduce break to one major: L23 L34 Change-Id: I1edeee1cb5c1523648e53a263090484f0f16e907 Signed-off-by: Harry Huang Issue-Id: VNFSDK-85 --- .../onap/vnfsdk/marketplace/msb/MsbRegister.java | 53 ++++++++++++---------- 1 file changed, 29 insertions(+), 24 deletions(-) (limited to 'vnfmarket-be/vnf-sdk-marketplace') diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegister.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegister.java index 3e4699e8..1b05af14 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegister.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/msb/MsbRegister.java @@ -23,58 +23,63 @@ import org.slf4j.LoggerFactory; public class MsbRegister { private static final Logger logger = LoggerFactory.getLogger(MsbRegister.class); - + + private MsbRegister() { + } + /** * Interface top handle MSB Registration */ - public static void handleMsbRegistration() + public static void handleMsbRegistration() { logger.info("VNF-SDK Market Place microservice register start."); int retry = 0; - while(CommonConstant.MsbRegisterCode.MSDB_REGISTER_RETRIES >= retry) - { + while(CommonConstant.MsbRegisterCode.MSDB_REGISTER_RETRIES >= retry) + { int retCode = MsbRegistration.getInstance().register(); - if(CommonConstant.MsbRegisterCode.MSDB_REGISTER_FILE_NOT_EXISTS == retCode) - { - logger.info("microservice register failed, MSB Register File Not Exists !"); - break; - } - - if(CommonConstant.MsbRegisterCode.MSDB_REGISTER_SUCESS != retCode) + + if(CommonConstant.MsbRegisterCode.MSDB_REGISTER_SUCESS != retCode) { logger.warn("microservice register failed, try again after(ms):" + CommonConstant.MsbRegisterCode.MSDB_REGISTER_RETRY_SLEEP); threadSleep(CommonConstant.MsbRegisterCode.MSDB_REGISTER_RETRY_SLEEP); - } - else + } + else { - logger.info("microservice register success !"); + if(CommonConstant.MsbRegisterCode.MSDB_REGISTER_FILE_NOT_EXISTS == retCode) + { + logger.info("microservice register failed, MSB Register File Not Exists !"); + } + else + { + logger.info("microservice register success !"); + } break; - } - + } + retry++; logger.info("VNF-SDK Market Place microservice register [retry count]:" + retry); } logger.info("VNF-SDK Market Place microservice register end."); } - - public static void handleMsbUnRegistration() + + public static void handleMsbUnRegistration() { logger.info("VNF-SDK Market Place microservice handleMsbUnRegistration Start."); MsbRegistration.getInstance().unRegister(); logger.info("VNF-SDK Market Place microservice handleMsbUnRegistration end."); } - - private static void threadSleep(int second) + + private static void threadSleep(int second) { - try + try { Thread.sleep(second); - } - catch(InterruptedException error) + } + catch(InterruptedException error) { logger.error("thread sleep error.errorMsg:", error); Thread.currentThread().interrupt(); } } -} +} -- cgit 1.2.3-korg