Skip to content

Include empty servers in BrokerServerView.#18200

Merged
gianm merged 9 commits intoapache:masterfrom
gianm:server-view-empties
Jul 6, 2025
Merged

Include empty servers in BrokerServerView.#18200
gianm merged 9 commits intoapache:masterfrom
gianm:server-view-empties

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Jul 3, 2025

Fixes #18199, because this makes empty Historicals visible through getDruidServerMetadatas. It also makes them visible through getDruidServers, causes them to show up in the sys.servers table.

Fixes apache#18199, because this makes empty Historicals visible through
getDruidServerMetadatas. It also makes them visible through getDruidServers,
causes them to show up in the sys.servers table.
@gianm gianm added this to the 34.0.0 milestone Jul 3, 2025
Copy link
Copy Markdown
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

LGTM, minor non-blocking nitpicks.

private void runServerCallbacks(final Function<ServerCallback, CallbackAction> fn)
{
for (final Map.Entry<ServerRemovedCallback, Executor> entry : serverRemovedCallbacks.entrySet()) {
for (final Map.Entry<ServerCallback, Executor> entry : serverCallbacks.entrySet()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Probably cleaner to use Map.forEach.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Personally, I prefer the regular for in situations where the forEach can't be a one-liner (& even sometimes then) so I kept it as-is.

@Override
public CallbackAction serverAdded(DruidServer server)
{
if (!server.getType().equals(ServerType.BROKER)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a 1-liner comment like "Do not keep inventory of other Brokers" or something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a comment We don't track brokers in this view.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

if (!server.getType().equals(ServerType.BROKER)) {
addServer(server);
}
return CallbackAction.CONTINUE;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we ever use the other callback action UNREGISTER?
I think it is not used anymore and can probably be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not used, & seems like it hasn't been used since #6742. I suppose we could remove it in this PR or in a new one.

public interface ServerView
{
void registerServerRemovedCallback(Executor exec, ServerRemovedCallback callback);
void registerServerCallback(Executor exec, ServerCallback callback);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Super nit:

To allow for more concise syntax (using lambdas) in the calling code, I wonder if we should have an overloaded method with the signature:

  void registerServerCallback(Executor exec, Consumer<DruidServer> onAdded, Consumer<DruidServer> onRemoved);

assuming we get rid of the CallbackAction altogether.

ServerCallback can then be a concrete class which takes two Consumer<DruidServer> in its constructor, default values for which would be no-op.

It might be useful even when we add new methods to ServerCallback as callers would need to override only the required methods.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A builder might be nice too. It would allow keeping together all the ServerCallback stuff in the interface. Something like:

ServerCallback.builder()
              .onServerAdded(server -> ...)
              .onServerRemoved(server -> ...)
              .build()

or for just doing one:

ServerCallback.onServerRemoved(server -> ...)

etc.

Would like to have this be a different PR, so that PR can focus on the thinking about the best way to specify callbacks that only want to listen to one thing.

@gianm gianm merged commit 17542d5 into apache:master Jul 6, 2025
140 of 142 checks passed
@gianm gianm deleted the server-view-empties branch July 6, 2025 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dart: Cannot use Historical with no segments as worker

2 participants