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 */ 018package org.apache.hadoop.hbase.ipc; 019 020import org.apache.yetus.audience.InterfaceAudience; 021 022@InterfaceAudience.Private 023public abstract class MetricsHBaseServerSourceFactory { 024 /** 025 * The name of the metrics 026 */ 027 static final String METRICS_NAME = "IPC"; 028 029 /** 030 * Description 031 */ 032 static final String METRICS_DESCRIPTION = "Metrics about HBase Server IPC"; 033 034 /** 035 * The Suffix of the JMX Context that a MetricsHBaseServerSource will register under. JMX_CONTEXT 036 * will be created by createContextName(serverClassName) + METRICS_JMX_CONTEXT_SUFFIX 037 */ 038 static final String METRICS_JMX_CONTEXT_SUFFIX = ",sub=" + METRICS_NAME; 039 040 abstract MetricsHBaseServerSource create(String serverName, MetricsHBaseServerWrapper wrapper); 041 042 /** 043 * From the name of the class that's starting up create the context that an IPC source should 044 * register itself. 045 * @param serverName The name of the class that's starting up. 046 * @return The Camel Cased context name. 047 */ 048 protected static String createContextName(String serverName) { 049 if (serverName.startsWith("HMaster") || serverName.startsWith("master")) { 050 return "Master"; 051 } else if (serverName.startsWith("HRegion") || serverName.startsWith("regionserver")) { 052 return "RegionServer"; 053 } 054 return "IPC"; 055 } 056}