Embed presentation

















![HDFS Audit Log
123 AddCloseOp(file=/a)
124 DeleteOp(file=/b)
125 SetReplicationOp(file=/a,
rep=5)
126 AddCloseOp(file=/c)
127 RenameOp(src=/c, dst=/d)
128 ConcatOp(dst=/x, src1=/y,
src2=/z)
...
DFSINotifyInputStream
123 CreateEvent
124 UnlinkEvent
125 MetadataUpdateEvent
126 CloseEvent
127 RenameEvent
128 [AppendEvent /x,
UnlinkEvent /y,
UnlinkEvent /z]
...](https://image.slidesharecdn.com/june9435pmclouderamccabe-150616224854-lva1-app6892/85/Keep-me-in-the-Loop-INotify-in-HDFS-18-320.jpg)


![DFSInotifyEventInputStream stream =
dfs.getInotifyEventStream(prevHighestTxId);
EventBatch batch = stream.take();
long newTxid = batch.getTxid();
switch (batch.getEvents()[0].getEventType()) {
case Event.EventType.RENAME:
…
}
stream.close();](https://image.slidesharecdn.com/june9435pmclouderamccabe-150616224854-lva1-app6892/85/Keep-me-in-the-Loop-INotify-in-HDFS-21-320.jpg)









This document describes how the HDFS client uses the NameNode's audit log and DFSInotifyEventInputStream to monitor file system changes since its last poll. The client caches the highest event ID it has seen and periodically polls the NameNode for any events with higher IDs. The NameNode assigns monotonically increasing IDs to each event in its audit log, which also gets replayed as events through the DFSInotifyEventInputStream that clients can read to learn about changes like renames, deletes, metadata updates etc.

















![HDFS Audit Log
123 AddCloseOp(file=/a)
124 DeleteOp(file=/b)
125 SetReplicationOp(file=/a,
rep=5)
126 AddCloseOp(file=/c)
127 RenameOp(src=/c, dst=/d)
128 ConcatOp(dst=/x, src1=/y,
src2=/z)
...
DFSINotifyInputStream
123 CreateEvent
124 UnlinkEvent
125 MetadataUpdateEvent
126 CloseEvent
127 RenameEvent
128 [AppendEvent /x,
UnlinkEvent /y,
UnlinkEvent /z]
...](https://image.slidesharecdn.com/june9435pmclouderamccabe-150616224854-lva1-app6892/85/Keep-me-in-the-Loop-INotify-in-HDFS-18-320.jpg)


![DFSInotifyEventInputStream stream =
dfs.getInotifyEventStream(prevHighestTxId);
EventBatch batch = stream.take();
long newTxid = batch.getTxid();
switch (batch.getEvents()[0].getEventType()) {
case Event.EventType.RENAME:
…
}
stream.close();](https://image.slidesharecdn.com/june9435pmclouderamccabe-150616224854-lva1-app6892/85/Keep-me-in-the-Loop-INotify-in-HDFS-21-320.jpg)







