summaryrefslogtreecommitdiffstats
path: root/rulemgt/src
diff options
context:
space:
mode:
authorGuangrongFu <fu.guangrong@zte.com.cn>2017-03-14 09:55:04 +0800
committerGuangrongFu <fu.guangrong@zte.com.cn>2017-03-14 09:55:04 +0800
commit6a7626d342add433d1c58ee369cf4c54f191ad43 (patch)
tree458b048849554caed035cdea26b6f06cd4e1ed68 /rulemgt/src
parent9fb39c874178ee713a061d959c31bcbfaa69a09c (diff)
Optimize the MSB Registration Logic
Change-Id: I1b58ef7499a871e5a04ac5f115e246cca4abb022 Issue-ID: HOLMES-50 Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'rulemgt/src')
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java29
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/resources/RuleMgtResources.java22
2 files changed, 29 insertions, 22 deletions
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java
index c7eaf15..96a1f00 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/RuleActiveApp.java
@@ -16,8 +16,15 @@
package org.openo.holmes.rulemgt;
+import io.dropwizard.setup.Environment;
+import java.io.IOException;
+import lombok.extern.slf4j.Slf4j;
import org.openo.dropwizard.ioc.bundle.IOCApplication;
+import org.openo.holmes.common.api.entity.ServiceRegisterEntity;
+import org.openo.holmes.common.config.MicroServiceConfig;
+import org.openo.holmes.common.utils.MSBRegisterUtil;
+@Slf4j
public class RuleActiveApp extends IOCApplication < RuleAppConfig > {
public static void main( String[] args ) throws Exception {
@@ -29,4 +36,26 @@ public class RuleActiveApp extends IOCApplication < RuleAppConfig > {
return "Holmes Rule Management ActiveApp APP ";
}
+ @Override
+ public void run(RuleAppConfig configuration, Environment environment) throws Exception {
+ super.run(configuration, environment);
+
+ try {
+ new MSBRegisterUtil().register(initServiceEntity());
+ } catch (IOException e) {
+ log.warn("Micro service registry httpclient close failure",e);
+ }
+
+ }
+
+ private ServiceRegisterEntity initServiceEntity() {
+ ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();
+ serviceRegisterEntity.setServiceName("holmes-rule-mgmt");
+ serviceRegisterEntity.setProtocol("REST");
+ serviceRegisterEntity.setVersion("v1");
+ serviceRegisterEntity.setUrl("/openoapi/holmes-rule-mgmt/v1");
+ serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9101", 0);
+ serviceRegisterEntity.setVisualRange("1|0");
+ return serviceRegisterEntity;
+ }
}
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 2c2c88d..f3256b2 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
@@ -64,19 +64,8 @@ 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)
@@ -176,15 +165,4 @@ public class RuleMgtResources {
I18nProxy.RULE_MANAGEMENT_DATA_FORMAT_ERROR));
}
}
-
- private ServiceRegisterEntity initServiceEntity() {
- ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();
- serviceRegisterEntity.setServiceName("holmes-rule-mgmt");
- serviceRegisterEntity.setProtocol("REST");
- serviceRegisterEntity.setVersion("v1");
- serviceRegisterEntity.setUrl("/openoapi/holmes-rule-mgmt/v1");
- serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9101", 0);
- serviceRegisterEntity.setVisualRange("1");
- return serviceRegisterEntity;
- }
}