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;
}
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;
}
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);
}
}
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);
}
}
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;
}
}
Aggregations