Search in sources :

Example 1 with CommandTracingID

use of es.bsc.compss.nio.commands.CommandTracingID in project compss by bsc-wdc.

the class NIOAgent method sendData.

/**
 * Reply the data
 *
 * @param c
 * @param d
 * @param receiverID
 */
public void sendData(Connection c, Data d, int receiverID) {
    if (NIOTracer.isActivated()) {
        int tag = abs(d.getName().hashCode());
        CommandTracingID cmd = new CommandTracingID(tracingID, tag);
        c.sendCommand(cmd);
        NIOTracer.emitDataTransferEvent(d.getName());
        NIOTracer.emitCommEvent(true, receiverID, tag);
    }
    String path = d.getFirstURI().getPath();
    if (path.startsWith(File.separator)) {
        File f = new File(path);
        LOGGER.debug("INSIDE SENDATA");
        if (f.exists()) {
            LOGGER.debug("Connection " + c.hashCode() + " will transfer file " + path + " as data " + d.getName());
            c.sendDataFile(path);
        } else {
            ErrorManager.warn("Can't send file '" + path + "' via connection " + c.hashCode() + " because file doesn't exist.");
            handleDataToSendNotAvailable(c, d);
        }
    } else {
        try {
            Object o = getObject(path);
            LOGGER.debug("Connection " + c.hashCode() + " will transfer an object as data " + d.getName());
            c.sendDataObject(o);
        } catch (SerializedObjectException soe) {
            // Exception has been raised because object has been serialized
            String newLocation = getObjectAsFile(path);
            LOGGER.debug("Connection " + c.hashCode() + " will transfer an object-file " + newLocation + " as data " + d.getName());
            c.sendDataFile(newLocation);
        }
    }
    if (NIOTracer.isActivated()) {
        NIOTracer.emitDataTransferEvent(NIOTracer.TRANSFER_END);
    }
    c.finishConnection();
}
Also used : SerializedObjectException(es.bsc.compss.nio.exceptions.SerializedObjectException) CommandTracingID(es.bsc.compss.nio.commands.CommandTracingID) File(java.io.File)

Aggregations

CommandTracingID (es.bsc.compss.nio.commands.CommandTracingID)1 SerializedObjectException (es.bsc.compss.nio.exceptions.SerializedObjectException)1 File (java.io.File)1