[ 
https://issues.apache.org/jira/browse/HDFS-16831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17651034#comment-17651034
 ] 

ASF GitHub Bot commented on HDFS-16831:
---------------------------------------

ZanderXu commented on PR #5098:
URL: https://github.com/apache/hadoop/pull/5098#issuecomment-1362283212

   \
   
   > 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.




> [RBF SBN] GetNamenodesForNameserviceId should shuffle Observer NameNodes 
> every time
> -----------------------------------------------------------------------------------
>
>                 Key: HDFS-16831
>                 URL: https://issues.apache.org/jira/browse/HDFS-16831
>             Project: Hadoop HDFS
>          Issue Type: Bug
>            Reporter: ZanderXu
>            Assignee: ZanderXu
>            Priority: Major
>              Labels: pull-request-available
>
> The method getNamenodesForNameserviceId in MembershipNamenodeResolver.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:
> {code:java}
> @Override
> public List<? extends FederationNamenodeContext> getNamenodesForNameserviceId(
>     final String nsId, boolean listObserversFirst) throws IOException {
>   List<? extends FederationNamenodeContext> ret = cacheNS.get(Pair.of(nsId, 
> listObserversFirst));
>   if (ret != null) {
>     return ret;
>   } 
>   ...
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to