klcopp commented on a change in pull request #2916:
URL: https://github.com/apache/hive/pull/2916#discussion_r787032118



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/metrics/DeltaFilesMetricReporter.java
##########
@@ -512,7 +284,177 @@ private void shutdown() {
     }
   }
 
-  public static class DeltaFilesMetadata implements Serializable {
-    public String dbName, tableName, partitionName;
+  public static void updateMetricsFromInitiator(AcidDirectory dir, String 
dbName, String tableName, String partitionName,
+      Configuration conf, TxnStore txnHandler) {
+    LOG.debug("Updating delta file metrics from initiator");
+    double deltaPctThreshold = MetastoreConf.getDoubleVar(conf, 
MetastoreConf.ConfVars.METASTORE_DELTAMETRICS_DELTA_PCT_THRESHOLD);
+    int deltasThreshold = MetastoreConf.getIntVar(conf, 
MetastoreConf.ConfVars.METASTORE_DELTAMETRICS_DELTA_NUM_THRESHOLD);
+    int obsoleteDeltasThreshold = MetastoreConf.getIntVar(conf,
+        
MetastoreConf.ConfVars.METASTORE_DELTAMETRICS_OBSOLETE_DELTA_NUM_THRESHOLD);
+    try {
+      // We have an AcidDir from the initiator, therefore we can use that to 
calculate active,small, obsolete delta
+      // count
+      long baseSize = getBaseSize(dir);
+
+      int numDeltas = dir.getCurrentDirectories().size();
+      int numSmallDeltas = 0;
+
+      for (AcidUtils.ParsedDelta delta : dir.getCurrentDirectories()) {
+        long deltaSize = getDirSize(delta, dir.getFs());
+        if (baseSize != 0 && deltaSize / (float) baseSize < deltaPctThreshold) 
{
+          numSmallDeltas++;
+        }
+      }
+
+      int numObsoleteDeltas = dir.getObsolete().size();

Review comment:
       I'm seriously wondering if we should.
   Cons:
   - the metric name is "obsolete deltas" would == obsolete + aborted deltas
   - We already have metrics about the amount of aborts in the system (gotten 
from metadata)
   
   Pros:
   - The Cleaner's job is to remove aborted directories as well ; so including 
metrics about aborted directories would help with observability of Cleaner 
health
   - Aborted directories can clog up the file system just as much as obsolete 
directories




-- 
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