Example usage for org.apache.hadoop.hdfs DFSUtilClient getNNAddress

List of usage examples for org.apache.hadoop.hdfs DFSUtilClient getNNAddress

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DFSUtilClient getNNAddress.

Prototype

public static InetSocketAddress getNNAddress(URI filesystemURI) 

Source Link

Usage

From source file:INotifyUtil.java

License:Apache License

/**
 * Poll events and output the details./*  w w w  .  j a v a2s.  c o  m*/
 * 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;
        }
    }
}