-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-22975 Add read and write QPS metrics at server level and table level #615
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
Conversation
|
💔 -1 overall
This message was automatically generated. |
6356d5f to
f584db1
Compare
|
🎊 +1 overall
This message was automatically generated. |
| */ | ||
| @InterfaceAudience.Private | ||
| public interface MetricsTableLatencies { | ||
| public interface MetricsTableLatencies extends BaseSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MetricsTableLatencies extends BaseSourceImpl which implements BaseSource.
Can't see the reason why MetricsTableLatencies extends this interface, again.
| * Query Per Second for a specific table in a RegionServer. | ||
| */ | ||
| @InterfaceAudience.Private | ||
| public interface MetricsTableQueryPerSecond { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming, MetricsTableQueryMeter sounds more succinct
| import org.apache.yetus.audience.InterfaceAudience; | ||
|
|
||
| /** | ||
| * Query Per Second for a specific table in a RegionServer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a specific table? which one? But it looks like target all tables in a RS?
| } | ||
|
|
||
| private static class TableMeters { | ||
| final Meter tableReadQueryPerSecondMeter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming, tableReadQueryMeter. There're few places in this class.
| public void updateTableReadQueryPerSecond(long count) { | ||
| tableReadQueryPerSecondMeter.mark(count); | ||
| } | ||
| public void updateTableReadQueryPerSecond() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, a new empty line between methods.
| */ | ||
| @InterfaceAudience.Private | ||
| public class MetricsTableQueryPerSecondImpl implements MetricsTableQueryPerSecond { | ||
| private final HashMap<TableName,TableMeters> metersByTable = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it hashmap enough? Are there concurrent accesses?
| if (!initialized) { | ||
| this.writeRequestsCount.add(batchOp.size()); | ||
| if (rsServices != null && rsServices.getMetrics() != null) { | ||
| rsServices.getMetrics().updateServerWriteQueryPerSecond(this.htableDescriptor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about increServerWriteQuery?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incre is usually used for simple numerical increments, but Meter is a complex data structure. What about updateWriteQueryMeter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, i see.
| this.writeRequestsCount.increment(); | ||
|
|
||
| if (rsServices != null && rsServices.getMetrics() != null) { | ||
| rsServices.getMetrics().updateServerWriteQueryPerSecond(this.htableDescriptor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
| private MetricRegistry metricRegistry; | ||
| private Timer bulkLoadTimer; | ||
| private Meter serverReadQueryPerSecond; | ||
| private Meter serverWriteQueryPerSecond; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about serverReadQueryMeter and serverWriteQueryMeter.
Reidddddd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left few comments.
f584db1 to
bf0d9be
Compare
|
💔 -1 overall
This message was automatically generated. |
|
|
||
| /** | ||
| * Implementation of {@link MetricsTableQueryMeter} to track query per second for one table in | ||
| * a RegionServer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc is wrong? Not for one table?
| public class RegionServerTableMetrics { | ||
|
|
||
| private final MetricsTableLatencies latencies; | ||
| private MetricsTableQueryMeter queryMeter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be final?
| } | ||
|
|
||
| private TableMeters getOrCreateTableMeter(String tableName) { | ||
| final TableName tn = TableName.valueOf(tableName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The upper layer passes down a TableName, but it is converted to String, here then it is converted back to TableName.
|
|
||
| private TableMeters getOrCreateTableMeter(String tableName) { | ||
| final TableName tn = TableName.valueOf(tableName); | ||
| return metersByTable.computeIfAbsent(tn, k -> new TableMeters(metricRegistry, tn)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lambda is confusing. Parameter k is never used. It should be k -> new TableMeters(metricRegistry, k)?
| } | ||
| if (rsServices != null && rsServices.getMetrics() != null) { | ||
| rsServices.getMetrics().updateReadQueryMeter(getRegionInfo().getTable()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the place right? The readRequestsCount is after outResults fetched.
| if (rsServices != null && rsServices.getMetrics() != null) { | ||
| rsServices.getMetrics().updateWriteQueryMeter(this.htableDescriptor. | ||
| getTableName()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The write meter update should place after write execution, it is different from writeRequestsCount because execution time matters.
Reidddddd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good overall, but it needs some polish.
bf0d9be to
ab8b784
Compare
|
💔 -1 overall
This message was automatically generated. |
| */ | ||
| @InterfaceAudience.Private | ||
| public class MetricsTableQueryMeterImpl implements MetricsTableQueryMeter { | ||
| private final Map<TableName,TableMeters> metersByTable = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, space between TableName,TableMeters
| boolean isSuccessful = false; | ||
| try { | ||
| this.writeRequestsCount.increment(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid unnecessary change.
|
|
||
| closeBulkRegionOperation(); | ||
| } | ||
| return isSuccessful ? storeFiles : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
|
💔 -1 overall
This message was automatically generated. |
ab3c998 to
f26adfb
Compare
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
Reidddddd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
HBASE-22975