Skip to content

Commit

Permalink
HDFS-8305: HDFS INotify: the destination field of RenameOp should alw…
Browse files Browse the repository at this point in the history
…ays end with the file name (cmccabe)
  • Loading branch information
Colin Patrick Mccabe committed May 5, 2015
1 parent b7dd3a4 commit fcd4cb7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ Release 2.7.1 - UNRELEASED
HDFS-8091: ACLStatus and XAttributes should be presented to
INodeAttributesProvider before returning to client (asuresh)

HDFS-8305: HDFS INotify: the destination field of RenameOp should always
end with the file name (cmccabe)

Release 2.7.0 - 2015-04-20

INCOMPATIBLE CHANGES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ private static boolean renameTo(FSDirectory fsd, FSPermissionChecker pc,
fsd.writeUnlock();
}
if (stat) {
fsd.getEditLog().logRename(src, dst, mtime, logRetryCache);
fsd.getEditLog().logRename(src, actualDst, mtime, logRetryCache);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,9 @@ public void logMkDir(String path, INode newNode) {
}

/**
* Add rename record to edit log
* Add rename record to edit log.
*
* The destination should be the file name, not the destination directory.
* TODO: use String parameters until just before writing to disk
*/
void logRename(String src, String dst, long timestamp, boolean toLogRpcIds) {
Expand All @@ -826,9 +828,11 @@ void logRename(String src, String dst, long timestamp, boolean toLogRpcIds) {
logRpcIds(op, toLogRpcIds);
logEdit(op);
}

/**
* Add rename record to edit log
* Add rename record to edit log.
*
* The destination should be the file name, not the destination directory.
*/
void logRename(String src, String dst, long timestamp, boolean toLogRpcIds,
Options.Rename... options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public void testBasic() throws IOException, URISyntaxException,
client.setAcl("/file5", AclEntry.parseAclSpec(
"user::rwx,user:foo:rw-,group::r--,other::---", true));
client.removeAcl("/file5"); // SetAclOp -> MetadataUpdateEvent
client.rename("/file5", "/dir"); // RenameOldOp -> RenameEvent

EventBatch batch = null;

Expand Down Expand Up @@ -343,6 +344,16 @@ public void testBasic() throws IOException, URISyntaxException,
Event.MetadataUpdateEvent.MetadataType.ACLS);
Assert.assertTrue(mue8.getAcls() == null);

// RenameOp (2)
batch = waitForNextEvents(eis);
Assert.assertEquals(1, batch.getEvents().length);
txid = checkTxid(batch, txid);
Assert.assertTrue(batch.getEvents()[0].getEventType() == Event.EventType.RENAME);
Event.RenameEvent re3 = (Event.RenameEvent) batch.getEvents()[0];
Assert.assertTrue(re3.getDstPath().equals("/dir/file5"));
Assert.assertTrue(re3.getSrcPath().equals("/file5"));
Assert.assertTrue(re.getTimestamp() > 0);

// Returns null when there are no further events
Assert.assertTrue(eis.poll() == null);

Expand Down

0 comments on commit fcd4cb7

Please sign in to comment.