Search in sources :

Example 11 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.

the class ThriftDataModelConversion method getErrorModel.

public static ErrorModel getErrorModel(Object object) {
    if (object != null) {
        ErrorModel errorModel = new ErrorModel();
        if (object instanceof ExperimentErrorResource) {
            ExperimentErrorResource errorResource = (ExperimentErrorResource) object;
            errorModel.setErrorId(errorResource.getErrorId());
            errorModel.setCreationTime(errorResource.getCreationTime().getTime());
            errorModel.setActualErrorMessage(errorResource.getActualErrorMessage());
            errorModel.setUserFriendlyMessage(errorResource.getUserFriendlyMessage());
            errorModel.setTransientOrPersistent(errorResource.getTransientOrPersistent());
            String rootCauseErrorIdList = errorResource.getRootCauseErrorIdList();
            if (rootCauseErrorIdList != null) {
                errorModel.setRootCauseErrorIdList(Arrays.asList(rootCauseErrorIdList.split(",")));
            }
            return errorModel;
        } else if (object instanceof ProcessErrorResource) {
            ProcessErrorResource errorResource = (ProcessErrorResource) object;
            errorModel.setErrorId(errorResource.getErrorId());
            errorModel.setCreationTime(errorResource.getCreationTime().getTime());
            errorModel.setActualErrorMessage(errorResource.getActualErrorMessage());
            errorModel.setUserFriendlyMessage(errorResource.getUserFriendlyMessage());
            errorModel.setTransientOrPersistent(errorResource.getTransientOrPersistent());
            String rootCauseErrorIdList = errorResource.getRootCauseErrorIdList();
            if (rootCauseErrorIdList != null) {
                errorModel.setRootCauseErrorIdList(Arrays.asList(rootCauseErrorIdList.split(",")));
            }
            return errorModel;
        } else if (object instanceof TaskErrorResource) {
            TaskErrorResource errorResource = (TaskErrorResource) object;
            errorModel.setErrorId(errorResource.getErrorId());
            errorModel.setCreationTime(errorResource.getCreationTime().getTime());
            errorModel.setActualErrorMessage(errorResource.getActualErrorMessage());
            errorModel.setUserFriendlyMessage(errorResource.getUserFriendlyMessage());
            errorModel.setTransientOrPersistent(errorResource.getTransientOrPersistent());
            String rootCauseErrorIdList = errorResource.getRootCauseErrorIdList();
            if (rootCauseErrorIdList != null) {
                errorModel.setRootCauseErrorIdList(Arrays.asList(rootCauseErrorIdList.split(",")));
            }
            return errorModel;
        } else {
            return null;
        }
    }
    return null;
}
Also used : ErrorModel(org.apache.airavata.model.commons.ErrorModel)

Example 12 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.

the class ThriftDataModelConversion method getProcessModel.

public static ProcessModel getProcessModel(ProcessResource processResource) throws RegistryException {
    if (processResource != null) {
        ProcessModel processModel = new ProcessModel();
        processModel.setProcessId(processResource.getProcessId());
        processModel.setExperimentId(processResource.getExperimentId());
        processModel.setCreationTime(processResource.getCreationTime().getTime());
        processModel.setLastUpdateTime(processResource.getLastUpdateTime().getTime());
        processModel.setProcessDetail(processResource.getProcessDetail());
        processModel.setApplicationInterfaceId(processResource.getApplicationInterfaceId());
        processModel.setTaskDag(processResource.getTaskDag());
        processModel.setGatewayExecutionId(processResource.getGatewayExecutionId());
        processModel.setApplicationDeploymentId(processResource.getApplicationDeploymentId());
        processModel.setComputeResourceId(processResource.getComputeResourceId());
        processModel.setEnableEmailNotification(processResource.getEnableEmailNotification());
        processModel.setExperimentDataDir(processResource.getExperimentDataDir());
        processModel.setUseUserCRPref(processResource.isUseUserCRPref());
        if (processModel.isEnableEmailNotification()) {
            String notificationEmails = processResource.getEmailAddresses();
            processModel.setEmailAddresses(getEmailAddresses(notificationEmails.split(",")));
        }
        processModel.setProcessInputs(getProcessInputs(processResource.getProcessInputs()));
        processModel.setProcessOutputs(getProcessOutputs(processResource.getProcessOutputs()));
        ErrorModel errorModel = getErrorModel(processResource.getProcessError());
        if (errorModel != null) {
            List<ErrorModel> errorModels = new ArrayList<>();
            errorModels.add(errorModel);
            processModel.setProcessErrors(errorModels);
        }
        ProcessStatus processStatus = getProcessStatus(processResource.getProcessStatus());
        if (processStatus != null) {
            List<ProcessStatus> statuses = new ArrayList<>();
            statuses.add(processStatus);
            processModel.setProcessStatuses(statuses);
        }
        ComputationalResourceSchedulingModel schedule = getProcessResourceSchedule(processResource.getProcessResourceSchedule());
        if (schedule != null) {
            processModel.setProcessResourceSchedule(schedule);
        }
        processModel.setTasks(getTaskModelList(processResource.getTaskList()));
        processModel.setStorageResourceId(processResource.getStorageResourceId());
        processModel.setUserDn(processResource.getUserDn());
        processModel.setGenerateCert(processResource.isGenerateCert());
        processModel.setUserName(processResource.getUserName());
        return processModel;
    }
    return null;
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) ArrayList(java.util.ArrayList) ErrorModel(org.apache.airavata.model.commons.ErrorModel) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 13 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.

the class CreateLaunchExperiment method getExperiment.

public static void getExperiment(Airavata.Client client, String expId) throws Exception {
    try {
        ExperimentModel experiment = client.getExperiment(new AuthzToken(""), expId);
        List<ErrorModel> errors = experiment.getErrors();
        if (errors != null && !errors.isEmpty()) {
            for (ErrorModel error : errors) {
                System.out.println("ERROR MESSAGE : " + error.getActualErrorMessage());
            }
        }
    } catch (ExperimentNotFoundException e) {
        logger.error("Experiment does not exist", e);
        throw new ExperimentNotFoundException("Experiment does not exist");
    } catch (AiravataSystemException e) {
        logger.error("Error while retrieving experiment", e);
        throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
    } catch (InvalidRequestException e) {
        logger.error("Error while retrieving experiment", e);
        throw new InvalidRequestException("Error while retrieving experiment");
    } catch (AiravataClientException e) {
        logger.error("Error while retrieving experiment", e);
        throw new AiravataClientException(AiravataErrorType.INTERNAL_ERROR);
    }
}
Also used : ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) ErrorModel(org.apache.airavata.model.commons.ErrorModel)

Example 14 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.

the class CreateLaunchBES method getExperiment.

public static void getExperiment(Airavata.Client client, String expId) throws Exception {
    try {
        ExperimentModel experiment = client.getExperiment(new AuthzToken(""), expId);
        List<ErrorModel> errors = experiment.getErrors();
        if (errors != null && !errors.isEmpty()) {
            for (ErrorModel error : errors) {
                System.out.println("ERROR MESSAGE : " + error.getActualErrorMessage());
            }
        }
    } catch (ExperimentNotFoundException e) {
        logger.error("Experiment does not exist", e);
        throw new ExperimentNotFoundException("Experiment does not exist");
    } catch (AiravataSystemException e) {
        logger.error("Error while retrieving experiment", e);
        throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
    } catch (InvalidRequestException e) {
        logger.error("Error while retrieving experiment", e);
        throw new InvalidRequestException("Error while retrieving experiment");
    } catch (AiravataClientException e) {
        logger.error("Error while retrieving experiment", e);
        throw new AiravataClientException(AiravataErrorType.INTERNAL_ERROR);
    }
}
Also used : ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) ErrorModel(org.apache.airavata.model.commons.ErrorModel)

Example 15 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.

the class SimpleOrchestratorImpl method validateExperiment.

public ValidationResults validateExperiment(ExperimentModel experiment) throws OrchestratorException, LaunchValidationException {
    org.apache.airavata.model.error.ValidationResults validationResults = new org.apache.airavata.model.error.ValidationResults();
    // initially making it to success, if atleast one failed them simply mark it failed.
    validationResults.setValidationState(true);
    String errorMsg = "Validation Errors : ";
    if (this.orchestratorConfiguration.isEnableValidation()) {
        List<String> validatorClasses = this.orchestratorContext.getOrchestratorConfiguration().getValidatorClasses();
        for (String validator : validatorClasses) {
            try {
                Class<? extends JobMetadataValidator> vClass = Class.forName(validator.trim()).asSubclass(JobMetadataValidator.class);
                JobMetadataValidator jobMetadataValidator = vClass.newInstance();
                validationResults = jobMetadataValidator.validate(experiment, null);
                if (validationResults.isValidationState()) {
                    logger.info("Validation of " + validator + " is SUCCESSFUL");
                } else {
                    List<ValidatorResult> validationResultList = validationResults.getValidationResultList();
                    for (ValidatorResult result : validationResultList) {
                        if (!result.isResult()) {
                            String validationError = result.getErrorDetails();
                            if (validationError != null) {
                                errorMsg += validationError + " ";
                            }
                        }
                    }
                    logger.error("Validation of " + validator + " for experiment Id " + experiment.getExperimentId() + " is FAILED:[error]. " + errorMsg);
                    validationResults.setValidationState(false);
                    try {
                        ErrorModel details = new ErrorModel();
                        details.setActualErrorMessage(errorMsg);
                        details.setCreationTime(Calendar.getInstance().getTimeInMillis());
                        orchestratorContext.getRegistry().getExperimentCatalog().add(ExpCatChildDataType.EXPERIMENT_ERROR, details, experiment.getExperimentId());
                    } catch (RegistryException e) {
                        logger.error("Error while saving error details to registry", e);
                    }
                    break;
                }
            } catch (ClassNotFoundException e) {
                logger.error("Error loading the validation class: ", validator, e);
                validationResults.setValidationState(false);
            } catch (InstantiationException e) {
                logger.error("Error loading the validation class: ", validator, e);
                validationResults.setValidationState(false);
            } catch (IllegalAccessException e) {
                logger.error("Error loading the validation class: ", validator, e);
                validationResults.setValidationState(false);
            }
        }
    }
    if (validationResults.isValidationState()) {
        return validationResults;
    } else {
        // atleast one validation has failed, so we throw an exception
        LaunchValidationException launchValidationException = new LaunchValidationException();
        launchValidationException.setValidationResult(validationResults);
        launchValidationException.setErrorMessage("Validation failed refer the validationResults list for " + "detail error. Validation errors : " + errorMsg);
        throw launchValidationException;
    }
}
Also used : ValidatorResult(org.apache.airavata.model.error.ValidatorResult) LaunchValidationException(org.apache.airavata.model.error.LaunchValidationException) ValidationResults(org.apache.airavata.model.error.ValidationResults) ValidationResults(org.apache.airavata.model.error.ValidationResults) ErrorModel(org.apache.airavata.model.commons.ErrorModel) JobMetadataValidator(org.apache.airavata.orchestrator.core.validator.JobMetadataValidator)

Aggregations

ErrorModel (org.apache.airavata.model.commons.ErrorModel)25 GFacException (org.apache.airavata.gfac.core.GFacException)11 TaskStatus (org.apache.airavata.model.status.TaskStatus)10 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)9 TException (org.apache.thrift.TException)6 RemoteCluster (org.apache.airavata.gfac.core.cluster.RemoteCluster)5 File (java.io.File)4 IOException (java.io.IOException)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)4 JobModel (org.apache.airavata.model.job.JobModel)4 PrintWriter (java.io.PrintWriter)3 StringWriter (java.io.StringWriter)3 URI (java.net.URI)3 URISyntaxException (java.net.URISyntaxException)3 ArrayList (java.util.ArrayList)3 JobSubmissionOutput (org.apache.airavata.gfac.core.cluster.JobSubmissionOutput)3 ResourceJobManager (org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager)3 JobStatus (org.apache.airavata.model.status.JobStatus)3 ProcessState (org.apache.airavata.model.status.ProcessState)3