Search in sources :

Example 1 with ErrorModel

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

the class GFacEngineImpl method outputDataStaging.

/**
 * @param taskContext
 * @param recovery
 * @return <code>true</code> if process execution interrupted , <code>false</code> otherwise.
 * @throws GFacException
 */
private boolean outputDataStaging(TaskContext taskContext, boolean recovery, boolean isArchive) throws GFacException {
    TaskStatus taskStatus = new TaskStatus(TaskState.EXECUTING);
    taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
    taskContext.setTaskStatus(taskStatus);
    GFacUtils.saveAndPublishTaskStatus(taskContext);
    ProcessContext processContext = taskContext.getParentProcessContext();
    Task dMoveTask = null;
    if (isArchive) {
        dMoveTask = Factory.getArchiveTask();
    } else {
        dMoveTask = Factory.getDataMovementTask(processContext.getDataMovementProtocol());
    }
    if (null == dMoveTask) {
        throw new GFacException("Unsupported security protocol, Airavata doesn't support " + processContext.getDataMovementProtocol() + " protocol yet.");
    }
    taskStatus = executeTask(taskContext, dMoveTask, recovery);
    taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
    taskContext.setTaskStatus(taskStatus);
    GFacUtils.saveAndPublishTaskStatus(taskContext);
    if (taskStatus.getState() == TaskState.FAILED) {
        log.error("expId: {}, processId: {}, taskId: {} type: {},:- output staging failed, " + "reason:" + " {}", taskContext.getParentProcessContext().getExperimentId(), taskContext.getParentProcessContext().getProcessId(), taskContext.getTaskId(), dMoveTask.getType().name(), taskStatus.getReason());
        String errorMsg = new StringBuilder("expId: ").append(processContext.getExperimentId()).append(", processId: ").append(processContext.getProcessId()).append(", taskId: ").append(taskContext.getTaskId()).append(", type: ").append(taskContext.getTaskType().name()).append(" :- Output staging failed. Reason: ").append(taskStatus.getReason()).toString();
        ErrorModel errorModel = new ErrorModel();
        errorModel.setUserFriendlyMessage("Error while staging output data");
        errorModel.setActualErrorMessage(errorMsg);
        GFacUtils.saveTaskError(taskContext, errorModel);
    }
    return false;
}
Also used : DataStreamingTask(org.apache.airavata.gfac.impl.task.DataStreamingTask) Task(org.apache.airavata.gfac.core.task.Task) JobSubmissionTask(org.apache.airavata.gfac.core.task.JobSubmissionTask) EnvironmentSetupTask(org.apache.airavata.gfac.impl.task.EnvironmentSetupTask) GFacException(org.apache.airavata.gfac.core.GFacException) ErrorModel(org.apache.airavata.model.commons.ErrorModel) TaskStatus(org.apache.airavata.model.status.TaskStatus) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext)

Example 2 with ErrorModel

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

the class GFacEngineImpl method saveErrorModel.

private void saveErrorModel(ProcessContext pc, Exception e, String userFriendlyMsg) throws GFacException {
    if (pc == null) {
        throw new GFacException("Can't save error process context is null", e);
    }
    StringWriter errors = new StringWriter();
    e.printStackTrace(new PrintWriter(errors));
    ErrorModel errorModel = new ErrorModel();
    errorModel.setUserFriendlyMessage(userFriendlyMsg);
    errorModel.setActualErrorMessage(errors.toString());
    errorModel.setCreationTime(AiravataUtils.getCurrentTimestamp().getTime());
    try {
        GFacUtils.saveProcessError(pc, errorModel);
        GFacUtils.saveExperimentError(pc, errorModel);
    } catch (GFacException e1) {
        log.error("Error while updating error model for process:" + pc.getProcessId());
    }
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) StringWriter(java.io.StringWriter) ErrorModel(org.apache.airavata.model.commons.ErrorModel) PrintWriter(java.io.PrintWriter)

Example 3 with ErrorModel

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

the class GFacEngineImpl method executeJobMonitoring.

private void executeJobMonitoring(TaskContext taskContext, boolean recovery) throws GFacException {
    ProcessContext processContext = taskContext.getParentProcessContext();
    TaskStatus taskStatus;
    JobMonitor monitorService = null;
    try {
        taskStatus = new TaskStatus(TaskState.EXECUTING);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskContext.setTaskStatus(taskStatus);
        GFacUtils.saveAndPublishTaskStatus(taskContext);
        MonitorTaskModel monitorTaskModel = ((MonitorTaskModel) taskContext.getSubTaskModel());
        monitorService = Factory.getMonitorService(monitorTaskModel.getMonitorMode());
        if (!monitorService.isMonitoring(processContext.getJobModel().getJobId())) {
            monitorService.monitor(processContext.getJobModel().getJobId(), taskContext);
        } else {
            log.warn("Jobid: {}, already in monitoring map", processContext.getJobModel().getJobId());
        }
    } catch (AiravataException | TException e) {
        taskStatus = new TaskStatus(TaskState.FAILED);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskStatus.setReason("Couldn't handover jobId {} to monitor service, monitor service type {}");
        taskContext.setTaskStatus(taskStatus);
        GFacUtils.saveAndPublishTaskStatus(taskContext);
        String errorMsg = new StringBuilder("expId: ").append(processContext.getExperimentId()).append(", processId: ").append(processContext.getProcessId()).append(", taskId: ").append(taskContext.getTaskId()).append(", type: ").append(taskContext.getTaskType().name()).append(" :- Input staging failed. Reason: ").append(taskStatus.getReason()).toString();
        ErrorModel errorModel = new ErrorModel();
        errorModel.setUserFriendlyMessage("Error while staging output data");
        errorModel.setActualErrorMessage(errorMsg);
        GFacUtils.saveTaskError(taskContext, errorModel);
        throw new GFacException(e);
    }
    if (processContext.isPauseTaskExecution()) {
        // we won't update task status to complete, job monitor will update task status to complete after it complete monitoring for this job id.
        return;
    }
    taskStatus = new TaskStatus(TaskState.COMPLETED);
    taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
    taskStatus.setReason("Successfully handed over job id to job monitor service.");
    taskContext.setTaskStatus(taskStatus);
    GFacUtils.saveAndPublishTaskStatus(taskContext);
}
Also used : TException(org.apache.thrift.TException) GFacException(org.apache.airavata.gfac.core.GFacException) ErrorModel(org.apache.airavata.model.commons.ErrorModel) TaskStatus(org.apache.airavata.model.status.TaskStatus) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext) JobMonitor(org.apache.airavata.gfac.core.monitor.JobMonitor) MonitorTaskModel(org.apache.airavata.model.task.MonitorTaskModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 4 with ErrorModel

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

the class DataStageTask method execute.

@Override
public TaskStatus execute(TaskContext taskContext) {
    TaskStatus status = new TaskStatus(TaskState.COMPLETED);
    if (taskContext.getTaskModel().getTaskType() != TaskTypes.DATA_STAGING) {
        status.setState(TaskState.FAILED);
        status.setReason("Invalid task call, expected " + TaskTypes.DATA_STAGING.toString() + " but found " + taskContext.getTaskModel().getTaskType().toString());
    } else {
        try {
            DataStagingTaskModel subTaskModel = ((DataStagingTaskModel) taskContext.getSubTaskModel());
            URI sourceURI = new URI(subTaskModel.getSource());
            URI destinationURI = new URI(subTaskModel.getDestination());
            ProcessState processState = taskContext.getParentProcessContext().getProcessState();
            if (processState == ProcessState.INPUT_DATA_STAGING) {
                /**
                 * copy local file to compute resource.
                 */
                taskContext.getParentProcessContext().getDataMovementRemoteCluster().copyTo(sourceURI.getPath(), destinationURI.getPath());
            } else if (processState == ProcessState.OUTPUT_DATA_STAGING) {
                /**
                 * copy remote file from compute resource.
                 */
                taskContext.getParentProcessContext().getDataMovementRemoteCluster().copyFrom(sourceURI.getPath(), destinationURI.getPath());
            }
            status.setReason("Successfully staged data");
        } catch (GFacException e) {
            String msg = "Scp attempt failed";
            log.error(msg, e);
            status.setState(TaskState.FAILED);
            status.setReason(msg);
            ErrorModel errorModel = new ErrorModel();
            errorModel.setActualErrorMessage(e.getMessage());
            errorModel.setUserFriendlyMessage(msg);
            taskContext.getTaskModel().setTaskErrors(Arrays.asList(errorModel));
        } catch (TException e) {
            String msg = "Invalid task invocation";
            log.error(msg, e);
            status.setState(TaskState.FAILED);
            status.setReason(msg);
            ErrorModel errorModel = new ErrorModel();
            errorModel.setActualErrorMessage(e.getMessage());
            errorModel.setUserFriendlyMessage(msg);
            taskContext.getTaskModel().setTaskErrors(Arrays.asList(errorModel));
        } catch (URISyntaxException e) {
            String msg = "source or destination is not a valid URI";
            log.error(msg, e);
            status.setState(TaskState.FAILED);
            status.setReason(msg);
            ErrorModel errorModel = new ErrorModel();
            errorModel.setActualErrorMessage(e.getMessage());
            errorModel.setUserFriendlyMessage(msg);
            taskContext.getTaskModel().setTaskErrors(Arrays.asList(errorModel));
        }
    }
    return status;
}
Also used : ProcessState(org.apache.airavata.model.status.ProcessState) TException(org.apache.thrift.TException) GFacException(org.apache.airavata.gfac.core.GFacException) DataStagingTaskModel(org.apache.airavata.model.task.DataStagingTaskModel) ErrorModel(org.apache.airavata.model.commons.ErrorModel) URISyntaxException(java.net.URISyntaxException) TaskStatus(org.apache.airavata.model.status.TaskStatus) URI(java.net.URI)

Example 5 with ErrorModel

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

the class EnvironmentSetupTask method execute.

@Override
public TaskStatus execute(TaskContext taskContext) {
    TaskStatus status = new TaskStatus(TaskState.COMPLETED);
    try {
        RemoteCluster remoteCluster = taskContext.getParentProcessContext().getJobSubmissionRemoteCluster();
        remoteCluster.makeDirectory(taskContext.getParentProcessContext().getWorkingDir());
        status.setReason("Successfully created environment");
    } catch (GFacException e) {
        String msg = "Error while environment setup";
        log.error(msg, e);
        status.setState(TaskState.FAILED);
        status.setReason(msg);
        ErrorModel errorModel = new ErrorModel();
        errorModel.setActualErrorMessage(e.getMessage());
        errorModel.setUserFriendlyMessage(msg);
        taskContext.getTaskModel().setTaskErrors(Arrays.asList(errorModel));
    }
    return status;
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) RemoteCluster(org.apache.airavata.gfac.core.cluster.RemoteCluster) ErrorModel(org.apache.airavata.model.commons.ErrorModel) TaskStatus(org.apache.airavata.model.status.TaskStatus)

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