HDFS-17116. RBF: Update invoke millisecond time as monotonicNow() in RouterSafemodeService (#5876). Contributed by Haiyang Hu.
Reviewed-by: hfutatzhanghb <1036798979@qq.com> Reviewed-by: Shilun Fan <slfan1989@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
This commit is contained in:
parent
6d32a06125
commit
87c036efb3
@ -17,13 +17,12 @@
|
||||
*/
|
||||
package org.apache.hadoop.hdfs.server.federation.router;
|
||||
|
||||
import static org.apache.hadoop.util.Time.now;
|
||||
import static org.apache.hadoop.util.Time.monotonicNow;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdfs.server.federation.store.StateStoreService;
|
||||
import org.apache.hadoop.util.Time;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -73,7 +72,7 @@ public class RouterSafemodeService extends PeriodicService {
|
||||
private long startupTime;
|
||||
|
||||
/** The time the Router enters safe mode in milliseconds. */
|
||||
private long enterSafeModeTime = now();
|
||||
private long enterSafeModeTime = monotonicNow();
|
||||
|
||||
|
||||
/**
|
||||
@ -107,7 +106,7 @@ void setManualSafeMode(boolean mode) {
|
||||
*/
|
||||
private void enter() {
|
||||
LOG.info("Entering safe mode");
|
||||
enterSafeModeTime = now();
|
||||
enterSafeModeTime = monotonicNow();
|
||||
safeMode = true;
|
||||
router.updateRouterState(RouterServiceState.SAFEMODE);
|
||||
}
|
||||
@ -117,7 +116,7 @@ private void enter() {
|
||||
*/
|
||||
private void leave() {
|
||||
// Cache recently updated, leave safemode
|
||||
long timeInSafemode = now() - enterSafeModeTime;
|
||||
long timeInSafemode = monotonicNow() - enterSafeModeTime;
|
||||
LOG.info("Leaving safe mode after {} milliseconds", timeInSafemode);
|
||||
RouterMetrics routerMetrics = router.getRouterMetrics();
|
||||
if (routerMetrics == null) {
|
||||
@ -151,7 +150,7 @@ protected void serviceInit(Configuration conf) throws Exception {
|
||||
LOG.info("Enter safe mode after {} ms without reaching the State Store",
|
||||
this.staleInterval);
|
||||
|
||||
this.startupTime = Time.now();
|
||||
this.startupTime = monotonicNow();
|
||||
|
||||
// Initializing the RPC server in safe mode, it will disable it later
|
||||
enter();
|
||||
@ -161,7 +160,7 @@ protected void serviceInit(Configuration conf) throws Exception {
|
||||
|
||||
@Override
|
||||
public void periodicInvoke() {
|
||||
long now = Time.now();
|
||||
long now = monotonicNow();
|
||||
long delta = now - startupTime;
|
||||
if (delta < startupInterval) {
|
||||
LOG.info("Delaying safemode exit for {} milliseconds...",
|
||||
|
@ -435,7 +435,7 @@ public void refreshCaches(boolean force) {
|
||||
}
|
||||
if (success) {
|
||||
// Uses local time, not driver time.
|
||||
this.cacheLastUpdateTime = Time.now();
|
||||
this.cacheLastUpdateTime = Time.monotonicNow();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user