\r
package org.onap.holmes.dsa.dmaap;\r
\r
+import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;\r
+\r
import io.dropwizard.setup.Environment;\r
-import java.io.IOException;\r
+import java.util.HashSet;\r
+import java.util.Set;\r
import lombok.extern.slf4j.Slf4j;\r
-import org.onap.holmes.common.api.entity.ServiceRegisterEntity;\r
import org.onap.holmes.common.config.MicroServiceConfig;\r
import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;\r
+import org.onap.holmes.common.exception.CorrelationException;\r
import org.onap.holmes.common.utils.MSBRegisterUtil;\r
+import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;\r
+import org.onap.msb.sdk.discovery.entity.Node;\r
\r
@Slf4j\r
public class DmaapDsaActiveApp extends IOCApplication<DmaapDsaConfig> {\r
@Override\r
public void run(DmaapDsaConfig configuration, Environment environment) throws Exception {\r
super.run(configuration, environment);\r
-\r
try {\r
- new MSBRegisterUtil().register(initServiceEntity());\r
- } catch (IOException e) {\r
- log.warn("Micro service registry httpclient close failure", e);\r
+ new MSBRegisterUtil().register2Msb(createMicroServiceInfo());\r
+ } catch (CorrelationException e) {\r
+ log.warn(e.getMessage(), e);\r
}\r
}\r
\r
- private ServiceRegisterEntity initServiceEntity() {\r
- ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();\r
- serviceRegisterEntity.setServiceName("holmes-dmaap-dsa");\r
- serviceRegisterEntity.setProtocol("REST");\r
- serviceRegisterEntity.setVersion("v1");\r
- serviceRegisterEntity.setUrl("/api/holmes-dmaap-dsa/v1/");\r
- serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9103", 0);\r
- serviceRegisterEntity.setVisualRange("1|0");\r
- return serviceRegisterEntity;\r
+ private MicroServiceInfo createMicroServiceInfo() {\r
+ String[] serviceAddrInfo = MicroServiceConfig.getMicroServiceIpAndPort();\r
+ MicroServiceInfo msinfo = new MicroServiceInfo();\r
+ msinfo.setServiceName("holmes-dmaap-dsa");\r
+ msinfo.setVersion("v1");\r
+ msinfo.setUrl("/api/holmes-dmaap-dsa/v1/");\r
+ msinfo.setProtocol("REST");\r
+ msinfo.setVisualRange("0|1");\r
+ Set<Node> nodes = new HashSet<>();\r
+ Node node = new Node();\r
+ node.setIp(serviceAddrInfo[0]);\r
+ node.setPort(serviceAddrInfo[1]);\r
+ nodes.add(node);\r
+ msinfo.setNodes(nodes);\r
+ return msinfo;\r
}\r
}\r