001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.hadoop.hdfs;
019
020 import java.util.concurrent.atomic.AtomicLong;
021
022 /**
023 * The client-side metrics for hedged read feature.
024 * This class has a number of metrics variables that are publicly accessible,
025 * we can grab them from client side, like HBase.
026 */
027 public class DFSHedgedReadMetrics {
028 public final AtomicLong hedgedReadOps = new AtomicLong();
029 public final AtomicLong hedgedReadOpsWin = new AtomicLong();
030 public final AtomicLong hedgedReadOpsInCurThread = new AtomicLong();
031
032 public void incHedgedReadOps() {
033 hedgedReadOps.incrementAndGet();
034 }
035
036 public void incHedgedReadOpsInCurThread() {
037 hedgedReadOpsInCurThread.incrementAndGet();
038 }
039
040 public void incHedgedReadWins() {
041 hedgedReadOpsWin.incrementAndGet();
042 }
043
044 public long getHedgedReadOps() {
045 return hedgedReadOps.longValue();
046 }
047
048 public long getHedgedReadOpsInCurThread() {
049 return hedgedReadOpsInCurThread.longValue();
050 }
051
052 public long getHedgedReadWins() {
053 return hedgedReadOpsWin.longValue();
054 }
055 }