diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java index a538d92a09e..c232550d41d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java @@ -133,13 +133,24 @@ public class TestReplicationStatus extends TestReplicationBase { * @param greaterThan size of replicationLoadSourceList must be greater before we proceed */ private List waitOnMetricsReport(int greaterThan, ServerName serverName) - throws IOException { - ClusterMetrics metrics = hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)); - List list = - metrics.getLiveServerMetrics().get(serverName).getReplicationLoadSourceList(); - while (list.size() <= greaterThan) { - Threads.sleep(1000); - } - return list; + throws Exception { + UTIL1.waitFor(30000, 1000, new Waiter.ExplainingPredicate() { + @Override + public boolean evaluate() throws Exception { + List list = + hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics() + .get(serverName).getReplicationLoadSourceList(); + return list.size() > greaterThan; + } + + @Override + public String explainFailure() throws Exception { + return "The ReplicationLoadSourceList's size is lesser than or equal to " + greaterThan + + " for " + serverName; + } + }); + + return hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics() + .get(serverName).getReplicationLoadSourceList(); } }