Search in sources :

Example 1 with WorkerDataRequest

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

the class NIOWorker method askForTransfer.

private void askForTransfer(boolean askTransfer, NIOParam param, int index, TransferringTask tt) {
    // Request the transfer if needed
    if (askTransfer) {
        WORKER_LOGGER.info("- Parameter " + index + "(" + (String) param.getValue() + ") does not exist, requesting data transfer");
        DataRequest dr = new WorkerDataRequest(tt, param.getType(), param.getData(), (String) param.getValue());
        addTransferRequest(dr);
    } else {
        // If no transfer, decrease the parameter counter
        // (we already have it)
        WORKER_LOGGER.info("- Parameter " + index + "(" + (String) param.getValue() + ") already exists.");
        tt.decreaseParams();
    }
}
Also used : WorkerDataRequest(es.bsc.compss.nio.dataRequest.WorkerDataRequest) WorkerDataRequest(es.bsc.compss.nio.dataRequest.WorkerDataRequest) DataRequest(es.bsc.compss.nio.dataRequest.DataRequest)

Example 2 with WorkerDataRequest

use of es.bsc.compss.nio.dataRequest.WorkerDataRequest 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 3 with WorkerDataRequest

use of es.bsc.compss.nio.dataRequest.WorkerDataRequest 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)

Aggregations

DataRequest (es.bsc.compss.nio.dataRequest.DataRequest)3 WorkerDataRequest (es.bsc.compss.nio.dataRequest.WorkerDataRequest)3 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1