2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.holmes.rulemgt.msb;
19 import org.apache.http.HttpResponse;
20 import org.jvnet.hk2.annotations.Service;
21 import org.onap.holmes.common.api.entity.ServiceEntity;
22 import org.onap.holmes.common.api.entity.ServiceNode4Query;
23 import org.onap.holmes.common.config.MicroServiceConfig;
24 import org.onap.holmes.common.utils.GsonUtil;
25 import org.onap.holmes.common.utils.HttpsUtils;
27 import javax.annotation.PostConstruct;
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.List;
33 public class EngineIpList {
35 private String[] msbAddrInfo;
42 msbAddrInfo = MicroServiceConfig.getMsbIpAndPort();
44 port = msbAddrInfo[1];
45 url = "http://" + ip + ":" + port + "/api/microservices/v1/services/holmes-engine-mgmt/version/v1" ;
48 public List<String> getServiceCount()throws Exception{
51 HttpResponse httpResponse = HttpsUtils
52 .get(url, new HashMap<>());
53 response = HttpsUtils.extractResponseEntity(httpResponse);
54 } catch (Exception e) {
57 ServiceEntity service = GsonUtil.jsonToBean(response, ServiceEntity.class);
58 List<ServiceNode4Query> nodesList = service.getNodes();
59 List<String> ipList = new ArrayList<>();
60 for(ServiceNode4Query node : nodesList){
61 ipList.add(node.getIp());