You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by is...@apache.org on 2022/11/21 12:49:00 UTC

[airavata] branch develop updated: Adding error logging

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new 895a44bf93 Adding error logging
     new acdbb13d6f Merge pull request #332 from isururanawaka/metaschedular
895a44bf93 is described below

commit 895a44bf9352b0f4a928a6d7a783a7e86fa21fb2
Author: Isuru Ranawaka <ir...@gmail.com>
AuthorDate: Mon Nov 21 07:47:06 2022 -0500

    Adding error logging
---
 .../orchestrator/server/OrchestratorServer.java    | 238 ++++++++++-----------
 1 file changed, 118 insertions(+), 120 deletions(-)

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 d8743097a2..74a8706810 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
@@ -1,5 +1,4 @@
 /**
- *
  * 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
@@ -7,9 +6,9 @@
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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
@@ -19,7 +18,6 @@
  */
 package org.apache.airavata.orchestrator.server;
 
-import org.apache.airavata.cluster.monitoring.ClusterStatusMonitorJobScheduler;
 import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.common.utils.IServer;
 import org.apache.airavata.common.utils.ServerSettings;
@@ -40,152 +38,152 @@ import java.net.InetSocketAddress;
 public class OrchestratorServer implements IServer {
 
     private final static Logger logger = LoggerFactory.getLogger(OrchestratorServer.class);
-	private static final String SERVER_NAME = "Orchestrator Server";
-	private static final String SERVER_VERSION = "1.0";
+    private static final String SERVER_NAME = "Orchestrator Server";
+    private static final String SERVER_VERSION = "1.0";
 
     private ServerStatus status;
 
-	private TServer server;
+    private TServer server;
 
-	private static ComputationalResourceMonitoringService monitoringService;
+    private static ComputationalResourceMonitoringService monitoringService;
 
 //	private ClusterStatusMonitorJobScheduler clusterStatusMonitorJobScheduler;
 
-	public OrchestratorServer() {
-		setStatus(ServerStatus.STOPPED);
-	}
+    public OrchestratorServer() {
+        setStatus(ServerStatus.STOPPED);
+    }
 
     public void StartOrchestratorServer(OrchestratorService.Processor<OrchestratorServerHandler> orchestratorServerHandlerProcessor)
             throws Exception {
-		final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.ORCHESTRATOT_SERVER_PORT, "8940"));
-		try {
+        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);
-			}
+            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));
+            //      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.STARTING);
-					logger.info("Starting Orchestrator Server ... ");
-				}
-			}.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("Started Orchestrator Server on Port " + serverPort + " ...");
-
-
-					}
-				}
-			}.start();
+                public void run() {
+                    server.serve();
+                    setStatus(ServerStatus.STARTING);
+                    logger.info("Starting Orchestrator Server ... ");
+                }
+            }.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("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 + " ...");
-		}
+            logger.error("Failed to start Orchestrator server on port " + serverPort + " ...");
+        }
     }
 
-	public void startClusterStatusMonitoring() throws SchedulerException, ApplicationSettingsException {
+    public void startClusterStatusMonitoring() throws SchedulerException, ApplicationSettingsException {
 //        clusterStatusMonitorJobScheduler = new ClusterStatusMonitorJobScheduler();
 //        clusterStatusMonitorJobScheduler.scheduleClusterStatusMonitoring();
 
-		try {
-			if (monitoringService == null) {
-				monitoringService = new ComputationalResourceMonitoringService();
-			}
-			if (monitoringService != null && !monitoringService.getStatus().equals(ServerStatus.STARTED)) {
-				monitoringService.start();
-				monitoringService.setServerStatus(ServerStatus.STARTED);
-				logger.info("Airavata compute resource monitoring service started ....");
-			}
-		} catch (Exception ex) {
-			logger.info("Airavata compute resource monitoring service failed ....");
-		}
-	}
+        try {
+            if (monitoringService == null) {
+                monitoringService = new ComputationalResourceMonitoringService();
+            }
+            if (monitoringService != null && !monitoringService.getStatus().equals(ServerStatus.STARTED)) {
+                monitoringService.start();
+                monitoringService.setServerStatus(ServerStatus.STARTED);
+                logger.info("Airavata compute resource monitoring service started ....");
+            }
+        } catch (Exception ex) {
+            logger.error("Airavata compute resource monitoring service failed ....",ex);
+        }
+    }
 
     public static void main(String[] args) {
-    	try {
-			new OrchestratorServer().start();
-		} catch (Exception e) {
+        try {
+            new OrchestratorServer().start();
+        } catch (Exception e) {
             logger.error(e.getMessage(), e);
-		}
+        }
     }
 
-	@Override
-	public void start() throws Exception {
-		if (ServerSettings.enableClusterStatusMonitoring()) {
-			//starting cluster status monitoring
-			startClusterStatusMonitoring();
-		}
+    @Override
+    public void start() throws Exception {
+        if (ServerSettings.enableClusterStatusMonitoring()) {
+            //starting cluster status monitoring
+            startClusterStatusMonitoring();
+        }
 
 
-		setStatus(ServerStatus.STARTING);
-		OrchestratorService.Processor<OrchestratorServerHandler> orchestratorService =
+        setStatus(ServerStatus.STARTING);
+        OrchestratorService.Processor<OrchestratorServerHandler> orchestratorService =
                 new OrchestratorService.Processor<OrchestratorServerHandler>(new OrchestratorServerHandler());
-		StartOrchestratorServer(orchestratorService);
-	}
-
-	@Override
-	public void stop() throws Exception {
-        if (server!=null && server.isServing()){
-			setStatus(ServerStatus.STOPING);
-			server.stop();
-		}
-        if(monitoringService != null){
-        	monitoringService.stop();
-			monitoringService.setServerStatus(ServerStatus.STOPPED);
-		}
-		
-	}
-
-	@Override
-	public void restart() throws Exception {
-		stop();
-		start();
-	}
-
-	@Override
-	public void configure() throws Exception {
-		// TODO Auto-generated method stub
-		
-	}
-
-	@Override
-	public ServerStatus getStatus() throws Exception {
-		return status;
-	}
-	
-	private void setStatus(ServerStatus stat){
-		status=stat;
-		status.updateTime();
-	}
-
-	@Override
-	public String getName() {
-		return SERVER_NAME;
-	}
-
-	@Override
-	public String getVersion() {
-		return SERVER_VERSION;
-	}
+        StartOrchestratorServer(orchestratorService);
+    }
+
+    @Override
+    public void stop() throws Exception {
+        if (server != null && server.isServing()) {
+            setStatus(ServerStatus.STOPING);
+            server.stop();
+        }
+        if (monitoringService != null) {
+            monitoringService.stop();
+            monitoringService.setServerStatus(ServerStatus.STOPPED);
+        }
+
+    }
+
+    @Override
+    public void restart() throws Exception {
+        stop();
+        start();
+    }
+
+    @Override
+    public void configure() throws Exception {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public ServerStatus getStatus() throws Exception {
+        return status;
+    }
+
+    private void setStatus(ServerStatus stat) {
+        status = stat;
+        status.updateTime();
+    }
+
+    @Override
+    public String getName() {
+        return SERVER_NAME;
+    }
+
+    @Override
+    public String getVersion() {
+        return SERVER_VERSION;
+    }
 
 }