Search in sources :

Example 1 with FileInterface

use of org.gridlab.gat.io.FileInterface in project compss by bsc-wdc.

the class GATCopy method doCopy.

private void doCopy(org.gridlab.gat.URI src, org.gridlab.gat.URI dest) throws GATCopyException {
    // Try to copy from each location until successful
    FileInterface f = null;
    LOGGER.debug("RawPath: " + src.getRawPath());
    LOGGER.debug("isLocal: " + src.isLocal());
    if (src.isLocal() && !(new File(src.getRawPath())).exists()) {
        String errorMessage = null;
        if (this.reason instanceof WorkersDebugInfoCopyTransferable) {
            // Only warn, hide error to ErrorManager
            errorMessage = "Workers Debug Information not supported in GAT Adaptor";
            LOGGER.warn(errorMessage);
        } else {
            // Notify error to ErrorManager
            errorMessage = "File '" + src.toString() + "' could not be copied to '" + dest.toString() + "' because it does not exist.";
            ErrorManager.warn(errorMessage);
            LOGGER.warn(errorMessage);
        }
        throw new GATCopyException(errorMessage);
    }
    try {
        f = org.gridlab.gat.GAT.createFile(GATAdaptor.getTransferContext(), src).getFileInterface();
        f.copy(dest);
    } catch (GATObjectCreationException | GATInvocationException e) {
        throw new GATCopyException(e);
    }
}
Also used : FileInterface(org.gridlab.gat.io.FileInterface) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) WorkersDebugInfoCopyTransferable(es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable) GATCopyException(es.bsc.compss.gat.master.exceptions.GATCopyException) File(java.io.File)

Example 2 with FileInterface

use of org.gridlab.gat.io.FileInterface in project compss by bsc-wdc.

the class FileAdaptorTest method canWriteTest.

private AdaptorTestResultEntry canWriteTest(GATContext gatContext, Preferences preferences, String host, String filename, int tabs, boolean correctValue) {
    FileInterface file = null;
    try {
        file = GAT.createFile(gatContext, preferences, "any://" + host + "/" + filename).getFileInterface();
    } catch (GATObjectCreationException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    }
    long start = System.currentTimeMillis();
    boolean writable;
    try {
        writable = file.canWrite();
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    }
    long stop = System.currentTimeMillis();
    return new AdaptorTestResultEntry(writable == correctValue, (stop - start), null);
}
Also used : FileInterface(org.gridlab.gat.io.FileInterface) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException)

Example 3 with FileInterface

use of org.gridlab.gat.io.FileInterface in project compss by bsc-wdc.

the class FileAdaptorTest method mkdirTest.

private AdaptorTestResultEntry mkdirTest(GATContext gatContext, Preferences preferences, String host, String filename, int tabs, boolean correctValue) {
    FileInterface file = null;
    try {
        file = GAT.createFile(gatContext, preferences, "any://" + host + "/" + filename).getFileInterface();
    } catch (GATObjectCreationException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    }
    long start = System.currentTimeMillis();
    boolean mkdir;
    try {
        mkdir = file.mkdir();
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    }
    long stop = System.currentTimeMillis();
    return new AdaptorTestResultEntry(mkdir == correctValue, (stop - start), null);
}
Also used : FileInterface(org.gridlab.gat.io.FileInterface) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException)

Example 4 with FileInterface

use of org.gridlab.gat.io.FileInterface in project compss by bsc-wdc.

the class FileAdaptorTest method createNewFileTest.

private AdaptorTestResultEntry createNewFileTest(GATContext gatContext, Preferences preferences, String host, String filename, int tabs, boolean correctValue) {
    FileInterface file = null;
    try {
        file = GAT.createFile(gatContext, preferences, "any://" + host + "/" + filename).getFileInterface();
    } catch (GATObjectCreationException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    }
    long start = System.currentTimeMillis();
    boolean created;
    try {
        created = file.createNewFile();
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    }
    long stop = System.currentTimeMillis();
    return new AdaptorTestResultEntry(created == correctValue, (stop - start), null);
}
Also used : FileInterface(org.gridlab.gat.io.FileInterface) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException)

Example 5 with FileInterface

use of org.gridlab.gat.io.FileInterface in project compss by bsc-wdc.

the class FileAdaptorTest method copyFileTest.

private AdaptorTestResultEntry copyFileTest(GATContext gatContext, Preferences preferences, String host, String filename, int tabs, boolean correctValue) {
    FileInterface file = null;
    try {
        file = GAT.createFile(gatContext, preferences, "any://" + host + "/" + filename).getFileInterface();
    } catch (GATObjectCreationException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    }
    long start = System.currentTimeMillis();
    try {
        file.copy(new URI("any:///" + filename + ".copy"));
    } catch (GATInvocationException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    } catch (URISyntaxException e) {
        return new AdaptorTestResultEntry(false, 0, e);
    }
    long stop = System.currentTimeMillis();
    boolean exists = new java.io.File(filename + ".copy").exists();
    if (exists) {
        new java.io.File(filename + ".copy").delete();
    }
    return new AdaptorTestResultEntry(exists == correctValue, (stop - start), null);
}
Also used : FileInterface(org.gridlab.gat.io.FileInterface) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) URISyntaxException(java.net.URISyntaxException) URI(org.gridlab.gat.URI)

Aggregations

GATInvocationException (org.gridlab.gat.GATInvocationException)14 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)14 FileInterface (org.gridlab.gat.io.FileInterface)14 GATCopyException (es.bsc.compss.gat.master.exceptions.GATCopyException)1 WorkersDebugInfoCopyTransferable (es.bsc.compss.types.data.transferable.WorkersDebugInfoCopyTransferable)1 File (java.io.File)1 URISyntaxException (java.net.URISyntaxException)1 URI (org.gridlab.gat.URI)1