4747import org .apache .hadoop .ozone .om .KeyManager ;
4848import org .apache .hadoop .ozone .om .OMConfigKeys ;
4949import org .apache .hadoop .ozone .om .OMMetadataManager ;
50+ import org .apache .hadoop .ozone .om .OMPerformanceMetrics ;
5051import org .apache .hadoop .ozone .om .OzoneManager ;
5152import org .apache .hadoop .ozone .om .helpers .OmBucketInfo ;
5253import org .apache .hadoop .ozone .om .helpers .OmKeyInfo ;
@@ -73,6 +74,7 @@ public abstract class AbstractKeyDeletingService extends BackgroundService
7374
7475 private final OzoneManager ozoneManager ;
7576 private final DeletingServiceMetrics metrics ;
77+ private final OMPerformanceMetrics perfMetrics ;
7678 private final ScmBlockLocationProtocol scmClient ;
7779 private final ClientId clientId = ClientId .randomId ();
7880 private final AtomicLong deletedDirsCount ;
@@ -94,6 +96,7 @@ public AbstractKeyDeletingService(String serviceName, long interval,
9496 this .movedFilesCount = new AtomicLong (0 );
9597 this .runCount = new AtomicLong (0 );
9698 this .metrics = ozoneManager .getDeletionMetrics ();
99+ this .perfMetrics = ozoneManager .getPerfMetrics ();
97100 }
98101
99102 protected int processKeyDeletes (List <BlockGroup > keyBlocksList ,
@@ -119,14 +122,15 @@ protected int processKeyDeletes(List<BlockGroup> keyBlocksList,
119122 LOG .info ("{} BlockGroup deletion are acked by SCM in {} ms" ,
120123 keyBlocksList .size (), Time .monotonicNow () - startTime );
121124 if (blockDeletionResults != null ) {
122- startTime = Time .monotonicNow ();
125+ long purgeStartTime = Time .monotonicNow ();
123126 delCount = submitPurgeKeysRequest (blockDeletionResults ,
124127 keysToModify , snapTableKey , expectedPreviousSnapshotId );
125128 int limit = ozoneManager .getConfiguration ().getInt (OMConfigKeys .OZONE_KEY_DELETING_LIMIT_PER_TASK ,
126129 OMConfigKeys .OZONE_KEY_DELETING_LIMIT_PER_TASK_DEFAULT );
127130 LOG .info ("Blocks for {} (out of {}) keys are deleted from DB in {} ms. Limit per task is {}." ,
128- delCount , blockDeletionResults .size (), Time .monotonicNow () - startTime , limit );
131+ delCount , blockDeletionResults .size (), Time .monotonicNow () - purgeStartTime , limit );
129132 }
133+ perfMetrics .setKeyDeletingServiceLatencyMs (Time .monotonicNow () - startTime );
130134 return delCount ;
131135 }
132136
@@ -416,6 +420,7 @@ public void optimizeDirDeletesAndSubmitRequest(
416420 dirNum , subdirDelNum , subFileNum , (subDirNum - subdirDelNum ),
417421 timeTakenInIteration , rnCnt );
418422 metrics .incrementDirectoryDeletionTotalMetrics (dirNum + subdirDelNum , subDirNum , subFileNum );
423+ perfMetrics .setDirectoryDeletingServiceLatencyMs (timeTakenInIteration );
419424 }
420425 }
421426
0 commit comments