Skip to content

HBASE-29289: Make hbase master ui show cluster client connections info#8058

Open
hingu-8103 wants to merge 1 commit into
apache:masterfrom
hingu-8103:HBASE-29289
Open

HBASE-29289: Make hbase master ui show cluster client connections info#8058
hingu-8103 wants to merge 1 commit into
apache:masterfrom
hingu-8103:HBASE-29289

Conversation

@hingu-8103
Copy link
Copy Markdown
Contributor

Added ClientConnectionInfo object which tracks client connection info for each client connections and also added ClientConnectionRegistry to track all the active ClientConnectionInfo.

I have added basic tests to test the change and also manually tested on the cluster.


// Verify that the connection is unregistered
connections = registry.getClientConnections();
assertTrue(connections.size() <= initialSize);
Copy link
Copy Markdown
Contributor Author

@hingu-8103 hingu-8103 Apr 10, 2026

Choose a reason for hiding this comment

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

I believe this assertion might introduce flakiness in tests when there are new client connections happens during this test execution by some other test case which is running parallel.

How should i make test robust in this kind of scenarios ?

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.

I do not think other tests can connect to the rpc server started in this test?

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.

Thanks @Apache9 for the clarification. I have verified it won't introduce any flakiness.

@hingu-8103 hingu-8103 marked this pull request as ready for review April 11, 2026 10:12
@hingu-8103 hingu-8103 requested a review from Apache9 April 12, 2026 07:08
Copy link
Copy Markdown
Contributor

@wchevreuil wchevreuil left a comment

Choose a reason for hiding this comment

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

I think we should try to reuse the existing metrics subsystem for tracking and reporting these info. Please look at MetricsUserSourceImpl, MetricsUserAggregateImpl, LossyCounting, ClusterStatus.ClientMetrics. If we reuse the existing metric system, we don't need the extra tracking logic at related RPC layer classes and it may also make it easier to update the hbtop views.

Comment thread hbase-protocol-shaded/src/main/protobuf/server/ClusterStatus.proto
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.

Another reason to try integrate this into the already existing client metrics: MetricsUserAggregateImpl already provides its own maps and tracking mechanisms, which would dismiss the need for changes in the rpc layer.

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.

Thanks @wchevreuil for the comments, Let me go through the existing implementation and try to use that for this purpose.

Copy link
Copy Markdown
Contributor

@PDavid PDavid left a comment

Choose a reason for hiding this comment

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

Many thanks, looks nice already.

<td><%= clientConnection.getUserName() %></td>
<td><%= clientConnection.getClientVersion() %></td>
<td><%= clientConnection.getServiceName() %></td>
<td><%= serverName.getServerName() %></td>cc
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.

Here there's a stray cc after the closing tag that will render as visible text in the HTML.

Suggested change
<td><%= serverName.getServerName() %></td>cc
<td><%= serverName.getServerName() %></td>

Comment on lines +31 to +32
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.

These are unused imports. Can we remove them?

Optional<ServerRpcConnection> rpcConnectionOptional = RpcServer.getCurrentServerRpcConnection();
if (rpcConnectionOptional.isPresent()) {
ServerRpcConnection rpcConnection = rpcConnectionOptional.get();
hostAddress = rpcConnection.getLocalHostAddress();
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.

The field localHostAddress in ServerRpcConnection represents the server-side IP (the RS's own address), but it's surfaced in the UI under the column "ClientIP" (via getHostAddress()).

This is confusing, the value shown as "ClientIP" is actually the region server's local bind address, not the client's IP. Shouldn't we use hostAddress from ServerRpcConnection here instead?

Comment on lines +42 to +44
<td><%= clientConnection.getUserName() %></td>
<td><%= clientConnection.getClientVersion() %></td>
<td><%= clientConnection.getServiceName() %></td>
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.

Here we directly interpolate values from these client-controlled fields (userName, clientVersion, serviceName) using <%= ... %> without HTML escaping. Malicious or buggy clients could inject <script> tags. Other HBase JSPs use StringEscapeUtils.escapeHtml4() - the same should be applied here.

Comment on lines +210 to +213
optional string host_address = 5;
optional string user_name = 6;
optional string client_version = 7;
optional string service_name = 8;
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.

Other fields are all having comments. Would it make sense to add comments for these new fields as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants