Search in sources :

Example 1 with StreamData

use of org.apache.airavata.gfac.impl.task.utils.StreamData in project airavata by apache.

the class DataStreamingTask method execute.

@Override
public TaskStatus execute(TaskContext taskContext) {
    ProcessState processState = taskContext.getParentProcessContext().getProcessState();
    try {
        TaskStatus status = new TaskStatus(TaskState.EXECUTING);
        final DataStagingTaskModel subTaskModel = (DataStagingTaskModel) ThriftUtils.getSubTaskModel(taskContext.getTaskModel());
        if (processState == ProcessState.OUTPUT_DATA_STAGING) {
            OutputDataObjectType processOutput = taskContext.getProcessOutput();
            if (processOutput != null && processOutput.getValue() == null) {
                log.error("expId: {}, processId:{}, taskId: {}:- Couldn't stage file {} , file name shouldn't be null", taskContext.getExperimentId(), taskContext.getProcessId(), taskContext.getTaskId(), processOutput.getName());
                status = new TaskStatus(TaskState.FAILED);
                if (processOutput.isIsRequired()) {
                    status.setReason("File name is null, but this output's isRequired bit is not set");
                } else {
                    status.setReason("File name is null");
                }
                return status;
            }
            if (processOutput != null) {
                if (processOutput.isOutputStreaming()) {
                    // stream output periodically
                    ComputationalResourceSchedulingModel resourceSchedule = taskContext.getParentProcessContext().getProcessModel().getProcessResourceSchedule();
                    int wallTimeLimit = resourceSchedule.getWallTimeLimit();
                    if (wallTimeLimit > 10) {
                        int period = wallTimeLimit / 10;
                        Timer timer = new Timer();
                        StreamData streamData = new StreamData(userName, hostName, inputPath, taskContext, subTaskModel);
                        timer.schedule(streamData, 0, 1000 * 60 * period);
                        status.setState(TaskState.COMPLETED);
                    }
                }
            }
        }
        return null;
    } catch (TException e) {
        log.error("Error while creating data streaming task", e);
        return null;
    }
}
Also used : ProcessState(org.apache.airavata.model.status.ProcessState) TException(org.apache.thrift.TException) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) Timer(java.util.Timer) DataStagingTaskModel(org.apache.airavata.model.task.DataStagingTaskModel) StreamData(org.apache.airavata.gfac.impl.task.utils.StreamData) TaskStatus(org.apache.airavata.model.status.TaskStatus) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Aggregations

Timer (java.util.Timer)1 StreamData (org.apache.airavata.gfac.impl.task.utils.StreamData)1 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)1 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)1 ProcessState (org.apache.airavata.model.status.ProcessState)1 TaskStatus (org.apache.airavata.model.status.TaskStatus)1 DataStagingTaskModel (org.apache.airavata.model.task.DataStagingTaskModel)1 TException (org.apache.thrift.TException)1