diff options
author | Guangrong Fu <fu.guangrong@zte.com.cn> | 2017-09-03 00:41:28 +0800 |
---|---|---|
committer | Guangrong Fu <fu.guangrong@zte.com.cn> | 2017-09-03 00:41:28 +0800 |
commit | 12d40aa626418ba2f0880fd335c1c3f9fa953038 (patch) | |
tree | 7df07cdaaa16f551c6878881c5b9c3ad58e67cf2 /engine-d/src/main/java | |
parent | b6c40da70021a19b9915ea79f28b88035185d1df (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>
Diffstat (limited to 'engine-d/src/main/java')
-rw-r--r-- | engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java | 43 |
1 files changed, 27 insertions, 16 deletions
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; } } |