-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HADOOP-18893. Make Trash Policy pluggable for different FileSystems #6061
base: trunk
Are you sure you want to change the base?
Conversation
Putting up an initial PR for Trash policy separation. Need to verify this in a cluster still, but have added a small test for S3A and ABFS. HDFS has some good tests for Trash too. |
💔 -1 overall
This message was automatically generated. |
* @param fs the file system to be used | ||
* @return an instance of TrashPolicy | ||
*/ | ||
@SuppressWarnings("ClassReferencesSubclass") | ||
public static TrashPolicy getInstance(Configuration conf, FileSystem fs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the conf come from the filesystem? as if so it'd let us do per-bucket stuff. if not, well, it's possibly too late
@@ -193,7 +193,7 @@ public boolean moveToTrash(Path path) throws IOException { | |||
// move to current trash | |||
fs.rename(path, trashPath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should check return value here. "false" isn't that useful, but it does mean the rename failed
@@ -347,31 +354,42 @@ private void createCheckpoint(Path trashRoot, Date date) throws IOException { | |||
while (true) { | |||
try { | |||
fs.rename(current, checkpoint, Rename.NONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, handle failure here
@@ -347,31 +354,42 @@ private void createCheckpoint(Path trashRoot, Date date) throws IOException { | |||
while (true) { | |||
try { | |||
fs.rename(current, checkpoint, Rename.NONE); | |||
LOG.info("Created trash checkpoint: " + checkpoint.toUri().getPath()); | |||
LOG.info("Created trash checkpoint: {}", checkpoint.toUri().getPath()); | |||
break; | |||
} catch (FileAlreadyExistsException e) { | |||
if (++attempt > 1000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets make this a constant
} catch (FileNotFoundException fnfe) { | ||
return; | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that the listStatus calls may not raise the FNFE until the next/hasNext call, so catch it in the iterator below too
Configuration conf = new Configuration(); | ||
Trash trash = new Trash(getFileSystem(), conf); | ||
assertEquals("Mismatch in Trash Policy set by the config", | ||
trash.getTrashPolicy().getClass(), EmptyTrashPolicy.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer assertJ
@Test | ||
public void testTrashSetToEmptyTrashPolicy() throws IOException { | ||
Configuration conf = new Configuration(); | ||
Trash trash = new Trash(getFileSystem(), conf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use conf from filesystem
@@ -3450,23 +3454,29 @@ public Path getTrashRoot(Path path) { | |||
public Collection<FileStatus> getTrashRoots(boolean allUsers) { | |||
Path userHome = new Path(getHomeDirectory().toUri().getPath()); | |||
List<FileStatus> ret = new ArrayList<>(); | |||
// an operation to look up a path status and add it to the return list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice bit of work
if (getFileSystem().delete(path, true)) { | ||
LOG.info("Deleted trash checkpoint: {}", path); | ||
} else { | ||
LOG.warn("Couldn't delete checkpoint: {}. Ignoring.", path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a check to see if path exists. if it doesn't exist any more, just log at info rather than warn
|
||
/** | ||
* parse the name of a checkpoint to extgact its timestamp. | ||
* Uses the Hadoop 0.23 checkpoint as well as the older version (!). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be time to return the older version code if it is over complex
Description of PR
Follow up from #4729
How was this patch tested?
For code changes:
LICENSE
,LICENSE-binary
,NOTICE-binary
files?