use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class ResourceBrokerCallBackExample method start.
public void start(String brokerURI) {
ResourceBroker broker = null;
Preferences prefs = new Preferences();
try {
broker = GAT.createResourceBroker(prefs, new URI(brokerURI));
} catch (GATObjectCreationException e) {
System.err.println("Failed to create resource broker at location '" + brokerURI + "': " + e);
return;
} catch (URISyntaxException e) {
System.err.println("Wrong uri '" + brokerURI + "': " + e);
return;
}
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/hostname");
try {
sd.setStdout(GAT.createFile("hostname.txt"));
} catch (GATObjectCreationException e) {
System.err.println("Failed to create the stdout file 'hostname.txt': " + e);
return;
}
JobDescription jd = new JobDescription(sd);
try {
broker.submitJob(jd, this, "job.status");
} catch (GATInvocationException e) {
System.err.println("Failed to submit the job: " + e);
return;
}
synchronized (this) {
try {
wait();
} catch (InterruptedException e) {
// ignore
}
}
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class ResourceBrokerPollingExample method start.
public void start(String brokerURI) {
ResourceBroker broker = null;
try {
broker = GAT.createResourceBroker(new URI(brokerURI));
} catch (GATObjectCreationException e) {
System.err.println("Failed to create resource broker at location '" + brokerURI + "': " + e);
return;
} catch (URISyntaxException e) {
System.err.println("Wrong uri '" + brokerURI + "': " + e);
return;
}
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/hostname");
try {
sd.setStdout(GAT.createFile("hostname.txt"));
} catch (GATObjectCreationException e) {
System.err.println("Failed to create the stdout file 'hostname.txt': " + e);
return;
}
JobDescription jd = new JobDescription(sd);
Job job = null;
try {
job = broker.submitJob(jd);
} catch (GATInvocationException e) {
System.err.println("Failed to submit the job: " + e);
return;
}
while (job.getState() != JobState.STOPPED) {
System.out.println("job is in state: " + job.getState());
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// ignore
}
}
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class ResourceBrokerJavaJobExample method start.
public void start(String brokerURI) {
ResourceBroker broker = null;
try {
broker = GAT.createResourceBroker(new URI(brokerURI));
} catch (GATObjectCreationException e) {
System.err.println("Failed to create resource broker at location '" + brokerURI + "': " + e);
return;
} catch (URISyntaxException e) {
System.err.println("Wrong uri '" + brokerURI + "': " + e);
return;
}
JavaSoftwareDescription sd = new JavaSoftwareDescription();
sd.setExecutable("/usr/bin/java");
sd.setJavaMain("my.package.HelloWorld");
sd.setJavaArguments("hello", "world");
sd.setJavaClassPath("myJar1:myDir");
sd.setJavaOptions("-version");
sd.addJavaSystemProperty("key", "value");
try {
sd.setStdout(GAT.createFile("javajob.txt"));
} catch (GATObjectCreationException e) {
System.err.println("Failed to create the stdout file 'javajob.txt': " + e);
return;
}
JobDescription jd = new JobDescription(sd);
Job job = null;
try {
job = broker.submitJob(jd);
} catch (GATInvocationException e) {
System.err.println("Failed to submit the job: " + e);
return;
}
while (job.getState() != JobState.STOPPED) {
System.out.println("job is in state: " + job.getState());
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// ignore
}
}
}
use of org.gridlab.gat.GATInvocationException in project compss by bsc-wdc.
the class LoadLevelerFileAdaptor 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 LoadLevelerFileAdaptor 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("LoadLevelerFile", e);
}
}
return res;
}
Aggregations