airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [5/6] airavata git commit: Added meaningful log messages and refactore ServerMain and Airavata Thrift Servers
Date Tue, 28 Jun 2016 21:06:34 GMT
Added meaningful log messages and refactore ServerMain and Airavata Thrift Servers


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

Branch: refs/heads/develop
Commit: 11558d6a56c6e86981c9e32939352de8e83f2894
Parents: 8e39083
Author: Shameera Rathnayaka <shameerainfo@gmail.com>
Authored: Thu Jun 23 12:39:19 2016 -0400
Committer: Shameera Rathnayaka <shameerainfo@gmail.com>
Committed: Tue Jun 28 16:32:37 2016 -0400

----------------------------------------------------------------------
 .../airavata/api/server/AiravataAPIServer.java  | 11 +++---
 .../main/resources/bin/airavata-server-start.sh | 11 +++---
 .../apache/airavata/gfac/server/GfacServer.java | 12 +++----
 .../orchestrator/server/OrchestratorServer.java | 19 ++++-------
 .../org/apache/airavata/server/ServerMain.java  | 35 ++++++++++++--------
 5 files changed, 45 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/11558d6a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
index 6c429d2..01649ab 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java
@@ -124,10 +124,8 @@ public class AiravataAPIServer implements IServer{
 						}
 					}
 				}.start();
-			}
-//            storeServerConfig();
-            /**********start thrift server over TLS******************/
-            if (ServerSettings.isTLSEnabled()) {
+				logger.info("Started API Server ....");
+			} else { /**********start thrift server over TLS******************/
                 TSSLTransportFactory.TSSLTransportParameters TLSParams =
                         new TSSLTransportFactory.TSSLTransportParameters();
                 TLSParams.setKeyStore(ServerSettings.getKeyStorePath(), ServerSettings.getKeyStorePassword());
@@ -160,7 +158,7 @@ public class AiravataAPIServer implements IServer{
                         }
                     }
                 }.start();
-                logger.info("Airavata API server starter over TLS on Port: " + ServerSettings.getTLSServerPort());
+                logger.info("API server started over TLS on Port: " + ServerSettings.getTLSServerPort()
+ " ...");
             }
 
             /*perform any security related initialization at the server startup, according
to the underlying security
@@ -172,7 +170,8 @@ public class AiravataAPIServer implements IServer{
             logger.error(e.getMessage());
             setStatus(ServerStatus.FAILED);
             ExperimentCatalogInitUtil.stopDerbyInServerMode();
-            throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+			logger.error("Failed to start Gfac server ...");
+			throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
         } catch (ApplicationSettingsException e) {
             logger.error(e.getMessage(), e);
             throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);

http://git-wip-us.apache.org/repos/asf/airavata/blob/11558d6a/distribution/src/main/resources/bin/airavata-server-start.sh
----------------------------------------------------------------------
diff --git a/distribution/src/main/resources/bin/airavata-server-start.sh b/distribution/src/main/resources/bin/airavata-server-start.sh
index 6e1e412..599fdd8 100644
--- a/distribution/src/main/resources/bin/airavata-server-start.sh
+++ b/distribution/src/main/resources/bin/airavata-server-start.sh
@@ -60,16 +60,17 @@ do
         -h)
             echo "Usage: airavata-server-start.sh [server-name/s] [command-options]"
             echo "Server names:"
-            echo "  api                 Start api server"
-            echo "  gfac                Start api server"
-            echo "  orchestrator        Start api server"
+            echo "  apiserver           Start apiserver"
+            echo "  gfac                Start gfac server"
+            echo "  orchestrator        Start orchestrator server"
+            echo "  credentialstore        Start credentialstore server"
 
             echo "command options:"
 	        echo "  -d                  Start server in daemon mode"
-	        echo "  --<key>[=<value>]   Server setting(s) to override or introduce
(overrides values in airavata-server.properties)"
-            echo "  -nologo             Do not show airavata logo"
             echo "  -xdebug             Start Airavata Server under JPDA debugger"
+            echo "  -nologo             Do not show airavata logo"
             echo "  -security           Enable Java 2 security"
+	        echo "  --<key>[=<value>]   Server setting(s) to override or introduce
(overrides values in airavata-server.properties)"
             echo "  -h                  Display this help and exit"
             shift
             exit 0

http://git-wip-us.apache.org/repos/asf/airavata/blob/11558d6a/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServer.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServer.java
b/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServer.java
index db65e28..017afa0 100644
--- a/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServer.java
+++ b/modules/gfac/gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServer.java
@@ -50,8 +50,8 @@ public class GfacServer implements IServer{
 
     public void StartGfacServer(GfacService.Processor<GfacServerHandler> gfacServerHandlerProcessor)
             throws Exception {
-        try {
-            final int serverPort = Integer.parseInt(ServerSettings.getGFacServerPort());
+		final int serverPort = Integer.parseInt(ServerSettings.getGFacServerPort());
+		try {
             final String serverHost = ServerSettings.getGfacServerHost();
 
             InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
@@ -63,8 +63,8 @@ public class GfacServer implements IServer{
             new Thread() {
 				public void run() {
 					server.serve();
-					setStatus(IServer.ServerStatus.STOPPED);
-					logger.info("Gfac Server Stopped.");
+					setStatus(ServerStatus.STARTING);
+					logger.info("Starting Gfac Server ...");
 				}
 			}.start();
 			new Thread() {
@@ -78,14 +78,14 @@ public class GfacServer implements IServer{
 					}
 					if (server.isServing()){
 						setStatus(IServer.ServerStatus.STARTED);
-			            logger.info("Starting Gfac Server on Port " + serverPort);
-			            logger.info("Listening to Gfac Clients ....");
+			            logger.info("Started Gfac Server on Port " + serverPort + " ...");
 					}
 				}
 			}.start();
         } catch (TTransportException e) {
             logger.error(e.getMessage());
             setStatus(IServer.ServerStatus.FAILED);
+			logger.error("Failed to start Gfac server on port " + serverPort + " ...");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/11558d6a/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServer.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServer.java
b/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServer.java
index e2c5eaf..7b33e82 100644
--- a/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServer.java
+++ b/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServer.java
@@ -51,31 +51,26 @@ public class OrchestratorServer implements IServer {
 
     public void StartOrchestratorServer(OrchestratorService.Processor<OrchestratorServerHandler>
orchestratorServerHandlerProcessor)
             throws Exception {
-        try {
-            final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.ORCHESTRATOT_SERVER_PORT,
"8940"));
-
+		final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.ORCHESTRATOT_SERVER_PORT,
"8940"));
+		try {
             final String serverHost = ServerSettings.getSetting(Constants.ORCHESTRATOT_SERVER_HOST,
null);
-            
 			TServerTransport serverTransport;
-			
 			if(serverHost == null){
 				serverTransport = new TServerSocket(serverPort);
 			}else{
 				InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
 				serverTransport = new TServerSocket(inetSocketAddress);
 			}
-			
             //server = new TSimpleServer(
               //      new TServer.Args(serverTransport).processor(orchestratorServerHandlerProcessor));
             TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
             options.minWorkerThreads = Integer.parseInt(ServerSettings.getSetting(Constants.ORCHESTRATOT_SERVER_MIN_THREADS,
"30"));
             server = new TThreadPoolServer(options.processor(orchestratorServerHandlerProcessor));
-
             new Thread() {
 				public void run() {
 					server.serve();
-					setStatus(ServerStatus.STOPPED);
-					logger.info("Orchestrator Server Stopped.");
+					setStatus(ServerStatus.STARTING);
+					logger.info("Starting Orchestrator Server ... ");
 				}
 			}.start();
 			new Thread() {
@@ -89,15 +84,15 @@ public class OrchestratorServer implements IServer {
 					}
 					if (server.isServing()){
 						setStatus(ServerStatus.STARTED);
-			            logger.info("Starting Orchestrator Server on Port " + serverPort);
-			            logger.info("Listening to Orchestrator Clients ....");
+			            logger.info("Started Orchestrator Server on Port " + serverPort + " ...");
 					}
 				}
 			}.start();
         } catch (TTransportException e) {
             logger.error(e.getMessage());
             setStatus(ServerStatus.FAILED);
-        }
+			logger.error("Failed to start Orchestrator server on port " + serverPort + " ...");
+		}
     }
 
     public static void main(String[] args) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/11558d6a/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 8055dda..0661a32 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
@@ -25,6 +25,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.airavata.common.exception.ApplicationSettingsException;
@@ -42,12 +43,18 @@ public class ServerMain {
 	private static final String SERVERS_KEY="servers";
     private final static Logger logger = LoggerFactory.getLogger(ServerMain.class);
     private static boolean serversLoaded=false;
-	private static final String stopFileNamePrefix = "airavata-server-stop";
+	private static final String stopFileNamePrefix = "server-stop";
 	private static int serverPID=-1;
 	private static final String serverStartedFileNamePrefix = "server-start";
 	private static boolean systemShutDown=false;
 	private static String STOP_COMMAND_STR = "stop";
 
+	// server names
+	private static String API_SERVER = "apiserver";
+	private static String CREDENTIAL_STORE = "credentialstore";
+	private static String GFAC_SERVER = "gfac";
+	private static String ORCHESTRATOR = "orcestrator";
+
     private static ServerCnxnFactory cnxnFactory;
 //	private static boolean shutdownHookCalledBefore=false;
     static{
@@ -57,7 +64,7 @@ public class ServerMain {
 	private static void loadServers(String serverNames) {
 		try {
 			if (serverNames !=null){
-				String[] serversList = serverNames.split(",");
+				List<String> serversList = handleServerDependencies(serverNames);
 				for (String serverString : serversList) {
 					serverString=serverString.trim();
 					String serverClassName = ServerSettings.getSetting(serverString);
@@ -90,6 +97,18 @@ public class ServerMain {
 		});
 	}
 
+	private static List<String> handleServerDependencies(String serverNames) {
+		List<String> serverList = new ArrayList<>(Arrays.asList(serverNames.split(",")));
+		// credential store should start before api server
+		int credPos = serverList.indexOf(CREDENTIAL_STORE);
+		if (credPos > 0) { // neither absent nor credentialstore is first element
+			String temp = serverList.get(0);
+			serverList.set(0, serverList.get(credPos));
+			serverList.set(credPos, temp);
+		}
+		return serverList;
+	}
+
 //	private static void addSecondaryShutdownHook(){
 //		Runtime.getRuntime().addShutdownHook(new Thread(){
 //			@Override
@@ -104,18 +123,6 @@ public class ServerMain {
 //	}
 	
 	public static void main(String args[]) throws ParseException, IOException {
-//		Properties properties = System.getProperties();
-//		for (Object key : properties.keySet()) {
-//			System.out.println(key.toString()+"     =       "+properties.get(key));
-//		}
-//		Map<String, String> env = System.getenv();
-//
-//		for (Object key : env.keySet()) {
-//			System.out.println(key.toString()+"     =       "+env.get(key));
-//		}
-//		if (true){
-//			return;
-//		}
         CommandLineParameters commandLineParameters = StringUtil.getCommandLineParser(args);
         if (commandLineParameters.getArguments().contains(STOP_COMMAND_STR)){
             performServerStopRequest(commandLineParameters);


Mime
View raw message