Search in sources :

Example 1 with FileSystem

use of org.talend.webhcat.launcher.fs.FileSystem in project tdi-studio-se by Talend.

the class Job method execute.

public Integer execute() throws IOException, InterruptedException, InvalidKeyException, URISyntaxException, StorageException {
    String status = this.statusFolder;
    String exitCode = status + "/exit";
    final String stderr = status + "/stderr";
    final FileSystem fs = this.fileSystem;
    class StreamStrErr implements Runnable {

        public void run() {
            InputStream is = null;
            BufferedReader d = null;
            try {
                while (!fs.exists(stderr)) {
                    Thread.sleep(2000);
                }
                is = fs.open(stderr);
                d = new BufferedReader(new InputStreamReader(is));
                String s;
                while ((s = d.readLine()) == null) {
                    if (is != null) {
                        is.close();
                    }
                    if (d != null) {
                        d.close();
                    }
                    is = fs.open(stderr);
                    d = new BufferedReader(new InputStreamReader(is));
                }
                do {
                    System.err.println(s);
                } while ((s = d.readLine()) != null);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                    }
                }
                if (d != null) {
                    try {
                        d.close();
                    } catch (IOException e) {
                    }
                }
            }
        }
    }
    StreamStrErr stream = new StreamStrErr();
    stream.run();
    while (!fs.exists(exitCode)) {
        Thread.sleep(2000);
    }
    InputStream is = fs.open(exitCode);
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    String r = br.readLine();
    try {
        return Integer.parseInt(r);
    } catch (Exception e) {
        return 1;
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) FileSystem(org.talend.webhcat.launcher.fs.FileSystem) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) StorageException(com.microsoft.azure.storage.StorageException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException)

Example 2 with FileSystem

use of org.talend.webhcat.launcher.fs.FileSystem in project tdi-studio-se by Talend.

the class MapReduceJob method main.

public static void main(String[] args) throws Exception {
    Configuration conf = new Configuration();
    conf.set("fs.default.name", "hdfs://hdp21:8020/");
    FileSystem fs = new HadoopFileSystem(conf);
    Job J = new MapReduceJob(fs);
    J.parseArg(args);
    J.callWS(J.sendFiles(), false);
    J.execute();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.talend.webhcat.launcher.fs.FileSystem) HadoopFileSystem(org.talend.webhcat.launcher.fs.HadoopFileSystem) Job(org.talend.webhcat.launcher.common.Job) HadoopFileSystem(org.talend.webhcat.launcher.fs.HadoopFileSystem)

Aggregations

FileSystem (org.talend.webhcat.launcher.fs.FileSystem)2 StorageException (com.microsoft.azure.storage.StorageException)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 URISyntaxException (java.net.URISyntaxException)1 InvalidKeyException (java.security.InvalidKeyException)1 Configuration (org.apache.hadoop.conf.Configuration)1 Job (org.talend.webhcat.launcher.common.Job)1 HadoopFileSystem (org.talend.webhcat.launcher.fs.HadoopFileSystem)1