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
019package org.apache.hadoop.hbase.client.metrics;
020
021import java.util.concurrent.atomic.AtomicLong;
022
023import org.apache.yetus.audience.InterfaceAudience;
024
025
026/**
027 * Provides metrics related to scan operations (both server side and client side metrics).
028 * <p>
029 * The data can be passed to mapreduce framework or other systems.
030 * We use atomic longs so that one thread can increment,
031 * while another atomically resets to zero after the values are reported
032 * to hadoop's counters.
033 * <p>
034 * Some of these metrics are general for any client operation such as put
035 * However, there is no need for this. So they are defined under scan operation
036 * for now.
037 */
038@InterfaceAudience.Public
039public class ScanMetrics extends ServerSideScanMetrics {
040
041  // AtomicLongs to hold the metrics values. These are all updated through ClientScanner and
042  // ScannerCallable. They are atomic longs so that atomic getAndSet can be used to reset the
043  // values after progress is passed to hadoop's counters.
044
045  public static final String RPC_CALLS_METRIC_NAME = "RPC_CALLS";
046  public static final String REMOTE_RPC_CALLS_METRIC_NAME = "REMOTE_RPC_CALLS";
047  public static final String MILLIS_BETWEEN_NEXTS_METRIC_NAME = "MILLIS_BETWEEN_NEXTS";
048  public static final String NOT_SERVING_REGION_EXCEPTION_METRIC_NAME = "NOT_SERVING_REGION_EXCEPTION";
049  public static final String BYTES_IN_RESULTS_METRIC_NAME = "BYTES_IN_RESULTS";
050  public static final String BYTES_IN_REMOTE_RESULTS_METRIC_NAME = "BYTES_IN_REMOTE_RESULTS";
051  public static final String REGIONS_SCANNED_METRIC_NAME = "REGIONS_SCANNED";
052  public static final String RPC_RETRIES_METRIC_NAME = "RPC_RETRIES";
053  public static final String REMOTE_RPC_RETRIES_METRIC_NAME = "REMOTE_RPC_RETRIES";
054 
055  /**
056   * number of RPC calls
057   */
058  public final AtomicLong countOfRPCcalls = createCounter(RPC_CALLS_METRIC_NAME);
059
060  /**
061   * number of remote RPC calls
062   */
063  public final AtomicLong countOfRemoteRPCcalls = createCounter(REMOTE_RPC_CALLS_METRIC_NAME);
064
065  /**
066   * sum of milliseconds between sequential next calls
067   */
068  public final AtomicLong sumOfMillisSecBetweenNexts = createCounter(MILLIS_BETWEEN_NEXTS_METRIC_NAME);
069
070  /**
071   * number of NotServingRegionException caught
072   */
073  public final AtomicLong countOfNSRE = createCounter(NOT_SERVING_REGION_EXCEPTION_METRIC_NAME);
074
075  /**
076   * number of bytes in Result objects from region servers
077   */
078  public final AtomicLong countOfBytesInResults = createCounter(BYTES_IN_RESULTS_METRIC_NAME);
079
080  /**
081   * number of bytes in Result objects from remote region servers
082   */
083  public final AtomicLong countOfBytesInRemoteResults = createCounter(BYTES_IN_REMOTE_RESULTS_METRIC_NAME);
084
085  /**
086   * number of regions
087   */
088  public final AtomicLong countOfRegions = createCounter(REGIONS_SCANNED_METRIC_NAME);
089
090  /**
091   * number of RPC retries
092   */
093  public final AtomicLong countOfRPCRetries = createCounter(RPC_RETRIES_METRIC_NAME);
094
095  /**
096   * number of remote RPC retries
097   */
098  public final AtomicLong countOfRemoteRPCRetries = createCounter(REMOTE_RPC_RETRIES_METRIC_NAME);
099
100  /**
101   * constructor
102   */
103  public ScanMetrics() {
104  }
105}