summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java
diff options
context:
space:
mode:
Diffstat (limited to 'rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java')
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java
index 682faf0..08d66f7 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java
@@ -22,6 +22,7 @@ import io.swagger.annotations.ApiParam;
import io.swagger.annotations.SwaggerDefinition;
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;
@@ -36,11 +37,14 @@ import javax.ws.rs.core.MediaType;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
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.I18nProxy;
import org.openo.holmes.common.utils.JacksonUtil;
import org.openo.holmes.common.utils.LanguageUtil;
+import org.openo.holmes.common.utils.MSBRegisterUtil;
import org.openo.holmes.common.utils.UserUtil;
import org.openo.holmes.rulemgt.bean.request.RuleCreateRequest;
import org.openo.holmes.rulemgt.bean.request.RuleDeleteRequest;
@@ -60,8 +64,19 @@ import org.openo.holmes.rulemgt.wrapper.RuleMgtWrapper;
public class RuleMgtResources {
@Inject
+ private MSBRegisterUtil msbRegisterUtil;
+ @Inject
private RuleMgtWrapper ruleMgtWrapper;
+ @PostConstruct
+ public void init() {
+ try {
+ msbRegisterUtil.register(initServiceEntity());
+ } catch (IOException e) {
+ log.warn("Micro service registry httpclient close failure",e);
+ }
+ }
+
@PUT
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Save the alarm+ rule to the database, and deployed to the engine when the enable to open.", response = RuleAddAndUpdateResponse.class)
@@ -161,4 +176,15 @@ public class RuleMgtResources {
I18nProxy.RULE_MANAGEMENT_DATA_FORMAT_ERROR));
}
}
+
+ 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(), "9101", 0);
+ serviceRegisterEntity.setVisualRange("1");
+ return serviceRegisterEntity;
+ }
}