001 /*
002 * Copyright 2014-2016 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2014-2016 UnboundID Corp.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021 package com.unboundid.ldap.sdk;
022
023
024
025 import java.io.Serializable;
026
027
028
029
030 /**
031 * This class provides a data structure that holds information about the result
032 * of an LDAP connection pool health check.
033 */
034 public final class LDAPConnectionPoolHealthCheckResult
035 implements Serializable
036 {
037 /**
038 * The serial version UID for this serializable class.
039 */
040 private static final long serialVersionUID = -7312002973891471180L;
041
042
043
044 // The number of connections found to be defunct.
045 private final int numDefunct;
046
047 // The number of connections examined during the health check.
048 private final int numExamined;
049
050 // The number of connections found to be expired.
051 private final int numExpired;
052
053
054
055 /**
056 * Creates a new health check result with the provided information.
057 *
058 * @param numExamined The number of connections examined during the health
059 * check.
060 * @param numExpired The number of connections found to have been
061 * established for longer than the pool's maximum
062 * connection age and were attempted to be replaced as
063 * expired.
064 * @param numDefunct The number of connections found to be invalid and were
065 * attempted to be replaced as defunct.
066 */
067 LDAPConnectionPoolHealthCheckResult(final int numExamined,
068 final int numExpired,
069 final int numDefunct)
070 {
071 this.numExamined = numExamined;
072 this.numExpired = numExpired;
073 this.numDefunct = numDefunct;
074 }
075
076
077
078 /**
079 * Retrieves the number of connections that were examined during the health
080 * check.
081 *
082 * @return The number of connections that were examined during the health
083 * check.
084 */
085 public int getNumExamined()
086 {
087 return numExamined;
088 }
089
090
091
092 /**
093 * Retrieves the number of connections found to have been established for
094 * longer than the pool's maximum connection age and were attempted to be
095 * replaced as expired.
096 *
097 * @return The number of connections found to have been established for
098 * longer than the pool's maximum connection age and were attempted
099 * to be replaced as expired.
100 */
101 public int getNumExpired()
102 {
103 return numExpired;
104 }
105
106
107
108 /**
109 * Retrieves the number of connections found to be invalid (e.g., because they
110 * were no longer established, or because they failed the health check) and
111 * were attempted to be replaced as defunct.
112 *
113 * @return The number of connections found to be invalid and were attempted
114 * to be replaced as defunct.
115 */
116 public int getNumDefunct()
117 {
118 return numDefunct;
119 }
120
121
122
123 /**
124 * Retrieves a string representation of this connection pool health check
125 * result.
126 *
127 * @return A string representation of this connection pool health check
128 * result.
129 */
130 @Override()
131 public String toString()
132 {
133 final StringBuilder buffer = new StringBuilder();
134 toString(buffer);
135 return buffer.toString();
136 }
137
138
139
140 /**
141 * Appends a string representation of this connection pool health check result
142 * to the provided buffer.
143 *
144 * @param buffer The buffer to which the information should be appended.
145 */
146 public void toString(final StringBuilder buffer)
147 {
148 buffer.append("LDAPConnectionPoolHealthCheckResult(numExamined=");
149 buffer.append(numExamined);
150 buffer.append(", numExpired=");
151 buffer.append(numExpired);
152 buffer.append(", numDefunct=");
153 buffer.append(numDefunct);
154 buffer.append(')');
155 }
156 }