Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][broker] fix broker may lost rack information #23331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -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);
Comment on lines +189 to +190
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to add a comment why all watchers are triggered when a new listener is added.

}

@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);
Comment on lines +206 to +207
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to add a comment why all watchers are triggered when a new listener is added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

@Override
Expand Down
Loading