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 getNumOpenConnections() { 071 if (!isServerStarted()) { 072 return 0; 073 } 074 return server.getNumOpenConnections(); 075 } 076 077 @Override 078 public int getActiveRpcHandlerCount() { 079 if (!isServerStarted() || this.server.getScheduler() == null) { 080 return 0; 081 } 082 return server.getScheduler().getActiveRpcHandlerCount(); 083 } 084 085 @Override 086 public long getNumGeneralCallsDropped() { 087 if (!isServerStarted() || this.server.getScheduler() == null) { 088 return 0; 089 } 090 return server.getScheduler().getNumGeneralCallsDropped(); 091 } 092 093 @Override 094 public long getNumLifoModeSwitches() { 095 if (!isServerStarted() || this.server.getScheduler() == null) { 096 return 0; 097 } 098 return server.getScheduler().getNumLifoModeSwitches(); 099 } 100 101 @Override 102 public int getWriteQueueLength() { 103 if (!isServerStarted() || this.server.getScheduler() == null) { 104 return 0; 105 } 106 return server.getScheduler().getWriteQueueLength(); 107 } 108 109 @Override 110 public int getReadQueueLength() { 111 if (!isServerStarted() || this.server.getScheduler() == null) { 112 return 0; 113 } 114 return server.getScheduler().getReadQueueLength(); 115 } 116 117 @Override 118 public int getScanQueueLength() { 119 if (!isServerStarted() || this.server.getScheduler() == null) { 120 return 0; 121 } 122 return server.getScheduler().getScanQueueLength(); 123 } 124 125 @Override 126 public int getActiveWriteRpcHandlerCount() { 127 if (!isServerStarted() || this.server.getScheduler() == null) { 128 return 0; 129 } 130 return server.getScheduler().getActiveWriteRpcHandlerCount(); 131 } 132 133 @Override 134 public int getActiveReadRpcHandlerCount() { 135 if (!isServerStarted() || this.server.getScheduler() == null) { 136 return 0; 137 } 138 return server.getScheduler().getActiveReadRpcHandlerCount(); 139 } 140 141 @Override 142 public int getActiveScanRpcHandlerCount() { 143 if (!isServerStarted() || this.server.getScheduler() == null) { 144 return 0; 145 } 146 return server.getScheduler().getActiveScanRpcHandlerCount(); 147 } 148}