Search in sources :

Example 1 with FileOutputStream

use of org.gridlab.gat.io.FileOutputStream in project compss by bsc-wdc.

the class FileOutputStreamExample method start.

public void start(String location) {
    FileOutputStream out = null;
    try {
        out = GAT.createFileOutputStream(location);
    } catch (GATObjectCreationException e) {
        System.err.println("failed to create outputstream at location '" + location + "': " + e);
        return;
    }
    OutputStreamWriter writer = new OutputStreamWriter(out);
    try {
        writer.write("Hello World!\n");
        writer.flush();
    } catch (IOException e) {
        System.err.println("failed to write to location '" + location + "': " + e);
    }
    try {
        writer.close();
    } catch (IOException e) {
        System.err.println("failed to close writer at location '" + location + "': " + e);
        return;
    }
}
Also used : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) FileOutputStream(org.gridlab.gat.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException)

Example 2 with FileOutputStream

use of org.gridlab.gat.io.FileOutputStream in project compss by bsc-wdc.

the class FileOutputStreamAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String host) {
    AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
    GATContext gatContext = new GATContext();
    PasswordSecurityContext password = new PasswordSecurityContext("username", "TeMpPaSsWoRd");
    password.addNote("adaptors", "ftp");
    gatContext.addSecurityContext(password);
    // CertificateSecurityContext ctxt = new CertificateSecurityContext(null, null, "username", "passphrase");
    // gatContext.addSecurityContext(ctxt);
    Preferences preferences = new Preferences();
    preferences.put("fileoutputstream.adaptor.name", adaptor);
    FileOutputStream out = null;
    try {
        out = GAT.createFileOutputStream(gatContext, preferences, "any://" + host + "/JavaGAT-test-fileoutputstream");
    } catch (GATObjectCreationException e) {
        adaptorTestResult.put("create         ", new AdaptorTestResultEntry(false, 0, e));
        run(host, "fileoutputstream-adaptor-test-clean.sh");
        return adaptorTestResult;
    }
    byte[] large = new byte[10 * 1024 * 1024];
    for (int i = 0; i < large.length; i++) {
        large[i] = 'a';
    }
    adaptorTestResult.put("write (small)", writeTest(out, "test\n"));
    adaptorTestResult.put("write (large)", writeTest(out, new String(large)));
    adaptorTestResult.put("flush        ", flushTest(out));
    adaptorTestResult.put("close        ", closeTest(out));
    run(host, "fileoutputstream-adaptor-test-clean.sh");
    return adaptorTestResult;
}
Also used : GATContext(org.gridlab.gat.GATContext) PasswordSecurityContext(org.gridlab.gat.security.PasswordSecurityContext) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) FileOutputStream(org.gridlab.gat.io.FileOutputStream) Preferences(org.gridlab.gat.Preferences)

Aggregations

GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)2 FileOutputStream (org.gridlab.gat.io.FileOutputStream)2 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 GATContext (org.gridlab.gat.GATContext)1 Preferences (org.gridlab.gat.Preferences)1 PasswordSecurityContext (org.gridlab.gat.security.PasswordSecurityContext)1