sumitagrawl commented on code in PR #7377: URL: https://github.com/apache/ozone/pull/7377#discussion_r1888637836
########## hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/DeletingServiceMetrics.java: ########## @@ -0,0 +1,336 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.ozone.om; + +import org.apache.hadoop.metrics2.annotation.Metric; +import org.apache.hadoop.metrics2.annotation.Metrics; +import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; +import org.apache.hadoop.metrics2.lib.MetricsRegistry; +import org.apache.hadoop.metrics2.lib.MutableGaugeLong; +import org.apache.hadoop.ozone.OzoneConsts; + +/** + * Class contains metrics related to the OM Deletion services. + */ +@Metrics(about = "Deletion Service Metrics", context = OzoneConsts.OZONE) +public final class DeletingServiceMetrics { + + public static final String METRICS_SOURCE_NAME = + DeletingServiceMetrics.class.getSimpleName(); + private MetricsRegistry registry; + + private DeletingServiceMetrics() { + this.registry = new MetricsRegistry(METRICS_SOURCE_NAME); + } + + /** + * Creates and returns DeletingServiceMetrics instance. + * + * @return DeletingServiceMetrics + */ + public static DeletingServiceMetrics create() { + return DefaultMetricsSystem.instance().register(METRICS_SOURCE_NAME, + "Metrics tracking the progress of deletion of directories and keys in the OM", + new DeletingServiceMetrics()); + } + /** + * Unregister the metrics instance. + */ + public static void unregister() { + DefaultMetricsSystem.instance().unregisterSource(METRICS_SOURCE_NAME); + } + + + /* + * Total directory deletion metrics across all iterations of DirectoryDeletingService since last restart. + */ + @Metric("Total no. of deleted directories sent for purge") + private MutableGaugeLong numDirsSentForPurge; + @Metric("Total no. of sub-directories sent for purge") + private MutableGaugeLong numSubDirsSentForPurge; + @Metric("Total no. of sub-files sent for purge") + private MutableGaugeLong numSubFilesSentForPurge; + + public void incrNumDirDeleted(long dirDel) { + numDirsSentForPurge.incr(dirDel); + } + + public void incrNumDirsMoved(long dirMove) { + numSubDirsSentForPurge.incr(dirMove); + } + + public void incrNumFilesMoved(long filesMove) { + numSubFilesSentForPurge.incr(filesMove); + } + + public void incrementDirectoryDeletionTotalMetrics(long dirDel, long dirMove, long filesMove) { + incrNumDirDeleted(dirDel); + incrNumDirsMoved(dirMove); + incrNumFilesMoved(filesMove); + } + + /* + * Directory deletion metrics in the latest iteration of DirectoryDeletingService. + */ + @Metric("Iteration run count of DirectoryDeletingService") + private MutableGaugeLong iterationDirRunCount; + @Metric("Iteration start time of DirectoryDeletingService") + private MutableGaugeLong iterationDirStartTime; + @Metric("Total time taken by the last iteration of DirectoryDeletingService") + private MutableGaugeLong iterationDirDuration; + @Metric("No. of directories deleted in last iteration") + private MutableGaugeLong iterationDirsDeleted; + @Metric("No. of sub-directories deleted in last iteration") + private MutableGaugeLong iterationSubDirsDeleted; + @Metric("No. of sub-directories sent for purge in last iteration") + private MutableGaugeLong iterationSubDirsSentForPurge; + @Metric("No. of files sent for purge in last iteration") + private MutableGaugeLong iterationFilesSentForPurge; + + public void setIterationDirRunCount(long runcount) { + iterationDirRunCount.set(runcount); + } + + public void setIterationDirStartTime(long startTime) { + iterationDirStartTime.set(startTime); + } + + public void setIterationDirDuration(long duration) { + iterationDirDuration.set(duration); + } + + public void setIterationDirDeleted(long dirDel) { + iterationDirsDeleted.set(dirDel); + } + + public void setIterationSubDirDeleted(long subdirDel) { + iterationSubDirsDeleted.set(subdirDel); + } + + public void setIterationFilesSentForPurge(long filesMove) { + iterationFilesSentForPurge.set(filesMove); + } + + public void setIterationSubDirsSentForPurge(long subdirMove) { + iterationSubDirsSentForPurge.set(subdirMove); + } + + public void setDirectoryDeletionIterationMetrics(long runcount, long startTime, long duration, + long dirDel, long subdirDel, + long filesMove, long subdirMove) { + setIterationDirRunCount(runcount); Review Comment: @errose28 I am not getting what we are going to achieve with runCount as metrics. If there are 10 threads running, it will be increase by 10 times as default. We can use `duration` as metrics for performance, but not the startTime. This will give better metrics. So startTime may not be useful, this can be easily identified as Timer task. For task running, based on delete count increase, and other data can show the progress. So Above metric is not useful. -- 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]
