Skip to content

Commit 70c03a3

Browse files
author
slfan1989
committed
YARN-11250. Capture the Performance Metrics of ZookeeperFederationStateStore.
1 parent 8c9533a commit 70c03a3

File tree

3 files changed

+238
-12
lines changed

3 files changed

+238
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* <p>
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
* <p>
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
package org.apache.hadoop.yarn.server.federation.store.impl;
18+
19+
import org.apache.hadoop.classification.InterfaceAudience;
20+
import org.apache.hadoop.classification.InterfaceStability;
21+
import org.apache.hadoop.metrics2.MetricsCollector;
22+
import org.apache.hadoop.metrics2.MetricsInfo;
23+
import org.apache.hadoop.metrics2.MetricsSource;
24+
import org.apache.hadoop.metrics2.MetricsSystem;
25+
import org.apache.hadoop.metrics2.annotation.Metric;
26+
import org.apache.hadoop.metrics2.annotation.Metrics;
27+
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
28+
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
29+
import org.apache.hadoop.metrics2.lib.MutableRate;
30+
31+
import static org.apache.hadoop.metrics2.lib.Interns.info;
32+
33+
@InterfaceAudience.Private
34+
@InterfaceStability.Unstable
35+
@Metrics(context="ZKFederationStateStore-op-durations")
36+
public final class ZKFederationStateStoreOpDurations implements MetricsSource {
37+
38+
@Metric("Duration for a add application homeSubcluster call")
39+
private MutableRate addAppHomeSubClusterCall;
40+
41+
@Metric("Duration for a update application homeSubcluster call")
42+
private MutableRate updateAppHomeSubClusterCall;
43+
44+
@Metric("Duration for a get application homeSubcluster call")
45+
private MutableRate getAppHomeSubClusterCall;
46+
47+
@Metric("Duration for a get applications homeSubcluster call")
48+
private MutableRate getAppsHomeSubClusterCall;
49+
50+
@Metric("Duration for a delete applications homeSubcluster call")
51+
private MutableRate deleteAppHomeSubClusterCall;
52+
53+
@Metric("Duration for a register subCluster call")
54+
private MutableRate registerSubClusterCall;
55+
56+
@Metric("Duration for a deregister subCluster call")
57+
private MutableRate deregisterSubCluster;
58+
59+
@Metric("Duration for a subCluster Heartbeat call")
60+
private MutableRate subClusterHeartbeat;
61+
62+
@Metric("Duration for a get SubCluster call")
63+
private MutableRate getSubCluster;
64+
65+
@Metric("Duration for a get SubClusters call")
66+
private MutableRate getSubClusters;
67+
68+
@Metric("Duration for a get PolicyConfiguration call")
69+
private MutableRate getPolicyConfiguration;
70+
71+
@Metric("Duration for a set PolicyConfiguration call")
72+
private MutableRate setPolicyConfiguration;
73+
74+
@Metric("Duration for a get PolicyConfigurations call")
75+
private MutableRate getPoliciesConfigurations;
76+
77+
protected static final MetricsInfo RECORD_INFO =
78+
info("ZKFederationStateStoreOpDurations", "Durations of ZKFederationStateStore calls");
79+
80+
private final MetricsRegistry registry;
81+
82+
private static final ZKFederationStateStoreOpDurations INSTANCE =
83+
new ZKFederationStateStoreOpDurations();
84+
85+
public static ZKFederationStateStoreOpDurations getInstance() {
86+
return INSTANCE;
87+
}
88+
89+
private ZKFederationStateStoreOpDurations() {
90+
registry = new MetricsRegistry(RECORD_INFO);
91+
registry.tag(RECORD_INFO, "ZKFederationStateStoreOpDurations");
92+
93+
MetricsSystem ms = DefaultMetricsSystem.instance();
94+
if (ms != null) {
95+
ms.register(RECORD_INFO.name(), RECORD_INFO.description(), this);
96+
}
97+
}
98+
99+
@Override
100+
public synchronized void getMetrics(MetricsCollector collector, boolean all) {
101+
registry.snapshot(collector.addRecord(registry.info()), all);
102+
}
103+
104+
public void addAppHomeSubClusterCallDuration(long value) {
105+
addAppHomeSubClusterCall.add(value);
106+
}
107+
108+
public void addUpdateAppHomeSubClusterCallDuration(long value) {
109+
updateAppHomeSubClusterCall.add(value);
110+
}
111+
112+
public void addGetAppHomeSubClusterCallDuration(long value) {
113+
getAppHomeSubClusterCall.add(value);
114+
}
115+
116+
public void addGetAppsHomeSubClusterCallDuration(long value) {
117+
getAppsHomeSubClusterCall.add(value);
118+
}
119+
120+
public void addDeleteAppHomeSubClusterCallDuration(long value) {
121+
deleteAppHomeSubClusterCall.add(value);
122+
}
123+
124+
public void addRegisterSubClusterCallDuration(long value) {
125+
registerSubClusterCall.add(value);
126+
}
127+
128+
public void addDeregisterSubClusterCallDuration(long value) {
129+
deregisterSubCluster.add(value);
130+
}
131+
132+
public void addSubClusterHeartbeatCallDuration(long value) {
133+
subClusterHeartbeat.add(value);
134+
}
135+
136+
public void addGetSubClusterCallDuration(long value) {
137+
getSubCluster.add(value);
138+
}
139+
140+
public void addGetSubClustersCallDuration(long value) {
141+
getSubClusters.add(value);
142+
}
143+
144+
public void addGetPolicyConfigurationDuration(long value) {
145+
getPolicyConfiguration.add(value);
146+
}
147+
148+
public void addSetPolicyConfigurationDuration(long value) {
149+
setPolicyConfiguration.add(value);
150+
}
151+
152+
public void addGetPoliciesConfigurationsDuration(long value) {
153+
getPoliciesConfigurations.add(value);
154+
}
155+
}

0 commit comments

Comments
 (0)