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

Add hdfs stats for local and remote rack bytes read #92

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
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 @@ -523,6 +523,12 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
String ZEROCOPY_BYTES_READ = "zeroCopyBytesRead";
String ZEROCOPY_BYTES_READ_DESC = "The number of bytes read through HDFS zero copy";

String LOCAL_RACK_BYTES_READ = "localRackBytesRead";
String LOCAL_RACK_BYTES_READ_DESC = "The number of bytes read from the same rack of the RegionServer, but not the local HDFS DataNode";

String REMOTE_RACK_BYTES_READ = "remoteRackBytesRead";
String REMOTE_RACK_BYTES_READ_DESC = "The number of bytes read from a different rack from that of the RegionServer";

String BLOCKED_REQUESTS_COUNT = "blockedRequestCount";
String BLOCKED_REQUESTS_COUNT_DESC = "The number of blocked requests because of memstore size is "
+ "larger than blockingMemStoreSize";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ public interface MetricsRegionServerWrapper {
/** Returns Number of bytes read from the local HDFS DataNode. */
long getLocalBytesRead();

long getLocalRackBytesRead();

long getRemoteRackBytesRead();

/** Returns Number of bytes read locally through HDFS short circuit. */
long getShortCircuitBytesRead();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ private MetricsRecordBuilder addGaugesToMetricsRecordBuilder(MetricsRecordBuilde
PERCENT_FILES_LOCAL_SECONDARY_REGIONS_DESC), rsWrap.getPercentFileLocalSecondaryRegions())
.addGauge(Interns.info(TOTAL_BYTES_READ, TOTAL_BYTES_READ_DESC), rsWrap.getTotalBytesRead())
.addGauge(Interns.info(LOCAL_BYTES_READ, LOCAL_BYTES_READ_DESC), rsWrap.getLocalBytesRead())
.addGauge(Interns.info(LOCAL_RACK_BYTES_READ, LOCAL_RACK_BYTES_READ_DESC), rsWrap.getLocalRackBytesRead())
.addGauge(Interns.info(REMOTE_RACK_BYTES_READ, REMOTE_RACK_BYTES_READ_DESC), rsWrap.getRemoteRackBytesRead())
.addGauge(Interns.info(SHORTCIRCUIT_BYTES_READ, SHORTCIRCUIT_BYTES_READ_DESC),
rsWrap.getShortCircuitBytesRead())
.addGauge(Interns.info(ZEROCOPY_BYTES_READ, ZEROCOPY_BYTES_READ_DESC),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.fs.GlobalStorageStatistics;
import org.apache.hadoop.fs.StorageStatistics;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
Expand Down Expand Up @@ -1037,6 +1039,29 @@ public long getLocalBytesRead() {
return FSDataInputStreamWrapper.getLocalBytesRead();
}

@Override
public long getLocalRackBytesRead() {
return getGlobalStorageStatistic("bytesReadDistanceOfOneOrTwo");
}

@Override
public long getRemoteRackBytesRead() {
return getGlobalStorageStatistic("bytesReadDistanceOfThreeOrFour")
+ getGlobalStorageStatistic("bytesReadDistanceOfFiveOrLarger");
}

private static long getGlobalStorageStatistic(String name) {
StorageStatistics stats = GlobalStorageStatistics.INSTANCE.get("hdfs");
if (stats == null) {
return 0;
}
Long val = stats.getLong(name);
if (val == null) {
return 0;
}
return val;
}

@Override
public long getShortCircuitBytesRead() {
return FSDataInputStreamWrapper.getShortCircuitBytesRead();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,16 @@ public long getLocalBytesRead() {
return 0;
}

@Override
public long getLocalRackBytesRead() {
return 0;
}

@Override
public long getRemoteRackBytesRead() {
return 0;
}

@Override
public long getShortCircuitBytesRead() {
return 0;
Expand Down