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();
}
Aggregations