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);
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations