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