summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore19
-rw-r--r--engine-d/src/main/java/org/openo/holmes/engine/EngineDActiveApp.java29
-rw-r--r--engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java28
3 files changed, 48 insertions, 28 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..45bb734
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,19 @@
+# Ignore Vim temporary files
+.*.sw?
+
+# Ignore changes to the JJB Configuration File
+jenkins.ini
+
+# We don't want .netrc files since they're credential files
+.netrc
+
+# Maven
+target/
+dependency-reduced-pom.xml
+
+# Vagrant
+.vagrant
+
+# IntelliJ
+.idea/
+*.iml
diff --git a/engine-d/src/main/java/org/openo/holmes/engine/EngineDActiveApp.java b/engine-d/src/main/java/org/openo/holmes/engine/EngineDActiveApp.java
index 24bff21..46108be 100644
--- a/engine-d/src/main/java/org/openo/holmes/engine/EngineDActiveApp.java
+++ b/engine-d/src/main/java/org/openo/holmes/engine/EngineDActiveApp.java
@@ -15,11 +15,40 @@
*/
package org.openo.holmes.engine;
+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 EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
public static void main(String[] args) throws Exception {
new EngineDActiveApp().run(args);
}
+
+ @Override
+ public void run(EngineDAppConfig 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");
+ return serviceRegisterEntity;
+ }
}
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 194546b..5be8eb9 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,9 +19,7 @@ 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;
@@ -34,12 +32,9 @@ 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;
@@ -55,18 +50,6 @@ 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)
@@ -129,15 +112,4 @@ public class EngineResources {
}
return true;
}
-
- private ServiceRegisterEntity initServiceEntity() {
- ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();
- serviceRegisterEntity.setServiceName("holmes-engine-mgmt");
- serviceRegisterEntity.setProtocol("REST");
- serviceRegisterEntity.setVersion("v1");
- serviceRegisterEntity.setUrl("/openoapi/holmes-engine-mgmt/v1");
- serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9102", 0);
- serviceRegisterEntity.setVisualRange("1|0");
- return serviceRegisterEntity;
- }
}