use of es.bsc.compss.types.data.operation.ResultListener in project compss by bsc-wdc.
the class TaskAnalyser method checkResultFileTransfer.
/**
* Checks if a finished task is the last writer of its file parameters and, eventually, order the necessary
* transfers
*
* @param t
*/
private void checkResultFileTransfer(Task t) {
LinkedList<DataInstanceId> fileIds = new LinkedList<>();
for (Parameter p : t.getTaskDescription().getParameters()) {
switch(p.getType()) {
case FILE_T:
FileParameter fp = (FileParameter) p;
switch(fp.getDirection()) {
case IN:
break;
case INOUT:
DataInstanceId dId = ((RWAccessId) fp.getDataAccessId()).getWrittenDataInstance();
if (writers.get(dId.getDataId()) == t) {
fileIds.add(dId);
}
break;
case OUT:
dId = ((WAccessId) fp.getDataAccessId()).getWrittenDataInstance();
if (writers.get(dId.getDataId()) == t) {
fileIds.add(dId);
}
break;
}
break;
default:
break;
}
}
// Order the transfer of the result files
final int numFT = fileIds.size();
if (numFT > 0) {
// List<ResultFile> resFiles = new ArrayList<ResultFile>(numFT);
for (DataInstanceId fileId : fileIds) {
try {
int id = fileId.getDataId();
DIP.blockDataAndGetResultFile(id, new ResultListener(new Semaphore(0)));
DIP.unblockDataId(id);
} catch (Exception e) {
LOGGER.error("Exception ordering trasnfer when task ends", e);
}
}
}
}
use of es.bsc.compss.types.data.operation.ResultListener in project compss by bsc-wdc.
the class GetResultFilesRequest method process.
@Override
public void process(AccessProcessor ap, TaskAnalyser ta, DataInfoProvider dip, TaskDispatcher td) {
ResultListener listener = new ResultListener(sem);
TreeSet<Integer> writtenDataIds = ta.getAndRemoveWrittenFiles(this.appId);
if (writtenDataIds != null) {
for (int dataId : writtenDataIds) {
ResultFile rf;
rf = dip.blockDataAndGetResultFile(dataId, listener);
if (rf == null) {
continue;
}
blockedData.add(rf);
}
listener.enable();
} else {
sem.release();
}
}
Aggregations