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
41          || this.server.getScheduler() == null) {
42        return 0;
43      }
44      return server.getScheduler().getGeneralQueueLength();
45    }
46  
47    @Override
48    public int getReplicationQueueLength() {
49      if (this.server == null
50          || this.server.getScheduler() == null) {
51        return 0;
52      }
53      return server.getScheduler().getReplicationQueueLength();
54    }
55  
56    @Override
57    public int getPriorityQueueLength() {
58      if (this.server == null
59          || this.server.getScheduler() == null) {
60        return 0;
61      }
62      return server.getScheduler().getPriorityQueueLength();
63    }
64  
65    @Override
66    public int getNumOpenConnections() {
67      if (this.server == null || this.server.connectionList == null) {
68        return 0;
69      }
70      return server.connectionList.size();
71    }
72  }