use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class RandomAccessFileExample method start.
public void start(String source, String target) {
RandomAccessFile sourceFile = null;
try {
sourceFile = GAT.createRandomAccessFile(source, "r");
} catch (GATObjectCreationException e) {
System.err.println("Failed to create random access file '" + source + "': " + e);
return;
}
RandomAccessFile targetFile = null;
try {
targetFile = GAT.createRandomAccessFile(target, "rw");
} catch (GATObjectCreationException e) {
System.err.println("Failed to create random access file '" + target + "': " + e);
return;
}
try {
targetFile.setLength(sourceFile.length());
} catch (IOException e) {
System.err.println("Failed to set/get the length: " + e);
return;
}
try {
for (int i = 0; i < sourceFile.length(); i++) {
targetFile.seek(targetFile.length() - 1 - i);
sourceFile.seek(i);
targetFile.writeByte(sourceFile.readByte());
}
} catch (IOException e) {
System.out.println("Failed to seek/read/write: " + e);
return;
}
}
use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class ResourceBrokerStreamingOutExample 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("/usr/bin/env");
sd.enableStreamingStdout(true);
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;
}
InputStream in = null;
try {
in = job.getStdout();
} catch (GATInvocationException e) {
System.err.println("Failed to get the stdout stream: " + e);
return;
}
while (true) {
int i = 0;
try {
i = in.read();
} catch (IOException e) {
System.err.println("Failed to read: " + e);
return;
}
if (i == -1) {
break;
} else {
System.out.print((char) i);
}
}
}
Aggregations