Upgraded to Java 11
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / utils / MSBRegisterUtil.java
index 8052f78..a849ab8 100644 (file)
@@ -1,12 +1,12 @@
 /**\r
- * Copyright 2017 ZTE Corporation.\r
- *\r
+ * Copyright 2017-2020 ZTE Corporation.\r
+ * <p>\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
+ * <p>\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * <p>\r
  * Unless required by applicable law or agreed to in writing, software\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 \r
 package org.onap.holmes.common.utils;\r
 \r
-import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;\r
-\r
-import com.eclipsesource.jaxrs.consumer.ConsumerFactory;\r
-import java.io.IOException;\r
 import lombok.extern.slf4j.Slf4j;\r
 import org.jvnet.hk2.annotations.Service;\r
-import org.onap.holmes.common.api.entity.ServiceRegisterEntity;\r
 import org.onap.holmes.common.config.MicroServiceConfig;\r
 import org.onap.holmes.common.exception.CorrelationException;\r
-import org.onap.holmes.common.msb.MicroserviceBusRest;\r
 import org.onap.msb.sdk.discovery.common.RouteException;\r
 import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;\r
 import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;\r
@@ -35,44 +29,12 @@ import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
 @Service\r
 public class MSBRegisterUtil {\r
 \r
-    public void register(ServiceRegisterEntity entity) throws IOException {\r
-        log.info("Start register Holmes Service to MSB...");\r
-        boolean flag = false;\r
-        int retry = 0;\r
-        while (!flag && retry < 20) {\r
-            log.info("Holmes Service Registration. Retry: " + retry);\r
-            retry++;\r
-            flag = innerRegister(entity);\r
-            if (!flag) {\r
-                log.warn("Failed to register the service to MSB. Sleep 30s and try again.");\r
-                threadSleep(30000);\r
-            } else {\r
-                log.info("Registration succeeded!");\r
-                break;\r
-            }\r
-        }\r
-        log.info("Service registration completed.");\r
-    }\r
-\r
-    private boolean innerRegister(ServiceRegisterEntity entity) {\r
-        try {\r
-            log.info("msbServerAddr:" + MicroServiceConfig.getMsbServerAddr());\r
-            log.info("entity:" + entity);\r
-            MicroserviceBusRest resourceserviceproxy = ConsumerFactory.createConsumer(\r
-                    MicroServiceConfig.getMsbServerAddr(), MicroserviceBusRest.class);\r
-            resourceserviceproxy.registerServce("false", entity);\r
-        } catch (Exception error) {\r
-            log.error("Micro-service registration failed!" + error.getMessage(), error);\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
     public void register2Msb(MicroServiceInfo msinfo) throws CorrelationException {\r
-        MSBServiceClient msbClient = new MSBServiceClient(MicroServiceConfig.getMsbServerIp(),\r
-                MicroServiceConfig.getMsbServerPort());\r
+        String[] msbAddrInfo = MicroServiceConfig.getMsbIpAndPort();\r
+        MSBServiceClient msbClient = new MSBServiceClient(msbAddrInfo[0],\r
+                Integer.parseInt(msbAddrInfo[1]));\r
 \r
-        log.info("Start register Holmes Service to MSB...");\r
+        log.info("Start to register Holmes Service to MSB...");\r
         MicroServiceFullInfo microServiceFullInfo = null;\r
         int retry = 0;\r
         while (null == microServiceFullInfo && retry < 20) {\r