use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class FileAdaptorTest method lastModifiedTest.
private AdaptorTestResultEntry lastModifiedTest(GATContext gatContext, Preferences preferences, String host, String filename, int tabs, long 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();
long time;
try {
time = file.lastModified();
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(time == correctValue, (stop - start), null);
}
use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class FileAdaptorTest method mkdirsTest.
private AdaptorTestResultEntry mkdirsTest(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 mkdirs;
try {
mkdirs = file.mkdirs();
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(mkdirs == correctValue, (stop - start), null);
}
use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class FileOutputStreamAdaptorTest method run.
private void run(String host, String script) {
Preferences preferences = new Preferences();
preferences.put("resourcebroker.adaptor.name", "commandlinessh,sshtrilead,local");
preferences.put("file.adaptor.name", "commandlinessh,sshtrilead,local");
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable("/bin/bash");
sd.setArguments(script);
try {
sd.addPreStagedFile(GAT.createFile(preferences, "tests" + java.io.File.separator + "src" + java.io.File.separator + "benchmarks" + java.io.File.separator + script));
} catch (GATObjectCreationException e) {
e.printStackTrace();
System.exit(1);
}
ResourceBroker broker = null;
try {
broker = GAT.createResourceBroker(preferences, new URI("any://" + host));
} catch (GATObjectCreationException e) {
e.printStackTrace();
System.exit(1);
} catch (URISyntaxException e) {
e.printStackTrace();
System.exit(1);
}
Job job = null;
try {
job = broker.submitJob(new JobDescription(sd));
} catch (GATInvocationException e) {
e.printStackTrace();
System.exit(1);
}
while (job.getState() != Job.JobState.STOPPED && job.getState() != Job.JobState.SUBMISSION_ERROR) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// ignored
}
}
}
use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class RandomAccessFileAdaptorTest method test.
public AdaptorTestResult test(String adaptor, String host) {
AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
GATContext gatContext = new GATContext();
Preferences preferences = new Preferences();
preferences.put("randomaccessfile.adaptor.name", adaptor);
RandomAccessFile randomAccessFile = null;
try {
randomAccessFile = GAT.createRandomAccessFile(gatContext, preferences, "any://" + host + "/JavaGAT-random-accessfile", "rw");
} catch (GATObjectCreationException e) {
e.printStackTrace();
GAT.end();
System.exit(1);
}
adaptorTestResult.put("length ", lengthTest(gatContext, preferences, randomAccessFile, 0));
adaptorTestResult.put("write 'lorem ipsum'", writeTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
adaptorTestResult.put("length after write", lengthTest(gatContext, preferences, randomAccessFile, 13));
adaptorTestResult.put("seek ", seekTest(gatContext, preferences, randomAccessFile, 0));
adaptorTestResult.put("read ", readTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
adaptorTestResult.put("write 'lorem ipsum' 2", writeTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
adaptorTestResult.put("length after write 2", lengthTest(gatContext, preferences, randomAccessFile, 26));
adaptorTestResult.put("seek 2 ", seekTest(gatContext, preferences, randomAccessFile, 0));
adaptorTestResult.put("read 2 ", readTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
adaptorTestResult.put("read 3 ", readTest(gatContext, preferences, randomAccessFile, "lorem ipsum"));
return adaptorTestResult;
}
use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class FileInputStreamExample method start.
public void start(String location) {
FileInputStream in = null;
try {
in = GAT.createFileInputStream(location);
} catch (GATObjectCreationException e) {
System.err.println("failed to create inputstream at location '" + location + "': " + e);
return;
}
InputStreamReader reader = new InputStreamReader(in);
BufferedReader bufferedReader = new BufferedReader(reader);
try {
System.out.println("read: " + bufferedReader.readLine());
} catch (IOException e) {
System.err.println("failed to read a line from inputstream at location '" + location + "': " + e);
return;
}
try {
bufferedReader.close();
} catch (IOException e) {
System.err.println("failed to close inputstream at location '" + location + "': " + e);
return;
}
}
Aggregations