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