001package org.apache.hadoop.hbase;
002
003/**
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *     http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020import java.lang.reflect.Field;
021import java.util.concurrent.atomic.LongAdder;
022
023import org.apache.yetus.audience.InterfaceAudience;
024
025/**
026 * Counters kept by the distributed WAL split log process.
027 * Used by master and regionserver packages.
028 */
029@InterfaceAudience.Private
030public class SplitLogCounters {
031  //Spnager counters
032  public final static LongAdder tot_mgr_log_split_batch_start = new LongAdder();
033  public final static LongAdder tot_mgr_log_split_batch_success = new LongAdder();
034  public final static LongAdder tot_mgr_log_split_batch_err = new LongAdder();
035  public final static LongAdder tot_mgr_new_unexpected_wals = new LongAdder();
036  public final static LongAdder tot_mgr_log_split_start = new LongAdder();
037  public final static LongAdder tot_mgr_log_split_success = new LongAdder();
038  public final static LongAdder tot_mgr_log_split_err = new LongAdder();
039  public final static LongAdder tot_mgr_node_create_queued = new LongAdder();
040  public final static LongAdder tot_mgr_node_create_result = new LongAdder();
041  public final static LongAdder tot_mgr_node_already_exists = new LongAdder();
042  public final static LongAdder tot_mgr_node_create_err = new LongAdder();
043  public final static LongAdder tot_mgr_node_create_retry = new LongAdder();
044  public final static LongAdder tot_mgr_get_data_queued = new LongAdder();
045  public final static LongAdder tot_mgr_get_data_result = new LongAdder();
046  public final static LongAdder tot_mgr_get_data_nonode = new LongAdder();
047  public final static LongAdder tot_mgr_get_data_err = new LongAdder();
048  public final static LongAdder tot_mgr_get_data_retry = new LongAdder();
049  public final static LongAdder tot_mgr_node_delete_queued = new LongAdder();
050  public final static LongAdder tot_mgr_node_delete_result = new LongAdder();
051  public final static LongAdder tot_mgr_node_delete_err = new LongAdder();
052  public final static LongAdder tot_mgr_resubmit = new LongAdder();
053  public final static LongAdder tot_mgr_resubmit_failed = new LongAdder();
054  public final static LongAdder tot_mgr_null_data = new LongAdder();
055  public final static LongAdder tot_mgr_orphan_task_acquired = new LongAdder();
056  public final static LongAdder tot_mgr_wait_for_zk_delete = new LongAdder();
057  public final static LongAdder tot_mgr_unacquired_orphan_done = new LongAdder();
058  public final static LongAdder tot_mgr_resubmit_threshold_reached = new LongAdder();
059  public final static LongAdder tot_mgr_missing_state_in_delete = new LongAdder();
060  public final static LongAdder tot_mgr_heartbeat = new LongAdder();
061  public final static LongAdder tot_mgr_rescan = new LongAdder();
062  public final static LongAdder tot_mgr_rescan_deleted = new LongAdder();
063  public final static LongAdder tot_mgr_task_deleted = new LongAdder();
064  public final static LongAdder tot_mgr_resubmit_unassigned = new LongAdder();
065  public final static LongAdder tot_mgr_relist_logdir = new LongAdder();
066  public final static LongAdder tot_mgr_resubmit_dead_server_task = new LongAdder();
067  public final static LongAdder tot_mgr_resubmit_force = new LongAdder();
068
069  // SplitLogWorker counters
070  public final static LongAdder tot_wkr_failed_to_grab_task_no_data = new LongAdder();
071  public final static LongAdder tot_wkr_failed_to_grab_task_exception = new LongAdder();
072  public final static LongAdder tot_wkr_failed_to_grab_task_owned = new LongAdder();
073  public final static LongAdder tot_wkr_failed_to_grab_task_lost_race = new LongAdder();
074  public final static LongAdder tot_wkr_task_acquired = new LongAdder();
075  public final static LongAdder tot_wkr_task_resigned = new LongAdder();
076  public final static LongAdder tot_wkr_task_done = new LongAdder();
077  public final static LongAdder tot_wkr_task_err = new LongAdder();
078  public final static LongAdder tot_wkr_task_heartbeat = new LongAdder();
079  public final static LongAdder tot_wkr_task_acquired_rescan = new LongAdder();
080  public final static LongAdder tot_wkr_get_data_queued = new LongAdder();
081  public final static LongAdder tot_wkr_get_data_result = new LongAdder();
082  public final static LongAdder tot_wkr_get_data_retry = new LongAdder();
083  public final static LongAdder tot_wkr_preempt_task = new LongAdder();
084  public final static LongAdder tot_wkr_task_heartbeat_failed = new LongAdder();
085  public final static LongAdder tot_wkr_final_transition_failed = new LongAdder();
086  public final static LongAdder tot_wkr_task_grabing = new LongAdder();
087
088  public static void resetCounters() throws Exception {
089    Class<?> cl = SplitLogCounters.class;
090    for (Field fld : cl.getDeclaredFields()) {
091      /* Guard against source instrumentation. */
092      if ((!fld.isSynthetic()) && (LongAdder.class.isAssignableFrom(fld.getType()))) {
093        ((LongAdder)fld.get(null)).reset();
094      }
095    }
096  }
097}