Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,21 @@ public void waitUntilPartitionsDropped(TablePath tablePath, List<String> dropped
"Fail to wait partitions dropped");
}

/** Wait until the assigned replica is ready as the local leader and return its server id. */
public int waitAndGetLeader(TableBucket tb) {
return waitLeaderAndIsrReady(tb).leader();
ZooKeeperClient zkClient = getZooKeeperClient();
return waitValue(
() -> {
Optional<LeaderAndIsr> leaderAndIsrOpt = zkClient.getLeaderAndIsr(tb);
if (!leaderAndIsrOpt.isPresent()) {
return Optional.empty();
}

int leader = leaderAndIsrOpt.get().leader();
return getReplica(tb, leader, true).map(ignored -> leader);
},
Duration.ofMinutes(1),
"Fail to wait leader replica ready for " + tb);
}

public int waitAndGetStandby(TableBucket tb) {
Expand Down
Loading