From 380585ef20d8139e9aadffa4adb8189fa3824554 Mon Sep 17 00:00:00 2001 From: XinSun Date: Sat, 26 Sep 2020 19:49:02 +0800 Subject: [PATCH] HBASE-25098 ReplicationStatisticsChore runs in wrong time unit (#2460) Signed-off-by: Viraj Jasani Signed-off-by: Guanghao Zhang --- .../hbase/replication/ReplicationSinkServiceImpl.java | 8 +++++--- .../hbase/replication/regionserver/Replication.java | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationSinkServiceImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationSinkServiceImpl.java index 9b0e3f79fe0..91dd8d08e67 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationSinkServiceImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationSinkServiceImpl.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.replication; import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.concurrent.TimeUnit; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; @@ -51,7 +52,7 @@ public class ReplicationSinkServiceImpl implements ReplicationSinkService { // ReplicationLoad to access replication metrics private ReplicationLoad replicationLoad; - private int statsPeriod; + private int statsPeriodInSecond; @Override public void replicateLogEntries(List entries, CellScanner cells, @@ -66,7 +67,7 @@ public class ReplicationSinkServiceImpl implements ReplicationSinkService { WALProvider walProvider) throws IOException { this.server = server; this.conf = server.getConfiguration(); - this.statsPeriod = + this.statsPeriodInSecond = this.conf.getInt("replication.stats.thread.period.seconds", 5 * 60); this.replicationLoad = new ReplicationLoad(); } @@ -75,7 +76,8 @@ public class ReplicationSinkServiceImpl implements ReplicationSinkService { public void startReplicationService() throws IOException { this.replicationSink = new ReplicationSink(this.conf); this.server.getChoreService().scheduleChore( - new ReplicationStatisticsChore("ReplicationSinkStatistics", server, statsPeriod)); + new ReplicationStatisticsChore("ReplicationSinkStatistics", server, + (int) TimeUnit.SECONDS.toMillis(statsPeriodInSecond))); } @Override diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java index 33975edb590..9be7b9a1e4c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java @@ -22,6 +22,8 @@ import java.util.ArrayList; import java.util.List; import java.util.OptionalLong; import java.util.UUID; +import java.util.concurrent.TimeUnit; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; @@ -64,7 +66,7 @@ public class Replication implements ReplicationSourceService { private SyncReplicationPeerInfoProvider syncReplicationPeerInfoProvider; // Hosting server private Server server; - private int statsPeriod; + private int statsPeriodInSecond; // ReplicationLoad to access replication metrics private ReplicationLoad replicationLoad; private MetricsReplicationGlobalSourceSource globalMetricsSource; @@ -139,7 +141,7 @@ public class Replication implements ReplicationSourceService { p.getSyncReplicationState(), p.getNewSyncReplicationState(), 0)); } } - this.statsPeriod = + this.statsPeriodInSecond = this.conf.getInt("replication.stats.thread.period.seconds", 5 * 60); this.replicationLoad = new ReplicationLoad(); @@ -169,7 +171,8 @@ public class Replication implements ReplicationSourceService { public void startReplicationService() throws IOException { this.replicationManager.init(); this.server.getChoreService().scheduleChore( - new ReplicationStatisticsChore("ReplicationSourceStatistics", server, statsPeriod)); + new ReplicationStatisticsChore("ReplicationSourceStatistics", server, + (int) TimeUnit.SECONDS.toMillis(statsPeriodInSecond))); LOG.info("{} started", this.server.toString()); }