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,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  package org.apache.http.pool;
28  
29  import org.apache.http.annotation.Immutable;
30  
31  /**
32   * Pool statistics.
33   *
34   * @since 4.2
35   *
36   */
37  @Immutable
38  public class PoolStats {
39  
40      private final int leased;
41      private final int pending;
42      private final int available;
43      private final int max;
44  
45      public PoolStats(int leased, int pending, int free, int max) {
46          super();
47          this.leased = leased;
48          this.pending = pending;
49          this.available = free;
50          this.max = max;
51      }
52  
53      public int getLeased() {
54          return this.leased;
55      }
56  
57      public int getPending() {
58          return this.pending;
59      }
60  
61      public int getAvailable() {
62          return this.available;
63      }
64  
65      public int getMax() {
66          return this.max;
67      }
68  
69      @Override
70      public String toString() {
71          StringBuilder buffer = new StringBuilder();
72          buffer.append("[leased: ");
73          buffer.append(this.leased);
74          buffer.append("; pending: ");
75          buffer.append(this.pending);
76          buffer.append("; available: ");
77          buffer.append(this.available);
78          buffer.append("; max: ");
79          buffer.append(this.max);
80          buffer.append("]");
81          return buffer.toString();
82      }
83  
84  }