use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.
the class GfacServerHandler method submissionErrorHandling.
private void submissionErrorHandling(ProcessStatus status, ProcessSubmitEvent event, TException e) throws RegistryException, AiravataException {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
ErrorModel errorModel = new ErrorModel();
errorModel.setUserFriendlyMessage("Process execution failed");
errorModel.setActualErrorMessage(errors.toString());
errorModel.setCreationTime(AiravataUtils.getCurrentTimestamp().getTime());
errorModel.setErrorId(AiravataUtils.getId("PROCESS_ERROR"));
Factory.getDefaultExpCatalog().add(ExpCatChildDataType.PROCESS_ERROR, errorModel, event.getProcessId());
errorModel.setErrorId(AiravataUtils.getId("EXP_ERROR"));
Factory.getDefaultExpCatalog().add(ExpCatChildDataType.EXPERIMENT_ERROR, errorModel, event.getExperimentId());
status.setState(ProcessState.FAILED);
status.setReason("Process execution failed");
status.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
Factory.getDefaultExpCatalog().update(ExperimentCatalogModelType.PROCESS_STATUS, status, event.getProcessId());
publishProcessStatus(event, status);
}
use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.
the class SimpleOrchestratorImpl method validateProcess.
public ValidationResults validateProcess(ExperimentModel experiment, ProcessModel processModel) 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> validatorClzzez = this.orchestratorContext.getOrchestratorConfiguration().getValidatorClasses();
for (String validator : validatorClzzez) {
try {
Class<? extends JobMetadataValidator> vClass = Class.forName(validator.trim()).asSubclass(JobMetadataValidator.class);
JobMetadataValidator jobMetadataValidator = vClass.newInstance();
validationResults = jobMetadataValidator.validate(experiment, processModel);
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.PROCESS_ERROR, details, processModel.getProcessId());
} catch (RegistryException e) {
logger.error("Error while saving error details to registry", e);
}
break;
}
} catch (ClassNotFoundException | InstantiationException | 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;
}
}
use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.
the class ExperimentRegistry method addExperiment.
// CPI Add Methods
public String addExperiment(ExperimentModel experiment) throws RegistryException {
String experimentId;
try {
if (!ExpCatResourceUtils.isUserExist(experiment.getUserName(), experiment.getGatewayId())) {
ExpCatResourceUtils.addUser(experiment.getUserName(), null, experiment.getGatewayId());
}
if (!workerResource.isProjectExists(experiment.getProjectId())) {
logger.error("Project does not exist in the system..");
throw new Exception("Project does not exist in the system, Please create the project first...");
}
experimentId = AiravataUtils.getId(experiment.getExperimentName());
experiment.setExperimentId(experimentId);
ExperimentResource experimentResource = new ExperimentResource();
experimentResource.setExperimentId(experimentId);
experimentResource.setProjectId(experiment.getProjectId());
experimentResource.setGatewayId(experiment.getGatewayId());
experimentResource.setExperimentType(experiment.getExperimentType().toString());
experimentResource.setUserName(experiment.getUserName());
experimentResource.setExperimentName(experiment.getExperimentName());
experimentResource.setCreationTime(AiravataUtils.getTime(experiment.getCreationTime()));
experimentResource.setDescription(experiment.getDescription());
experimentResource.setExecutionId(experiment.getExecutionId());
experimentResource.setGatewayExecutionId(experiment.getGatewayExecutionId());
experimentResource.setGatewayInstanceId(experiment.getGatewayInstanceId());
if (experiment.isEnableEmailNotification()) {
experimentResource.setEnableEmailNotification(true);
if (experiment.getEmailAddresses() != null) {
experimentResource.setEmailAddresses(StringUtils.join(experiment.getEmailAddresses(), ","));
}
} else {
experimentResource.setEnableEmailNotification(false);
}
experimentResource.save();
if (experiment.getUserConfigurationData() != null) {
addUserConfigData(experiment.getUserConfigurationData(), experimentId);
}
if (experiment.getExperimentInputs() != null && experiment.getExperimentInputs().size() > 0) {
addExpInputs(experiment.getExperimentInputs(), experimentId);
}
if (experiment.getExperimentOutputs() != null && experiment.getExperimentOutputs().size() > 0) {
addExpOutputs(experiment.getExperimentOutputs(), experimentId);
}
ExperimentStatus experimentStatus = new ExperimentStatus();
experimentStatus.setState(ExperimentState.CREATED);
experimentStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
addExperimentStatus(experimentStatus, experimentId);
List<ErrorModel> errors = experiment.getErrors();
if (errors != null && !errors.isEmpty()) {
for (ErrorModel errror : errors) {
addExperimentError(errror, experimentId);
}
}
} catch (Exception e) {
logger.error("Error while saving experiment to registry", e);
throw new RegistryException(e);
}
return experimentId;
}
use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.
the class ExperimentRegistry method updateExperiment.
// CPI Update Methods
public void updateExperiment(ExperimentModel experiment, String expId) throws RegistryException {
try {
if (!workerResource.isProjectExists(experiment.getProjectId())) {
logger.error("Project does not exist in the system..");
throw new Exception("Project does not exist in the system, Please create the project first...");
}
ExperimentResource existingExperiment = gatewayResource.getExperiment(expId);
existingExperiment.setExperimentName(experiment.getExperimentName());
existingExperiment.setUserName(experiment.getUserName());
existingExperiment.setGatewayId(experiment.getGatewayId());
existingExperiment.setGatewayExecutionId(experiment.getGatewayExecutionId());
existingExperiment.setGatewayInstanceId(experiment.getGatewayInstanceId());
existingExperiment.setProjectId(experiment.getProjectId());
existingExperiment.setCreationTime(AiravataUtils.getTime(experiment.getCreationTime()));
existingExperiment.setDescription(experiment.getDescription());
existingExperiment.setExecutionId(experiment.getExecutionId());
if (experiment.isEnableEmailNotification()) {
existingExperiment.setEnableEmailNotification(true);
if (experiment.getEmailAddresses() != null) {
existingExperiment.setEmailAddresses(StringUtils.join(experiment.getEmailAddresses(), ","));
}
} else {
existingExperiment.setEnableEmailNotification(false);
}
existingExperiment.save();
UserConfigurationDataModel userConfigurationData = experiment.getUserConfigurationData();
if (userConfigurationData != null) {
updateUserConfigData(userConfigurationData, expId);
}
List<InputDataObjectType> experimentInputs = experiment.getExperimentInputs();
if (experimentInputs != null && !experimentInputs.isEmpty()) {
updateExpInputs(experimentInputs, expId);
}
List<OutputDataObjectType> experimentOutputs = experiment.getExperimentOutputs();
if (experimentOutputs != null && !experimentOutputs.isEmpty()) {
updateExpOutputs(experimentOutputs, expId);
}
List<ExperimentStatus> experimentStatuses = experiment.getExperimentStatus();
if (experimentStatuses != null && experimentStatuses.size() > 0) {
if (experimentStatuses.get(0) != null) {
updateExperimentStatus(experimentStatuses.get(0), expId);
}
}
List<ErrorModel> errors = experiment.getErrors();
if (errors != null && !errors.isEmpty()) {
for (ErrorModel errror : errors) {
updateExperimentError(errror, expId);
}
}
} catch (Exception e) {
logger.error("Error while updating experiment...", e);
throw new RegistryException(e);
}
}
use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.
the class ThriftDataModelConversion method getTaskModel.
public static TaskModel getTaskModel(TaskResource taskResource) throws RegistryException {
TaskModel model = new TaskModel();
model.setTaskId(taskResource.getTaskId());
model.setTaskType(TaskTypes.valueOf(taskResource.getTaskType()));
model.setParentProcessId(taskResource.getParentProcessId());
model.setCreationTime(taskResource.getCreationTime().getTime());
model.setLastUpdateTime(taskResource.getLastUpdateTime().getTime());
model.setTaskDetail(taskResource.getTaskDetail());
model.setSubTaskModel(taskResource.getSubTaskModel());
TaskStatus taskStatus = getTaskStatus(taskResource.getTaskStatus());
if (taskStatus != null) {
List<TaskStatus> taskStatuses = new ArrayList<>();
taskStatuses.add(taskStatus);
model.setTaskStatuses(taskStatuses);
}
ErrorModel errorModel = getErrorModel(taskResource.getTaskError());
if (errorModel != null) {
List<ErrorModel> errors = new ArrayList<>();
errors.add(errorModel);
model.setTaskErrors(errors);
}
return model;
}
Aggregations