Search in sources :

Example 16 with DataLocation

use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.

the class ServiceInstance method obtainData.

@Override
public void obtainData(LogicalData ld, DataLocation source, DataLocation target, LogicalData tgtData, Transferable reason, EventListener listener) {
    // Delegate on the master to obtain the data value
    String path = target.getProtocol().getSchema() + target.getPath();
    DataLocation tgtLoc = null;
    try {
        SimpleURI uri = new SimpleURI(path);
        tgtLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + path, e);
    }
    COMPSsNode node = Comm.getAppHost().getNode();
    node.obtainData(ld, source, tgtLoc, tgtData, reason, listener);
}
Also used : SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) InitNodeException(es.bsc.compss.exceptions.InitNodeException) COMPSsNode(es.bsc.compss.types.COMPSsNode)

Example 17 with DataLocation

use of es.bsc.compss.types.data.location.DataLocation 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)

Example 18 with DataLocation

use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.

the class LogicalData method writeToStorage.

/**
 * Writes memory value to file
 *
 * @throws Exception
 */
public synchronized void writeToStorage() throws IOException {
    if (this.id != null) {
    // It is a persistent object that is already persisted
    // Nothing to do
    // If the PSCO is not persisted we treat it as a normal object
    } else {
        // The object must be written to file
        String targetPath = Comm.getAppHost().getWorkingDirectory() + this.name;
        Serializer.serialize(value, targetPath);
        String targetPathWithSchema = Protocol.FILE_URI.getSchema() + targetPath;
        SimpleURI targetURI = new SimpleURI(targetPathWithSchema);
        DataLocation loc = DataLocation.createLocation(Comm.getAppHost(), targetURI);
        this.isBeingSaved = false;
        this.locations.add(loc);
        for (Resource r : loc.getHosts()) {
            switch(loc.getType()) {
                case PRIVATE:
                    r.addLogicalData(this);
                    break;
                case SHARED:
                    SharedDiskManager.addLogicalData(loc.getSharedDisk(), this);
                    break;
                case PERSISTENT:
                    // Nothing to do
                    break;
            }
        }
    }
}
Also used : SimpleURI(es.bsc.compss.types.uri.SimpleURI) Resource(es.bsc.compss.types.resources.Resource) DataLocation(es.bsc.compss.types.data.location.DataLocation)

Example 19 with DataLocation

use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.

the class LogicalData method loadFromStorage.

/**
 * Loads the value of the LogicalData from a file
 *
 * @throws CannotLoadException
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws StorageException
 * @throws UnstartedNodeException
 *
 * @throws Exception
 */
public synchronized void loadFromStorage() throws CannotLoadException {
    if (value != null) {
        // Value is already loaded in memory
        return;
    }
    for (DataLocation loc : this.locations) {
        switch(loc.getType()) {
            case PRIVATE:
            case SHARED:
                // Get URI and deserialize object if possible
                MultiURI u = loc.getURIInHost(Comm.getAppHost());
                if (u == null) {
                    continue;
                }
                String path = u.getPath();
                if (path.startsWith(File.separator)) {
                    try {
                        this.value = Serializer.deserialize(path);
                    } catch (ClassNotFoundException | IOException e) {
                        // Check next location since deserialization was invalid
                        this.value = null;
                        continue;
                    }
                    String targetPath = Protocol.OBJECT_URI.getSchema() + this.name;
                    SimpleURI uri = new SimpleURI(targetPath);
                    try {
                        DataLocation tgtLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
                        addLocation(tgtLoc);
                    } catch (IOException e) {
                        // Check next location since location was invalid
                        this.value = null;
                        continue;
                    }
                }
                return;
            case PERSISTENT:
                PersistentLocation pLoc = (PersistentLocation) loc;
                if (Tracer.isActivated()) {
                    Tracer.emitEvent(Tracer.Event.STORAGE_GETBYID.getId(), Tracer.Event.STORAGE_GETBYID.getType());
                }
                try {
                    this.value = StorageItf.getByID(pLoc.getId());
                    this.id = pLoc.getId();
                } catch (StorageException se) {
                    // Check next location since cannot retrieve the object from the storage Back-end
                    continue;
                } finally {
                    if (Tracer.isActivated()) {
                        Tracer.emitEvent(Tracer.EVENT_END, Tracer.Event.STORAGE_GETBYID.getType());
                    }
                }
                String targetPath = Protocol.OBJECT_URI.getSchema() + this.name;
                SimpleURI uri = new SimpleURI(targetPath);
                try {
                    DataLocation tgtLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
                    addLocation(tgtLoc);
                } catch (IOException e) {
                    // Check next location since location was invalid
                    this.value = null;
                    continue;
                }
                return;
        }
    }
    // Any location has been able to load the value
    throw new CannotLoadException("Object has not any valid location available in the master");
}
Also used : MultiURI(es.bsc.compss.types.uri.MultiURI) PersistentLocation(es.bsc.compss.types.data.location.PersistentLocation) CannotLoadException(es.bsc.compss.exceptions.CannotLoadException) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) IOException(java.io.IOException) StorageException(storage.StorageException)

Example 20 with DataLocation

use of es.bsc.compss.types.data.location.DataLocation in project compss by bsc-wdc.

the class LogicalData method finishedCopy.

/**
 * Marks the end of a copy. Returns the location of the finished copy or null if not found
 *
 * @param c
 * @return
 */
public synchronized DataLocation finishedCopy(Copy c) {
    DataLocation loc = null;
    Iterator<CopyInProgress> it = this.inProgress.iterator();
    while (it.hasNext()) {
        CopyInProgress cip = it.next();
        if (cip.c == c) {
            it.remove();
            loc = cip.loc;
            break;
        }
    }
    return loc;
}
Also used : DataLocation(es.bsc.compss.types.data.location.DataLocation)

Aggregations

DataLocation (es.bsc.compss.types.data.location.DataLocation)30 SimpleURI (es.bsc.compss.types.uri.SimpleURI)16 IOException (java.io.IOException)14 LogicalData (es.bsc.compss.types.data.LogicalData)9 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)6 InitNodeException (es.bsc.compss.exceptions.InitNodeException)5 MultiURI (es.bsc.compss.types.uri.MultiURI)5 Semaphore (java.util.concurrent.Semaphore)5 StorageException (storage.StorageException)5 CannotLoadException (es.bsc.compss.exceptions.CannotLoadException)4 COMPSsNode (es.bsc.compss.types.COMPSsNode)4 File (java.io.File)4 DataAccessId (es.bsc.compss.types.data.DataAccessId)3 DataInstanceId (es.bsc.compss.types.data.DataInstanceId)3 Copy (es.bsc.compss.types.data.operation.copy.Copy)3 Resource (es.bsc.compss.types.resources.Resource)3 AccessMode (es.bsc.compss.types.data.AccessParams.AccessMode)2 RAccessId (es.bsc.compss.types.data.DataAccessId.RAccessId)2 RWAccessId (es.bsc.compss.types.data.DataAccessId.RWAccessId)2 WAccessId (es.bsc.compss.types.data.DataAccessId.WAccessId)2