Search in sources :

Example 1 with TaskState

use of es.bsc.compss.types.Task.TaskState in project compss by bsc-wdc.

the class TaskAnalyser method endTask.

/**
 * Registers the end of execution of task @task
 *
 * @param task
 */
public void endTask(Task task) {
    int taskId = task.getId();
    boolean isFree = task.isFree();
    TaskState taskState = task.getStatus();
    LOGGER.info("Notification received for task " + taskId + " with end status " + taskState);
    // Check status
    if (!isFree) {
        LOGGER.debug("Task " + taskId + " is not registered as free. Waiting for other executions to end");
        return;
    }
    if (taskState == TaskState.FAILED) {
        ErrorManager.error(TASK_FAILED + task);
        return;
    }
    /*
         * Treat end of task
         */
    LOGGER.debug("Ending task " + taskId);
    // Free dependencies
    Long appId = task.getAppId();
    Integer taskCount = appIdToTaskCount.get(appId) - 1;
    appIdToTaskCount.put(appId, taskCount);
    if (taskCount == 0) {
        // Remove the appId from the barrier flags (if existant, otherwise do nothing)
        appIdBarrierFlags.remove(appId);
        Semaphore sem = appIdToSemaphore.remove(appId);
        if (sem != null) {
            // App was synchornized on a barrier flag or a no more tasks
            // Release the application semaphore
            appIdToTaskCount.remove(appId);
            sem.release();
        }
    }
    // Check if task is being waited
    List<Semaphore> sems = waitedTasks.remove(task);
    if (sems != null) {
        for (Semaphore sem : sems) {
            sem.release();
        }
    }
    for (Parameter param : task.getTaskDescription().getParameters()) {
        DataType type = param.getType();
        if (type == DataType.FILE_T || type == DataType.OBJECT_T || type == DataType.PSCO_T || type == DataType.EXTERNAL_OBJECT_T) {
            DependencyParameter dPar = (DependencyParameter) param;
            DataAccessId dAccId = dPar.getDataAccessId();
            LOGGER.debug("Treating that data " + dAccId + " has been accessed at " + dPar.getDataTarget());
            DIP.dataHasBeenAccessed(dAccId);
        }
    }
    // Task generation is finished if we are on noMoreTasks but we are not on a barrier
    if (appIdToSemaphore.get(appId) != null && !appIdBarrierFlags.contains(appId)) {
        checkResultFileTransfer(task);
    }
    // Release data dependent tasks
    task.releaseDataDependents();
}
Also used : ExternalObjectParameter(es.bsc.compss.types.parameter.ExternalObjectParameter) ObjectParameter(es.bsc.compss.types.parameter.ObjectParameter) FileParameter(es.bsc.compss.types.parameter.FileParameter) Parameter(es.bsc.compss.types.parameter.Parameter) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) DataType(es.bsc.compss.types.annotations.parameter.DataType) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) Semaphore(java.util.concurrent.Semaphore) TaskState(es.bsc.compss.types.Task.TaskState) DataAccessId(es.bsc.compss.types.data.DataAccessId)

Aggregations

TaskState (es.bsc.compss.types.Task.TaskState)1 DataType (es.bsc.compss.types.annotations.parameter.DataType)1 DataAccessId (es.bsc.compss.types.data.DataAccessId)1 DependencyParameter (es.bsc.compss.types.parameter.DependencyParameter)1 ExternalObjectParameter (es.bsc.compss.types.parameter.ExternalObjectParameter)1 FileParameter (es.bsc.compss.types.parameter.FileParameter)1 ObjectParameter (es.bsc.compss.types.parameter.ObjectParameter)1 Parameter (es.bsc.compss.types.parameter.Parameter)1 Semaphore (java.util.concurrent.Semaphore)1