001/*
002 * Copyright 2014-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2014-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2014-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.monitors;
037
038
039
040import java.io.Serializable;
041
042import com.unboundid.ldap.sdk.OperationType;
043import com.unboundid.util.NotMutable;
044import com.unboundid.util.NotNull;
045import com.unboundid.util.Nullable;
046import com.unboundid.util.ThreadSafety;
047import com.unboundid.util.ThreadSafetyLevel;
048
049
050
051/**
052 * This class provides a data structure that encapsulates information about a
053 * result code included in the result code monitor entry.
054 * <BR>
055 * <BLOCKQUOTE>
056 *   <B>NOTE:</B>  This class, and other classes within the
057 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
058 *   supported for use against Ping Identity, UnboundID, and
059 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
060 *   for proprietary functionality or for external specifications that are not
061 *   considered stable or mature enough to be guaranteed to work in an
062 *   interoperable way with other types of LDAP servers.
063 * </BLOCKQUOTE>
064 */
065@NotMutable()
066@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
067public final class ResultCodeInfo
068       implements Serializable
069{
070  /**
071   * The serial version UID for this serializable class.
072   */
073  private static final long serialVersionUID = 1223217954357101681L;
074
075
076
077  // The average response time, in milliseconds, for operations with this result
078  // code.
079  private final double averageResponseTimeMillis;
080
081  // The percent of operations of the associated type with this result code.
082  private final double percent;
083
084  // The sum of all response times, in milliseconds, for operations with this
085  // result code.
086  private final double totalResponseTimeMillis;
087
088  // The integer value for this result code.
089  private final int intValue;
090
091  // The total number of operations of the specified type with this result code.
092  private final long count;
093
094  // The operation type for which this information is maintained, or null if
095  // it applies to all types of operations.
096  @Nullable private final OperationType operationType;
097
098  // The name for this result code.
099  @NotNull private final String name;
100
101
102
103  /**
104   * Creates a new result code info object with the provided information.
105   *
106   * @param  intValue                   The integer value for this result code.
107   * @param  name                       The name for this result code.
108   * @param  operationType              The type of operation to which the
109   *                                    statistics apply.  This may be
110   *                                    {@code null} if the statistics apply to
111   *                                    all types of operations.
112   * @param  count                      The total number of operations of the
113   *                                    specified type with this result code.
114   * @param  percent                    The percent of operations of the
115   *                                    specified type with this result code.
116   * @param  totalResponseTimeMillis    The total response time, in
117   *                                    milliseconds, for all operations of the
118   *                                    specified type with this result code.
119   * @param  averageResponseTimeMillis  The average response time, in
120   *                                    milliseconds, for operations of the
121   *                                    specified type with this result code.
122   */
123  ResultCodeInfo(final int intValue, @NotNull final String name,
124                 @Nullable final OperationType operationType, final long count,
125                 final double percent, final double totalResponseTimeMillis,
126                 final double averageResponseTimeMillis)
127  {
128    this.intValue                  = intValue;
129    this.name                      = name;
130    this.operationType             = operationType;
131    this.count                     = count;
132    this.totalResponseTimeMillis   = totalResponseTimeMillis;
133    this.averageResponseTimeMillis = averageResponseTimeMillis;
134    this.percent                   = percent;
135  }
136
137
138
139  /**
140   * Retrieves the integer value for this result code.
141   *
142   * @return  The integer value for this result code.
143   */
144  public int intValue()
145  {
146    return intValue;
147  }
148
149
150
151  /**
152   * Retrieves the name for this result code.
153   *
154   * @return  The name for this result code.
155   */
156  @NotNull()
157  public String getName()
158  {
159    return name;
160  }
161
162
163
164  /**
165   * Retrieves the type of operation with which the result code statistics are
166   * associated, if appropriate.
167   *
168   * @return  The type of operation with which the result code statistics are
169   *          associated, or {@code null} if the statistics apply to all types
170   *          of operations.
171   */
172  @Nullable()
173  public OperationType getOperationType()
174  {
175    return operationType;
176  }
177
178
179
180  /**
181   * The total number of operations of the associated type (or of all
182   * operations if the operation type is {@code null}) with this result code.
183   *
184   * @return  The total number of operations of the associated type with this
185   *          result code.
186   */
187  public long getCount()
188  {
189    return count;
190  }
191
192
193
194  /**
195   * The percent of operations of the associated type (or of all operations if
196   * the operation type is {@code null}) with this result code.
197   *
198   * @return  The percent of operations of the associated type with this result
199   *          code.
200   */
201  public double getPercent()
202  {
203    return percent;
204  }
205
206
207
208  /**
209   * The sum of the response times, in milliseconds, for all operations of the
210   * associated type (or of all operations if the operation type is
211   * {@code null}) with this result code.
212   *
213   * @return  The sum of the response times, in milliseconds, for all operations
214   *          of the associated type with this result code.
215   */
216  public double getTotalResponseTimeMillis()
217  {
218    return totalResponseTimeMillis;
219  }
220
221
222
223  /**
224   * The average response time, in milliseconds, for all operations of the
225   * associated type (or of all operations if the operation type is
226   * {@code null}) with this result code.
227   *
228   * @return  The average response time, in milliseconds, for all operations of
229   *          the associated type with this result code.
230   */
231  public double getAverageResponseTimeMillis()
232  {
233    return averageResponseTimeMillis;
234  }
235}