airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject git commit: adding zk in embedded mode
Date Tue, 29 Jul 2014 17:30:34 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 1a2411d2e -> aef99c061


adding zk in embedded mode


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

Branch: refs/heads/master
Commit: aef99c061ec1b2f61f3d99f27182a43897f2ec2e
Parents: 1a2411d
Author: lahiru <lahiru@apache.org>
Authored: Tue Jul 29 13:30:18 2014 -0400
Committer: lahiru <lahiru@apache.org>
Committed: Tue Jul 29 13:30:18 2014 -0400

----------------------------------------------------------------------
 .../client/samples/CreateLaunchExperiment.java  |   4 +-
 .../airavata/common/utils/ServerSettings.java   |   4 +
 .../main/resources/airavata-server.properties   |   2 +-
 .../server/src/main/resources/zoo.cfg           |   5 +
 .../server/src/main/assembly/bin-assembly.xml   |   1 +
 .../airavata/gfac/server/GfacServerHandler.java |  75 ++-
 .../gfac/ssh/security/TokenizedSSHAuthInfo.java |   2 +-
 .../gfac/services/impl/CredentialStoreTest.java |  36 +-
 modules/gfac/pom.xml                            |   1 +
 .../integration-tests/tomcat-distribution.iml   | 656 -------------------
 modules/server/pom.xml                          |   7 +-
 .../org/apache/airavata/server/ServerMain.java  |  91 ++-
 12 files changed, 161 insertions(+), 723 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
index 8d006ef..f00dc31 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
@@ -82,10 +82,10 @@ public class CreateLaunchExperiment {
 ////            final String expId = createExperimentForSSHHost(airavata);
 ////            final String expId = createExperimentForTrestles(client);
 ////            final String expId = createExperimentForStampede(client);
-//            final String expId = createExperimentForLocalHost(client);
+            final String expId = createExperimentForLocalHost(client);
 //            final String expId = createExperimentForLonestar(airavata);
 //            final String expId = createExperimentWRFTrestles(client);
-            final String expId = createExperimentForBR2(client);
+//            final String expId = createExperimentForBR2(client);
 //            final String expId = createExperimentForBR2Amber(client);
 //            final String expId = createExperimentWRFStampede(client);
 //            final String expId = createExperimentForStampedeAmber(client);

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
index 71e1437..93f3bc3 100644
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
+++ b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
@@ -48,6 +48,7 @@ public class ServerSettings extends ApplicationSettings{
     
     private static final String TOMCAT_PORT = "port";
     private static final String SERVER_CONTEXT_ROOT="server.context-root";
+    public static final String EMBEDDED_ZK = "embedded.zk";
     private static String tomcatPort=null;
 
     private static final String CREDENTIAL_STORE_DB_URL ="credential.store.jdbc.url";
@@ -218,4 +219,7 @@ public class ServerSettings extends ApplicationSettings{
     public static String[] getActivityListeners() throws ApplicationSettingsException {
         return getSetting(ACTIVITY_LISTENERS).split(",");
     }
+    public static boolean isEmbeddedZK() {
+        return Boolean.parseBoolean(getSetting(EMBEDDED_ZK, "true"));
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/configuration/server/src/main/resources/airavata-server.properties
----------------------------------------------------------------------
diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties
index fbde207..743372d 100644
--- a/modules/configuration/server/src/main/resources/airavata-server.properties
+++ b/modules/configuration/server/src/main/resources/airavata-server.properties
@@ -247,7 +247,7 @@ gfac.server.port=8950
 orchestrator.server.min.threads=50
 
 ##----------------------------- Zookeeper Server Configurations ----------------------###
-
+embedded.zk=true
 zookeeper.server.host=localhost
 zookeeper.server.port=2181
 airavata-server=/api-server

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/configuration/server/src/main/resources/zoo.cfg
----------------------------------------------------------------------
diff --git a/modules/configuration/server/src/main/resources/zoo.cfg b/modules/configuration/server/src/main/resources/zoo.cfg
new file mode 100644
index 0000000..5a9ebe9
--- /dev/null
+++ b/modules/configuration/server/src/main/resources/zoo.cfg
@@ -0,0 +1,5 @@
+tickTime=2000
+initLimit=10
+syncLimit=5
+dataDir=data
+clientPort=2181

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/distribution/server/src/main/assembly/bin-assembly.xml
----------------------------------------------------------------------
diff --git a/modules/distribution/server/src/main/assembly/bin-assembly.xml b/modules/distribution/server/src/main/assembly/bin-assembly.xml
index 75f941d..e84d7b9 100644
--- a/modules/distribution/server/src/main/assembly/bin-assembly.xml
+++ b/modules/distribution/server/src/main/assembly/bin-assembly.xml
@@ -106,6 +106,7 @@
             <outputDirectory>bin</outputDirectory>
             <includes>
                 <include>airavata-server.properties</include>
+		<include>zoo.cfg</include>
                 <include>registry.properties</include>
                 <include>log4j.properties</include>
                 <include>host.xml</include>

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java b/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
index 6f3247c..b098120 100644
--- a/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
+++ b/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
@@ -73,47 +73,26 @@ public class GfacServerHandler implements GfacService.Iface, Watcher{
 
     private MonitorPublisher publisher;
 
+    private String gfacServer;
+
+    private String gfacExperiments;
+
+    private String airavataServerHostPort;
 
     public GfacServerHandler() {
         // registering with zk
         try {
             String zkhostPort = AiravataZKUtils.getZKhostPort();
-            String airavataServerHostPort = ServerSettings.getSetting(Constants.GFAC_SERVER_HOST)
+            airavataServerHostPort = ServerSettings.getSetting(Constants.GFAC_SERVER_HOST)
                     + ":" + ServerSettings.getSetting(Constants.GFAC_SERVER_PORT);
             try {
                 zk = new ZooKeeper(zkhostPort, 6000, this);   // no watcher is required, this will only use to store some data
-                String gfacServer = ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NODE,"/gfac-server");
-                String gfacExperiments = ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE,"/gfac-experiments");
+                gfacServer = ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NODE,"/gfac-server");
+                gfacExperiments = ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE,"/gfac-experiments");
                 synchronized(mutex){
                     mutex.wait();  // waiting for the syncConnected event
                 }
-                Stat zkStat = zk.exists(gfacServer, false);
-                if (zkStat == null) {
-                    zk.create(gfacServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE,
-                            CreateMode.PERSISTENT);
-                }
-                String instanceId = ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME);
-                String instantNode = gfacServer + File.separator + instanceId;
-                zkStat = zk.exists(instantNode, false);
-                if (zkStat == null) {
-                    zk.create(instantNode,
-                            airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
-                            CreateMode.EPHEMERAL);      // other component will watch these childeren creation deletion to monitor the status of the node
-                }
-                zkStat = zk.exists(gfacExperiments, false);
-                if (zkStat == null) {
-                    zk.create(gfacExperiments,
-                            airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
-                            CreateMode.PERSISTENT);
-                }
-                zkStat = zk.exists(gfacExperiments + File.separator + instanceId, false);
-                if (zkStat == null) {
-                    zk.create(gfacExperiments + File.separator + instanceId,
-                            airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
-                            CreateMode.PERSISTENT);
-                }else{
-                    logger.error(" Zookeeper is inconsistent state  !!!!!");
-                }
+                storeServerConfig();
                 logger.info("Finished starting ZK: " + zk);
             } catch (IOException e) {
                 e.printStackTrace();
@@ -137,9 +116,40 @@ public class GfacServerHandler implements GfacService.Iface, Watcher{
         }
     }
 
+    private void storeServerConfig() throws KeeperException, InterruptedException, ApplicationSettingsException {
+        Stat zkStat = zk.exists(gfacServer, false);
+        if (zkStat == null) {
+            zk.create(gfacServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE,
+                    CreateMode.PERSISTENT);
+        }
+        String instanceId = ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME);
+        String instantNode = gfacServer + File.separator + instanceId;
+        zkStat = zk.exists(instantNode, false);
+        if (zkStat == null) {
+            zk.create(instantNode,
+                    airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
+                    CreateMode.EPHEMERAL);      // other component will watch these childeren creation deletion to monitor the status of the node
+        }
+        zkStat = zk.exists(gfacExperiments, false);
+        if (zkStat == null) {
+            zk.create(gfacExperiments,
+                    airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
+                    CreateMode.PERSISTENT);
+        }
+        zkStat = zk.exists(gfacExperiments + File.separator + instanceId, false);
+        if (zkStat == null) {
+            zk.create(gfacExperiments + File.separator + instanceId,
+                    airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
+                    CreateMode.PERSISTENT);
+        }else{
+            logger.error(" Zookeeper is inconsistent state  !!!!!");
+        }
+    }
+
     synchronized public void process(WatchedEvent watchedEvent) {
         synchronized (mutex) {
             Event.KeeperState state = watchedEvent.getState();
+            logger.info(state.name());
             if (state == Event.KeeperState.SyncConnected) {
                 mutex.notify();
                 connected = true;
@@ -147,10 +157,15 @@ public class GfacServerHandler implements GfacService.Iface, Watcher{
                     state == Event.KeeperState.Disconnected){
                 try {
                     zk = new ZooKeeper(AiravataZKUtils.getZKhostPort(),6000,this);
+                    storeServerConfig();
                 } catch (IOException e) {
                     e.printStackTrace();
                 } catch (ApplicationSettingsException e) {
                     e.printStackTrace();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                } catch (KeeperException e) {
+                    e.printStackTrace();
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/security/TokenizedSSHAuthInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/security/TokenizedSSHAuthInfo.java b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/security/TokenizedSSHAuthInfo.java
index afa43f5..9e3fc58 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/security/TokenizedSSHAuthInfo.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/security/TokenizedSSHAuthInfo.java
@@ -84,7 +84,7 @@ public class TokenizedSSHAuthInfo implements SSHPublicKeyFileAuthentication {
                 gssCredentials = getCredentialsFromStore();
             } catch (Exception e) {
                 log.error("An exception occurred while retrieving credentials from the credential store. " +
-                        "Will continue with my proxy user name and password. Provided TokenId:" + requestData.getTokenId(), e);
+                        "Will continue with my proxy user name and password. Provided TokenId:" + requestData.getTokenId() + e.getMessage(), e);
             }
 
             if (gssCredentials == null) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/gfac/gfac-ssh/src/test/java/org/apache/airavata/core/gfac/services/impl/CredentialStoreTest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/test/java/org/apache/airavata/core/gfac/services/impl/CredentialStoreTest.java b/modules/gfac/gfac-ssh/src/test/java/org/apache/airavata/core/gfac/services/impl/CredentialStoreTest.java
index 5398885..8b3653a 100644
--- a/modules/gfac/gfac-ssh/src/test/java/org/apache/airavata/core/gfac/services/impl/CredentialStoreTest.java
+++ b/modules/gfac/gfac-ssh/src/test/java/org/apache/airavata/core/gfac/services/impl/CredentialStoreTest.java
@@ -65,46 +65,36 @@ public class CredentialStoreTest {
         System.setProperty("myproxy.username", "ogce");
         System.setProperty("myproxy.password", "OpenGwy14");
         System.setProperty("trusted.cert.location", "/Users/lahirugunathilake/Downloads/certificates");
-        System.setProperty("credential.store.jdbc.url","jdbc:mysql://gw85.iu.xsede.org:3306/airavata_pga_prod");
-        System.setProperty("credential.store.jdbc.user","pgaAiravataUser");
-        System.setProperty("credential.store.jdbc.password","pgaAiravataPWD");
+        System.setProperty("credential.store.jdbc.url","jdbc:mysql://gw85.iu.xsede.org:3306/airavata_gta_prod");
+        System.setProperty("credential.store.jdbc.user","gtaAiravataUser");
+        System.setProperty("credential.store.jdbc.password","gtaAiravataPWD");
         System.setProperty("credential.store.jdbc.driver","com.mysql.jdbc.Driver");
 
 
-        try {
-            AiravataRegistry2 registry = AiravataRegistryFactory.getRegistry(new Gateway("default"),
-                    new AiravataUser("admin"));
+
             UUID uuid = UUID.randomUUID();
             System.out.println("TokenId: " + uuid.toString());
-            String publicKey = registry.createCredential("default",uuid.toString(),"lginnali" );
-            System.out.println("Public-Key: " +publicKey);
-            String tokenId = uuid.toString();
-//            String tokenId = "2c308fa9-99f8-4baa-92e4-d062e311483c";
-            CredentialReader credentialReader = new CredentialReaderImpl(new DBUtil("jdbc:mysql://gw85.iu.xsede.org:3306/airavata_pga_prod",
-                    "pgaAiravataUser", "pgaAiravataPWD", "com.mysql.jdbc.Driver"));
+//            String publicKey = registry.createCredential("default",uuid.toString(),"lginnali" );
+//            System.out.println("Public-Key: " +publicKey);
+//            String tokenId = uuid.toString();
+            String tokenId = "2c308fa9-99f8-4baa-92e4-d062e311483c";
+            CredentialReader credentialReader = new CredentialReaderImpl(new DBUtil("jdbc:mysql://gw85.iu.xsede.org:3306/airavata_gta_prod",
+                    "ptaAiravataUser", "ptaAiravataPWD", "com.mysql.jdbc.Driver"));
 
 
             RequestData requestData = new RequestData();
-            requestData.setMyProxyUserName("lginnali");
+            requestData.setMyProxyUserName("cgateway");
             requestData.setTokenId(tokenId);
             requestData.setGatewayId("default");
             TokenizedSSHAuthInfo tokenizedSSHAuthInfo = new TokenizedSSHAuthInfo(credentialReader, requestData);
 
             SSHCredential credentials = tokenizedSSHAuthInfo.getCredentials();
-            ServerInfo serverInfo = new ServerInfo("lginnali", "bigred2.uits.iu.edu");
+            ServerInfo serverInfo = new ServerInfo("cgateway", "bigred2.uits.iu.edu");
 
             PBSCluster pbsCluster = new PBSCluster(serverInfo, tokenizedSSHAuthInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
             Assert.assertNotNull(pbsCluster);
             return;
-        } catch (RegAccessorInvalidException e) {
-            e.printStackTrace();
-        } catch (RegAccessorInstantiateException e) {
-            e.printStackTrace();
-        } catch (RegException e) {
-            e.printStackTrace();
-        } catch (AiravataConfigurationException e) {
-            e.printStackTrace();
-        }
+
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/gfac/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/pom.xml b/modules/gfac/pom.xml
index 9454661..ed3e27d 100644
--- a/modules/gfac/pom.xml
+++ b/modules/gfac/pom.xml
@@ -17,6 +17,7 @@
         <relativePath>../../pom.xml</relativePath>
     </parent>
 
+
     <modelVersion>4.0.0</modelVersion>
     <artifactId>gfac</artifactId>
     <packaging>pom</packaging>

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/integration-tests/tomcat-distribution.iml
----------------------------------------------------------------------
diff --git a/modules/integration-tests/tomcat-distribution.iml b/modules/integration-tests/tomcat-distribution.iml
deleted file mode 100644
index 55aff36..0000000
--- a/modules/integration-tests/tomcat-distribution.iml
+++ /dev/null
@@ -1,656 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more
-    contributor license agreements. See the NOTICE file ~ distributed with this
-    work for additional information ~ regarding copyright ownership. The ASF
-    licenses this file ~ to you under the Apache License, Version 2.0 (the ~
-    "License"); you may not use this file except in compliance ~ with the License.
-    You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0
-    ~ ~ Unless required by applicable law or agreed to in writing, ~ software
-    distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT
-    WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the
-    License for the ~ specific language governing permissions and limitations
-    ~ under the License. -->
-
-<module relativePaths="false" type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="false">
-    <output url="file://$MODULE_DIR$/target/classes" />
-    <output-test url="file://$MODULE_DIR$/target/test-classes" />
-    <exclude-output />
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/target/maven-shared-archive-resources" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/target/maven-shared-archive-resources" isTestSource="true" />
-      <excludeFolder url="file://$MODULE_DIR$/target/antrun" />
-      <excludeFolder url="file://$MODULE_DIR$/target/classes" />
-      <excludeFolder url="file://$MODULE_DIR$/target/dependency-maven-plugin-markers" />
-      <excludeFolder url="file://$MODULE_DIR$/target/failsafe-reports" />
-      <excludeFolder url="file://$MODULE_DIR$/target/generated-sources" />
-      <excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" />
-      <excludeFolder url="file://$MODULE_DIR$/target/surefire" />
-      <excludeFolder url="file://$MODULE_DIR$/target/surefire-reports" />
-      <excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
-      <excludeFolder url="file://$MODULE_DIR$/target/tests" />
-    </content>
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="module" module-name="airavata-client-api" />
-    <orderEntry type="module" module-name="airavata-registry-api" />
-    <orderEntry type="module" module-name="airavata-gfac-schema-utils" />
-    <orderEntry type="module" module-name="airavata-common-utils" />
-    <orderEntry type="module" module-name="airavata-message-monitor" />
-    <orderEntry type="module" module-name="airavata-workflow-model-core" />
-    <orderEntry type="module" module-name="airavata-workflow-tracking" />
-    <orderEntry type="module" module-name="airavata-messenger-client" />
-    <orderEntry type="module" module-name="airavata-messenger-commons" />
-    <orderEntry type="module" module-name="airavata-workflow-execution-context" />
-    <orderEntry type="module" module-name="airavata-workflow-model-component" />
-    <orderEntry type="module" module-name="airavata-message-broker" />
-    <orderEntry type="module" module-name="airavata-gfac-core" />
-    <orderEntry type="module" module-name="airavata-message-box" />
-    <orderEntry type="module" module-name="airavata-xbaya-gui" />
-    <orderEntry type="module" module-name="airavata-jpa-registry" />
-    <orderEntry type="module" module-name="airavata-gfac-axis2-interface" />
-    <orderEntry type="module" module-name="airavata-rest-mappings" />
-    <orderEntry type="module" module-name="airavata-rest-client" />
-    <orderEntry type="module" module-name="airavata-registry-service" />
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/xmlbeans/xbean/2.5.0/xbean-2.5.0.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/wsdl4j/wsdl4j/1.5.2/wsdl4j-1.5.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/xml-apis/xml-apis/1.3.04/xml-apis-1.3.04.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/xmlbeans/xmlbeans/2.5.0/xmlbeans-2.5.0.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/stax/stax-api/1.0.1/stax-api-1.0.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/xpp5/xpp5/1.2.6/xpp5-1.2.6.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/xsul/xsul/2.10.5_d/xsul-2.10.5_d.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/xsul5-ogce/xsul5-2007-02-27/1/xsul5-2007-02-27-1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/axis2/axis2-kernel/1.5.1/axis2-kernel-1.5.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/ws/commons/axiom/axiom-api/1.2.8/axiom-api-1.2.8.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.0.1/geronimo-activation_1.1_spec-1.0.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.2/geronimo-javamail_1.4_spec-1.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/jaxen/jaxen/1.1.1/jaxen-1.1.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/ws/commons/axiom/axiom-impl/1.2.8/axiom-impl-1.2.8.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/woodstox/wstx-asl/3.2.4/wstx-asl-3.2.4.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/ws/commons/axiom/axiom-dom/1.2.8/axiom-dom-1.2.8.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/geronimo/specs/geronimo-ws-metadata_2.0_spec/1.1.2/geronimo-ws-metadata_2.0_spec-1.1.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1/geronimo-jta_1.1_spec-1.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.2/commons-codec-1.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/commons-fileupload/commons-fileupload/1.2/commons-fileupload-1.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/ws/commons/schema/XmlSchema/1.4.3/XmlSchema-1.4.3.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/neethi/neethi/2.0.4/neethi-2.0.4.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/woden/woden-api/1.0M8/woden-api-1.0M8.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/ant/ant/1.7.0/ant-1.7.0.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/xerces/xmlParserAPIs/2.6.0/xmlParserAPIs-2.6.0.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/woden/woden-impl-dom/1.0M8/woden-impl-dom-1.0M8.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/javax/mail/mail/1.4/mail-1.4.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/javax/activation/activation/1.1/activation-1.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/xalan/xalan/2.7.0/xalan-2.7.0.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/1.4/commons-io-1.4.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/gpel/gpel_client/1.0.7-BETA/gpel_client-1.0.7-BETA.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.7/junit-4.7.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/slf4j/jcl-over-slf4j/1.7.2/jcl-over-slf4j-1.7.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-log4j12/1.7.2/slf4j-log4j12-1.7.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.17/log4j-1.2.17.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/atomixmiser/atomixmiser/0.9.4/atomixmiser-0.9.4.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/edu/berkeley/yfilter/1.0/yfilter-1.0.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/axis2/axis2-transport-http/1.5.1/axis2-transport-http-1.5.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.0/httpcore-4.0.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/axis2/axis2-transport-local/1.5.1/axis2-transport-local-1.5.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/axis2/axis2-codegen/1.5.1/axis2-codegen-1.5.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/axis2/axis2-adb/1.5.1/axis2-adb-1.5.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/axis2/axis2-adb-codegen/1.5.1/axis2-adb-codegen-1.5.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/javax/jcr/jcr/2.0/jcr-2.0.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-json/1.13/jersey-json-1.13.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/jettison/jettison/1.1/jettison-1.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-impl-2.2.3-1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/javax/xml/bind/jaxb-api/2.2.2/jaxb-api-2.2.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/jackson/jackson-core-asl/1.9.2/jackson-core-asl-1.9.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/jackson/jackson-mapper-asl/1.9.2/jackson-mapper-asl-1.9.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/jackson/jackson-jaxrs/1.9.2/jackson-jaxrs-1.9.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/jackson/jackson-xc/1.9.2/jackson-xc-1.9.2.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-core/1.13/jersey-core-1.13.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-client/1.13/jersey-client-1.13.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-  </component>
-</module>
-

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/server/pom.xml
----------------------------------------------------------------------
diff --git a/modules/server/pom.xml b/modules/server/pom.xml
index dba1472..c09d6ec 100644
--- a/modules/server/pom.xml
+++ b/modules/server/pom.xml
@@ -50,10 +50,15 @@
             <artifactId>airavata-api-server</artifactId>
             <version>${project.version}</version>
         </dependency>
-	<dependency>
+	    <dependency>
             <groupId>org.apache.airavata</groupId>
             <artifactId>airavata-server-configuration</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.zookeeper</groupId>
+            <artifactId>zookeeper</artifactId>
+            <version>3.4.0</version>
+        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/airavata/blob/aef99c06/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java b/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java
index 1f14e8d..03787af 100644
--- a/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java
+++ b/modules/server/src/main/java/org/apache/airavata/server/ServerMain.java
@@ -24,6 +24,7 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -36,6 +37,11 @@ import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.common.utils.StringUtil;
 import org.apache.airavata.common.utils.StringUtil.CommandLineParameters;
 import org.apache.commons.cli.ParseException;
+import org.apache.zookeeper.server.ServerCnxnFactory;
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,6 +56,7 @@ public class ServerMain {
 	private static boolean systemShutDown=false;
 	private static String STOP_COMMAND_STR = "stop";
 
+    private static ServerCnxnFactory cnxnFactory;
 //	private static boolean shutdownHookCalledBefore=false;
     static{
 		servers = new ArrayList<IServer>();
@@ -118,16 +125,79 @@ public class ServerMain {
 //		if (true){
 //			return;
 //		}
-		
-		AiravataUtils.setExecutionAsServer();
-		CommandLineParameters commandLineParameters = StringUtil.getCommandLineParser(args);
-		if (commandLineParameters.getArguments().contains(STOP_COMMAND_STR)){
-			performServerStopRequest(commandLineParameters);
-		}else{
-			performServerStart(args);
+
+        AiravataUtils.setExecutionAsServer();
+        CommandLineParameters commandLineParameters = StringUtil.getCommandLineParser(args);
+        if (commandLineParameters.getArguments().contains(STOP_COMMAND_STR)){
+            performServerStopRequest(commandLineParameters);
+        }else{
+            if (ServerSettings.isEmbeddedZK()) {
+                ServerConfig serverConfig = new ServerConfig();
+                URL resource = ServerMain.class.getClassLoader().getResource("zoo.cfg");
+                if (resource == null) {
+                    logger.error("There is no zoo.cfg file in the classpath... Failed to start Zookeeper Server");
+                    System.exit(1);
+                }
+                try {
+                    serverConfig.parse(resource.getPath());
+                } catch (QuorumPeerConfig.ConfigException e) {
+                    logger.error("Error while starting embedded Zookeeper", e);
+                    System.exit(2);
+                }
+
+                final ServerConfig fServerConfig = serverConfig;
+                (new Thread() {
+                    public void run() {
+                        try {
+                            runZKFromConfig(fServerConfig);
+                        } catch (IOException e) {
+                            logger.error("Error while starting embedded Zookeeper", e);
+                            System.exit(3);
+                        }
+                    }
+                }).start();
+            }else{
+                logger.info("Skipping Zookeeper embedded startup ...");
+            }
+            performServerStart(args);
 		}
-	}
 
+    }
+
+    private static void runZKFromConfig(ServerConfig config) throws IOException {
+        logger.info("Starting Zookeeper server...");
+        FileTxnSnapLog txnLog = null;
+        try {
+            // Note that this thread isn't going to be doing anything else,
+            // so rather than spawning another thread, we will just call
+            // run() in this thread.
+            // create a file logger url from the command line args
+            ZooKeeperServer zkServer = new ZooKeeperServer();
+
+            txnLog = new FileTxnSnapLog(new File(config.getDataDir()), new File(
+                    config.getDataDir()));
+            zkServer.setTxnLogFactory(txnLog);
+            zkServer.setTickTime(config.getTickTime());
+            zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
+            zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
+            cnxnFactory = ServerCnxnFactory.createFactory();
+            cnxnFactory.configure(config.getClientPortAddress(),
+                    config.getMaxClientCnxns());
+            cnxnFactory.startup(zkServer);
+            cnxnFactory.join();
+            if (zkServer.isRunning()) {
+                zkServer.shutdown();
+            }
+        } catch (InterruptedException e) {
+            // warn, but generally this is ok
+            logger.warn("Server interrupted", e);
+            System.exit(1);
+        } finally {
+            if (txnLog != null) {
+                txnLog.close();
+            }
+        }
+    }
 	private static void performServerStart(String[] args) {
 		setServerStarted();
 		logger.info("Airavata server instance starting...");
@@ -182,7 +252,10 @@ public class ServerMain {
 		}else{
 			logger.error("Server"+(serverPID==-1? "":" instance "+serverPID)+" is not running!!!");
 		}
-	}
+        if (ServerSettings.isEmbeddedZK()) {
+            cnxnFactory.shutdown();
+        }
+    }
 
 	@SuppressWarnings("resource")
 	private static void requestStop() throws IOException {


Mime
View raw message