Search in sources :

Example 1 with TracingCopyTransferable

use of es.bsc.compss.types.data.transferable.TracingCopyTransferable in project compss by bsc-wdc.

the class Resource method getTracingPackageToMaster.

private void getTracingPackageToMaster() {
    COMPSsNode masterNode = Comm.getAppHost().getNode();
    Semaphore sem = new Semaphore(0);
    String fileName = getName() + "_compss_trace.tar.gz";
    SimpleURI fileOriginURI = node.getCompletePath(DataType.FILE_T, fileName);
    if (DEBUG) {
        LOGGER.debug("Copying tracing package from : " + fileOriginURI.getPath() + ",to : " + Comm.getAppHost().getAppLogDirPath() + "trace" + File.separator + fileName);
    }
    TracingCopyListener tracingListener = new TracingCopyListener(sem);
    tracingListener.addOperation();
    // Source data location
    DataLocation source;
    try {
        source = DataLocation.createLocation(this, fileOriginURI);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + fileOriginURI.getPath(), e);
        return;
    }
    // Target data location
    DataLocation tgt;
    String targetPath = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getAppLogDirPath() + "trace" + File.separator + fileName;
    try {
        SimpleURI uri = new SimpleURI(targetPath);
        tgt = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath);
        return;
    }
    // Ask for data
    masterNode.obtainData(new LogicalData("tracing" + this.getName()), source, tgt, new LogicalData("tracing" + this.getName()), new TracingCopyTransferable(), tracingListener);
    tracingListener.enable();
    try {
        sem.acquire();
    } catch (InterruptedException ex) {
        LOGGER.error("Error waiting for tracing files in resource " + getName() + " to get saved");
    }
    if (DEBUG) {
        LOGGER.debug("Removing " + this.getName() + " tracing temporary files");
    }
    File f = null;
    try {
        f = new File(source.getPath());
        if (!f.delete()) {
            LOGGER.error("Unable to remove tracing temporary files of node " + this.getName());
        }
    } catch (Exception e) {
        LOGGER.error("Unable to remove tracing temporary files of node " + this.getName(), e);
    }
}
Also used : TracingCopyTransferable(es.bsc.compss.types.data.transferable.TracingCopyTransferable) LogicalData(es.bsc.compss.types.data.LogicalData) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) Semaphore(java.util.concurrent.Semaphore) TracingCopyListener(es.bsc.compss.types.data.listener.TracingCopyListener) File(java.io.File) COMPSsNode(es.bsc.compss.types.COMPSsNode) InitNodeException(es.bsc.compss.exceptions.InitNodeException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException)

Example 2 with TracingCopyTransferable

use of es.bsc.compss.types.data.transferable.TracingCopyTransferable in project compss by bsc-wdc.

the class Tracer method transferMasterPackage.

private static void transferMasterPackage() {
    if (DEBUG) {
        LOGGER.debug("Tracing: Transferring master package");
    }
    // Create source and target locations for tar.gz file
    String filename = "master_compss_trace.tar.gz";
    DataLocation source = null;
    String sourcePath = DataLocation.Protocol.FILE_URI.getSchema() + filename;
    try {
        SimpleURI uri = new SimpleURI(sourcePath);
        source = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + sourcePath, e);
    }
    DataLocation target = null;
    String targetPath = DataLocation.Protocol.FILE_URI.getSchema() + traceDirPath + filename;
    try {
        SimpleURI uri = new SimpleURI(targetPath);
        target = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath, e);
    }
    // Ask for data
    Semaphore sem = new Semaphore(0);
    TracingCopyListener tracingListener = new TracingCopyListener(sem);
    tracingListener.addOperation();
    Comm.getAppHost().getNode().obtainData(new LogicalData("tracing master package"), source, target, new LogicalData("tracing master package"), new TracingCopyTransferable(), tracingListener);
    // Wait for data
    tracingListener.enable();
    try {
        sem.acquire();
    } catch (InterruptedException ex) {
        ErrorManager.warn("Error waiting for tracing files in master to get saved");
    }
}
Also used : TracingCopyTransferable(es.bsc.compss.types.data.transferable.TracingCopyTransferable) LogicalData(es.bsc.compss.types.data.LogicalData) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) Semaphore(java.util.concurrent.Semaphore) TracingCopyListener(es.bsc.compss.types.data.listener.TracingCopyListener) IOException(java.io.IOException)

Aggregations

LogicalData (es.bsc.compss.types.data.LogicalData)2 TracingCopyListener (es.bsc.compss.types.data.listener.TracingCopyListener)2 DataLocation (es.bsc.compss.types.data.location.DataLocation)2 TracingCopyTransferable (es.bsc.compss.types.data.transferable.TracingCopyTransferable)2 SimpleURI (es.bsc.compss.types.uri.SimpleURI)2 Semaphore (java.util.concurrent.Semaphore)2 InitNodeException (es.bsc.compss.exceptions.InitNodeException)1 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)1 COMPSsNode (es.bsc.compss.types.COMPSsNode)1 File (java.io.File)1 IOException (java.io.IOException)1