adoroszlai commented on code in PR #11738: URL: https://github.com/apache/ozone/pull/11738#discussion_r4692640474
########## hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OmClientMetrics.java: ########## @@ -0,0 +1,141 @@ +/* + * 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 java.util.Arrays; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.hadoop.hdds.annotation.InterfaceAudience; +import org.apache.hadoop.hdds.conf.ConfigurationSource; +import org.apache.hadoop.metrics2.MetricsCollector; +import org.apache.hadoop.metrics2.MetricsRecordBuilder; +import org.apache.hadoop.metrics2.MetricsSource; +import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; +import org.apache.hadoop.metrics2.lib.MetricsRegistry; +import org.apache.hadoop.ozone.OzoneConsts; +import org.apache.hadoop.ozone.conf.OMClientConfig; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type; +import org.apache.hadoop.ozone.util.PerformanceMetrics; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Process-wide latency of OM calls made by initialized RpcClients, including failed calls and background requests. + * Each sample measures one transport submission, including transport retries but excluding retries by its caller. + * These are client-side nanoseconds, not OM server processing time or a count of physical RPC attempts. + */ [email protected] +public final class OmClientMetrics implements MetricsSource { + public static final String SOURCE_NAME = OmClientMetrics.class.getSimpleName(); + private static final Logger LOG = LoggerFactory.getLogger(OmClientMetrics.class); + private static OmClientMetrics instance; + private static int referenceCount; + + private final MetricsRegistry registry = new MetricsRegistry(SOURCE_NAME); + private final Map<Type, PerformanceMetrics> latencies = new ConcurrentHashMap<>(); + private final int[] intervals; + private boolean closed; + + private OmClientMetrics(int[] intervals) { + this.intervals = intervals; + } + + /** The first active client supplies the percentile intervals until the last client closes. */ + public static synchronized Handle acquireHandle(ConfigurationSource conf) { + int[] intervals = conf.getObject(OMClientConfig.class).getMetricsPercentilesIntervals(); Review Comment: Please move `conf.getObject(OMClientConfig.class)` to the caller, and pass `OMClientConfig`. ########## hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java: ########## @@ -371,6 +373,9 @@ public RpcClient(ConfigurationSource conf, String omServiceId) OZONE_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS, OZONE_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_DEFAULT, TimeUnit.MILLISECONDS); + // Acquire last so a failed client constructor cannot retain an OM metrics reference. + this.omClientMetricsHandle = OmClientMetrics.acquireHandle(conf); Review Comment: `RpcClient` can store `OMClientConfig` for its lifetime, similar to: https://github.com/apache/ozone/blob/00bdef09825f829e273f28208ebe0387706cbb3b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java#L282 -- 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]
