deniskuzZ commented on code in PR #3645:
URL: https://github.com/apache/hive/pull/3645#discussion_r991915282


##########
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));

Review Comment:
   shouldn't it be vice versa? when INITIATED_RESPONSE ->  
oldestEnqueueTimePerPool, when WORKING_RESPONSE -> oldestWorkingTimePerPool



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to