Skip to content

Commit 1183f06

Browse files
2005hithljApache9
authored andcommitted
HBASE-27269 The implementation of TestReplicationStatus.waitOnMetricsReport is incorrect (#4678)
Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 2dc2608)
1 parent 1094b15 commit 1183f06

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,24 @@ public boolean evaluate() throws Exception {
133133
* @param greaterThan size of replicationLoadSourceList must be greater before we proceed
134134
*/
135135
private List<ReplicationLoadSource> waitOnMetricsReport(int greaterThan, ServerName serverName)
136-
throws IOException {
137-
ClusterMetrics metrics = hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS));
138-
List<ReplicationLoadSource> list =
139-
metrics.getLiveServerMetrics().get(serverName).getReplicationLoadSourceList();
140-
while (list.size() <= greaterThan) {
141-
Threads.sleep(1000);
142-
}
143-
return list;
136+
throws Exception {
137+
UTIL1.waitFor(30000, 1000, new Waiter.ExplainingPredicate<Exception>() {
138+
@Override
139+
public boolean evaluate() throws Exception {
140+
List<ReplicationLoadSource> list =
141+
hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics()
142+
.get(serverName).getReplicationLoadSourceList();
143+
return list.size() > greaterThan;
144+
}
145+
146+
@Override
147+
public String explainFailure() throws Exception {
148+
return "The ReplicationLoadSourceList's size is lesser than or equal to " + greaterThan
149+
+ " for " + serverName;
150+
}
151+
});
152+
153+
return hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics()
154+
.get(serverName).getReplicationLoadSourceList();
144155
}
145156
}

0 commit comments

Comments
 (0)