001    /*
002     * Copyright 2014-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2015 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.unboundidds.monitors;
022    
023    
024    
025    import java.io.Serializable;
026    
027    import com.unboundid.ldap.sdk.OperationType;
028    import com.unboundid.util.NotMutable;
029    import com.unboundid.util.ThreadSafety;
030    import com.unboundid.util.ThreadSafetyLevel;
031    
032    
033    
034    /**
035     * <BLOCKQUOTE>
036     *   <B>NOTE:</B>  This class is part of the Commercial Edition of the UnboundID
037     *   LDAP SDK for Java.  It is not available for use in applications that
038     *   include only the Standard Edition of the LDAP SDK, and is not supported for
039     *   use in conjunction with non-UnboundID products.
040     * </BLOCKQUOTE>
041     * This class provides a data structure that encapsulates information about a
042     * result code included in the result code monitor entry.
043     */
044    @NotMutable()
045    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
046    public final class ResultCodeInfo
047           implements Serializable
048    {
049      /**
050       * The serial version UID for this serializable class.
051       */
052      private static final long serialVersionUID = 1223217954357101681L;
053    
054    
055    
056      // The average response time, in milliseconds, for operations with this result
057      // code.
058      private final double averageResponseTimeMillis;
059    
060      // The percent of operations of the associated type with this result code.
061      private final double percent;
062    
063      // The sum of all response times, in milliseconds, for operations with this
064      // result code.
065      private final double totalResponseTimeMillis;
066    
067      // The integer value for this result code.
068      private final int intValue;
069    
070      // The total number of operations of the specified type with this result code.
071      private final long count;
072    
073      // The operation type for which this information is maintained, or null if
074      // it applies to all types of operations.
075      private final OperationType operationType;
076    
077      // The name for this result code.
078      private final String name;
079    
080    
081    
082      /**
083       * Creates a new result code info object with the provided information.
084       *
085       * @param  intValue                   The integer value for this result code.
086       * @param  name                       The name for this result code.
087       * @param  operationType              The type of operation to which the
088       *                                    statistics apply.  This may be
089       *                                    {@code null} if the statistics apply to
090       *                                    all types of operations.
091       * @param  count                      The total number of operations of the
092       *                                    specified type with this result code.
093       * @param  percent                    The percent of operations of the
094       *                                    specified type with this result code.
095       * @param  totalResponseTimeMillis    The total response time, in
096       *                                    milliseconds, for all operations of the
097       *                                    specified type with this result code.
098       * @param  averageResponseTimeMillis  The average response time, in
099       *                                    milliseconds, for operations of the
100       *                                    specified type with this result code.
101       */
102      ResultCodeInfo(final int intValue, final String name,
103                     final OperationType operationType, final long count,
104                     final double percent, final double totalResponseTimeMillis,
105                     final double averageResponseTimeMillis)
106      {
107        this.intValue                  = intValue;
108        this.name                      = name;
109        this.operationType             = operationType;
110        this.count                     = count;
111        this.totalResponseTimeMillis   = totalResponseTimeMillis;
112        this.averageResponseTimeMillis = averageResponseTimeMillis;
113        this.percent                   = percent;
114      }
115    
116    
117    
118      /**
119       * Retrieves the integer value for this result code.
120       *
121       * @return  The integer value for this result code.
122       */
123      public int intValue()
124      {
125        return intValue;
126      }
127    
128    
129    
130      /**
131       * Retrieves the name for this result code.
132       *
133       * @return  The name for this result code.
134       */
135      public String getName()
136      {
137        return name;
138      }
139    
140    
141    
142      /**
143       * Retrieves the type of operation with which the result code statistics are
144       * associated, if appropriate.
145       *
146       * @return  The type of operation with which the result code statistics are
147       *          associated, or {@code null} if the statistics apply to all types
148       *          of operations.
149       */
150      public OperationType getOperationType()
151      {
152        return operationType;
153      }
154    
155    
156    
157      /**
158       * The total number of operations of the associated type (or of all
159       * operations if the operation type is {@code null}) with this result code.
160       *
161       * @return  The total number of operations of the associated type with this
162       *          result code.
163       */
164      public long getCount()
165      {
166        return count;
167      }
168    
169    
170    
171      /**
172       * The percent of operations of the associated type (or of all operations if
173       * the operation type is {@code null}) with this result code.
174       *
175       * @return  The percent of operations of the associated type with this result
176       *          code.
177       */
178      public double getPercent()
179      {
180        return percent;
181      }
182    
183    
184    
185      /**
186       * The sum of the response times, in milliseconds, for all operations of the
187       * associated type (or of all operations if the operation type is
188       * {@code null}) with this result code.
189       *
190       * @return  The sum of the response times, in milliseconds, for all operations
191       *          of the associated type with this result code.
192       */
193      public double getTotalResponseTimeMillis()
194      {
195        return totalResponseTimeMillis;
196      }
197    
198    
199    
200      /**
201       * The average response time, in milliseconds, for all operations of the
202       * associated type (or of all operations if the operation type is
203       * {@code null}) with this result code.
204       *
205       * @return  The average response time, in milliseconds, for all operations of
206       *          the associated type with this result code.
207       */
208      public double getAverageResponseTimeMillis()
209      {
210        return averageResponseTimeMillis;
211      }
212    }