use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class LoadLevelerFileAdaptor method listFiles.
/*
* (non-Javadoc)
*
* @see org.gridlab.gat.io.File#listFiles(java.io.FilenameFilter)
*/
public org.gridlab.gat.io.File[] listFiles(FilenameFilter arg0) throws GATInvocationException {
File[] r = f.listFiles(arg0);
ArrayList<File> l = new ArrayList<File>();
for (int i = 0; i < r.length; i++) {
if (!(ignoreHiddenFiles && r[i].isHidden())) {
l.add(r[i]);
}
}
org.gridlab.gat.io.File[] res = new org.gridlab.gat.io.File[r.length];
for (int i = 0; i < res.length; i++) {
try {
res[i] = GAT.createFile(gatContext, localToURI(l.get(i).getPath()));
} catch (Exception e) {
throw new GATInvocationException("LoadLevelerFile", e);
}
}
return res;
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class LoadLevelerFileAdaptor method move.
/*
* (non-Javadoc)
*
* @see org.gridlab.gat.io.File#move(java.net.URI)
*/
public void move(URI destination) throws GATInvocationException {
destination = newcorrectURI(destination);
String path = getPath();
String destPath = destination.getPath();
if (logger.isInfoEnabled()) {
logger.info("move of " + path + " to " + destPath);
}
if (destPath.equals(path)) {
if (logger.isInfoEnabled()) {
logger.info("move, source is the same file as dest.");
}
return;
}
if (!exists()) {
throw new GATInvocationException("the source file does not exist, path = " + path);
}
File tmp = new File(destPath);
boolean res = f.renameTo(tmp);
if (!res) {
throw new GATInvocationException("Could not move file");
}
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class LoadLevelerJob method waitForTrigger.
// Wait for the creation of a special file (by the application).
void waitForTrigger(JobState state) throws GATInvocationException {
if (triggerDirectory == null) {
return;
}
if (jobName == null) {
return;
}
if (waiter == null) {
try {
waiter = FileWaiter.createFileWaiter(GAT.createFile(gatContext, triggerDirectory));
} catch (GATObjectCreationException e) {
throw new GATInvocationException("Could not create", e);
}
}
String filename = jobName + "." + state.toString().substring(0, 3);
File file;
try {
file = GAT.createFile(gatContext, triggerDirectory + "/" + filename);
} catch (GATObjectCreationException e) {
throw new GATInvocationException("Could not create");
}
if (logger.isDebugEnabled()) {
logger.debug("Waiting for " + filename + " in directory " + triggerDirectory);
}
waiter.waitFor(filename);
if (logger.isDebugEnabled()) {
logger.debug("Finished waiting for " + filename + " in directory " + triggerDirectory);
}
synchronized (this.getClass()) {
if (!file.delete()) {
if (logger.isDebugEnabled()) {
logger.debug("Could not remove " + file.toGATURI());
}
}
}
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class LsfFileAdaptor method copy.
private static void copy(File in, File out) throws GATInvocationException {
FileInputStream inBuf = null;
FileOutputStream outBuf = null;
try {
out.createNewFile();
// Copy source to destination
inBuf = new FileInputStream(in);
outBuf = new FileOutputStream(out);
} catch (IOException e) {
throw new GATInvocationException("LsfFile", e);
}
try {
byte[] buf = new byte[8192];
for (; ; ) {
int len = inBuf.read(buf);
if (len < 0) {
break;
}
outBuf.write(buf, 0, len);
}
} catch (IOException e) {
throw new GATInvocationException("LsfFile", e);
} finally {
if (outBuf != null) {
try {
outBuf.close();
} catch (IOException e) {
throw new GATInvocationException("LsfFile", e);
}
}
if (inBuf != null) {
try {
inBuf.close();
} catch (IOException e) {
throw new GATInvocationException("LsfFile", e);
}
}
}
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class LsfFileAdaptor method move.
/*
* (non-Javadoc)
*
* @see org.gridlab.gat.io.File#move(java.net.URI)
*/
public void move(URI destination) throws GATInvocationException {
destination = newcorrectURI(destination);
String path = getPath();
String destPath = destination.getPath();
if (logger.isInfoEnabled()) {
logger.info("move of " + path + " to " + destPath);
}
if (destPath.equals(path)) {
if (logger.isInfoEnabled()) {
logger.info("move, source is the same file as dest.");
}
return;
}
if (!exists()) {
throw new GATInvocationException("the source file does not exist, path = " + path);
}
File tmp = new File(destPath);
boolean res = f.renameTo(tmp);
if (!res) {
throw new GATInvocationException("Could not move file");
}
}
Aggregations