2 * Copyright 2017 ZTE Corporation.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package org.onap.holmes.dsa.dmaap;
\r
19 import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
\r
21 import io.dropwizard.setup.Environment;
\r
22 import java.util.HashSet;
\r
23 import java.util.Set;
\r
24 import lombok.extern.slf4j.Slf4j;
\r
25 import org.onap.holmes.common.config.MicroServiceConfig;
\r
26 import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;
\r
27 import org.onap.holmes.common.exception.CorrelationException;
\r
28 import org.onap.holmes.common.utils.MSBRegisterUtil;
\r
29 import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
\r
30 import org.onap.msb.sdk.discovery.entity.Node;
\r
33 public class DmaapDsaActiveApp extends IOCApplication<DmaapDsaConfig> {
\r
34 public static void main(String[] args) throws Exception {
\r
35 new DmaapDsaActiveApp().run(args);
\r
39 public void run(DmaapDsaConfig configuration, Environment environment) throws Exception {
\r
40 super.run(configuration, environment);
\r
42 new MSBRegisterUtil().register2Msb(createMicroServiceInfo());
\r
43 } catch (CorrelationException e) {
\r
44 log.warn(e.getMessage(), e);
\r
48 private MicroServiceInfo createMicroServiceInfo() {
\r
49 String[] serviceAddrInfo = MicroServiceConfig.getMicroServiceIpAndPort();
\r
50 MicroServiceInfo msinfo = new MicroServiceInfo();
\r
51 msinfo.setServiceName("holmes-dmaap-dsa");
\r
52 msinfo.setVersion("v1");
\r
53 msinfo.setUrl("/api/holmes-dmaap-dsa/v1/");
\r
54 msinfo.setProtocol("REST");
\r
55 msinfo.setVisualRange("0|1");
\r
56 Set<Node> nodes = new HashSet<>();
\r
57 Node node = new Node();
\r
58 node.setIp(serviceAddrInfo[0]);
\r
59 node.setPort(serviceAddrInfo[1]);
\r
61 msinfo.setNodes(nodes);
\r