Search in sources :

Example 1 with SafeCopyTransferable

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

the class Resource method retrieveData.

/**
 * Retrieves all the data from the Resource
 *
 * @param saveUniqueData
 */
public void retrieveData(boolean saveUniqueData) {
    if (DEBUG) {
        LOGGER.debug("Retrieving data resource " + this.getName());
    }
    Semaphore sem = new Semaphore(0);
    SafeCopyListener listener = new SafeCopyListener(sem);
    Set<LogicalData> lds = getAllDataFromHost();
    Map<String, String> disks = SharedDiskManager.terminate(this);
    COMPSsNode masterNode = Comm.getAppHost().getNode();
    for (LogicalData ld : lds) {
        ld.notifyToInProgressCopiesEnd(listener);
        DataLocation lastLoc = ld.removeHostAndCheckLocationToSave(this, disks);
        if (lastLoc != null && saveUniqueData) {
            listener.addOperation();
            DataLocation safeLoc = null;
            String safePath = Protocol.FILE_URI.getSchema() + Comm.getAppHost().getTempDirPath() + ld.getName();
            try {
                SimpleURI uri = new SimpleURI(safePath);
                safeLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
            } catch (Exception e) {
                ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + safePath, e);
            }
            masterNode.obtainData(ld, lastLoc, safeLoc, ld, new SafeCopyTransferable(), listener);
        }
    }
    if (DEBUG) {
        LOGGER.debug("Waiting for finishing saving copies for " + this.getName());
    }
    listener.enable();
    try {
        sem.acquire();
    } catch (InterruptedException ex) {
        LOGGER.error("Error waiting for files in resource " + getName() + " to get saved");
    }
    if (DEBUG) {
        LOGGER.debug("Unique files saved for " + this.getName());
    }
    if (this.getType() != Type.SERVICE) {
        shutdownExecutionManager();
        if (Tracer.isActivated()) {
            if (node.generatePackage()) {
                getTracingPackageToMaster();
                if (DEBUG) {
                    LOGGER.debug("Tracing package obtained for " + this.getName());
                }
            }
        }
        if (DEBUG) {
            if (node.generateWorkersDebugInfo()) {
                getWorkersDebugInfo();
                LOGGER.debug("Workers Debug files obtained for " + this.getName());
            }
        }
    }
}
Also used : SafeCopyListener(es.bsc.compss.types.data.listener.SafeCopyListener) LogicalData(es.bsc.compss.types.data.LogicalData) SafeCopyTransferable(es.bsc.compss.types.data.transferable.SafeCopyTransferable) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) Semaphore(java.util.concurrent.Semaphore) COMPSsNode(es.bsc.compss.types.COMPSsNode) InitNodeException(es.bsc.compss.exceptions.InitNodeException) UnstartedNodeException(es.bsc.compss.exceptions.UnstartedNodeException)

Aggregations

InitNodeException (es.bsc.compss.exceptions.InitNodeException)1 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)1 COMPSsNode (es.bsc.compss.types.COMPSsNode)1 LogicalData (es.bsc.compss.types.data.LogicalData)1 SafeCopyListener (es.bsc.compss.types.data.listener.SafeCopyListener)1 DataLocation (es.bsc.compss.types.data.location.DataLocation)1 SafeCopyTransferable (es.bsc.compss.types.data.transferable.SafeCopyTransferable)1 SimpleURI (es.bsc.compss.types.uri.SimpleURI)1 Semaphore (java.util.concurrent.Semaphore)1