summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2017-09-03 00:41:28 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2017-09-03 00:41:28 +0800
commit12d40aa626418ba2f0880fd335c1c3f9fa953038 (patch)
tree7df07cdaaa16f551c6878881c5b9c3ad58e67cf2
parentb6c40da70021a19b9915ea79f28b88035185d1df (diff)
Introduce MSB Java SDK
Regiser the services using MSB Java SDK Change-Id: I2aa89fdcc243e49de48ec0ebd39d80579ec22ea6 Issue-ID: HOLMES-48 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
-rw-r--r--engine-d/pom.xml8
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java43
-rw-r--r--pom.xml11
3 files changed, 46 insertions, 16 deletions
diff --git a/engine-d/pom.xml b/engine-d/pom.xml
index 44ae940..0a7c3eb 100644
--- a/engine-d/pom.xml
+++ b/engine-d/pom.xml
@@ -35,6 +35,10 @@
<dependencies>
<dependency>
+ <groupId>org.onap.msb.java-sdk</groupId>
+ <artifactId>msb-java-sdk</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
</dependency>
@@ -152,6 +156,10 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
index ef671e3..f8c2660 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
@@ -15,13 +15,19 @@
*/
package org.onap.holmes.engine;
+import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
+
import io.dropwizard.setup.Environment;
-import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
import lombok.extern.slf4j.Slf4j;
-import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;
-import org.onap.holmes.common.api.entity.ServiceRegisterEntity;
import org.onap.holmes.common.config.MicroServiceConfig;
+import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;
+import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.MSBRegisterUtil;
+import org.onap.holmes.engine.resources.EngineResources;
+import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
+import org.onap.msb.sdk.discovery.entity.Node;
@Slf4j
public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
@@ -30,25 +36,30 @@ public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
new EngineDActiveApp().run(args);
}
- @Override
public void run(EngineDAppConfig configuration, Environment environment) throws Exception {
super.run(configuration, environment);
+ environment.jersey().register(new EngineResources());
try {
- new MSBRegisterUtil().register(initServiceEntity());
- } catch (IOException e) {
- log.warn("Micro service registry httpclient close failure", e);
+ new MSBRegisterUtil().register2Msb(createMicroServiceInfo());
+ } catch (CorrelationException e) {
+ log.warn(e.getMessage(), e);
}
}
- private ServiceRegisterEntity initServiceEntity() {
- ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();
- serviceRegisterEntity.setServiceName("holmes-engine-mgmt");
- serviceRegisterEntity.setProtocol("REST");
- serviceRegisterEntity.setVersion("v1");
- serviceRegisterEntity.setUrl("/onapapi/holmes-engine-mgmt/v1");
- serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9102", 0);
- serviceRegisterEntity.setVisualRange("1|0");
- return serviceRegisterEntity;
+ private MicroServiceInfo createMicroServiceInfo() {
+ MicroServiceInfo msinfo = new MicroServiceInfo();
+ msinfo.setServiceName("holmes-engine-mgmt");
+ msinfo.setVersion("v1");
+ msinfo.setUrl("/onapapi/holmes-engine-mgmt/v1");
+ msinfo.setProtocol("REST");
+ msinfo.setVisualRange("0|1");
+ Set<Node> nodes = new HashSet<>();
+ Node node = new Node();
+ node.setIp(MicroServiceConfig.getServiceIp());
+ node.setPort("9102");
+ nodes.add(node);
+ msinfo.setNodes(nodes);
+ return msinfo;
}
}
diff --git a/pom.xml b/pom.xml
index 554ab3b..74af517 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,6 +68,11 @@
<dependencyManagement>
<dependencies>
<dependency>
+ <groupId>org.onap.msb.java-sdk</groupId>
+ <artifactId>msb-java-sdk</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>${reflections.version}</version>
@@ -156,6 +161,12 @@
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>19.0</version>
+ </dependency>
</dependencies>
</dependencyManagement>
</project>