001/** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020package org.apache.hadoop.hbase.ipc; 021 022import org.apache.yetus.audience.InterfaceAudience; 023 024@InterfaceAudience.Private 025public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper { 026 027 private RpcServer server; 028 029 MetricsHBaseServerWrapperImpl(RpcServer server) { 030 this.server = server; 031 } 032 033 private boolean isServerStarted() { 034 return this.server != null && this.server.isStarted(); 035 } 036 037 @Override 038 public long getTotalQueueSize() { 039 if (!isServerStarted()) { 040 return 0; 041 } 042 return server.callQueueSizeInBytes.sum(); 043 } 044 045 @Override 046 public int getGeneralQueueLength() { 047 if (!isServerStarted() || this.server.getScheduler() == null) { 048 return 0; 049 } 050 return server.getScheduler().getGeneralQueueLength(); 051 } 052 053 @Override 054 public int getReplicationQueueLength() { 055 if (!isServerStarted() || this.server.getScheduler() == null) { 056 return 0; 057 } 058 return server.getScheduler().getReplicationQueueLength(); 059 } 060 061 @Override 062 public int getPriorityQueueLength() { 063 if (!isServerStarted() || this.server.getScheduler() == null) { 064 return 0; 065 } 066 return server.getScheduler().getPriorityQueueLength(); 067 } 068 069 @Override 070 public int getMetaPriorityQueueLength() { 071 if (!isServerStarted() || this.server.getScheduler() == null) { 072 return 0; 073 } 074 return server.getScheduler().getMetaPriorityQueueLength(); 075 } 076 077 @Override 078 public int getNumOpenConnections() { 079 if (!isServerStarted()) { 080 return 0; 081 } 082 return server.getNumOpenConnections(); 083 } 084 085 @Override 086 public int getActiveRpcHandlerCount() { 087 if (!isServerStarted() || this.server.getScheduler() == null) { 088 return 0; 089 } 090 return server.getScheduler().getActiveRpcHandlerCount(); 091 } 092 @Override 093 public long getNumGeneralCallsDropped() { 094 if (!isServerStarted() || this.server.getScheduler() == null) { 095 return 0; 096 } 097 return server.getScheduler().getNumGeneralCallsDropped(); 098 } 099 100 @Override 101 public long getNumLifoModeSwitches() { 102 if (!isServerStarted() || this.server.getScheduler() == null) { 103 return 0; 104 } 105 return server.getScheduler().getNumLifoModeSwitches(); 106 } 107 108 @Override 109 public int getWriteQueueLength() { 110 if (!isServerStarted() || this.server.getScheduler() == null) { 111 return 0; 112 } 113 return server.getScheduler().getWriteQueueLength(); 114 } 115 116 @Override 117 public int getReadQueueLength() { 118 if (!isServerStarted() || this.server.getScheduler() == null) { 119 return 0; 120 } 121 return server.getScheduler().getReadQueueLength(); 122 } 123 124 @Override 125 public int getScanQueueLength() { 126 if (!isServerStarted() || this.server.getScheduler() == null) { 127 return 0; 128 } 129 return server.getScheduler().getScanQueueLength(); 130 } 131 132 @Override 133 public int getActiveWriteRpcHandlerCount() { 134 if (!isServerStarted() || this.server.getScheduler() == null) { 135 return 0; 136 } 137 return server.getScheduler().getActiveWriteRpcHandlerCount(); 138 } 139 140 @Override 141 public int getActiveReadRpcHandlerCount() { 142 if (!isServerStarted() || this.server.getScheduler() == null) { 143 return 0; 144 } 145 return server.getScheduler().getActiveReadRpcHandlerCount(); 146 } 147 148 @Override 149 public int getActiveScanRpcHandlerCount() { 150 if (!isServerStarted() || this.server.getScheduler() == null) { 151 return 0; 152 } 153 return server.getScheduler().getActiveScanRpcHandlerCount(); 154 } 155}