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