Search in sources :

Example 1 with FileInputStream

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

the class FileInputStreamAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String host) {
    run(host, "fileinputstream-adaptor-test-init.sh");
    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("fileinputstream.adaptor.name", adaptor);
    FileInputStream in = null;
    try {
        in = GAT.createFileInputStream(gatContext, preferences, "any://" + host + "/JavaGAT-test-fileinputstream");
    } catch (GATObjectCreationException e) {
        adaptorTestResult.put("create         ", new AdaptorTestResultEntry(false, 0, e));
        run(host, "fileinputstream-adaptor-test-clean.sh");
        return adaptorTestResult;
    }
    adaptorTestResult.put("markSupported      ", markSupportedTest(in));
    adaptorTestResult.put("available:         ", availableTest(in, 0, true));
    adaptorTestResult.put("read: single char a", readTest(in, 'a', true));
    adaptorTestResult.put("read: single char b", readTest(in, 'b', true));
    adaptorTestResult.put("read: single char c", readTest(in, 'c', true));
    adaptorTestResult.put("read: single char !d", readTest(in, 'q', false));
    adaptorTestResult.put("read: small       ", readTest(in, "efg".getBytes(), true));
    byte[] bytes = new byte[1024 * 1024 * 10];
    byte current = 'h';
    for (int i = 0; i < bytes.length; i++) {
        bytes[i] = current;
        if (current == 'z') {
            current = '\n';
        } else if (current == '\n') {
            current = 'a';
        } else {
            current++;
        }
    }
    adaptorTestResult.put("read: large          ", readTest(in, bytes, true));
    adaptorTestResult.put("skip: small          ", skipTest(in, 100));
    adaptorTestResult.put("skip: large          ", skipTest(in, 10 * 1024 * 1024));
    adaptorTestResult.put("close                ", closeTest(in));
    run(host, "fileinputstream-adaptor-test-clean.sh");
    return adaptorTestResult;
}
Also used : GATContext(org.gridlab.gat.GATContext) PasswordSecurityContext(org.gridlab.gat.security.PasswordSecurityContext) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) Preferences(org.gridlab.gat.Preferences) FileInputStream(org.gridlab.gat.io.FileInputStream)

Example 2 with FileInputStream

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

the class RemoteCat method main.

public static void main(String[] args) throws Exception {
    FileInputStream in = GAT.createFileInputStream(new URI(args[0]));
    java.io.InputStreamReader reader = new java.io.InputStreamReader(in);
    java.io.BufferedReader buf = new java.io.BufferedReader(reader);
    while (true) {
        String result = buf.readLine();
        if (result == null) {
            break;
        }
        System.out.println(result);
    }
    in.close();
    GAT.end();
}
Also used : URI(org.gridlab.gat.URI) FileInputStream(org.gridlab.gat.io.FileInputStream)

Example 3 with FileInputStream

use of org.gridlab.gat.io.FileInputStream 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;
    }
}
Also used : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) FileInputStream(org.gridlab.gat.io.FileInputStream)

Aggregations

FileInputStream (org.gridlab.gat.io.FileInputStream)3 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 GATContext (org.gridlab.gat.GATContext)1 Preferences (org.gridlab.gat.Preferences)1 URI (org.gridlab.gat.URI)1 PasswordSecurityContext (org.gridlab.gat.security.PasswordSecurityContext)1