1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.ipc;
21
22 public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper {
23
24 private RpcServer server;
25
26 MetricsHBaseServerWrapperImpl(RpcServer server) {
27 this.server = server;
28 }
29
30 private boolean isServerStarted() {
31 return this.server != null && this.server.isStarted();
32 }
33
34 @Override
35 public long getTotalQueueSize() {
36 if (!isServerStarted()) {
37 return 0;
38 }
39 return server.callQueueSize.get();
40 }
41
42 @Override
43 public int getGeneralQueueLength() {
44 if (!isServerStarted() || this.server.getScheduler() == null) {
45 return 0;
46 }
47 return server.getScheduler().getGeneralQueueLength();
48 }
49
50 @Override
51 public int getReplicationQueueLength() {
52 if (!isServerStarted() || this.server.getScheduler() == null) {
53 return 0;
54 }
55 return server.getScheduler().getReplicationQueueLength();
56 }
57
58 @Override
59 public int getPriorityQueueLength() {
60 if (!isServerStarted() || this.server.getScheduler() == null) {
61 return 0;
62 }
63 return server.getScheduler().getPriorityQueueLength();
64 }
65
66 @Override
67 public int getNumOpenConnections() {
68 if (!isServerStarted() || this.server.connectionList == null) {
69 return 0;
70 }
71 return server.connectionList.size();
72 }
73
74 @Override
75 public int getActiveRpcHandlerCount() {
76 if (!isServerStarted() || this.server.getScheduler() == null) {
77 return 0;
78 }
79 return server.getScheduler().getActiveRpcHandlerCount();
80 }
81 }