Example usage for org.apache.hadoop.hdfs DFSClient getInotifyEventStream

List of usage examples for org.apache.hadoop.hdfs DFSClient getInotifyEventStream

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DFSClient getInotifyEventStream.

Prototype

public DFSInotifyEventInputStream getInotifyEventStream() throws IOException 

Source Link

Usage

From source file:INotifyUtil.java

License:Apache License

/**
 * Poll events and output the details./*ww  w.  ja  va2  s  . c om*/
 * Ctrl + C to stop polling.
 * @param args the parameter is not used.
 * @throws IOException if configuration error or I/O error happens.
 */
public static void main(String args[]) throws IOException {
    Configuration conf = new HdfsConfiguration();
    DFSClient client = new DFSClient(DFSUtilClient.getNNAddress(conf), conf);
    DFSInotifyEventInputStream iStream = client.getInotifyEventStream();
    while (true) {
        try {
            EventBatch eventBatch = iStream.take();
            for (Event event : eventBatch.getEvents()) {
                System.out.println(event.toString());
            }
        } catch (InterruptedException e) {
            System.out.println("Interrupted. Exiting...");
            return;
        } catch (MissingEventsException e) {
            e.printStackTrace();
            return;
        }
    }
}