Search in sources :

Example 11 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI 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 12 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.

the class Tracer method cleanMasterPackage.

private static void cleanMasterPackage() {
    String filename = DataLocation.Protocol.FILE_URI.getSchema() + "master_compss_trace.tar.gz";
    String filePath;
    try {
        SimpleURI uri = new SimpleURI(filename);
        filePath = new File(uri.getPath()).getCanonicalPath();
    } catch (Exception e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + filename, e);
        return;
    }
    if (DEBUG) {
        LOGGER.debug("Tracing: Removing tracing master package: " + filePath);
    }
    File f;
    try {
        f = new File(filePath);
        boolean deleted = f.delete();
        if (!deleted) {
            ErrorManager.warn("Unable to remove tracing temporary files of master node.");
        } else if (DEBUG) {
            LOGGER.debug("Deleted master tracing package.");
        }
    } catch (Exception e) {
        ErrorManager.warn("Exception while trying to remove tracing temporary " + "files of master node.", e);
    }
}
Also used : SimpleURI(es.bsc.compss.types.uri.SimpleURI) File(java.io.File) IOException(java.io.IOException)

Example 13 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.

the class SimpleURITest method objectURIs.

@Test
public void objectURIs() {
    logger.info("Begin Object URI Test");
    SimpleURI fileURI = new SimpleURI("object://d1v1RAND.IT");
    assertEquals("File Schema", fileURI.getSchema(), "object://");
    assertEquals("File Host", fileURI.getHost(), "");
    assertEquals("File Path", fileURI.getPath(), "d1v1RAND.IT");
    SimpleURI fileURI2 = new SimpleURI("object://localhost@d1v1RAND.IT");
    assertEquals("File Schema", fileURI2.getSchema(), "object://");
    assertEquals("File Host", fileURI2.getHost(), "localhost");
    assertEquals("File Path", fileURI2.getPath(), "d1v1RAND.IT");
}
Also used : SimpleURI(es.bsc.compss.types.uri.SimpleURI) Test(org.junit.Test)

Example 14 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.

the class SimpleURITest method fileURIs.

/*
     * *************************************************************** 
     * CONSTRUCTOR TESTS
     * **************************************************************
     */
@Test
public void fileURIs() {
    logger.info("Begin File URI Test");
    SimpleURI fileURI = new SimpleURI("file:///home/compss/.COMPSs/file.IT");
    assertEquals("File Schema", fileURI.getSchema(), "file://");
    assertEquals("File Host", fileURI.getHost(), "");
    assertEquals("File Path", fileURI.getPath(), "/home/compss/.COMPSs/file.IT");
    SimpleURI fileURI2 = new SimpleURI("file://localhost@/home/compss/.COMPSs/remoteFile.IT");
    assertEquals("File Schema", fileURI2.getSchema(), "file://");
    assertEquals("File Host", fileURI2.getHost(), "localhost");
    assertEquals("File Path", fileURI2.getPath(), "/home/compss/.COMPSs/remoteFile.IT");
}
Also used : SimpleURI(es.bsc.compss.types.uri.SimpleURI) Test(org.junit.Test)

Example 15 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI 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)

Aggregations

SimpleURI (es.bsc.compss.types.uri.SimpleURI)22 DataLocation (es.bsc.compss.types.data.location.DataLocation)16 IOException (java.io.IOException)9 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)6 LogicalData (es.bsc.compss.types.data.LogicalData)6 InitNodeException (es.bsc.compss.exceptions.InitNodeException)5 Semaphore (java.util.concurrent.Semaphore)5 CannotLoadException (es.bsc.compss.exceptions.CannotLoadException)4 COMPSsNode (es.bsc.compss.types.COMPSsNode)4 DataInstanceId (es.bsc.compss.types.data.DataInstanceId)4 File (java.io.File)4 StorageException (storage.StorageException)4 DataAccessId (es.bsc.compss.types.data.DataAccessId)3 RAccessId (es.bsc.compss.types.data.DataAccessId.RAccessId)3 Test (org.junit.Test)3 RWAccessId (es.bsc.compss.types.data.DataAccessId.RWAccessId)2 WAccessId (es.bsc.compss.types.data.DataAccessId.WAccessId)2 TracingCopyListener (es.bsc.compss.types.data.listener.TracingCopyListener)2 OneOpWithSemListener (es.bsc.compss.types.data.operation.OneOpWithSemListener)2 TracingCopyTransferable (es.bsc.compss.types.data.transferable.TracingCopyTransferable)2