This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit 7d6073b9227c2cd1949e1e41f4371f2ca755e8d3
Author: Dimuthu Wannipurage <[email protected]>
AuthorDate: Mon Nov 2 14:47:53 2020 -0500

    Automatically creating the helix cluster if not available
---
 .../airavata/helix/impl/controller/HelixController.java   | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/controller/HelixController.java
 
b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/controller/HelixController.java
index 799b216..ee4656e 100644
--- 
a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/controller/HelixController.java
+++ 
b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/controller/HelixController.java
@@ -22,6 +22,9 @@ package org.apache.airavata.helix.impl.controller;
 import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.helix.controller.HelixControllerMain;
+import org.apache.helix.manager.zk.ZKHelixAdmin;
+import org.apache.helix.manager.zk.ZNRecordSerializer;
+import org.apache.helix.manager.zk.ZkClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -57,6 +60,18 @@ public class HelixController implements Runnable {
 
     public void run() {
         try {
+            ZkClient zkClient = new 
ZkClient(ServerSettings.getZookeeperConnection(), 
ZkClient.DEFAULT_SESSION_TIMEOUT,
+                    ZkClient.DEFAULT_CONNECTION_TIMEOUT, new 
ZNRecordSerializer());
+            ZKHelixAdmin zkHelixAdmin = new ZKHelixAdmin(zkClient);
+
+            // Creates the zk cluster if not available
+            if (! zkHelixAdmin.getClusters().contains(clusterName)) {
+                zkHelixAdmin.addCluster(clusterName, true);
+            }
+
+            zkHelixAdmin.close();
+            zkClient.close();
+
             logger.info("Connection to helix cluster : " + clusterName + " 
with name : " + controllerName);
             logger.info("Zookeeper connection string " + zkAddress);
 

Reply via email to