001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2009 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2016 ForgeRock AS. 016 */ 017package org.opends.guitools.controlpanel.datamodel; 018 019import static org.opends.messages.AdminToolMessages.*; 020 021import org.forgerock.i18n.LocalizableMessage; 022import org.opends.server.monitors.TraditionalWorkQueueMonitor; 023import org.opends.server.util.ServerConstants; 024 025/** 026 * The enumeration containing the different monitoring attributes that can be 027 * displayed in the monitoring panels. 028 */ 029public enum BasicMonitoringAttributes implements MonitoringAttributes 030{ 031 /** Start Date. */ 032 START_DATE(LocalizableMessage.EMPTY, ServerConstants.ATTR_START_TIME), 033 /** Current Date. */ 034 CURRENT_DATE(LocalizableMessage.EMPTY, ServerConstants.ATTR_CURRENT_TIME), 035 /** Current Connections. */ 036 CURRENT_CONNECTIONS(LocalizableMessage.EMPTY, ServerConstants.ATTR_CURRENT_CONNS), 037 /** Maximum Connections. */ 038 MAX_CONNECTIONS(LocalizableMessage.EMPTY, ServerConstants.ATTR_MAX_CONNS), 039 /** Total Connections. */ 040 TOTAL_CONNECTIONS(LocalizableMessage.EMPTY, ServerConstants.ATTR_TOTAL_CONNS), 041 /** Average Request Backlog. */ 042 AVERAGE_REQUEST_BACKLOG(INFO_CTRL_PANEL_AVERAGE_REQUEST_BACKLOG.get(), 043 TraditionalWorkQueueMonitor.ATTR_AVERAGE_BACKLOG), 044 /** Max Request Backlog. */ 045 MAX_REQUEST_BACKLOG(INFO_CTRL_PANEL_MAX_REQUEST_BACKLOG.get(), 046 TraditionalWorkQueueMonitor.ATTR_MAX_BACKLOG), 047 /** Current Request Backlog. */ 048 CURRENT_REQUEST_BACKLOG(INFO_CTRL_PANEL_CURRENT_REQUEST_BACKLOG.get(), 049 TraditionalWorkQueueMonitor.ATTR_CURRENT_BACKLOG), 050 /** Requests submitted. */ 051 REQUESTS_SUBMITTED(INFO_CTRL_PANEL_REQUESTS_SUBMITTED.get(), 052 TraditionalWorkQueueMonitor.ATTR_OPS_SUBMITTED), 053 /** Requests rejected. */ 054 REQUESTS_REJECTED(INFO_CTRL_PANEL_REQUESTS_REJECTED.get(), 055 TraditionalWorkQueueMonitor.ATTR_OPS_REJECTED_QUEUE_FULL), 056 /** Entry cache Hits. */ 057 ENTRY_CACHE_HITS(INFO_CTRL_PANEL_ENTRY_CACHE_HITS.get(), 058 "entryCacheHits"), 059 /** Current entry cache count. */ 060 CURRENT_ENTRY_CACHE_COUNT(INFO_CTRL_PANEL_CURRENT_ENTRY_CACHE_COUNT.get(), 061 "currentEntryCacheCount"), 062 /** Entry cache tries. */ 063 ENTRY_CACHE_TRIES(INFO_CTRL_PANEL_ENTRY_CACHE_TRIES.get(), 064 "entryCacheTries"), 065 /** Entry cache hit ratio. */ 066 ENTRY_CACHE_HIT_RATIO(INFO_CTRL_PANEL_ENTRY_CACHE_HIT_RATIO.get(), 067 "entryCacheHitRatio"), 068 /** Entry cache current size. */ 069 CURRENT_ENTRY_CACHE_SIZE(INFO_CTRL_PANEL_CURRENT_ENTRY_CACHE_SIZE.get(), 070 "currentEntryCacheSize"), 071 /** Entry cache max size. */ 072 MAX_ENTRY_CACHE_SIZE(INFO_CTRL_PANEL_MAX_ENTRY_CACHE_SIZE.get(), 073 "maxEntryCacheSize"), 074 /** Entry cache max count. */ 075 MAX_ENTRY_CACHE_COUNT(INFO_CTRL_PANEL_MAX_ENTRY_CACHE_COUNT.get(), 076 "maxEntryCacheCount"), 077 /** Available CPUs. */ 078 AVAILABLE_CPUS(INFO_CTRL_PANEL_AVAILABLE_CPUS.get(), 079 "availableCPUs"), 080 /** System Name. */ 081 SYSTEM_NAME(INFO_CTRL_PANEL_SYSTEM_NAME.get(), 082 "systemName"), 083 /** Operating System. */ 084 OPERATING_SYSTEM(INFO_CTRL_PANEL_OPERATING_SYSTEM.get(), 085 "operatingSystem"), 086 /** Free used memory. */ 087 FREE_USED_MEMORY(INFO_CTRL_PANEL_FREE_USED_MEMORY.get(), 088 "freeUsedMemory"), 089 /** Max memory. */ 090 MAX_MEMORY(INFO_CTRL_PANEL_MAX_MEMORY.get(), 091 "maxMemory"), 092 /** Used memory. */ 093 USED_MEMORY(INFO_CTRL_PANEL_USED_MEMORY.get(), 094 "usedMemory"), 095 /** Class path. */ 096 CLASS_PATH(INFO_CTRL_PANEL_CLASS_PATH.get(), 097 "classPath"), 098 /** Java Vendor. */ 099 JAVA_VENDOR(INFO_CTRL_PANEL_JAVA_VENDOR.get(), 100 "javaVendor"), 101 /** JVM Vendor. */ 102 JVM_VENDOR(INFO_CTRL_PANEL_JVM_VENDOR.get(), 103 "javaVendor"), 104 /** Java Version. */ 105 JAVA_VERSION(INFO_CTRL_PANEL_JAVA_VERSION.get(), 106 "javaVersion"), 107 /** JVM Version. */ 108 JVM_VERSION(INFO_CTRL_PANEL_JVM_VERSION.get(), 109 "jvmVersion"), 110 /** JVM Architecture. */ 111 JVM_ARCHITECTURE(INFO_CTRL_PANEL_JVM_ARCHITECTURE.get(), 112 "jvmArchitecture"), 113 /** JVM Arguments. */ 114 JVM_ARGUMENTS(INFO_CTRL_PANEL_JVM_ARGUMENTS.get(), 115 "jvmArguments"), 116 /** Add Request. */ 117 ADD_REQUESTS(INFO_CTRL_PANEL_ADD_REQUESTS_LABEL.get(), 118 "addRequests"), 119 /** Add Responses. */ 120 ADD_RESPONSES(INFO_CTRL_PANEL_ADD_RESPONSES_LABEL.get(), 121 "addResponses"), 122 /** Bind Request. */ 123 BIND_REQUESTS(INFO_CTRL_PANEL_BIND_REQUESTS_LABEL.get(), 124 "bindRequests"), 125 /** Bind Responses. */ 126 BIND_RESPONSES(INFO_CTRL_PANEL_BIND_RESPONSES_LABEL.get(), 127 "bindResponses"), 128 /** Compare Requests. */ 129 COMPARE_REQUESTS(INFO_CTRL_PANEL_COMPARE_REQUESTS_LABEL.get(), 130 "compareRequests"), 131 /** Compare Responses. */ 132 COMPARE_RESPONSES(INFO_CTRL_PANEL_COMPARE_RESPONSES_LABEL.get(), 133 "compareResponses"), 134 /** Delete Request. */ 135 DELETE_REQUESTS(INFO_CTRL_PANEL_DELETE_REQUESTS_LABEL.get(), 136 "deleteRequests"), 137 /** Delete Responses. */ 138 DELETE_RESPONSES(INFO_CTRL_PANEL_DELETE_RESPONSES_LABEL.get(), 139 "deleteResponses"), 140 /** Extended Request. */ 141 EXTENDED_REQUESTS(INFO_CTRL_PANEL_EXTENDED_REQUESTS_LABEL.get(), 142 "extendedRequests"), 143 /** Extended Responses. */ 144 EXTENDED_RESPONSES(INFO_CTRL_PANEL_EXTENDED_RESPONSES_LABEL.get(), 145 "extendedResponses"), 146 /** Modify DN Request. */ 147 MOD_DN_REQUESTS(INFO_CTRL_PANEL_MOD_DN_REQUESTS_LABEL.get(), 148 "modifyDNRequests"), 149 /** Modify DN Responses. */ 150 MOD_DN_RESPONSES(INFO_CTRL_PANEL_MOD_DN_RESPONSES_LABEL.get(), 151 "modifyDNResponses"), 152 /** Modify Request. */ 153 MOD_REQUESTS(INFO_CTRL_PANEL_MOD_REQUESTS_LABEL.get(), 154 "modifyRequests"), 155 /** Modify Responses. */ 156 MOD_RESPONSES(INFO_CTRL_PANEL_MOD_RESPONSES_LABEL.get(), 157 "modifyResponses"), 158 /** Search Request. */ 159 SEARCH_REQUESTS(INFO_CTRL_PANEL_SEARCH_REQUESTS_LABEL.get(), 160 "searchRequests"), 161 /** Searches Done. */ 162 SEARCH_DONE(INFO_CTRL_PANEL_SEARCH_DONE_LABEL.get(), 163 "searchResultsDone"), 164 /** Unbind Request. */ 165 UNBIND_REQUESTS(INFO_CTRL_PANEL_UNBIND_REQUESTS_LABEL.get(), 166 "unbindRequests"),; 167 168 static 169 { 170 // Do this here, since static references do not work if this is done 171 // in the constructor. 172 for (BasicMonitoringAttributes attr : BasicMonitoringAttributes.values()) 173 { 174 attr.calculateProperties(); 175 } 176 } 177 178 private final LocalizableMessage msg; 179 private final String attributeName; 180 private boolean isNumeric; 181 private boolean isGMTDate; 182 private boolean isValueInBytes; 183 private boolean canHaveAverage; 184 private boolean isTime; 185 186 private BasicMonitoringAttributes(LocalizableMessage msg, String attributeName) 187 { 188 this.msg = msg; 189 this.attributeName = attributeName; 190 } 191 192 @Override 193 public LocalizableMessage getMessage() 194 { 195 return msg; 196 } 197 198 @Override 199 public String getAttributeName() 200 { 201 return attributeName; 202 } 203 204 @Override 205 public boolean isNumeric() 206 { 207 return isNumeric; 208 } 209 210 @Override 211 public boolean isTime() 212 { 213 return isTime; 214 } 215 216 @Override 217 public boolean isGMTDate() 218 { 219 return isGMTDate; 220 } 221 222 @Override 223 public boolean isValueInBytes() 224 { 225 return isValueInBytes; 226 } 227 228 @Override 229 public boolean canHaveAverage() 230 { 231 return canHaveAverage; 232 } 233 234 @Override 235 public boolean isNumericDate() 236 { 237 return false; 238 } 239 240 private void calculateProperties() 241 { 242 canHaveAverage = attributeName.endsWith("total-count") || 243 attributeName.endsWith("Requests") || 244 attributeName.endsWith("Responses") || 245 this == SEARCH_DONE; 246 247 isGMTDate = this == START_DATE || 248 this == CURRENT_DATE; 249 250 isValueInBytes = this == FREE_USED_MEMORY || 251 this == MAX_MEMORY || 252 this == USED_MEMORY; 253 254 isTime = attributeName.contains("time"); 255 256 isNumeric = 257 !isGMTDate() && 258 this != SYSTEM_NAME && 259 this != OPERATING_SYSTEM && 260 this != CLASS_PATH && 261 this != JAVA_VENDOR && 262 this != JVM_VENDOR && 263 this != JAVA_VERSION && 264 this != JVM_VERSION && 265 this != JVM_ARCHITECTURE && 266 this != JVM_ARGUMENTS; 267 } 268}