Skip to content

Commit

Permalink
[fix][broker] fix broker may lost rack information (#23331)
Browse files Browse the repository at this point in the history
Co-authored-by: fanjianye <fanjianye@bigo.sg>
  • Loading branch information
TakaHiR07 and fanjianye authored Feb 14, 2025
1 parent 5812084 commit 1d53d36
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,13 @@ private CompletableFuture<Versioned<Set<BookieId>>> getBookiesThenFreshCache(Str
@Override
public CompletableFuture<Void> watchWritableBookies(RegistrationListener registrationListener) {
writableBookiesWatchers.add(registrationListener);
// trigger all listeners in writableBookiesWatchers one by one. It aims to keep a sync way
// to make sure the previous listener has finished when a new listener is register.
// Though it would bring duplicate trigger listener problem, but since watchWritableBookies
// is only executed when bookieClient construct, the duplicate problem is acceptable.
return getWritableBookies()
.thenAcceptAsync(registrationListener::onBookiesChanged, executor);
.thenAcceptAsync(bookies ->
writableBookiesWatchers.forEach(w -> w.onBookiesChanged(bookies)), executor);
}

@Override
Expand All @@ -193,8 +198,13 @@ public void unwatchWritableBookies(RegistrationListener registrationListener) {
@Override
public CompletableFuture<Void> watchReadOnlyBookies(RegistrationListener registrationListener) {
readOnlyBookiesWatchers.add(registrationListener);
// trigger all listeners in readOnlyBookiesWatchers one by one. It aims to keep a sync way
// to make sure the previous listener has finished when a new listener is register.
// Though it would bring duplicate trigger listener problem, but since watchReadOnlyBookies
// is only executed when bookieClient construct, the duplicate problem is acceptable.
return getReadOnlyBookies()
.thenAcceptAsync(registrationListener::onBookiesChanged, executor);
.thenAcceptAsync(bookies ->
readOnlyBookiesWatchers.forEach(w -> w.onBookiesChanged(bookies)), executor);
}

@Override
Expand Down

0 comments on commit 1d53d36

Please sign in to comment.