From 68d0b52af532f4cde355b642593e76cf737aeb21 Mon Sep 17 00:00:00 2001 From: 6092002067 Date: Tue, 14 Mar 2017 19:36:20 +0800 Subject: Add UT for actions Change-Id: Ic2dd7c4326111d9d3b8565a6b7e83b4f46bc197d Issue-ID: HOLMES-50 Signed-off-by: youbowu --- .../java/org/openo/holmes/common/msb/MicroserviceBusRest.java | 5 +++-- .../main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'holmes-actions/src/main') diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/msb/MicroserviceBusRest.java b/holmes-actions/src/main/java/org/openo/holmes/common/msb/MicroserviceBusRest.java index eb9deef..c8e03e9 100644 --- a/holmes-actions/src/main/java/org/openo/holmes/common/msb/MicroserviceBusRest.java +++ b/holmes-actions/src/main/java/org/openo/holmes/common/msb/MicroserviceBusRest.java @@ -26,10 +26,11 @@ import org.openo.holmes.common.api.entity.ServiceRegisterEntity; @Path("/openoapi/microservices/v1/services") public interface MicroserviceBusRest { + @Path("") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate, - ServiceRegisterEntity entity) throws Exception; + ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate, + ServiceRegisterEntity entity); } diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java index 91e28a6..f7825e7 100644 --- a/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java +++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java @@ -35,7 +35,7 @@ public class MSBRegisterUtil { while (!flag && retry < 20) { log.info("Holmes microservice register. retry:" + retry); retry++; - flag = inner_register(entity); + flag = innerRegister(entity); if (!flag) { log.warn("micro service register failed, sleep 30S and try again."); threadSleep(30000); @@ -47,7 +47,7 @@ public class MSBRegisterUtil { log.info("holmes micro service register end."); } - private boolean inner_register(ServiceRegisterEntity entity) { + private boolean innerRegister(ServiceRegisterEntity entity) { try { log.info("msbServerAddr:" + MicroServiceConfig.getMsbServerAddr()); log.info("entity:" + entity); @@ -55,7 +55,7 @@ public class MSBRegisterUtil { MicroServiceConfig.getMsbServerAddr(), MicroserviceBusRest.class); resourceserviceproxy.registerServce("false", entity); } catch (Exception error) { - log.error("microservice register failed!" + error.getMessage()); + log.error("microservice register failed!" + error.getMessage(), error); return false; } return true; @@ -66,7 +66,7 @@ public class MSBRegisterUtil { try { Thread.sleep(second); } catch (InterruptedException error) { - log.error("thread sleep error.errorMsg:" + error.getMessage()); + log.error("thread sleep error.errorMsg:" + error.getMessage(), error); } log.info("sleep end ."); } -- cgit 1.2.3-korg