[
https://issues.apache.org/jira/browse/YARN-11250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17581326#comment-17581326
]
ASF GitHub Bot commented on YARN-11250:
---------------------------------------
slfan1989 commented on code in PR #4738:
URL: https://github.com/apache/hadoop/pull/4738#discussion_r949069282
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZKFederationStateStoreOpDurations.java:
##########
@@ -0,0 +1,155 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.yarn.server.federation.store.impl;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.metrics2.MetricsCollector;
+import org.apache.hadoop.metrics2.MetricsInfo;
+import org.apache.hadoop.metrics2.MetricsSource;
+import org.apache.hadoop.metrics2.MetricsSystem;
+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.MutableRate;
+
+import static org.apache.hadoop.metrics2.lib.Interns.info;
+
[email protected]
[email protected]
+@Metrics(context="ZKFederationStateStore-op-durations")
+public final class ZKFederationStateStoreOpDurations implements MetricsSource {
+
+ @Metric("Duration for a add application homeSubcluster call")
+ private MutableRate addAppHomeSubCluster;
+
+ @Metric("Duration for a update application homeSubcluster call")
+ private MutableRate updateAppHomeSubCluster;
+
+ @Metric("Duration for a get application homeSubcluster call")
+ private MutableRate getAppHomeSubCluster;
+
+ @Metric("Duration for a get applications homeSubcluster call")
+ private MutableRate getAppsHomeSubCluster;
+
+ @Metric("Duration for a delete applications homeSubcluster call")
+ private MutableRate deleteAppHomeSubCluster;
+
+ @Metric("Duration for a register subCluster call")
+ private MutableRate registerSubCluster;
+
+ @Metric("Duration for a deregister subCluster call")
+ private MutableRate deregisterSubCluster;
+
+ @Metric("Duration for a subCluster Heartbeat call")
+ private MutableRate subClusterHeartbeat;
+
+ @Metric("Duration for a get SubCluster call")
+ private MutableRate getSubCluster;
+
+ @Metric("Duration for a get SubClusters call")
+ private MutableRate getSubClusters;
+
+ @Metric("Duration for a get PolicyConfiguration call")
+ private MutableRate getPolicyConfiguration;
+
+ @Metric("Duration for a set PolicyConfiguration call")
+ private MutableRate setPolicyConfiguration;
+
+ @Metric("Duration for a get PolicyConfigurations call")
+ private MutableRate getPoliciesConfigurations;
+
+ protected static final MetricsInfo RECORD_INFO =
+ info("ZKFederationStateStoreOpDurations", "Durations of
ZKFederationStateStore calls");
+
+ private final MetricsRegistry registry;
+
+ private static final ZKFederationStateStoreOpDurations INSTANCE =
+ new ZKFederationStateStoreOpDurations();
+
+ public static ZKFederationStateStoreOpDurations getInstance() {
+ return INSTANCE;
+ }
+
+ private ZKFederationStateStoreOpDurations() {
+ registry = new MetricsRegistry(RECORD_INFO);
+ registry.tag(RECORD_INFO, "ZKFederationStateStoreOpDurations");
+
+ MetricsSystem ms = DefaultMetricsSystem.instance();
+ if (ms != null) {
+ ms.register(RECORD_INFO.name(), RECORD_INFO.description(), this);
+ }
+ }
+
+ @Override
+ public synchronized void getMetrics(MetricsCollector collector, boolean all)
{
+ registry.snapshot(collector.addRecord(registry.info()), all);
+ }
+
+ public void addAppHomeSubClusterDuration(long endTime, long startTime) {
+ addAppHomeSubCluster.add(endTime - startTime);
+ }
+
+ public void addUpdateAppHomeSubClusterDuration(long endTime, long startTime)
{
+ updateAppHomeSubCluster.add(endTime - startTime);
+ }
+
+ public void addGetAppHomeSubClusterDuration(long endTime, long startTime) {
+ getAppHomeSubCluster.add(endTime - startTime);
+ }
+
+ public void addGetAppsHomeSubClusterDuration(long endTime, long startTime) {
+ getAppsHomeSubCluster.add(endTime - startTime);
+ }
+
+ public void addDeleteAppHomeSubClusterDuration(long endTime, long startTime)
{
+ deleteAppHomeSubCluster.add(endTime - startTime);
+ }
+
+ public void addRegisterSubClusterDuration(long endTime, long startTime) {
+ registerSubCluster.add(endTime - startTime);
+ }
+
+ public void addDeregisterSubClusterDuration(long endTime, long startTime) {
Review Comment:
Thanks for your suggestion, I will modify the code.
> Capture the Performance Metrics of ZookeeperFederationStateStore
> ----------------------------------------------------------------
>
> Key: YARN-11250
> URL: https://issues.apache.org/jira/browse/YARN-11250
> Project: Hadoop YARN
> Issue Type: Improvement
> Components: federation
> Affects Versions: 3.4.0, 3.3.4
> Reporter: fanshilun
> Assignee: fanshilun
> Priority: Major
> Labels: pull-request-available
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]