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

Chen Liang commented on HDFS-13898:
-----------------------------------

Thanks [~csun] for reporting and fixing this! My main question was also that if 
we are mocking BlockManager why do we still need to change DN number. Seems 
that the {{Requested replication factor of 0 is less than the required minimum 
of 1}} was reported in {{BlockManager.verifyReplication}}, I wonder is it 
possible to mock the method {{verifyReplication}}, making it a no-op, so it 
won't perform this check? e.g. I randomly added the following lines before 
{{createNewFile}}, seems the test can pass without changing the num of DN. Not 
sure if this is a better way to go though. Just a thought.
{code:java}
BlockManager bmSpy1 = NameNodeAdapter.spyOnBlockManager(namenodes[0]);
doNothing().when(bmSpy1).verifyReplication(anyString(), anyShort(), 
anyString());{code}
Also, there is an inconsistency on the style of the mocking arguments, that 
some are {{Mock.any()}}, while some others are like {{anyBoolean()}}. (no Mock.)

> Throw retriable exception for getBlockLocations when ObserverNameNode is in 
> safemode
> ------------------------------------------------------------------------------------
>
>                 Key: HDFS-13898
>                 URL: https://issues.apache.org/jira/browse/HDFS-13898
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>            Reporter: Chao Sun
>            Assignee: Chao Sun
>            Priority: Major
>         Attachments: HDFS-13898-HDFS-12943.000.patch
>
>
> When ObserverNameNode is in safe mode, {{getBlockLocations}} may throw safe 
> mode exception if the given file doesn't have any block yet. 
> {code}
>     try {
>       checkOperation(OperationCategory.READ);
>       res = FSDirStatAndListingOp.getBlockLocations(
>           dir, pc, srcArg, offset, length, true);
>       if (isInSafeMode()) {
>         for (LocatedBlock b : res.blocks.getLocatedBlocks()) {
>           // if safemode & no block locations yet then throw safemodeException
>           if ((b.getLocations() == null) || (b.getLocations().length == 0)) {
>             SafeModeException se = newSafemodeException(
>                 "Zero blocklocations for " + srcArg);
>             if (haEnabled && haContext != null &&
>                 haContext.getState().getServiceState() == 
> HAServiceState.ACTIVE) {
>               throw new RetriableException(se);
>             } else {
>               throw se;
>             }
>           }
>         }
>       }
> {code}
> It only throws {{RetriableException}} for active NN so requests on observer 
> may just fail.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to