airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [12/50] [abbrv] airavata git commit: Stop registry-server if db-event handlers fail to start
Date Wed, 05 Apr 2017 19:10:36 GMT
Stop registry-server if db-event handlers fail to start


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/c14db595
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/c14db595
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/c14db595

Branch: refs/heads/develop
Commit: c14db5955e3fb9d8e190d02f48c15adf87e0d376
Parents: 030468d
Author: Gourav Shenoy <shenoy.200@gmail.com>
Authored: Mon Apr 3 16:08:59 2017 -0400
Committer: Gourav Shenoy <shenoy.200@gmail.com>
Committed: Mon Apr 3 16:08:59 2017 -0400

----------------------------------------------------------------------
 .../registry/api/service/RegistryAPIServer.java | 29 +++++++++++++++-----
 1 file changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/c14db595/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/RegistryAPIServer.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/RegistryAPIServer.java
b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/RegistryAPIServer.java
index 991ace2..04bcdd4 100644
--- a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/RegistryAPIServer.java
+++ b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/RegistryAPIServer.java
@@ -20,6 +20,7 @@
 */
 package org.apache.airavata.registry.api.service;
 
+import org.apache.airavata.common.exception.AiravataException;
 import org.apache.airavata.common.utils.IServer;
 import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.registry.api.RegistryService;
@@ -79,13 +80,6 @@ public class RegistryAPIServer implements IServer {
                 serverTransport = new TServerSocket(inetSocketAddress);
             }
 
-            // db-event handlers
-            logger.info("Registring registry service with publishers for db-events.");
-            RegistryServiceDBEventMessagingFactory.registerRegistryServiceWithPublishers(Constants.DB_EVENT_SUBSCRIBERS);
-
-            logger.info("Starting registry service db-event-handler subscriber.");
-            RegistryServiceDBEventMessagingFactory.getDBEventSubscriber();
-
             // thrift server start
             TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
             options.minWorkerThreads = Integer.parseInt(ServerSettings.getSetting(Constants.REGISTRY_SERVER_MIN_THREADS,
"30"));
@@ -109,6 +103,12 @@ public class RegistryAPIServer implements IServer {
                     if (server.isServing()){
                         setStatus(ServerStatus.STARTED);
                         logger.info("Started Registry Server on Port " + serverPort + " ...");
+
+                        // start db event handlers
+                        if (!startDatabaseEventHandlers()) {
+                            logger.error("Stopping Registry Server as DB event handlers failed
to start!");
+                            server.stop();
+                        }
                     }
                 }
             }.start();
@@ -119,6 +119,21 @@ public class RegistryAPIServer implements IServer {
         }
     }
 
+    private boolean startDatabaseEventHandlers() {
+        try {
+            // db-event handlers
+            logger.info("Registring registry service with publishers for db-events.");
+            RegistryServiceDBEventMessagingFactory.registerRegistryServiceWithPublishers(Constants.DB_EVENT_SUBSCRIBERS);
+
+            logger.info("Starting registry service db-event-handler subscriber.");
+            RegistryServiceDBEventMessagingFactory.getDBEventSubscriber();
+        } catch (Exception ex) {
+            logger.error("Failed to start database event handlers, reason: " + ex.getMessage(),
ex);
+            return false;
+        }
+        return true;
+    }
+
     public static void main(String[] args) {
         try {
             new RegistryAPIServer().start();


Mime
View raw message