-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-17509. RBF: Fix ClientProtocol.concat will throw NPE if tgr is a empty file. #6784
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
97bffaa
HDFS-17509
7b8c582
triggle compile
382c3f8
Fix SpotBugs Report
0aa6a1e
Fix checkstyle
e1fea88
get first right file for mulitple file with different nameservice
acc8139
add getFileRemoteLocation function && add test case for a src empty src
61d08c5
test for verify exception msg with empty src file
0c3ea01
fix code style
7a591b0
add expection msg for test case
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1163,6 +1163,21 @@ public void testProxyGetPreferedBlockSize() throws Exception { | |
routerProtocol, nnProtocol, m, new Object[] {badPath}); | ||
} | ||
|
||
private void testConcat( | ||
String source, String target, boolean failureExpected, boolean verfiyException, String msg) { | ||
boolean failure = false; | ||
try { | ||
// Concat test file with fill block length file via router | ||
routerProtocol.concat(target, new String[] {source}); | ||
} catch (IOException ex) { | ||
failure = true; | ||
if (verfiyException) { | ||
assertExceptionContains(msg, ex); | ||
} | ||
} | ||
assertEquals(failureExpected, failure); | ||
} | ||
|
||
private void testConcat( | ||
String source, String target, boolean failureExpected) { | ||
boolean failure = false; | ||
|
@@ -1224,6 +1239,27 @@ public void testProxyConcatFile() throws Exception { | |
String badPath = "/unknownlocation/unknowndir"; | ||
compareResponses(routerProtocol, nnProtocol, m, | ||
new Object[] {badPath, new String[] {routerFile}}); | ||
|
||
// Test when concat trg is a empty file | ||
createFile(routerFS, existingFile, existingFileSize); | ||
String sameRouterEmptyFile = | ||
cluster.getFederatedTestDirectoryForNS(sameNameservice) + | ||
"_newemptyfile"; | ||
createFile(routerFS, sameRouterEmptyFile, 0); | ||
// Concat in same namespaces, succeeds | ||
testConcat(existingFile, sameRouterEmptyFile, false); | ||
FileStatus mergedStatus = getFileStatus(routerFS, sameRouterEmptyFile); | ||
assertEquals(existingFileSize, mergedStatus.getLen()); | ||
|
||
// Test when concat srclist has some empty file, namenode will throw IOException. | ||
String srcEmptyFile = cluster.getFederatedTestDirectoryForNS(sameNameservice) + "_srcEmptyFile"; | ||
createFile(routerFS, srcEmptyFile, 0); | ||
String targetFile = cluster.getFederatedTestDirectoryForNS(sameNameservice) + "_targetFile"; | ||
createFile(routerFS, targetFile, existingFileSize); | ||
// Concat in same namespaces, succeeds | ||
testConcat(srcEmptyFile, targetFile, true, true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here please check if the exception is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Thanks |
||
"org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.HadoopIllegalArgumentException): concat: source file " | ||
+ srcEmptyFile + " is invalid or empty or underConstruction"); | ||
} | ||
|
||
@Test | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we also need to check the empty source file.
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.
When there is a empty source file, it will throw exception in namenode. This behaiver is as same as with dfsrouter.
And when trg is a empty file, it is diffrent . Without dfsrouter ,it success. And with dfsrouter, it will throw Exception.
So I think there is no need to check the empty source file. Or implement it in another PR.
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.
Do the namenode and rbf throw the same Exception?
Maybe RBF throws NPE, but NN throws
org.apache.hadoop.HadoopIllegalArgumentException
.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.
When srclist has a empty file ,both namenode and dfsrouter will throw the same IOException
https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirConcatOp.java#L153-L155
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.
Can you modify the UT to cover the case that one or more source files are empty?
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 test for a empty src file