HBASE-27269 The implementation of TestReplicationStatus.waitOnMetricsReport is incorrect (#4678)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
LiangJun He 2022-08-04 22:42:36 +08:00 committed by GitHub
parent fb529e2352
commit 2dc26082be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 8 deletions

View File

@ -133,13 +133,24 @@ public class TestReplicationStatus extends TestReplicationBase {
* @param greaterThan size of replicationLoadSourceList must be greater before we proceed * @param greaterThan size of replicationLoadSourceList must be greater before we proceed
*/ */
private List<ReplicationLoadSource> waitOnMetricsReport(int greaterThan, ServerName serverName) private List<ReplicationLoadSource> waitOnMetricsReport(int greaterThan, ServerName serverName)
throws IOException { throws Exception {
ClusterMetrics metrics = hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)); UTIL1.waitFor(30000, 1000, new Waiter.ExplainingPredicate<Exception>() {
List<ReplicationLoadSource> list = @Override
metrics.getLiveServerMetrics().get(serverName).getReplicationLoadSourceList(); public boolean evaluate() throws Exception {
while (list.size() <= greaterThan) { List<ReplicationLoadSource> list =
Threads.sleep(1000); hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics()
} .get(serverName).getReplicationLoadSourceList();
return list; 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();
} }
} }