List of usage examples for org.apache.hadoop.hdfs DFSInotifyEventInputStream take
public EventBatch take() throws IOException, InterruptedException, MissingEventsException
From source file:INotifyUtil.java
License:Apache License
/** * Poll events and output the details./*from w w w . j a v a2 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; } } }