You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/10/11 07:32:13 UTC
[GitHub] [hive] veghlaci05 commented on a diff in pull request #3645: HIVE-26471: Addendum: Fix metric computing
veghlaci05 commented on code in PR #3645:
URL: https://github.com/apache/hive/pull/3645#discussion_r991914034
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/CompactionMetricData.java:
##########
@@ -67,34 +70,53 @@ static CompactionMetricData of(List<ShowCompactResponseElement> compacts) {
private void init() {
final Map<String, ShowCompactResponseElement> lastElements = new HashMap<>();
- poolCount = new HashMap<>();
+ initiatedPoolCount = new HashMap<>();
+ workingPoolCount = new HashMap<>();
+ oldestEnqueueTimePerPool = new HashMap<>();
+ oldestWorkingTimePerPool = new HashMap<>();
oldestEnqueueTime = OLDEST_TIME_NO_VALUE;
oldestWorkingTime = OLDEST_TIME_NO_VALUE;
oldestCleaningTime = OLDEST_TIME_NO_VALUE;
+
+ long currentTime = System.currentTimeMillis();
for (ShowCompactResponseElement element : compacts) {
final String key = element.getDbname() + "/" + element.getTablename() +
(element.getPartitionname() != null ? "/" + element.getPartitionname() : "");
// If new key, add the element, if there is an existing one, change to the element if the element.id is greater than old.id
lastElements.compute(key, (k, old) -> (old == null) ? element : (element.getId() > old.getId() ? element : old));
- // find the oldest elements with initiated and working states
String state = element.getState();
- if (TxnStore.INITIATED_RESPONSE.equals(state) && (oldestEnqueueTime > element.getEnqueueTime())) {
- oldestEnqueueTime = element.getEnqueueTime();
- poolCount.compute(element.getPoolName(), (k, old) -> (old == null) ? 1 : old + 1);
+ if (TxnStore.INITIATED_RESPONSE.equals(state)) {
+ final int enqueueSeconds = (int) ((currentTime - element.getEnqueueTime()) / 1000);
+ oldestWorkingTimePerPool.compute(element.getPoolName(), (k, old) -> (old == null) ? enqueueSeconds : Math.max(enqueueSeconds, old));
+
+ initiatedPoolCount.compute(element.getPoolName(), (k, old) -> (old == null) ? 1 : old + 1);
+ // find the oldest element
+ if (oldestEnqueueTime > element.getEnqueueTime()) {
+ oldestEnqueueTime = element.getEnqueueTime();
+ }
}
if (element.isSetStart()) {
- if (TxnStore.WORKING_RESPONSE.equals(state) && (oldestWorkingTime > element.getStart())) {
- oldestWorkingTime = element.getStart();
+ if (TxnStore.WORKING_RESPONSE.equals(state)) {
+ final int startSeconds = (int) ((currentTime - element.getStart()) / 1000);
+ oldestEnqueueTimePerPool.compute(element.getPoolName(), (k, old) -> (old == null) ? startSeconds : Math.max(startSeconds, old));
+
+ workingPoolCount.compute(element.getPoolName(), (k, old) -> (old == null) ? 1 : old + 1);
+ // find the oldest element
+ if (oldestWorkingTime > element.getStart()) {
+ oldestWorkingTime = element.getStart();
+ }
}
}
if (element.isSetCleanerStart()) {
- if (TxnStore.CLEANING_RESPONSE.equals(state) && (oldestCleaningTime > element.getCleanerStart())) {
- oldestCleaningTime = element.getCleanerStart();
+ if (TxnStore.CLEANING_RESPONSE.equals(state)) {
Review Comment:
Just to have the same structure as above. I can revert it if you prefer
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org