Return-Path: X-Original-To: apmail-airavata-commits-archive@www.apache.org Delivered-To: apmail-airavata-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ABED117D84 for ; Fri, 3 Oct 2014 01:40:16 +0000 (UTC) Received: (qmail 48413 invoked by uid 500); 3 Oct 2014 01:40:16 -0000 Delivered-To: apmail-airavata-commits-archive@airavata.apache.org Received: (qmail 48316 invoked by uid 500); 3 Oct 2014 01:40:16 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 48263 invoked by uid 99); 3 Oct 2014 01:40:16 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Oct 2014 01:40:16 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E47ECA1E6CA; Fri, 3 Oct 2014 01:40:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shameera@apache.org To: commits@airavata.apache.org Date: Fri, 03 Oct 2014 01:40:16 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/4] git commit: Added airavata logger implementation and Fixed AIRAVATA-1462 Added airavata logger implementation and Fixed AIRAVATA-1462 Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/595be55f Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/595be55f Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/595be55f Branch: refs/heads/master Commit: 595be55fd0dfe89fd045e0c2eacc5ab234f69731 Parents: 2bbeb7a Author: shamrath Authored: Thu Oct 2 20:57:14 2014 -0400 Committer: shamrath Committed: Thu Oct 2 20:57:14 2014 -0400 ---------------------------------------------------------------------- .../server/handler/AiravataServerHandler.java | 272 ++++---- .../airavata/common/logger/AiravataLogger.java | 677 +++++++++++++++++++ .../common/logger/AiravataLoggerFactory.java | 34 + .../common/logger/AiravataLoggerImpl.java | 323 +++++++++ .../airavata/gfac/server/GfacServerHandler.java | 24 +- .../airavata/gfac/core/monitor/MonitorID.java | 17 +- .../handlers/GridPullMonitorHandler.java | 9 +- .../monitor/impl/pull/qstat/HPCPullMonitor.java | 36 +- .../airavata/gfac/monitor/util/CommonUtils.java | 18 +- .../server/OrchestratorServerHandler.java | 47 +- .../registry/jpa/impl/ExperimentRegistry.java | 19 +- .../registry/cpi/CompositeIdentifier.java | 12 + 12 files changed, 1274 insertions(+), 214 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/595be55f/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java index 1051654..e75f099 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java @@ -42,6 +42,8 @@ import org.apache.airavata.api.Airavata; import org.apache.airavata.api.airavataAPIConstants; import org.apache.airavata.api.server.util.DataModelUtils; import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.common.logger.AiravataLogger; +import org.apache.airavata.common.logger.AiravataLoggerFactory; import org.apache.airavata.common.utils.AiravataUtils; import org.apache.airavata.common.utils.AiravataZKUtils; import org.apache.airavata.common.utils.ServerSettings; @@ -58,7 +60,6 @@ import org.apache.airavata.model.error.AiravataErrorType; import org.apache.airavata.model.error.AiravataSystemException; import org.apache.airavata.model.error.ExperimentNotFoundException; import org.apache.airavata.model.error.InvalidRequestException; -import org.apache.airavata.model.error.LaunchValidationException; import org.apache.airavata.model.error.ProjectNotFoundException; import org.apache.airavata.model.util.ExecutionType; import org.apache.airavata.model.workspace.Project; @@ -68,7 +69,6 @@ import org.apache.airavata.orchestrator.cpi.OrchestratorService; import org.apache.airavata.orchestrator.cpi.OrchestratorService.Client; import org.apache.airavata.persistance.registry.jpa.ResourceUtils; import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory; -import org.apache.airavata.persistance.registry.jpa.model.JobDetail; import org.apache.airavata.registry.cpi.ChildDataType; import org.apache.airavata.registry.cpi.ParentDataType; import org.apache.airavata.registry.cpi.Registry; @@ -88,11 +88,9 @@ import org.apache.zookeeper.Watcher; import org.apache.zookeeper.ZooDefs; import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.data.Stat; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class AiravataServerHandler implements Airavata.Iface, Watcher { - private static final Logger logger = LoggerFactory.getLogger(AiravataServerHandler.class); + private static final AiravataLogger logger = AiravataLoggerFactory.getLogger(AiravataServerHandler.class); private Registry registry; private AppCatalog appCatalog; @@ -682,9 +680,11 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { exception.setMessage("Cannot create experiments with empty experiment name"); throw exception; } - return (String)registry.add(ParentDataType.EXPERIMENT, experiment); + String experimentId = (String)registry.add(ParentDataType.EXPERIMENT, experiment); + logger.infoId(experimentId, "Created new experiment with experiment name {}", experiment.getName()); + return experimentId; } catch (Exception e) { - logger.error("Error while creating the experiment", e); + logger.error("Error while creating the experiment with experiment name {}", experiment.getName()); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while creating the experiment. More info : " + e.getMessage()); @@ -760,30 +760,20 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { public void updateExperiment(String airavataExperimentId, Experiment experiment) throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException, AiravataSystemException, TException { try { registry = RegistryFactory.getDefaultRegistry(); - if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ + if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)) { + logger.errorId(airavataExperimentId, "Update request failed, Experiment {} doesn't exist.", airavataExperimentId); throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); } ExperimentStatus experimentStatus = getExperimentStatus(airavataExperimentId); if (experimentStatus != null){ ExperimentState experimentState = experimentStatus.getExperimentState(); switch (experimentState){ - case CREATED: - registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId); - break; - case VALIDATED: - registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId); - break; - case CANCELED: - registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId); - break; - case FAILED: - registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId); - break; - case UNKNOWN: + case CREATED: case VALIDATED: case CANCELED: case FAILED: case UNKNOWN: registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId); + logger.infoId(airavataExperimentId, "Successfully updated experiment {} ", experiment.getName()); break; default: - logger.error("Error while updating experiment. Update experiment is only valid for experiments " + + logger.errorId(airavataExperimentId, "Error while updating experiment. Update experiment is only valid for experiments " + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " + "experiment is in one of above statuses... "); AiravataSystemException exception = new AiravataSystemException(); @@ -795,7 +785,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } } } catch (Exception e) { - logger.error("Error while updating experiment", e); + logger.errorId(airavataExperimentId, "Error while updating experiment", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating experiment. More info : " + e.getMessage()); @@ -808,31 +798,21 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { try { registry = RegistryFactory.getDefaultRegistry(); if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ + logger.errorId(airavataExperimentId, "Update experiment configuration failed, experiment {} doesn't exist.", airavataExperimentId); throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); } ExperimentStatus experimentStatus = getExperimentStatus(airavataExperimentId); if (experimentStatus != null){ ExperimentState experimentState = experimentStatus.getExperimentState(); switch (experimentState){ - case CREATED: - registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId); - break; - case VALIDATED: - registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId); - break; - case CANCELED: - registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId); - break; - case FAILED: - registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId); - break; - case UNKNOWN: + case CREATED: case VALIDATED: case CANCELED: case FAILED: case UNKNOWN: registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId); + logger.infoId(airavataExperimentId, "Successfully updated experiment configuration for experiment {}.", airavataExperimentId); break; default: - logger.error("Error while updating experiment. Update experiment is only valid for experiments " + + logger.errorId(airavataExperimentId, "Error while updating experiment {}. Update experiment is only valid for experiments " + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " + - "experiment is in one of above statuses... "); + "experiment is in one of above statuses... ", airavataExperimentId); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating experiment. Update experiment is only valid for experiments " + @@ -842,7 +822,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } } } catch (Exception e) { - logger.error("Error while updating user configuration", e); + logger.errorId(airavataExperimentId, "Error while updating user configuration", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating user configuration. " + @@ -858,29 +838,19 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { try { registry = RegistryFactory.getDefaultRegistry(); if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ + logger.infoId(airavataExperimentId, "Update resource scheduling failed, experiment {} doesn't exist.", airavataExperimentId); throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); } ExperimentStatus experimentStatus = getExperimentStatus(airavataExperimentId); if (experimentStatus != null){ ExperimentState experimentState = experimentStatus.getExperimentState(); switch (experimentState){ - case CREATED: - registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId); - break; - case VALIDATED: - registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId); - break; - case CANCELED: - registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId); - break; - case FAILED: - registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId); - break; - case UNKNOWN: + case CREATED: case VALIDATED: case CANCELED: case FAILED: case UNKNOWN: registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId); + logger.infoId(airavataExperimentId, "Successfully updated resource scheduling for the experiment {}.", airavataExperimentId); break; default: - logger.error("Error while updating scheduling info. Update experiment is only valid for experiments " + + logger.errorId(airavataExperimentId, "Error while updating scheduling info. Update experiment is only valid for experiments " + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " + "experiment is in one of above statuses... "); AiravataSystemException exception = new AiravataSystemException(); @@ -892,7 +862,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } } } catch (Exception e) { - logger.error("Error while updating scheduling info", e); + logger.errorId(airavataExperimentId, "Error while updating scheduling info", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating scheduling info. " + @@ -918,11 +888,12 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { public boolean validateExperiment(String airavataExperimentId) throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException, AiravataSystemException, TException { try { registry = RegistryFactory.getDefaultRegistry(); - if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ - throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); - } - } catch (RegistryException e1) { - logger.error("Error while retrieving projects", e1); + if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)) { + logger.errorId(airavataExperimentId, "Experiment validation failed , experiment {} doesn't exist.", airavataExperimentId); + throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); + } + } catch (RegistryException e1) { + logger.errorId(airavataExperimentId, "Error while retrieving projects", e1); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving projects. More info : " + e1.getMessage()); @@ -930,8 +901,10 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } if (getOrchestratorClient().validateExperiment(airavataExperimentId)) { + logger.infoId(airavataExperimentId, "Experiment validation succeed."); return true; } else { + logger.infoId(airavataExperimentId, "Experiment validation failed."); return false; } } @@ -967,12 +940,13 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { try { registry = RegistryFactory.getDefaultRegistry(); if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ + logger.errorId(airavataExperimentId, "Error while retrieving experiment status, experiment {} doesn't exist.", airavataExperimentId); throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); } return (ExperimentStatus)registry.get(RegistryModelType.EXPERIMENT_STATUS, airavataExperimentId); } catch (Exception e) { - logger.error("Error while retrieving the experiment status", e); + logger.errorId(airavataExperimentId, "Error while retrieving the experiment status", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving the experiment status. More info : " + e.getMessage()); @@ -985,11 +959,12 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { try { registry = RegistryFactory.getDefaultRegistry(); if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ + logger.errorId(airavataExperimentId, "Get experiment outputs failed, experiment {} doesn't exit.", airavataExperimentId); throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); } return (List)registry.get(RegistryModelType.EXPERIMENT_OUTPUT, airavataExperimentId); } catch (Exception e) { - logger.error("Error while retrieving the experiment outputs", e); + logger.errorId(airavataExperimentId, "Error while retrieving the experiment outputs", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving the experiment outputs. More info : " + e.getMessage()); @@ -1002,6 +977,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { try { registry = RegistryFactory.getDefaultRegistry(); if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ + logger.errorId(airavataExperimentId, "Error while retrieving job status, the experiment {} doesn't exist.", airavataExperimentId); throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); } List workflowNodes = registry.get(RegistryModelType.WORKFLOW_NODE_DETAIL, Constants.FieldConstants.WorkflowNodeConstants.EXPERIMENT_ID, airavataExperimentId); @@ -1024,7 +1000,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } } } catch (Exception e) { - logger.error("Error while retrieving the job statuses", e); + logger.errorId(airavataExperimentId, "Error while retrieving the job statuses", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving the job statuses. More info : " + e.getMessage()); @@ -1039,6 +1015,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { try { registry = RegistryFactory.getDefaultRegistry(); if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ + logger.errorId(airavataExperimentId, "Error while retrieving job details, experiment {} doesn't exist.", airavataExperimentId); throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); } List workflowNodes = registry.get(RegistryModelType.WORKFLOW_NODE_DETAIL, Constants.FieldConstants.WorkflowNodeConstants.EXPERIMENT_ID, airavataExperimentId); @@ -1060,7 +1037,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } } } catch (Exception e) { - logger.error("Error while retrieving the job details", e); + logger.errorId(airavataExperimentId, "Error while retrieving the job details", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving the job details. More info : " + e.getMessage()); @@ -1074,7 +1051,8 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { List dataTransferDetailList = new ArrayList(); try { registry = RegistryFactory.getDefaultRegistry(); - if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ + if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)) { + logger.errorId(airavataExperimentId, "Error while retrieving data transfer details, experiment {} doesn't exit.", airavataExperimentId); throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); } List workflowNodes = registry.get(RegistryModelType.WORKFLOW_NODE_DETAIL, Constants.FieldConstants.WorkflowNodeConstants.EXPERIMENT_ID, airavataExperimentId); @@ -1096,7 +1074,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } } } catch (Exception e) { - logger.error("Error while retrieving the data transfer details", e); + logger.errorId(airavataExperimentId, "Error while retrieving the data transfer details", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving the data transfer details. More info : " + e.getMessage()); @@ -1141,19 +1119,20 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { * rather an Airavata Administrator will be notified to take corrective action. */ @Override - public void launchExperiment(String airavataExperimentId, String airavataCredStoreToken) throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException, AiravataSystemException, LaunchValidationException, TException { + public void launchExperiment(final String airavataExperimentId, String airavataCredStoreToken) throws TException { try { registry = RegistryFactory.getDefaultRegistry(); - if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){ - throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); - } - } catch (RegistryException e1) { - logger.error("Error while retrieving projects", e1); - AiravataSystemException exception = new AiravataSystemException(); - exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); - exception.setMessage("Error while retrieving projects. More info : " + e1.getMessage()); - throw exception; - } + if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)) { + logger.errorId(airavataExperimentId, "Error while launching experiment, experiment {} doesn't exist.", airavataExperimentId); + throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system.."); + } + } catch (RegistryException e1) { + logger.errorId(airavataExperimentId, "Error while retrieving projects", e1); + AiravataSystemException exception = new AiravataSystemException(); + exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); + exception.setMessage("Error while retrieving projects. More info : " + e1.getMessage()); + throw exception; + } final String expID = airavataExperimentId; final String token = airavataCredStoreToken; @@ -1161,38 +1140,43 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { Experiment experiment = getExperiment(expID); ExecutionType executionType = DataModelUtils.getExecutionType(experiment); Thread thread = null; - if (executionType==ExecutionType.SINGLE_APP){ - //its an single application execution experiment - final OrchestratorService.Client orchestratorClient = getOrchestratorClient(); - if (orchestratorClient.validateExperiment(expID)) { - thread = new Thread() { - public void run() { - try { - launchSingleAppExperiment(expID, token, orchestratorClient); - } catch (TException e) { - e.printStackTrace(); - } - } - }; - } else { - throw new InvalidRequestException("Experiment Validation Failed, please check the configuration"); - } - - } else if (executionType == ExecutionType.WORKFLOW){ + if (executionType==ExecutionType.SINGLE_APP) { + //its an single application execution experiment + logger.debugId(airavataExperimentId, "Launching single application experiment {}.", airavataExperimentId); + final OrchestratorService.Client orchestratorClient = getOrchestratorClient(); + if (orchestratorClient.validateExperiment(expID)) { + thread = new Thread() { + public void run() { + try { + launchSingleAppExperiment(expID, token, orchestratorClient); + } catch (TException e) { + // throwing exception from here useless, just print the error log + logger.errorId(airavataExperimentId, "Error while launching single application experiment.", e); + } + } + }; + } else { + logger.errorId(airavataExperimentId, "Experiment validation failed. Please check the configurations."); + throw new InvalidRequestException("Experiment Validation Failed, please check the configuration"); + } + + } else if (executionType == ExecutionType.WORKFLOW){ //its a workflow execution experiment + logger.debugId(airavataExperimentId, "Launching workflow experiment {}.", airavataExperimentId); thread = new Thread() { public void run() { try { launchWorkflowExperiment(expID, token); } catch (TException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }; } else { - throw new InvalidRequestException("Experiment '"+expID+"' launch failed. Unable to figureout execution type for application "+experiment.getApplicationId()); - } - thread.start(); + logger.errorId(airavataExperimentId, "Couldn't identify experiment type, experiment {} is neither single application nor workflow.", airavataExperimentId); + throw new InvalidRequestException("Experiment '" + expID + "' launch failed. Unable to figureout execution type for application " + experiment.getApplicationId()); + } + thread.start(); } } @@ -1201,8 +1185,8 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { WorkflowEngine workflowEngine = WorkflowEngineFactory.getWorkflowEngine(); workflowEngine.launchExperiment(experimentId, airavataCredStoreToken); } catch (WorkflowEngineException e) { - e.printStackTrace(); - } + logger.errorId(experimentId, "Error while launching experiment.", e); + } } private boolean launchSingleAppExperiment(String experimentId, String airavataCredStoreToken, OrchestratorService.Client orchestratorClient) throws TException { @@ -1217,7 +1201,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { //iterate through all the generated tasks and performs the job submisssion+monitoring experiment = (Experiment) registry.get(RegistryModelType.EXPERIMENT, experimentId); if (experiment == null) { - logger.error("Error retrieving the Experiment by the given experimentID: " + experimentId); + logger.errorId(experimentId, "Error retrieving the Experiment by the given experimentID: {}", experimentId); return false; } ExperimentStatus status = new ExperimentStatus(); @@ -1243,9 +1227,10 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { try { registry.update(RegistryModelType.EXPERIMENT_STATUS, status, experimentId); } catch (RegistryException e1) { + logger.errorId(experimentId, "Error while updating experiment status to " + status.toString(), e); throw new TException(e); } - + logger.errorId(experimentId, "Error while updating task status, hence updated experiment status to " + status.toString(), e); throw new TException(e); } return true; @@ -1303,6 +1288,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { try { registry = RegistryFactory.getDefaultRegistry(); if (!registry.isExist(RegistryModelType.EXPERIMENT, existingExperimentID)){ + logger.errorId(existingExperimentID, "Error while cloning experiment {}, experiment doesn't exist.", existingExperimentID); throw new ExperimentNotFoundException("Requested experiment id " + existingExperimentID + " does not exist in the system.."); } Experiment existingExperiment = (Experiment)registry.get(RegistryModelType.EXPERIMENT, existingExperimentID); @@ -1318,7 +1304,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } return (String)registry.add(ParentDataType.EXPERIMENT, existingExperiment); } catch (Exception e) { - logger.error("Error while cloning the experiment with existing configuration...", e); + logger.errorId(existingExperimentID, "Error while cloning the experiment with existing configuration...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while cloning the experiment with existing configuration. More info : " + e.getMessage()); @@ -1387,7 +1373,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog = AppCatalogFactory.getAppCatalog(); return appCatalog.getApplicationInterface().getApplicationModule(appModuleId); } catch (AppCatalogException e) { - logger.error("Error while retrieving application module...", e); + logger.errorId(appModuleId, "Error while retrieving application module...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving the adding application module. More info : " + e.getMessage()); @@ -1410,7 +1396,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog.getApplicationInterface().updateApplicationModule(appModuleId, applicationModule); return true; } catch (AppCatalogException e) { - logger.error("Error while updating application module...", e); + logger.errorId(appModuleId, "Error while updating application module...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating application module. More info : " + e.getMessage()); @@ -1431,7 +1417,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog = AppCatalogFactory.getAppCatalog(); return appCatalog.getApplicationInterface().removeApplicationModule(appModuleId); } catch (AppCatalogException e) { - logger.error("Error while deleting application module...", e); + logger.errorId(appModuleId, "Error while deleting application module...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while deleting the application module. More info : " + e.getMessage()); @@ -1472,7 +1458,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog = AppCatalogFactory.getAppCatalog(); return appCatalog.getApplicationDeployment().getApplicationDeployement(appDeploymentId); } catch (AppCatalogException e) { - logger.error("Error while retrieving application deployment...", e); + logger.errorId(appDeploymentId, "Error while retrieving application deployment...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving application deployment. More info : " + e.getMessage()); @@ -1495,7 +1481,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog.getApplicationDeployment().updateApplicationDeployment(appDeploymentId, applicationDeployment); return true; } catch (AppCatalogException e) { - logger.error("Error while updating application deployment...", e); + logger.errorId(appDeploymentId, "Error while updating application deployment...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating application deployment. More info : " + e.getMessage()); @@ -1517,7 +1503,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog.getApplicationDeployment().removeAppDeployment(appDeploymentId); return true; } catch (AppCatalogException e) { - logger.error("Error while deleting application deployment...", e); + logger.errorId(appDeploymentId, "Error while deleting application deployment...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while deleting application deployment. More info : " + e.getMessage()); @@ -1545,7 +1531,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } return appDeployments; } catch (AppCatalogException e) { - logger.error("Error while retrieving application deployments...", e); + logger.errorId(appModuleId, "Error while retrieving application deployments...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving application deployment. More info : " + e.getMessage()); @@ -1586,7 +1572,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog = AppCatalogFactory.getAppCatalog(); return appCatalog.getApplicationInterface().getApplicationInterface(appInterfaceId); } catch (AppCatalogException e) { - logger.error("Error while retrieving application interface...", e); + logger.errorId(appInterfaceId, "Error while retrieving application interface...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving application interface. More info : " + e.getMessage()); @@ -1609,7 +1595,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog.getApplicationInterface().updateApplicationInterface(appInterfaceId, applicationInterface); return true; } catch (AppCatalogException e) { - logger.error("Error while updating application interface...", e); + logger.errorId(appInterfaceId, "Error while updating application interface...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating application interface. More info : " + e.getMessage()); @@ -1630,7 +1616,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog = AppCatalogFactory.getAppCatalog(); return appCatalog.getApplicationInterface().removeApplicationInterface(appInterfaceId); } catch (AppCatalogException e) { - logger.error("Error while deleting application interface...", e); + logger.errorId(appInterfaceId, "Error while deleting application interface...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while deleting application interface. More info : " + e.getMessage()); @@ -1698,7 +1684,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog = AppCatalogFactory.getAppCatalog(); return appCatalog.getApplicationInterface().getApplicationInputs(appInterfaceId); } catch (AppCatalogException e) { - logger.error("Error while retrieving application inputs...", e); + logger.errorId(appInterfaceId, "Error while retrieving application inputs...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving application inputs. More info : " + e.getMessage()); @@ -1719,7 +1705,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog = AppCatalogFactory.getAppCatalog(); return appCatalog.getApplicationInterface().getApplicationOutputs(appInterfaceId); } catch (AppCatalogException e) { - logger.error("Error while retrieving application outputs...", e); + logger.errorId(appInterfaceId, "Error while retrieving application outputs...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving application outputs. More info : " + e.getMessage()); @@ -1759,7 +1745,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } return availableComputeResources; } catch (AppCatalogException e) { - logger.error("Error while saving compute resource...", e); + logger.errorId(appInterfaceId, "Error while saving compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while saving compute resource. More info : " + e.getMessage()); @@ -1801,7 +1787,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog = AppCatalogFactory.getAppCatalog(); return appCatalog.getComputeResource().getComputeResource(computeResourceId); } catch (AppCatalogException e) { - logger.error("Error while retrieving compute resource...", e); + logger.errorId(computeResourceId, "Error while retrieving compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving compute resource. More info : " + e.getMessage()); @@ -1844,7 +1830,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog.getComputeResource().updateComputeResource(computeResourceId, computeResourceDescription); return true; } catch (AppCatalogException e) { - logger.error("Error while updating compute resource...", e); + logger.errorId(computeResourceId, "Error while updating compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updaing compute resource. More info : " + e.getMessage()); @@ -1866,7 +1852,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog.getComputeResource().removeComputeResource(computeResourceId); return true; } catch (AppCatalogException e) { - logger.error("Error while deleting compute resource...", e); + logger.errorId(computeResourceId, "Error while deleting compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while deleting compute resource. More info : " + e.getMessage()); @@ -1893,7 +1879,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { computeResource.addLocalJobSubmission(localSubmission), JobSubmissionProtocol.LOCAL, priorityOrder); return true; } catch (AppCatalogException e) { - logger.error("Error while adding job submission interface to resource compute resource...", e); + logger.errorId(computeResourceId, "Error while adding job submission interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage()); @@ -1917,7 +1903,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { submission.save(); return true; } catch (AppCatalogException e) { - logger.error("Error while adding job submission interface to resource compute resource...", e); + logger.errorId(jobSubmissionInterfaceId, "Error while adding job submission interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage()); @@ -1955,7 +1941,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { computeResource.addSSHJobSubmission(sshJobSubmission), JobSubmissionProtocol.SSH, priorityOrder); return true; } catch (AppCatalogException e) { - logger.error("Error while adding job submission interface to resource compute resource...", e); + logger.errorId(computeResourceId, "Error while adding job submission interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage()); @@ -1982,7 +1968,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { computeResource.addCloudJobSubmission(cloudJobSubmission), JobSubmissionProtocol.CLOUD, priorityOrder); return true; } catch (AppCatalogException e) { - logger.error("Error while adding job submission interface to resource compute resource...", e); + logger.errorId(computeResourceId, "Error while adding job submission interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage()); @@ -2006,7 +1992,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { submission.save(); return true; } catch (AppCatalogException e) { - logger.error("Error while adding job submission interface to resource compute resource...", e); + logger.errorId(jobSubmissionInterfaceId, "Error while adding job submission interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage()); @@ -2030,7 +2016,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { submission.save(); return true; } catch (AppCatalogException e) { - logger.error("Error while adding job submission interface to resource compute resource...", e); + logger.errorId(jobSubmissionInterfaceId, "Error while adding job submission interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage()); @@ -2056,7 +2042,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { computeResource.addLocalDataMovement(localDataMovement), DataMovementProtocol.LOCAL, priorityOrder); return true; } catch (AppCatalogException e) { - logger.error("Error while adding data movement interface to resource compute resource...", e); + logger.errorId(computeResourceId, "Error while adding data movement interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding data movement interface to resource compute resource. More info : " + e.getMessage()); @@ -2080,7 +2066,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { movment.save(); return true; } catch (AppCatalogException e) { - logger.error("Error while adding job submission interface to resource compute resource...", e); + logger.errorId(jobSubmissionInterfaceId, "Error while adding job submission interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage()); @@ -2118,7 +2104,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { computeResource.addScpDataMovement(scpDataMovement), DataMovementProtocol.SCP, priorityOrder); return true; } catch (AppCatalogException e) { - logger.error("Error while adding data movement interface to resource compute resource...", e); + logger.errorId(computeResourceId, "Error while adding data movement interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding data movement interface to resource compute resource. More info : " + e.getMessage()); @@ -2143,7 +2129,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { movment.save(); return true; } catch (AppCatalogException e) { - logger.error("Error while adding job submission interface to resource compute resource...", e); + logger.errorId(jobSubmissionInterfaceId, "Error while adding job submission interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage()); @@ -2170,7 +2156,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { computeResource.addGridFTPDataMovement(gridFTPDataMovement), DataMovementProtocol.GridFTP, priorityOrder); return true; } catch (AppCatalogException e) { - logger.error("Error while adding data movement interface to resource compute resource...", e); + logger.errorId(computeResourceId, "Error while adding data movement interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding data movement interface to resource compute resource. More info : " + e.getMessage()); @@ -2195,7 +2181,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { movment.save(); return true; } catch (AppCatalogException e) { - logger.error("Error while adding job submission interface to resource compute resource...", e); + logger.errorId(jobSubmissionInterfaceId, "Error while adding job submission interface to resource compute resource...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage()); @@ -2267,7 +2253,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog.getComputeResource().removeJobSubmissionInterface(jobSubmissionInterfaceId); return true; } catch (AppCatalogException e) { - logger.error("Error while deleting job submission interface...", e); + logger.errorId(jobSubmissionInterfaceId, "Error while deleting job submission interface...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while deleting job submission interface. More info : " + e.getMessage()); @@ -2289,7 +2275,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { appCatalog.getComputeResource().removeDataMovementInterface(dataMovementInterfaceId); return true; } catch (AppCatalogException e) { - logger.error("Error while deleting data movement interface...", e); + logger.errorId(dataMovementInterfaceId, "Error while deleting data movement interface...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while deleting data movement interface. More info : " + e.getMessage()); @@ -2335,7 +2321,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); return gatewayProfile.getGatewayProfile(gatewayID); } catch (AppCatalogException e) { - logger.error("Error while retrieving gateway resource profile...", e); + logger.errorId(gatewayID, "Error while retrieving gateway resource profile...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while retrieving gateway resource profile. More info : " + e.getMessage()); @@ -2359,7 +2345,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { gatewayProfile.updateGatewayResourceProfile(gatewayID, gatewayResourceProfile); return true; } catch (AppCatalogException e) { - logger.error("Error while updating gateway resource profile...", e); + logger.errorId(gatewayID, "Error while updating gateway resource profile...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating gateway resource profile. More info : " + e.getMessage()); @@ -2382,7 +2368,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { gatewayProfile.removeGatewayResourceProfile(gatewayID); return true; } catch (AppCatalogException e) { - logger.error("Error while removing gateway resource profile...", e); + logger.errorId(gatewayID, "Error while removing gateway resource profile...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while removing gateway resource profile. More info : " + e.getMessage()); @@ -2414,7 +2400,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { gatewayProfile.updateGatewayResourceProfile(gatewayID, profile); return true; } catch (AppCatalogException e) { - logger.error("Error while registering gateway resource profile preference...", e); + logger.errorId(gatewayID, "Error while registering gateway resource profile preference...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while registering gateway resource profile preference. More info : " + e.getMessage()); @@ -2437,14 +2423,14 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); ComputeResource computeResource = appCatalog.getComputeResource(); if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)){ - logger.error("Given gateway profile does not exist in the system. Please provide a valid gateway id..."); + logger.errorId(gatewayID, "Given gateway profile does not exist in the system. Please provide a valid gateway id..."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Given gateway profile does not exist in the system. Please provide a valid gateway id..."); throw exception; } if (!computeResource.isComputeResourceExists(computeResourceId)){ - logger.error("Given compute resource does not exist in the system. Please provide a valid compute resource id..."); + logger.errorId(computeResourceId, "Given compute resource does not exist in the system. Please provide a valid compute resource id..."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Given compute resource does not exist in the system. Please provide a valid compute resource id..."); @@ -2452,7 +2438,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { } return gatewayProfile.getComputeResourcePreference(gatewayID, computeResourceId); } catch (AppCatalogException e) { - logger.error("Error while reading gateway compute resource preference...", e); + logger.errorId(gatewayID, "Error while reading gateway compute resource preference...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while reading gateway compute resource preference. More info : " + e.getMessage()); @@ -2474,7 +2460,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); return gatewayProfile.getGatewayProfile(gatewayID).getComputeResourcePreferences(); } catch (AppCatalogException e) { - logger.error("Error while reading gateway compute resource preferences...", e); + logger.errorId(gatewayID, "Error while reading gateway compute resource preferences...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while reading gateway compute resource preferences. More info : " + e.getMessage()); @@ -2513,7 +2499,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { gatewayProfile.updateGatewayResourceProfile(gatewayID, profile); return true; } catch (AppCatalogException e) { - logger.error("Error while reading gateway compute resource preference...", e); + logger.errorId(gatewayID, "Error while reading gateway compute resource preference...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating gateway compute resource preference. More info : " + e.getMessage()); @@ -2550,7 +2536,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher { gatewayProfile.updateGatewayResourceProfile(gatewayID, profile); return true; } catch (AppCatalogException e) { - logger.error("Error while reading gateway compute resource preference...", e); + logger.errorId(gatewayID, "Error while reading gateway compute resource preference...", e); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); exception.setMessage("Error while updating gateway compute resource preference. More info : " + e.getMessage()); http://git-wip-us.apache.org/repos/asf/airavata/blob/595be55f/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java new file mode 100644 index 0000000..9477cc9 --- /dev/null +++ b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java @@ -0,0 +1,677 @@ +/* + * + * 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. + * + */ + +package org.apache.airavata.common.logger; + +public interface AiravataLogger{ + + /** + * Return the name of this Logger instance. + * + * @return name of this logger instance + */ + String getName(); + + /** + * Is the logger instance enabled for the TRACE level? + * + * @return True if this Logger is enabled for the TRACE level, + * false otherwise. + * @since 1.4 + */ + boolean isTraceEnabled(); + + /** + * Log a message at the TRACE level. + * + * @param msg the message string to be logged + * @since 1.4 + */ + void trace(String msg); + + /** + * Log a message at the TRACE level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + * @since 1.4 + */ + void traceId(String etjId, String msg); + + /** + * Log a message at the TRACE level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the TRACE level.

+ * + * @param format the format string + * @param arg the argument + * @since 1.4 + */ + void trace(String format, Object arg); + + /** + * Log a message at the TRACE level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the TRACE level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + * @since 1.4 + */ + void traceId(String etjId, String format, Object arg); + + /** + * Log a message at the TRACE level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the TRACE level.

+ * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + * @since 1.4 + */ + void trace(String format, Object arg1, Object arg2); + + /** + * Log a message at the TRACE level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the TRACE level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + * @since 1.4 + */ + void traceId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log a message at the TRACE level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the TRACE level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and + * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.

+ * + * @param format the format string + * @param arguments a list of 3 or more arguments + * @since 1.4 + */ + void trace(String format, Object... arguments); + + /** + * Log a message at the TRACE level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the TRACE level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and + * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + * @since 1.4 + */ + void traceId(String etjId, String format, Object... arguments); + + /** + * Log an exception (throwable) at the TRACE level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + * @since 1.4 + */ + void trace(String msg, Throwable t); + + /** + * Log an exception (throwable) at the TRACE level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + * @since 1.4 + */ + void traceId(String etjId, String msg, Throwable t); + + /** + * Is the logger instance enabled for the DEBUG level? + * + * @return True if this Logger is enabled for the DEBUG level, + * false otherwise. + */ + boolean isDebugEnabled(); + + /** + * Log a message at the DEBUG level. + * + * @param msg the message string to be logged + */ + void debug(String msg); + + /** + * Log a message at the DEBUG level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + */ + void debugId(String etjId, String msg); + + /** + * Log a message at the DEBUG level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the DEBUG level.

+ * + * @param format the format string + * @param arg the argument + */ + void debug(String format, Object arg); + + /** + * Log a message at the DEBUG level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the DEBUG level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + */ + void debugId(String etjId, String format, Object arg); + + /** + * Log a message at the DEBUG level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the DEBUG level.

+ * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void debug(String format, Object arg1, Object arg2); + + /** + * Log a message at the DEBUG level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the DEBUG level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void debugId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log a message at the DEBUG level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the DEBUG level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for DEBUG. The variants taking + * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.

+ * + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void debug(String format, Object... arguments); + + /** + * Log a message at the DEBUG level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the DEBUG level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for DEBUG. The variants taking + * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void debugId(String etjId, String format, Object... arguments); + + /** + * Log an exception (throwable) at the DEBUG level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void debug(String msg, Throwable t); + + /** + * Log an exception (throwable) at the DEBUG level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void debugId(String etjId, String msg, Throwable t); + + /** + * Is the logger instance enabled for the INFO level? + * + * @return True if this Logger is enabled for the INFO level, + * false otherwise. + */ + boolean isInfoEnabled(); + + /** + * Log a message at the INFO level. + * + * @param msg the message string to be logged + */ + void info(String msg); + + /** + * Log a message at the INFO level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + */ + void infoId(String etjId, String msg); + + /** + * Log a message at the INFO level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the INFO level.

+ * + * @param format the format string + * @param arg the argument + */ + void info(String format, Object arg); + + /** + * Log a message at the INFO level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the INFO level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + */ + void infoId(String etjId, String format, Object arg); + + /** + * Log a message at the INFO level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the INFO level.

+ * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void info(String format, Object arg1, Object arg2); + + /** + * Log a message at the INFO level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the INFO level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void infoId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log a message at the INFO level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the INFO level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for INFO. The variants taking + * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.

+ * + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void info(String format, Object... arguments); + + /** + * Log a message at the INFO level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the INFO level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for INFO. The variants taking + * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void infoId(String etjId, String format, Object... arguments); + + /** + * Log an exception (throwable) at the INFO level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void info(String msg, Throwable t); + + /** + * Log an exception (throwable) at the INFO level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void infoId(String etjId, String msg, Throwable t); + + /** + * Is the logger instance enabled for the WARN level? + * + * @return True if this Logger is enabled for the WARN level, + * false otherwise. + */ + boolean isWarnEnabled(); + + /** + * Log a message at the WARN level. + * + * @param msg the message string to be logged + */ + void warn(String msg); + + /** + * Log a message at the WARN level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + */ + void warnId(String etjId, String msg); + + /** + * Log a message at the WARN level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the WARN level.

+ * + * @param format the format string + * @param arg the argument + */ + void warn(String format, Object arg); + + /** + * Log a message at the WARN level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the WARN level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + */ + void warnId(String etjId, String format, Object arg); + + /** + * Log a message at the WARN level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the WARN level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for WARN. The variants taking + * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.

+ * + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void warn(String format, Object... arguments); + + /** + * Log a message at the WARN level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the WARN level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for WARN. The variants taking + * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void warnId(String etjId, String format, Object... arguments); + + /** + * Log a message at the WARN level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the WARN level.

+ * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void warn(String format, Object arg1, Object arg2); + + /** + * Log a message at the WARN level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the WARN level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void warnId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log an exception (throwable) at the WARN level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void warn(String msg, Throwable t); + + /** + * Log an exception (throwable) at the WARN level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void warnId(String etjId, String msg, Throwable t); + + /** + * Is the logger instance enabled for the ERROR level? + * + * @return True if this Logger is enabled for the ERROR level, + * false otherwise. + */ + boolean isErrorEnabled(); + + /** + * Log a message at the ERROR level. + * + * @param msg the message string to be logged + */ + void error(String msg); + + /** + * Log a message at the ERROR level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + */ + void errorId(String etjId, String msg); + + /** + * Log a message at the ERROR level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the ERROR level.

+ * + * @param format the format string + * @param arg the argument + */ + void error(String format, Object arg); + + /** + * Log a message at the ERROR level according to the specified format + * and argument. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the ERROR level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + */ + void errorId(String etjId, String format, Object arg); + + /** + * Log a message at the ERROR level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the ERROR level.

+ * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void error(String format, Object arg1, Object arg2); + + /** + * Log a message at the ERROR level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous object creation when the logger + * is disabled for the ERROR level.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void errorId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log a message at the ERROR level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the ERROR level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for ERROR. The variants taking + * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.

+ * + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void error(String format, Object... arguments); + + /** + * Log a message at the ERROR level according to the specified format + * and arguments. + *

+ *

This form avoids superfluous string concatenation when the logger + * is disabled for the ERROR level. However, this variant incurs the hidden + * (and relatively small) cost of creating an Object[] before invoking the method, + * even if this logger is disabled for ERROR. The variants taking + * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.

+ * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void errorId(String etjId, String format, Object... arguments); + + /** + * Log an exception (throwable) at the ERROR level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void error(String msg, Throwable t); + + /** + * Log an exception (throwable) at the ERROR level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void errorId(String etjId, String msg, Throwable t); + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/595be55f/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java new file mode 100644 index 0000000..a1a9462 --- /dev/null +++ b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java @@ -0,0 +1,34 @@ +/* + * + * 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. + * + */ + +package org.apache.airavata.common.logger; + +public class AiravataLoggerFactory { + + public static AiravataLogger getLogger(Class aClass) { + return new AiravataLoggerImpl(aClass); + } + + public static AiravataLogger getLogger(String className) { + return new AiravataLoggerImpl(className); + } + +}