001/*
002 * Copyright 2011-2019 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2019 Ping Identity Corporation
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 */
021package com.unboundid.ldap.sdk.unboundidds.monitors;
022
023
024
025import java.util.Collections;
026import java.util.LinkedHashMap;
027import java.util.Map;
028
029import com.unboundid.ldap.sdk.Entry;
030import com.unboundid.util.NotMutable;
031import com.unboundid.util.StaticUtils;
032import com.unboundid.util.ThreadSafety;
033import com.unboundid.util.ThreadSafetyLevel;
034
035import static com.unboundid.ldap.sdk.unboundidds.monitors.MonitorMessages.*;
036
037
038
039/**
040 * This class defines a monitor entry that provides information about the
041 * processing times of operations that are performed in the server in the
042 * context of a single application.  It derives most of its functionality
043 * from its parent class, {@link ProcessingTimeHistogramMonitorEntry}.  The
044 * only additional information that is provided is the name of the application
045 * to which the monitor entry applies.
046 * <BR>
047 * <BLOCKQUOTE>
048 *   <B>NOTE:</B>  This class, and other classes within the
049 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
050 *   supported for use against Ping Identity, UnboundID, and
051 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
052 *   for proprietary functionality or for external specifications that are not
053 *   considered stable or mature enough to be guaranteed to work in an
054 *   interoperable way with other types of LDAP servers.
055 * </BLOCKQUOTE>
056 * <BR>
057 * The server can present zero or more per application processing time
058 * histogram monitor entries.  They can be retrieved using the
059 * {@link MonitorManager#getPerApplicationProcessingTimeHistogramMonitorEntries}
060 * method.  This entry provides specific methods for accessing information about
061 * processing times per bucket (e.g., the
062 * Alternately, this information may be accessed using the generic
063 * API.  See the {@link MonitorManager} class documentation for an example that
064 * demonstrates the use of the generic API for accessing monitor data.
065 */
066@NotMutable()
067@ThreadSafety(level= ThreadSafetyLevel.COMPLETELY_THREADSAFE)
068public final class PerApplicationProcessingTimeHistogramMonitorEntry
069       extends ProcessingTimeHistogramMonitorEntry
070{
071  /**
072   * The serial version UID for this serializable class.
073   */
074  private static final long serialVersionUID = 1467986373260986009L;
075
076
077
078  /**
079   * The structural object class used in processing time histogram monitor
080   * entries.
081   */
082  static final String PER_APPLICATION_PROCESSING_TIME_HISTOGRAM_MONITOR_OC =
083       "ds-per-application-processing-time-histogram-monitor-entry";
084
085
086
087  /**
088   * The name of the attribute that contains the name of the application to
089   * which this monitor entry applies.
090   */
091  private static final String ATTR_APPLICATION_NAME = "applicationName";
092
093
094
095  // The name of the application to which this monitor entry applies.
096  private final String applicationName;
097
098
099  /**
100   * Creates a new processing time histogram monitor entry from the provided
101   * entry.
102   *
103   * @param  entry  The entry to be parsed as a processing time histogram
104   *                monitor entry.  It must not be {@code null}.
105   */
106  public PerApplicationProcessingTimeHistogramMonitorEntry(final Entry entry)
107  {
108    super(entry);
109
110    applicationName = entry.getAttributeValue(ATTR_APPLICATION_NAME);
111  }
112
113
114
115  /**
116   * Returns the name of the application to which this monitor entry applies.
117   *
118   * @return  The name of the application to which this monitor entry applies,
119   *          or {@code null} if it was not included in the monitor entry.
120   */
121  public String getApplicationName()
122  {
123    return applicationName;
124  }
125
126
127
128  /**
129   * {@inheritDoc}
130   */
131  @Override()
132  public String getMonitorDisplayName()
133  {
134    return INFO_PER_APP_PROCESSING_TIME_MONITOR_DISPNAME.get();
135  }
136
137
138
139  /**
140   * {@inheritDoc}
141   */
142  @Override()
143  public String getMonitorDescription()
144  {
145    return INFO_PER_APP_PROCESSING_TIME_MONITOR_DESC.get();
146  }
147
148
149
150  /**
151   * {@inheritDoc}
152   */
153  @Override()
154  public Map<String,MonitorAttribute> getMonitorAttributes()
155  {
156    final Map<String,MonitorAttribute> superAttrs =
157         super.getMonitorAttributes();
158
159    final LinkedHashMap<String,MonitorAttribute> attrs = new LinkedHashMap<>(
160         StaticUtils.computeMapCapacity(superAttrs.size()+1));
161    attrs.putAll(superAttrs);
162
163    if (applicationName != null)
164    {
165      addMonitorAttribute(attrs,
166           ATTR_APPLICATION_NAME,
167           INFO_PER_APP_PROCESSING_TIME_DISPNAME_APP_NAME.get(),
168           INFO_PER_APP_PROCESSING_TIME_DESC_APP_NAME.get(),
169           applicationName);
170    }
171
172    return Collections.unmodifiableMap(attrs);
173  }
174}