[ https://issues.apache.org/jira/browse/HDFS-13475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16541965#comment-16541965 ]
Íñigo Goiri commented on HDFS-13475: ------------------------------------ I think the proposal in [^HDFS-13475.002.patch] is much cleaner; isolating the safe mode logic makes the code simpler. I think the unit test covers the issue described in this JIRA. My only concern is how long it takes as it is adding an extra 7 seconds which is basically doubling the test length. I wonder if there is any way to speed this up a little; for example, cutting the times a little and waiting for it to get into RUNNING instead of just sleeping. A minor nit regarding code, we currently have: {code} RouterSafemodeService safeModeService = this.router.getSafemodeService(); if (safeModeService != null) { this.router.updateRouterState(RouterServiceState.SAFEMODE); safeModeService.setManualSafeMode(true); return EnterSafeModeResponse.newInstance(verifySafeMode(true)); } return EnterSafeModeResponse.newInstance(false); {code} It is personal preference, but I would go for a single point of exit: {code} boolean success = false; RouterSafemodeService safeModeService = this.router.getSafemodeService(); if (safeModeService != null) { this.router.updateRouterState(RouterServiceState.SAFEMODE); safeModeService.setManualSafeMode(true); success = verifySafeMode(true); } return EnterSafeModeResponse.newInstance(success); {code} Similar for the other modified methods in {{RouterAdminServer}}. > RBF: Admin cannot enforce Router enter SafeMode > ----------------------------------------------- > > Key: HDFS-13475 > URL: https://issues.apache.org/jira/browse/HDFS-13475 > Project: Hadoop HDFS > Issue Type: Sub-task > Reporter: Wei Yan > Assignee: Chao Sun > Priority: Major > Attachments: HDFS-13475.000.patch, HDFS-13475.001.patch, > HDFS-13475.002.patch > > > To reproduce the issue: > {code:java} > $ bin/hdfs dfsrouteradmin -safemode enter > Successfully enter safe mode. > $ bin/hdfs dfsrouteradmin -safemode get > Safe Mode: true{code} > And then, > {code:java} > $ bin/hdfs dfsrouteradmin -safemode get > Safe Mode: false{code} > From the code, it looks like the periodicInvoke triggers the leave. > {code:java} > public void periodicInvoke() { > ...... > // Always update to indicate our cache was updated > if (isCacheStale) { > if (!rpcServer.isInSafeMode()) { > enter(); > } > } else if (rpcServer.isInSafeMode()) { > // Cache recently updated, leave safe mode > leave(); > } > } > {code} > > -- 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