[SECIOTSRK-681] *Add health check for server MQ: +add check dsm is running
authorm.dalakov <m.dalakov@samsung.com>
Tue, 7 Nov 2017 11:07:19 +0000 (13:07 +0200)
committerm.dalakov <m.dalakov@samsung.com>
Tue, 7 Nov 2017 11:40:14 +0000 (13:40 +0200)
cloud/account/pom.xml
cloud/interface/pom.xml
cloud/messagequeue/pom.xml
cloud/pom.xml
cloud/resourcedirectory/pom.xml
cloud/stack/pom.xml
servers/mq/src/main/java/com/samsung/servermq/ServerMQ.java

index c9ea53c..93309ab 100644 (file)
@@ -4,7 +4,7 @@
 
        <parent>
                <groupId>org.iotivity.cloud</groupId>
-               <artifactId>parent</artifactId>
+               <artifactId>parentCloud</artifactId>
                <version>0.0.1-SNAPSHOT</version>
        </parent>
 
index deb404e..fccaa49 100644 (file)
@@ -4,7 +4,7 @@
 
        <parent>
                <groupId>org.iotivity.cloud</groupId>
-               <artifactId>parent</artifactId>
+               <artifactId>parentCloud</artifactId>
                <version>0.0.1-SNAPSHOT</version>
        </parent>
 
index d5162c5..db0542e 100644 (file)
@@ -4,7 +4,7 @@
 
        <parent>
                <groupId>org.iotivity.cloud</groupId>
-               <artifactId>parent</artifactId>
+               <artifactId>parentCloud</artifactId>
                <version>0.0.1-SNAPSHOT</version>
        </parent>
 
index bc7f51b..ebe3d09 100644 (file)
@@ -6,7 +6,7 @@
     <modelVersion>4.0.0</modelVersion>
 
     <groupId>org.iotivity.cloud</groupId>
-    <artifactId>parent</artifactId>
+    <artifactId>parentCloud</artifactId>
     <packaging>pom</packaging>
     <version>0.0.1-SNAPSHOT</version>
     <name>Iotivity Parent</name>
index 2c0693c..3dc18dc 100644 (file)
@@ -4,7 +4,7 @@
 
        <parent>
                <groupId>org.iotivity.cloud</groupId>
-               <artifactId>parent</artifactId>
+               <artifactId>parentCloud</artifactId>
                <version>0.0.1-SNAPSHOT</version>
        </parent>
 
index b207625..c619f81 100644 (file)
@@ -4,7 +4,7 @@
 
        <parent>
                <groupId>org.iotivity.cloud</groupId>
-               <artifactId>parent</artifactId>
+               <artifactId>parentCloud</artifactId>
                <version>0.0.1-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
index 11fb572..b9cef01 100644 (file)
@@ -5,6 +5,8 @@
  */
 package com.samsung.servermq;
 
+import com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor;
+import org.apache.log4j.Logger;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -25,8 +27,9 @@ import static org.iotivity.cloud.util.HealthCheck.checkSocket;
  * @par LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
  * @par Copyright : (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
  */
-@PropertySource("classpath:iotivity.properties")
-
+@PropertySources({
+        @PropertySource("classpath:application.properties"),
+        @PropertySource("classpath:iotivity.properties") })
 @SpringBootApplication
 @ImportResource("classpath:root-context.xml")
 @EnableAutoConfiguration(exclude = {
@@ -38,6 +41,8 @@ public class ServerMQ {
 
     private static String zookeeperHost;
     private static String kafkaHost;
+    private static String dmsHost;
+    private static final Logger LOG = Logger.getLogger(ServerMQ.class);
 
     private static void getHosts() {
         @SuppressWarnings("resource")
@@ -46,6 +51,7 @@ public class ServerMQ {
         ctx.refresh();
         zookeeperHost = ctx.getEnvironment().getRequiredProperty("iotivity.zookeeper_host");
         kafkaHost = ctx.getEnvironment().getRequiredProperty("iotivity.kafka_host");
+        dmsHost = ctx.getEnvironment().getRequiredProperty("dsm.host").replace("http://", "");
     }
 
     /**
@@ -60,12 +66,17 @@ public class ServerMQ {
         getHosts();
         while (!checkSocket(zookeeperHost)) {
             Thread.sleep(1000);
-            System.out.println("can not connect to zookeeper...");
+            LOG.info("can not connect to zookeeper...");
         }
 
         while (!checkSocket(kafkaHost)) {
             Thread.sleep(1000);
-            System.out.println("can not connect to kafka...");
+            LOG.info("can not connect to kafka...");
+        }
+
+        while (!checkSocket(dmsHost)) {
+            Thread.sleep(1000);
+            LOG.info("can not connect to dms server...");
         }
 
         context = SpringApplication.run(ServerMQ.class, args);