View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
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    @Override
31    public long getTotalQueueSize() {
32      if (this.server == null) {
33        return 0;
34      }
35      return server.callQueueSize.get();
36    }
37  
38    @Override
39    public int getGeneralQueueLength() {
40      if (this.server == null || this.server.getScheduler() == null) {
41        return 0;
42      }
43      return server.getScheduler().getGeneralQueueLength();
44    }
45  
46    @Override
47    public int getReplicationQueueLength() {
48      if (this.server == null || this.server.getScheduler() == null) {
49        return 0;
50      }
51      return server.getScheduler().getReplicationQueueLength();
52    }
53  
54    @Override
55    public int getPriorityQueueLength() {
56      if (this.server == null || this.server.getScheduler() == null) {
57        return 0;
58      }
59      return server.getScheduler().getPriorityQueueLength();
60    }
61  
62    @Override
63    public int getNumOpenConnections() {
64      if (this.server == null || this.server.connectionList == null) {
65        return 0;
66      }
67      return server.connectionList.size();
68    }
69  
70    @Override
71    public int getActiveRpcHandlerCount() {
72      if (this.server == null || this.server.getScheduler() == null) {
73        return 0;
74      }
75      return server.getScheduler().getActiveRpcHandlerCount();
76    }
77  }