diff options
author | 2017-03-09 10:40:01 +0800 | |
---|---|---|
committer | 2017-03-09 10:40:01 +0800 | |
commit | 2df1df637f5104f02a37132e323f72c6a6c927b7 (patch) | |
tree | 075e45f5dc6b6d2f9d4a217c2d5751e642c7459d /engine-d/src/main/java/org | |
parent | b464eec16a30627bf5237b71ba0088d458640c22 (diff) |
Add register msb
Change-Id: Id6e87b4c243c78d88207e196d71948f04bd028fe
Issue-ID: HOLMES-47
Signed-off-by: FengLiang <feng.liang1@zte.com.cn>
Diffstat (limited to 'engine-d/src/main/java/org')
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java b/engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java index 94fc040..24de064 100644 --- a/engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java @@ -19,7 +19,9 @@ package org.openo.holmes.engine.resources; import com.codahale.metrics.annotation.Timed; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import java.io.IOException; import java.util.Locale; +import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.DELETE; @@ -32,9 +34,12 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import lombok.extern.slf4j.Slf4j; import org.jvnet.hk2.annotations.Service; +import org.openo.holmes.common.api.entity.ServiceRegisterEntity; +import org.openo.holmes.common.config.MicroServiceConfig; import org.openo.holmes.common.exception.CorrelationException; import org.openo.holmes.common.utils.ExceptionUtil; import org.openo.holmes.common.utils.LanguageUtil; +import org.openo.holmes.common.utils.MSBRegisterUtil; import org.openo.holmes.engine.manager.DroolsEngine; import org.openo.holmes.engine.request.CompileRuleRequest; import org.openo.holmes.engine.request.DeployRuleRequest; @@ -50,6 +55,18 @@ public class EngineResources { @Inject DroolsEngine droolsEngine; + @Inject + MSBRegisterUtil msbRegisterUtil; + + @PostConstruct + private void initMsbService() { + try { + msbRegisterUtil.register(initServiceEntity()); + } catch (IOException e) { + log.warn("Failed register msb" + e.getMessage(), e); + } + } + @PUT @ApiOperation(value = "Add rule to Engine and Cache", response = CorrelationRuleResponse.class) @Produces(MediaType.APPLICATION_JSON) @@ -111,4 +128,15 @@ public class EngineResources { } return true; } + + private ServiceRegisterEntity initServiceEntity() { + ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity(); + serviceRegisterEntity.setServiceName("holmes"); + serviceRegisterEntity.setProtocol("REST"); + serviceRegisterEntity.setVersion("v1"); + serviceRegisterEntity.setUrl("/api/holmes/v1"); + serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9102", 0); + serviceRegisterEntity.setVisualRange("1"); + return serviceRegisterEntity; + } } |