Search in sources :

Example 56 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class GFacEngineImpl method configureWorkspace.

private boolean configureWorkspace(TaskContext taskContext, boolean recover) throws GFacException {
    try {
        EnvironmentSetupTaskModel subTaskModel = (EnvironmentSetupTaskModel) taskContext.getSubTaskModel();
        Task envSetupTask = null;
        if (subTaskModel.getProtocol() == SecurityProtocol.SSH_KEYS || subTaskModel.getProtocol() == SecurityProtocol.LOCAL) {
            envSetupTask = new EnvironmentSetupTask();
        } else {
            throw new GFacException("Unsupported security protocol, Airavata doesn't support " + subTaskModel.getProtocol().name() + " protocol yet.");
        }
        TaskStatus status = new TaskStatus(TaskState.EXECUTING);
        status.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskContext.setTaskStatus(status);
        GFacUtils.saveAndPublishTaskStatus(taskContext);
        TaskStatus taskStatus = executeTask(taskContext, envSetupTask, recover);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskContext.setTaskStatus(taskStatus);
        GFacUtils.saveAndPublishTaskStatus(taskContext);
        if (taskStatus.getState() == TaskState.FAILED) {
            log.error("expId: {}, processId: {}, taskId: {} type: {},:- Input staging failed, " + "reason:" + " {}", taskContext.getParentProcessContext().getExperimentId(), taskContext.getParentProcessContext().getProcessId(), taskContext.getTaskId(), envSetupTask.getType().name(), taskStatus.getReason());
            ProcessContext processContext = taskContext.getParentProcessContext();
            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(" :- Environment Setup failed. Reason: ").append(taskStatus.getReason()).toString();
            ErrorModel errorModel = new ErrorModel();
            errorModel.setUserFriendlyMessage("Error while environment setup");
            errorModel.setActualErrorMessage(errorMsg);
            GFacUtils.saveTaskError(taskContext, errorModel);
            throw new GFacException("Error while environment setup");
        }
    } catch (TException e) {
        throw new GFacException("Couldn't get environment setup task model", e);
    }
    return false;
}
Also used : TException(org.apache.thrift.TException) EnvironmentSetupTaskModel(org.apache.airavata.model.task.EnvironmentSetupTaskModel) 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) EnvironmentSetupTask(org.apache.airavata.gfac.impl.task.EnvironmentSetupTask) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext)

Example 57 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class GFacEngineImpl method executeJobSubmission.

private boolean executeJobSubmission(TaskContext taskContext, boolean recovery) throws GFacException {
    TaskStatus taskStatus = new TaskStatus(TaskState.EXECUTING);
    taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
    taskContext.setTaskStatus(taskStatus);
    GFacUtils.saveAndPublishTaskStatus(taskContext);
    try {
        JobSubmissionTaskModel jobSubmissionTaskModel = ((JobSubmissionTaskModel) taskContext.getSubTaskModel());
        JobSubmissionTask jobSubmissionTask = Factory.getJobSubmissionTask(jobSubmissionTaskModel.getJobSubmissionProtocol());
        ProcessContext processContext = taskContext.getParentProcessContext();
        taskStatus = executeTask(taskContext, jobSubmissionTask, recovery);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskContext.setTaskStatus(taskStatus);
        GFacUtils.saveAndPublishTaskStatus(taskContext);
        checkFailures(taskContext, taskStatus, jobSubmissionTask);
        return false;
    } catch (TException e) {
        throw new GFacException(e);
    }
}
Also used : TException(org.apache.thrift.TException) GFacException(org.apache.airavata.gfac.core.GFacException) JobSubmissionTask(org.apache.airavata.gfac.core.task.JobSubmissionTask) TaskStatus(org.apache.airavata.model.status.TaskStatus) JobSubmissionTaskModel(org.apache.airavata.model.task.JobSubmissionTaskModel) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext)

Example 58 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class GFacEngineImpl method checkFailures.

private void checkFailures(TaskContext taskContext, TaskStatus taskStatus, Task task) throws GFacException {
    if (taskStatus.getState() == TaskState.FAILED) {
        log.error("expId: {}, processId: {}, taskId: {} type: {},:- " + task.getType().toString() + " failed, " + "reason:" + " {}", taskContext.getParentProcessContext().getExperimentId(), taskContext.getParentProcessContext().getProcessId(), taskContext.getTaskId(), task.getType().name(), taskStatus.getReason());
        String errorMsg = new StringBuilder("expId: ").append(taskContext.getParentProcessContext().getExperimentId()).append(", processId: ").append(taskContext.getParentProcessContext().getProcessId()).append(", taskId: ").append(taskContext.getTaskId()).append(", type: ").append(taskContext.getTaskType().name()).append(" :- " + task.getType().toString() + " failed. Reason: ").append(taskStatus.getReason()).toString();
        ErrorModel errorModel = new ErrorModel();
        errorModel.setUserFriendlyMessage("Error while executing " + task.getType() + " task");
        errorModel.setActualErrorMessage(errorMsg);
        GFacUtils.saveTaskError(taskContext, errorModel);
        throw new GFacException("Error: userFriendly msg :" + errorModel.getUserFriendlyMessage() + ", actual msg :" + errorModel.getActualErrorMessage());
    }
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) ErrorModel(org.apache.airavata.model.commons.ErrorModel)

Example 59 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class GFacEngineImpl method updateProcessFailure.

private void updateProcessFailure(ProcessContext pc, String reason) throws GFacException {
    if (pc == null) {
        throw new GFacException("Can't update process failure, process context is null");
    }
    ProcessStatus status = new ProcessStatus(ProcessState.FAILED);
    status.setReason(reason);
    pc.setProcessStatus(status);
    try {
        GFacUtils.saveAndPublishProcessStatus(pc);
    } catch (GFacException e) {
        log.error("Error while save and publishing process failed status event");
    }
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) ProcessStatus(org.apache.airavata.model.status.ProcessStatus)

Example 60 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class GFacEngineImpl method getResourceJobManager.

public static ResourceJobManager getResourceJobManager(ProcessContext processCtx) throws AppCatalogException, GFacException {
    List<JobSubmissionInterface> jobSubmissionInterfaces = Factory.getDefaultAppCatalog().getComputeResource().getComputeResource(processCtx.getComputeResourceId()).getJobSubmissionInterfaces();
    ResourceJobManager resourceJobManager = null;
    JobSubmissionInterface jsInterface = null;
    for (JobSubmissionInterface jobSubmissionInterface : jobSubmissionInterfaces) {
        if (jobSubmissionInterface.getJobSubmissionProtocol() == processCtx.getJobSubmissionProtocol()) {
            jsInterface = jobSubmissionInterface;
            break;
        }
    }
    if (jsInterface == null) {
        throw new GFacException("Job Submission interface cannot be empty at this point");
    } else if (jsInterface.getJobSubmissionProtocol() == JobSubmissionProtocol.SSH) {
        SSHJobSubmission sshJobSubmission = Factory.getDefaultAppCatalog().getComputeResource().getSSHJobSubmission(jsInterface.getJobSubmissionInterfaceId());
        // fixme - Move this to populate process
        processCtx.setMonitorMode(sshJobSubmission.getMonitorMode());
        // context method.
        resourceJobManager = sshJobSubmission.getResourceJobManager();
    } else if (jsInterface.getJobSubmissionProtocol() == JobSubmissionProtocol.LOCAL) {
        LOCALSubmission localSubmission = Factory.getDefaultAppCatalog().getComputeResource().getLocalJobSubmission(jsInterface.getJobSubmissionInterfaceId());
        resourceJobManager = localSubmission.getResourceJobManager();
    } else if (jsInterface.getJobSubmissionProtocol() == JobSubmissionProtocol.SSH_FORK) {
        SSHJobSubmission sshJobSubmission = Factory.getDefaultAppCatalog().getComputeResource().getSSHJobSubmission(jsInterface.getJobSubmissionInterfaceId());
        // fixme - Move this to populate process
        processCtx.setMonitorMode(sshJobSubmission.getMonitorMode());
        resourceJobManager = sshJobSubmission.getResourceJobManager();
    } else if (jsInterface.getJobSubmissionProtocol() == JobSubmissionProtocol.CLOUD) {
        return null;
    } else {
        throw new GFacException("Unsupported JobSubmissionProtocol - " + jsInterface.getJobSubmissionProtocol().name());
    }
    if (resourceJobManager == null) {
        throw new GFacException("Resource Job Manager is empty.");
    }
    return resourceJobManager;
}
Also used : LOCALSubmission(org.apache.airavata.model.appcatalog.computeresource.LOCALSubmission) JobSubmissionInterface(org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface) GFacException(org.apache.airavata.gfac.core.GFacException) ResourceJobManager(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager) SSHJobSubmission(org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission)

Aggregations

GFacException (org.apache.airavata.gfac.core.GFacException)73 IOException (java.io.IOException)24 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)19 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)16 JSchException (com.jcraft.jsch.JSchException)15 RegistryException (org.apache.airavata.registry.cpi.RegistryException)15 AiravataException (org.apache.airavata.common.exception.AiravataException)14 TaskStatus (org.apache.airavata.model.status.TaskStatus)13 URISyntaxException (java.net.URISyntaxException)12 ErrorModel (org.apache.airavata.model.commons.ErrorModel)11 CredentialStoreException (org.apache.airavata.credential.store.store.CredentialStoreException)10 TException (org.apache.thrift.TException)9 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)8 DefaultClientConfiguration (eu.unicore.util.httpclient.DefaultClientConfiguration)7 URI (java.net.URI)7 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)7 Session (com.jcraft.jsch.Session)6 InvalidKeyException (java.security.InvalidKeyException)6 RemoteCluster (org.apache.airavata.gfac.core.cluster.RemoteCluster)6 JobModel (org.apache.airavata.model.job.JobModel)6