use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class LsfFileAdaptor method listFiles.
/*
* (non-Javadoc)
*
* @see org.gridlab.gat.io.File#listFiles()
*/
public org.gridlab.gat.io.File[] listFiles() throws GATInvocationException {
if (!isDirectory()) {
throw new GATInvocationException("this is not a directory: " + location);
}
File[] r = f.listFiles();
if (r == null) {
throw new GATInvocationException("IO error in LSF file adaptor");
}
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[l.size()];
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("LsfFile", e);
}
}
return res;
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class LsfFileAdaptor method copy.
/**
* This method copies the physical file represented by this File instance to
* a physical file identified by the passed URI.
*
* @param destination
* The new location
*/
public void copy(URI destination) throws GATInvocationException {
destination = newcorrectURI(destination);
String path = getPath();
String destPath = destination.getPath();
if (logger.isInfoEnabled()) {
logger.info("copy of " + path + " to " + destPath);
}
if (destPath.equals(path)) {
if (logger.isInfoEnabled()) {
logger.info("copy, source is the same file as dest.");
}
return;
}
File destFile = getFile(destination);
if (!exists()) {
throw new GATInvocationException("the source file does not exist, path = " + path);
}
if (isDirectory()) {
if (logger.isDebugEnabled()) {
logger.debug("copy, it is a dir");
}
copyDir(f, destFile);
return;
}
if (logger.isDebugEnabled()) {
logger.debug("copy, it is a file");
}
if (gatContext.getPreferences().containsKey("file.create")) {
if (((String) gatContext.getPreferences().get("file.create")).equalsIgnoreCase("true")) {
File destinationParentFile = destFile.getParentFile();
if (destinationParentFile != null) {
boolean result = destinationParentFile.mkdirs();
if (logger.isDebugEnabled()) {
logger.debug("new dirs created: " + result);
}
}
}
}
// if the destination URI is a dir, append the file name.
if (destFile.isDirectory()) {
destPath = destPath + File.separator + getName();
destFile = new File(destPath);
}
try {
destFile.createNewFile();
} catch (IOException e) {
throw new GATInvocationException("Creating file failed", e);
}
copy(f, destFile);
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class SshLSFJob method kill.
protected void kill(String jobID) {
try {
// Create qdel job
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("bkill");
sd.setArguments(jobID);
sd.addAttribute(SoftwareDescription.SANDBOX_USEROOT, "true");
sd.addAttribute(SoftwareDescription.SANDBOX_ROOT, sandbox.getSandboxPath());
sd.addAttribute(SoftwareDescription.STOP_ON_EXIT, "false");
JobDescription jd = new JobDescription(sd);
Job job = jobHelper.submitJob(jd, this, "job.status");
synchronized (job) {
while (job.getState() != Job.JobState.STOPPED && job.getState() != Job.JobState.SUBMISSION_ERROR) {
try {
job.wait();
} catch (InterruptedException e) {
// ignore
}
}
}
if (job.getState() != Job.JobState.STOPPED || job.getExitStatus() != 0) {
throw new GATInvocationException("Could not submit scancel job");
}
} catch (Throwable e) {
logger.info("Failed to stop sshSlurm job: " + jobID, e);
}
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class AdvertServiceAdaptorTest method exportTest.
private AdaptorTestResultEntry exportTest(AdvertService advert, String exportLocation) {
long start = System.currentTimeMillis();
try {
advert.exportDataBase(new URI(exportLocation));
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0, e);
} catch (URISyntaxException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(true, (stop - start), null);
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class AllFileInputStreamAdaptorsTest method printResults.
private static void printResults(AdaptorTestResult[] results, String host) throws IOException {
File outFile = new File("FileInputStream-results-" + host + ".html");
if (!outFile.exists()) {
outFile.createNewFile();
}
FileOutputStream out = new FileOutputStream(outFile);
out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n".getBytes());
out.write("<html>\n".getBytes());
out.write("<head>\n".getBytes());
out.write("<title>JavaGAT test results: File</title>\n".getBytes());
out.write(("<script>\n" + "function showhide(id){\n" + "\tif (document.getElementById){\n" + "\t\tobj = document.getElementById(id);\n" + "\t\tif (obj.style.display == \"none\"){\n" + "\t\t\tobj.style.display = \"\";\n" + "\t\t} else {\n" + "\t\t\tobj.style.display = \"none\";\n" + "\t\t}\n" + "\t}\n" + "}\n" + "</script>\n").getBytes());
out.write("</head>\n".getBytes());
out.write("<body>\n".getBytes());
out.write("<table frame=box cellpadding=5 cellspacing=0>\n".getBytes());
out.write("<tr>\n".getBytes());
out.write("<td></td>\n".getBytes());
for (AdaptorTestResult result : results) {
out.write(("<td align=right>" + result.getAdaptor() + "</td>\n").getBytes());
}
out.write("</tr>\n".getBytes());
boolean background = true;
String[] keys = results[0].getTestResultEntries().keySet().toArray(new String[results[0].getTestResultEntries().size()]);
Arrays.sort(keys);
for (String key : keys) {
if (background) {
out.write("<tr bgcolor=#DDDDDD>\n".getBytes());
} else {
out.write("<tr bgcolor=#FFFFFF>\n".getBytes());
}
background = !background;
out.write(("<td>" + key + "</td>\n").getBytes());
for (AdaptorTestResult result : results) {
AdaptorTestResultEntry entry = result.getTestResultEntries().get(key);
if (entry == null) {
out.write("<td align=right>not present</td>\n".getBytes());
continue;
}
if (entry.getException() == null && !entry.getResult()) {
out.write("<td align=right bgcolor=#FFDDDD>".getBytes());
} else {
out.write("<td align=right>".getBytes());
}
if (entry.getException() == null) {
out.write((entry.getTime() + " ms").getBytes());
} else {
if (entry.getException() instanceof GATInvocationException && ((GATInvocationException) entry.getException()).getExceptions().length > 0 && ((GATInvocationException) entry.getException()).getExceptions()[0] instanceof UnsupportedOperationException) {
out.write("n.i.".getBytes());
} else if (entry.getException() instanceof GATObjectCreationException && ((GATObjectCreationException) entry.getException()).getExceptions().length > 0 && ((GATObjectCreationException) entry.getException()).getExceptions()[0] instanceof GATObjectCreationException && ((GATObjectCreationException) ((GATObjectCreationException) entry.getException()).getExceptions()[0]).getExceptions().length > 0 && ((GATObjectCreationException) ((GATObjectCreationException) entry.getException()).getExceptions()[0]).getExceptions()[0] instanceof AdaptorNotApplicableException) {
out.write("n.a.".getBytes());
} else {
out.write(("<div style=\"display: none;\" id=\"" + result.getAdaptor() + key + "\">\n").getBytes());
out.write((entry.getException().toString().replace("\n", "<br/>\n") + "\n").getBytes());
StringWriter s = new StringWriter();
PrintWriter p = new PrintWriter(s);
entry.getException().printStackTrace(p);
out.write((s.toString().replace("\n", "<br/>\n") + "\n").getBytes());
out.write("</div>\n".getBytes());
out.write(("<a href=\"#\" onclick=\"showhide('" + result.getAdaptor() + key + "'); return(false);\">show/hide</a>\n").getBytes());
}
}
out.write("</td>\n".getBytes());
}
out.write("</tr>\n".getBytes());
}
out.write("<tr>\n".getBytes());
out.write("<td>total</td>\n".getBytes());
for (AdaptorTestResult result : results) {
out.write(("<td align=right>" + result.getTotalRunTime() + " ms</td>\n").getBytes());
}
out.write("</tr>\n".getBytes());
out.write("<tr>\n".getBytes());
out.write("<td>average</td>\n".getBytes());
for (AdaptorTestResult result : results) {
out.write(("<td align=right>" + result.getAverageRunTime() + " ms</td>\n").getBytes());
}
out.write("</tr>\n".getBytes());
out.write("</table>\n".getBytes());
out.write("</body>\n".getBytes());
out.write("</html>\n".getBytes());
}
Aggregations