Search in sources :

Example 1 with ResultListener

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);
            }
        }
    }
}
Also used : DataInstanceId(es.bsc.compss.types.data.DataInstanceId) ResultListener(es.bsc.compss.types.data.operation.ResultListener) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) 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) FileParameter(es.bsc.compss.types.parameter.FileParameter) Semaphore(java.util.concurrent.Semaphore) LinkedList(java.util.LinkedList)

Example 2 with ResultListener

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();
    }
}
Also used : ResultListener(es.bsc.compss.types.data.operation.ResultListener) ResultFile(es.bsc.compss.types.data.ResultFile)

Aggregations

ResultListener (es.bsc.compss.types.data.operation.ResultListener)2 RWAccessId (es.bsc.compss.types.data.DataAccessId.RWAccessId)1 DataInstanceId (es.bsc.compss.types.data.DataInstanceId)1 ResultFile (es.bsc.compss.types.data.ResultFile)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 LinkedList (java.util.LinkedList)1 Semaphore (java.util.concurrent.Semaphore)1