Repository: airavata
Updated Branches:
  refs/heads/master c6fe0decd -> f70d074b7


stop starting credential store service by default - AIRAVATA-1561


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

Branch: refs/heads/master
Commit: f70d074b7853295c756d91b1fe5e580dde51caf8
Parents: c6fe0de
Author: Chathuri Wimalasena <[email protected]>
Authored: Mon Feb 9 12:33:27 2015 -0500
Committer: Chathuri Wimalasena <[email protected]>
Committed: Mon Feb 9 12:33:27 2015 -0500

----------------------------------------------------------------------
 .../common/utils/ApplicationSettings.java       | 16 ++++
 .../apache/airavata/common/utils/Constants.java |  2 +
 .../main/resources/airavata-server.properties   |  5 +-
 .../store/server/CredentialStoreServer.java     | 88 +++++++++++---------
 .../src/main/resources/bin/airavata-server.sh   |  2 +-
 .../org/apache/airavata/server/ServerMain.java  |  4 +-
 6 files changed, 72 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/f70d074b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
----------------------------------------------------------------------
diff --git 
a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
 
b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
index 6c7ce75..cec498f 100644
--- 
a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
+++ 
b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
@@ -361,6 +361,18 @@ public class ApplicationSettings {
         return getSetting("credential.store.keystore.url");
     }
 
+    public static String getCredentialStoreThriftServerKeyStorePath() throws 
ApplicationSettingsException {
+        return getSetting("credential.store.thrift.server.keystore");
+    }
+
+    public static boolean isCredentialStoreStartEnabled() throws 
ApplicationSettingsException {
+        String enableCredentialStore = getSetting("start.credential.store");
+        if (enableCredentialStore.equals("true")){
+            return true;
+        }
+        return false;
+    }
+
     public static String getCredentialStoreKeyAlias() throws 
ApplicationSettingsException {
         return getSetting("credential.store.keystore.alias");
     }
@@ -369,6 +381,10 @@ public class ApplicationSettings {
         return getSetting("credential.store.keystore.password");
     }
 
+    public static String getCredentialStoreThriftServerKeyStorePassword() 
throws ApplicationSettingsException {
+        return getSetting("credential.store.thrift.server.keystore.password");
+    }
+
     public static String getCredentialStoreServerHost() throws 
ApplicationSettingsException {
         return getSetting("credential.store.server.host");
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/f70d074b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
----------------------------------------------------------------------
diff --git 
a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
 
b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
index 8fe5b6e..fd17064 100644
--- 
a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
+++ 
b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java
@@ -41,6 +41,8 @@ public final class Constants {
     public static final String ORCHESTRATOR_SERVER_PORT = 
"orchestrator.server.port";
     public static final String GFAC_SERVER_HOST = "gfac.server.host";
     public static final String GFAC_SERVER_PORT = "gfac.server.port";
+    public static final String CREDNETIAL_SERVER_HOST = 
"credential.store.server.host";
+    public static final String CREDNETIAL_SERVER_PORT = 
"credential.store.server.port";
     public static final String ZOOKEEPER_EXPERIMENT_CATALOG = 
"experiment-catalog";
     public static final String ZOOKEEPER_APPCATALOG = "app-catalog";
     public static final String ZOOKEEPER_RABBITMQ = "rabbit-mq";

http://git-wip-us.apache.org/repos/asf/airavata/blob/f70d074b/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 3754096..1c1aa30 100644
--- a/modules/configuration/server/src/main/resources/airavata-server.properties
+++ b/modules/configuration/server/src/main/resources/airavata-server.properties
@@ -96,7 +96,8 @@ job.notification.flags=abe
 ###########################################################################
 # Credential Store module Configuration
 ###########################################################################
-credential.store.keystore.url=/Users/lahirugunathilake/Downloads/airavata_sym.jks
+start.credential.store=true
+credential.store.keystore.url=/Users/chathuri/dev/airavata/credential-store/oa4mp/airavata_sym.jks
 credential.store.keystore.alias=airavata
 credential.store.keystore.password=airavata
 
credential.store.jdbc.url=jdbc:derby://localhost:1527/persistent_data;create=true;user=airavata;password=airavata
@@ -106,6 +107,8 @@ 
credential.store.jdbc.driver=org.apache.derby.jdbc.ClientDriver
 credential.store.server.host=localhost
 credential.store.server.port=8960
 
credentialstore=org.apache.airavata.credential.store.server.CredentialStoreServer
+credential.store.thrift.server.keystore=/Users/chathuri/dev/airavata/credential-store/oa4mp/airavata.jks
+credential.store.thrift.server.keystore.password=airavata
 
 notifier.enabled=false
 #period in milliseconds

http://git-wip-us.apache.org/repos/asf/airavata/blob/f70d074b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java
----------------------------------------------------------------------
diff --git 
a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java
 
b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java
index efaddbe..c5a8023 100644
--- 
a/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java
+++ 
b/modules/credential-store-service/credential-store/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java
@@ -2,6 +2,7 @@
 package org.apache.airavata.credential.store.server;
 
 
+import org.apache.airavata.common.utils.Constants;
 import org.apache.airavata.common.utils.IServer;
 import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.credential.store.cpi.CredentialStoreService;
@@ -14,6 +15,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.net.InetAddress;
+import java.net.InetSocketAddress;
 
 public class CredentialStoreServer  implements IServer {
     private final static Logger logger = 
LoggerFactory.getLogger(CredentialStoreServer.class);
@@ -39,49 +41,52 @@ public class CredentialStoreServer  implements IServer {
 
     @Override
     public void start() throws Exception {
-        try {
-            setStatus(ServerStatus.STARTING);
-            TSSLTransportFactory.TSSLTransportParameters params =
-                    new TSSLTransportFactory.TSSLTransportParameters();
-            String keystorePath = 
ServerSettings.getCredentialStoreKeyStorePath();
-            String keystorePWD = 
ServerSettings.getCredentialStoreKeyStorePassword();
-            String host = ServerSettings.getCredentialStoreServerHost();
-            final int port = 
Integer.valueOf(ServerSettings.getCredentialStoreServerPort());
-            params.setKeyStore(keystorePath, keystorePWD);
-
-            TServerSocket serverTransport = 
TSSLTransportFactory.getServerSocket(
-                    port, 10000, InetAddress.getByName(host), params);
-            CredentialStoreService.Processor processor = new 
CredentialStoreService.Processor(new CredentialStoreServerHandler());
-
-            server = new TThreadPoolServer(new 
TThreadPoolServer.Args(serverTransport).
-                    processor(processor));
-            new Thread() {
-                public void run() {
-                    server.serve();
-                    setStatus(ServerStatus.STOPPED);
-                    logger.info("Credential Store Server Stopped.");
-                }
-            }.start();
-            new Thread() {
-                public void run() {
-                    while(!server.isServing()){
-                        try {
-                            Thread.sleep(500);
-                        } catch (InterruptedException e) {
-                            break;
-                        }
+        if(ServerSettings.isCredentialStoreStartEnabled()) {
+            try {
+                setStatus(ServerStatus.STARTING);
+                TSSLTransportFactory.TSSLTransportParameters params =
+                        new TSSLTransportFactory.TSSLTransportParameters();
+                String keystorePath = 
ServerSettings.getCredentialStoreThriftServerKeyStorePath();
+                String keystorePWD = 
ServerSettings.getCredentialStoreThriftServerKeyStorePassword();
+                final int serverPort = 
Integer.parseInt(ServerSettings.getSetting(Constants.CREDNETIAL_SERVER_PORT, 
"8960"));
+                final String serverHost = 
ServerSettings.getSetting(Constants.CREDNETIAL_SERVER_HOST, null);
+                params.setKeyStore(keystorePath, keystorePWD);
+
+                TServerSocket serverTransport = 
TSSLTransportFactory.getServerSocket(serverPort, 100, 
InetAddress.getByName(serverHost), params);
+
+
+                CredentialStoreService.Processor processor = new 
CredentialStoreService.Processor(new CredentialStoreServerHandler());
+
+                server = new TThreadPoolServer(new 
TThreadPoolServer.Args(serverTransport).
+                        processor(processor));
+                new Thread() {
+                    public void run() {
+                        server.serve();
+                        setStatus(ServerStatus.STOPPED);
+                        logger.info("Credential Store Server Stopped.");
                     }
-                    if (server.isServing()){
-                        setStatus(ServerStatus.STARTED);
-                        logger.info("Starting Credential Store Server on Port 
" + port);
-                        logger.info("Listening to Credential Store Clients 
....");
+                }.start();
+                new Thread() {
+                    public void run() {
+                        while (!server.isServing()) {
+                            try {
+                                Thread.sleep(500);
+                            } catch (InterruptedException e) {
+                                break;
+                            }
+                        }
+                        if (server.isServing()) {
+                            setStatus(ServerStatus.STARTED);
+                            logger.info("Starting Credential Store Server on 
Port " + serverPort);
+                            logger.info("Listening to Credential Store Clients 
....");
+                        }
                     }
-                }
-            }.start();
-        } catch (TTransportException e) {
-            setStatus(ServerStatus.FAILED);
-            logger.error("Error while starting the credential store service", 
e);
-            throw new Exception("Error while starting the credential store 
service", e);
+                }.start();
+            } catch (TTransportException e) {
+                setStatus(ServerStatus.FAILED);
+                logger.error("Error while starting the credential store 
service", e);
+                throw new Exception("Error while starting the credential store 
service", e);
+            }
         }
     }
 
@@ -130,4 +135,5 @@ public class CredentialStoreServer  implements IServer {
         this.server = server;
     }
 
+
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/f70d074b/modules/distribution/server/src/main/resources/bin/airavata-server.sh
----------------------------------------------------------------------
diff --git 
a/modules/distribution/server/src/main/resources/bin/airavata-server.sh 
b/modules/distribution/server/src/main/resources/bin/airavata-server.sh
index 7ea448f..4222f9d 100755
--- a/modules/distribution/server/src/main/resources/bin/airavata-server.sh
+++ b/modules/distribution/server/src/main/resources/bin/airavata-server.sh
@@ -27,7 +27,7 @@ IS_DAEMON_MODE=false
 LOGO=true
 STOP=false
 FORCE=false
-SERVERS="--servers=apiserver,orchestrator,gfac"
+SERVERS="--servers=apiserver,orchestrator,gfac,credentialstore"
 for var in "$@"
 do
     case $var in

http://git-wip-us.apache.org/repos/asf/airavata/blob/f70d074b/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 1b1a41b..fdf1660 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
@@ -313,7 +313,7 @@ public class ServerMain {
                        count+=SERVER_STATUS_CHANGE_WAIT_INTERVAL;
                }
                if (server.getStatus()!=ServerStatus.STARTED){
-                       throw new Exception("The "+server.getName()+" did not 
start!!!");
+                       logger.error("The "+server.getName()+" did not 
start!!!");
                }
        }
 
@@ -328,7 +328,7 @@ public class ServerMain {
                        count+=SERVER_STATUS_CHANGE_WAIT_INTERVAL;
                }
                if (server.getStatus()!=ServerStatus.STOPPED){
-                       throw new Exception("Error stopping the 
"+server.getName()+"!!!");
+            logger.error("Error stopping the "+server.getName()+"!!!");
                }
        }
 

Reply via email to