Skip to content

HDFS-17684. Add LocalBytesRead and LocalBytesWritten metrics to DataNode.#8317

Open
balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity:HDFS-17684
Open

HDFS-17684. Add LocalBytesRead and LocalBytesWritten metrics to DataNode.#8317
balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity:HDFS-17684

Conversation

@balodesecurity
Copy link

Summary

DataNodeMetrics already tracks WritesFromLocalClient / WritesFromRemoteClient (count only) and RemoteBytesRead / RemoteBytesWritten (bytes), but there is no byte-level metric for local client reads/writes.

This patch adds two new MutableCounterLong metrics:

Metric Description
LocalBytesRead Bytes read by local (same-host) clients
LocalBytesWritten Bytes written by local (same-host) clients

These are incremented in incrReadsFromClient(boolean local, long size) and incrWritesFromClient(boolean local, long size) alongside the existing remote-bytes counters, so no call-site changes are required.

Changes

  • DataNodeMetrics.java — added localBytesRead / localBytesWritten fields and updated incrReadsFromClient / incrWritesFromClient to increment them
  • TestDataNodeMetrics.java — added testLocalBytesMetrics which spins up a MiniDFSCluster, writes then reads a file from the local client, and asserts both new counters are positive while the remote-bytes counters remain zero

Testing

Test class Test method Result Duration
TestDataNodeMetrics testLocalBytesMetrics PASSED 2.391 s

…ode.

Track per-client-locality byte counts separately so operators can
distinguish local vs remote traffic volume in DataNode metrics dashboards.
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.

2 participants