Search in sources :

Example 6 with DataRequest

use of es.bsc.compss.nio.dataRequest.DataRequest in project compss by bsc-wdc.

the class NIOWorker method receivedValue.

@Override
public void receivedValue(Destination type, String dataId, Object object, List<DataRequest> achievedRequests) {
    if (type == Transfer.Destination.OBJECT) {
        WORKER_LOGGER.info("Received data " + dataId + " with associated object " + object);
        storeObject(dataId, object);
    } else {
        WORKER_LOGGER.info("Received data " + dataId);
    }
    for (DataRequest dr : achievedRequests) {
        WorkerDataRequest wdr = (WorkerDataRequest) dr;
        wdr.getTransferringTask().decreaseParams();
        if (NIOTracer.isActivated()) {
            NIOTracer.emitDataTransferEvent(NIOTracer.TRANSFER_END);
        }
        if (wdr.getTransferringTask().getParams() == 0) {
            if (!wdr.getTransferringTask().getError()) {
                executeTask(wdr.getTransferringTask().getTask());
            } else {
                sendTaskDone(wdr.getTransferringTask().getTask(), false);
            }
        }
    }
}
Also used : WorkerDataRequest(es.bsc.compss.nio.dataRequest.WorkerDataRequest) WorkerDataRequest(es.bsc.compss.nio.dataRequest.WorkerDataRequest) DataRequest(es.bsc.compss.nio.dataRequest.DataRequest)

Example 7 with DataRequest

use of es.bsc.compss.nio.dataRequest.DataRequest in project compss by bsc-wdc.

the class NIOWorker method handleRequestedDataNotAvailableError.

// This is called when the master couldn't send a data to the worker.
// The master abruptly finishes the connection. The NIOMessageHandler
// handles this as an error, which treats with its function handleError,
// and notifies the worker in this case.
@Override
public void handleRequestedDataNotAvailableError(List<DataRequest> failedRequests, String dataId) {
    for (DataRequest dr : failedRequests) {
        // For every task pending on this request, flag it as an error
        WorkerDataRequest wdr = (WorkerDataRequest) dr;
        wdr.getTransferringTask().decreaseParams();
        // Mark as an error task. When all the params've been consumed, sendTaskDone unsuccessful
        wdr.getTransferringTask().setError(true);
        if (wdr.getTransferringTask().getParams() == 0) {
            sendTaskDone(wdr.getTransferringTask().getTask(), false);
        }
        // Create job*_[NEW|RESUBMITTED|RESCHEDULED].[out|err]
        // If we don't create this when the task fails to retrieve a value,
        // the master will try to get the out of this job, and it will get blocked.
        // Same for the worker when sending, throwing an error when trying
        // to read the job out, which wouldn't exist
        String baseJobPath = workingDir + File.separator + "jobs" + File.separator + "job" + wdr.getTransferringTask().getTask().getJobId() + "_" + wdr.getTransferringTask().getTask().getHist();
        File fout = new File(baseJobPath + ".out");
        File ferr = new File(baseJobPath + ".err");
        if (!fout.exists() || !ferr.exists()) {
            String errorMessage = "Worker closed because the data " + dataId + " couldn't be retrieved.";
            try (FileOutputStream outputStream = new FileOutputStream(fout)) {
                outputStream.write(errorMessage.getBytes());
                outputStream.close();
            } catch (IOException ioe) {
                WORKER_LOGGER.error("IOException writing worker output file: " + fout, ioe);
            }
            try (FileOutputStream errorStream = new FileOutputStream(ferr)) {
                errorStream.write(errorMessage.getBytes());
                errorStream.close();
            } catch (IOException ioe) {
                WORKER_LOGGER.error("IOException writing worker error file: " + ferr, ioe);
            }
        }
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) WorkerDataRequest(es.bsc.compss.nio.dataRequest.WorkerDataRequest) WorkerDataRequest(es.bsc.compss.nio.dataRequest.WorkerDataRequest) DataRequest(es.bsc.compss.nio.dataRequest.DataRequest) IOException(java.io.IOException) File(java.io.File)

Example 8 with DataRequest

use of es.bsc.compss.nio.dataRequest.DataRequest in project compss by bsc-wdc.

the class NIOAdaptor method receivedValue.

@Override
public void receivedValue(Destination type, String dataId, Object object, List<DataRequest> achievedRequests) {
    for (DataRequest dr : achievedRequests) {
        MasterDataRequest mdr = (MasterDataRequest) dr;
        Copy c = (Copy) mdr.getOperation();
        DataLocation actualLocation = c.getSourceData().finishedCopy(c);
        LogicalData tgtData = c.getTargetData();
        if (tgtData != null) {
            tgtData.addLocation(actualLocation);
            if (object != null) {
                tgtData.setValue(object);
            }
        }
        c.end(DataOperation.OpEndState.OP_OK);
    }
    if (NIOTracer.isActivated()) {
        NIOTracer.emitDataTransferEvent(NIOTracer.TRANSFER_END);
    }
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) Copy(es.bsc.compss.types.data.operation.copy.Copy) DataLocation(es.bsc.compss.types.data.location.DataLocation) MasterDataRequest(es.bsc.compss.nio.dataRequest.MasterDataRequest) DataRequest(es.bsc.compss.nio.dataRequest.DataRequest) MasterDataRequest(es.bsc.compss.nio.dataRequest.MasterDataRequest)

Example 9 with DataRequest

use of es.bsc.compss.nio.dataRequest.DataRequest in project compss by bsc-wdc.

the class NIOAdaptor method requestData.

public void requestData(Copy c, DataType paramType, Data d, String path) {
    DataRequest dr = new MasterDataRequest(c, paramType, d, path);
    addTransferRequest(dr);
    requestTransfers();
}
Also used : MasterDataRequest(es.bsc.compss.nio.dataRequest.MasterDataRequest) DataRequest(es.bsc.compss.nio.dataRequest.DataRequest) MasterDataRequest(es.bsc.compss.nio.dataRequest.MasterDataRequest)

Aggregations

DataRequest (es.bsc.compss.nio.dataRequest.DataRequest)9 MasterDataRequest (es.bsc.compss.nio.dataRequest.MasterDataRequest)4 WorkerDataRequest (es.bsc.compss.nio.dataRequest.WorkerDataRequest)3 Copy (es.bsc.compss.types.data.operation.copy.Copy)3 IOException (java.io.IOException)3 Data (es.bsc.compss.nio.commands.Data)2 LogicalData (es.bsc.compss.types.data.LogicalData)2 File (java.io.File)2 Connection (es.bsc.comm.Connection)1 NIONode (es.bsc.comm.nio.NIONode)1 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)1 NIOURI (es.bsc.compss.nio.NIOURI)1 CommandDataDemand (es.bsc.compss.nio.commands.CommandDataDemand)1 SerializedObjectException (es.bsc.compss.nio.exceptions.SerializedObjectException)1 DataLocation (es.bsc.compss.types.data.location.DataLocation)1 DeferredCopy (es.bsc.compss.types.data.operation.copy.DeferredCopy)1 StorageCopy (es.bsc.compss.types.data.operation.copy.StorageCopy)1 MultiURI (es.bsc.compss.types.uri.MultiURI)1 FileOutputStream (java.io.FileOutputStream)1 HashMap (java.util.HashMap)1