summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2017-03-09 02:48:56 +0000
committerGerrit Code Review <gerrit@open-o.org>2017-03-09 02:48:56 +0000
commit258eaccb5b06a0dfe89d5a1bc057259ff136de67 (patch)
tree9f288cf88ef5cc0deb9928ea2e493507096be64f
parentb7d709e72df8aae9e05566630b740c283708879d (diff)
parent2df1df637f5104f02a37132e323f72c6a6c927b7 (diff)
Merge "Add register msb"
-rw-r--r--engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java28
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;
+ }
}