-
Notifications
You must be signed in to change notification settings - Fork 8.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
HDFS-16831. [RBF SBN] GetNamenodesForNameserviceId should shuffle Observer NameNodes every time #5098
Conversation
…erver NameNodes every time
💔 -1 overall
This message was automatically generated. |
@omalley @simbadzina Master, please help me review this PR too. The failed building may not relate this change. It works well locally. The method |
List<T> inputNameNodes, boolean listObserversFirst) { | ||
if (!listObserversFirst) { | ||
return inputNameNodes; | ||
} else { |
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.
No ned for elses when we do the return.
} | ||
} | ||
|
||
if (observerNNList.size() <= 1) { |
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 could've done this check earlier.
@goiri Sir, thanks for your review. I have updated this PR, please help me review it again when you are available. Thanks so much. |
💔 -1 overall
This message was automatically generated. |
@ZanderXu Thanks for your contribution, we should fix the checkstyle issue. |
@slfan1989 Sir, thanks for your review. I have fixed the checkstyle in the last commit. |
💔 -1 overall
This message was automatically generated. |
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.
+1 LGTM after last commit. @ZanderXu - Do you think we need to add a UT ?
@ashutoshcipher Sir, thanks for your review. I will add one UT to test it. Do you have some good ideas to test shuffling result? |
@ashutoshcipher @goiri @slfan1989 Sir, I have add one UT to test it. Please help me review it again. Thanks so much. |
🎊 +1 overall
This message was automatically generated. |
.../main/java/org/apache/hadoop/hdfs/server/federation/resolver/MembershipNamenodeResolver.java
Show resolved
Hide resolved
.../main/java/org/apache/hadoop/hdfs/server/federation/resolver/MembershipNamenodeResolver.java
Show resolved
Hide resolved
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@goiri Sir, can help me review this PR again? Thanks so much. |
@simbadzina Master, can you help me review this PR when you are available? |
Code looks good to me. Just one small recommended change to test the shuffling. Thanks for working on this. |
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.
To test the shuffling, one approach would be to call namenodeResolver.getNamenodesForNameserviceId() 100 times in a loop and check if ever the two observers swap positions in the list. If there is never a swap we fail the test.
The test will be probabilistic but the chance of it flaking will be extremely low 0.5^100.
List<? extends FederationNamenodeContext> observerList3 ;
for(int i = 0; i < 100; i++) {
observerList3 = namenodeResolver.getNamenodesForNameserviceId(NAMESERVICES[0], true);
assertEquals(FederationNamenodeServiceState.OBSERVER, observerList3.get(0).getState());
assertEquals(FederationNamenodeServiceState.OBSERVER, observerList3.get(1).getState());
if (observerList3.get(0).getNamenodeId().equals(observerList2.get(1).getNamenodeId()) &&
observerList3.get(1).getNamenodeId().equals(observerList2.get(0).getNamenodeId())) {
return;
}
}
Assert.fail("Observer order never changed.");
\
@simbadzina Thanks for your nice suggestion, I will do it. |
@simbadzina master, I have modified the UT, please help me review again, thanks. |
🎊 +1 overall
This message was automatically generated. |
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.
Both code and tests look good to me.
Merged, thanks @ashutoshcipher @simbadzina @slfan1989 @goiri for your review. Thanks so much. |
…erver NameNodes every time (apache#5098)
…erver NameNodes every time (apache#5098)
Description of PR
HDFS-16831
The method
getNamenodesForNameserviceId
inMembershipNamenodeResolver.class
should shuffle Observer NameNodes every time. The current logic will return the cached list and will caused all of read requests are forwarding to the first observer namenode.The related code as bellow: