001/*
002 * Copyright 2014-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;
022
023
024
025import java.util.Date;
026
027import com.unboundid.ldap.sdk.Entry;
028import com.unboundid.ldap.sdk.ReadOnlyEntry;
029import com.unboundid.util.NotMutable;
030import com.unboundid.util.ThreadSafety;
031import com.unboundid.util.ThreadSafetyLevel;
032
033
034
035/**
036 * This class provides a data structure for representing an administrative entry
037 * as exposed by the alarms backend in the Directory Server.  Alarm entries
038 * provide information about potential ongoing or resolved conditions within the
039 * server.
040 * <BR>
041 * <BLOCKQUOTE>
042 *   <B>NOTE:</B>  This class, and other classes within the
043 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
044 *   supported for use against Ping Identity, UnboundID, and
045 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
046 *   for proprietary functionality or for external specifications that are not
047 *   considered stable or mature enough to be guaranteed to work in an
048 *   interoperable way with other types of LDAP servers.
049 * </BLOCKQUOTE>
050 */
051@NotMutable()
052@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
053public final class AlarmEntry
054       extends ReadOnlyEntry
055{
056  /**
057   * The serial version UID for this serializable class.
058   */
059  private static final long serialVersionUID = -2481622467368820030L;
060
061
062
063  // The current severity for this alarm entry.
064  private final AlarmSeverity currentSeverity;
065
066  // The previous severity for this alarm entry.
067  private final AlarmSeverity previousSeverity;
068
069  // The last time the alarm severity was set to critical.
070  private final Date lastCriticalTime;
071
072  // The last time the alarm severity was set to indeterminate.
073  private final Date lastIndeterminateTime;
074
075  // The last time the alarm severity was set to major.
076  private final Date lastMajorTime;
077
078  // The last time the alarm severity was set to minor.
079  private final Date lastMinorTime;
080
081  // The last time the alarm severity was set to normal.
082  private final Date lastNormalTime;
083
084  // The last time the alarm severity was set to warning.
085  private final Date lastWarningTime;
086
087  // The start time for this alarm entry.
088  private final Date startTime;
089
090  // The X.733 event type for the alarm.
091  private final Integer eventType;
092
093  // The X.733 probable cause for the alarm.
094  private final Integer probableCause;
095
096  // The total length of time in milliseconds spent at the critical severity.
097  private final Long totalDurationCriticalMillis;
098
099  // The total length of time in milliseconds spent at the indeterminate
100  // severity.
101  private final Long totalDurationIndeterminateMillis;
102
103  // The total length of time in milliseconds spent at the major severity.
104  private final Long totalDurationMajorMillis;
105
106  // The total length of time in milliseconds spent at the minor severity.
107  private final Long totalDurationMinorMillis;
108
109  // The total length of time in milliseconds spent at the normal severity.
110  private final Long totalDurationNormalMillis;
111
112  // The total length of time in milliseconds spent at the warning severity.
113  private final Long totalDurationWarningMillis;
114
115  // The additional text for this alarm entry.
116  private final String additionalText;
117
118  // The condition for this alarm entry.
119  private final String condition;
120
121  // The details for this alarm entry.
122  private final String details;
123
124  // The identifier for this alarm entry.
125  private final String id;
126
127  // The specific resource for this alarm entry.
128  private final String specificResource;
129
130  // The specific resource type for this alarm entry.
131  private final String specificResourceType;
132
133
134
135  /**
136   * Creates a new alarm entry from the provided entry.
137   *
138   * @param  entry  The entry to use to create this alarm entry.
139   */
140  public AlarmEntry(final Entry entry)
141  {
142    super(entry);
143
144    id = entry.getAttributeValue("ds-alarm-id");
145    condition = entry.getAttributeValue("ds-alarm-condition");
146    startTime = entry.getAttributeValueAsDate("ds-alarm-start-time");
147    specificResource = entry.getAttributeValue("ds-alarm-specific-resource");
148    specificResourceType =
149         entry.getAttributeValue("ds-alarm-specific-resource-type");
150    details = entry.getAttributeValue("ds-alarm-details");
151    additionalText = entry.getAttributeValue("ds-alarm-additional-text");
152    lastNormalTime = entry.getAttributeValueAsDate("ds-alarm-normal-last-time");
153    lastWarningTime =
154         entry.getAttributeValueAsDate("ds-alarm-warning-last-time");
155    lastMinorTime = entry.getAttributeValueAsDate("ds-alarm-minor-last-time");
156    lastMajorTime = entry.getAttributeValueAsDate("ds-alarm-major-last-time");
157    lastCriticalTime =
158         entry.getAttributeValueAsDate("ds-alarm-critical-last-time");
159    lastIndeterminateTime =
160         entry.getAttributeValueAsDate("ds-alarm-indeterminate-last-time");
161    totalDurationNormalMillis =
162         entry.getAttributeValueAsLong("ds-alarm-normal-total-duration-millis");
163    totalDurationWarningMillis = entry.getAttributeValueAsLong(
164         "ds-alarm-warning-total-duration-millis");
165    totalDurationMinorMillis =
166         entry.getAttributeValueAsLong("ds-alarm-minor-total-duration-millis");
167    totalDurationMajorMillis =
168         entry.getAttributeValueAsLong("ds-alarm-major-total-duration-millis");
169    totalDurationCriticalMillis = entry.getAttributeValueAsLong(
170         "ds-alarm-critical-total-duration-millis");
171    totalDurationIndeterminateMillis = entry.getAttributeValueAsLong(
172         "ds-alarm-indeterminate-total-duration-millis");
173    eventType = entry.getAttributeValueAsInteger("ds-alarm-event-type");
174    probableCause = entry.getAttributeValueAsInteger("ds-alarm-probable-cause");
175
176    final String currentSeverityStr =
177         entry.getAttributeValue("ds-alarm-severity");
178    if (currentSeverityStr == null)
179    {
180      currentSeverity = null;
181    }
182    else
183    {
184      currentSeverity = AlarmSeverity.forName(currentSeverityStr);
185    }
186
187    final String previousSeverityStr =
188         entry.getAttributeValue("ds-alarm-previous-severity");
189    if (previousSeverityStr == null)
190    {
191      previousSeverity = null;
192    }
193    else
194    {
195      previousSeverity = AlarmSeverity.forName(previousSeverityStr);
196    }
197  }
198
199
200
201  /**
202   * Retrieves the identifier for the alarm.
203   *
204   * @return  The identifier for the alarm, or {@code null} if it was not
205   *          included in the alarm entry.
206   */
207  public String getAlarmID()
208  {
209    return id;
210  }
211
212
213
214  /**
215   * Retrieves the condition for the alarm.
216   *
217   * @return  The condition for the alarm, or {@code null} if it was not
218   *          included in the alarm entry.
219   */
220  public String getAlarmCondition()
221  {
222    return condition;
223  }
224
225
226
227  /**
228   * Retrieves the current severity for the alarm.
229   *
230   * @return  The current severity for the alarm, or {@code null} if it was not
231   *          included in the alarm entry.
232   */
233  public AlarmSeverity getCurrentAlarmSeverity()
234  {
235    return currentSeverity;
236  }
237
238
239
240  /**
241   * Retrieves the previous severity for the alarm.
242   *
243   * @return  The previous severity for the alarm, or {@code null} if it was not
244   *          included in the alarm entry.
245   */
246  public AlarmSeverity getPreviousAlarmSeverity()
247  {
248    return previousSeverity;
249  }
250
251
252
253  /**
254   * Retrieves the start time for the alarm.
255   *
256   * @return  The start time for the alarm, or {@code null} if it was not
257   *          included in the alarm entry.
258   */
259  public Date getAlarmStartTime()
260  {
261    return startTime;
262  }
263
264
265
266  /**
267   * Retrieves the specific resource for the alarm, if any.
268   *
269   * @return  The specific resource for the alarm, or {@code null} if it was not
270   *          included in the alarm entry.
271   */
272  public String getAlarmSpecificResource()
273  {
274    return specificResource;
275  }
276
277
278
279  /**
280   * Retrieves the specific resource type for the alarm, if any.
281   *
282   * @return  The specific resource type for the alarm, or {@code null} if it
283   *          was not included in the alarm entry.
284   */
285  public String getAlarmSpecificResourceType()
286  {
287    return specificResourceType;
288  }
289
290
291
292  /**
293   * Retrieves the details message for the alarm, if any.
294   *
295   * @return  The details message for the alarm, or {@code null} if it was not
296   *          included in the alarm entry.
297   */
298  public String getAlarmDetails()
299  {
300    return details;
301  }
302
303
304
305  /**
306   * Retrieves the additional text for the alarm, if any.
307   *
308   * @return  The additional text for the alarm, or {@code null} if it was not
309   *          included in the alarm entry.
310   */
311  public String getAlarmAdditionalText()
312  {
313    return additionalText;
314  }
315
316
317
318  /**
319   * Retrieves the time that the alarm last transitioned to a normal severity,
320   * if available.
321   *
322   * @return  The time that the alarm last transitioned to a normal severity, or
323   *          {@code null} if it was not included in the alarm entry.
324   */
325  public Date getAlarmLastNormalTime()
326  {
327    return lastNormalTime;
328  }
329
330
331
332  /**
333   * Retrieves the time that the alarm last transitioned to a warning severity,
334   * if available.
335   *
336   * @return  The time that the alarm last transitioned to a warning severity,
337   *          or {@code null} if it was not included in the alarm entry.
338   */
339  public Date getAlarmLastWarningTime()
340  {
341    return lastWarningTime;
342  }
343
344
345
346  /**
347   * Retrieves the time that the alarm last transitioned to a minor severity,
348   * if available.
349   *
350   * @return  The time that the alarm last transitioned to a minor severity, or
351   *          {@code null} if it was not included in the alarm entry.
352   */
353  public Date getAlarmLastMinorTime()
354  {
355    return lastMinorTime;
356  }
357
358
359
360  /**
361   * Retrieves the time that the alarm last transitioned to a major severity,
362   * if available.
363   *
364   * @return  The time that the alarm last transitioned to a major severity, or
365   *          {@code null} if it was not included in the alarm entry.
366   */
367  public Date getAlarmLastMajorTime()
368  {
369    return lastMajorTime;
370  }
371
372
373
374  /**
375   * Retrieves the time that the alarm last transitioned to a critical severity,
376   * if available.
377   *
378   * @return  The time that the alarm last transitioned to a critical severity,
379   *          or {@code null} if it was not included in the alarm entry.
380   */
381  public Date getAlarmLastCriticalTime()
382  {
383    return lastCriticalTime;
384  }
385
386
387
388  /**
389   * Retrieves the time that the alarm last transitioned to an indeterminate
390   * severity, if available.
391   *
392   * @return  The time that the alarm last transitioned to an indeterminate
393   *          severity, or {@code null} if it was not included in the alarm
394   *          entry.
395   */
396  public Date getAlarmLastIndeterminateTime()
397  {
398    return lastIndeterminateTime;
399  }
400
401
402
403  /**
404   * Retrieves the length of time in milliseconds the alarm has spent at the
405   * normal severity, if available.
406   *
407   * @return  The length of time in milliseconds the alarm has spent at the
408   *          normal severity, or {@code null} if it was not included in the
409   *          alarm entry.
410   */
411  public Long getAlarmTotalDurationNormalMillis()
412  {
413    return totalDurationNormalMillis;
414  }
415
416
417
418  /**
419   * Retrieves the length of time in milliseconds the alarm has spent at the
420   * warning severity, if available.
421   *
422   * @return  The length of time in milliseconds the alarm has spent at the
423   *          warning severity, or {@code null} if it was not included in the
424   *          alarm entry.
425   */
426  public Long getAlarmTotalDurationWarningMillis()
427  {
428    return totalDurationWarningMillis;
429  }
430
431
432
433  /**
434   * Retrieves the length of time in milliseconds the alarm has spent at the
435   * minor severity, if available.
436   *
437   * @return  The length of time in milliseconds the alarm has spent at the
438   *          minor severity, or {@code null} if it was not included in the
439   *          alarm entry.
440   */
441  public Long getAlarmTotalDurationMinorMillis()
442  {
443    return totalDurationMinorMillis;
444  }
445
446
447
448  /**
449   * Retrieves the length of time in milliseconds the alarm has spent at the
450   * major severity, if available.
451   *
452   * @return  The length of time in milliseconds the alarm has spent at the
453   *          major severity, or {@code null} if it was not included in the
454   *          alarm entry.
455   */
456  public Long getAlarmTotalDurationMajorMillis()
457  {
458    return totalDurationMajorMillis;
459  }
460
461
462
463  /**
464   * Retrieves the length of time in milliseconds the alarm has spent at the
465   * critical severity, if available.
466   *
467   * @return  The length of time in milliseconds the alarm has spent at the
468   *          critical severity, or {@code null} if it was not included in the
469   *          alarm entry.
470   */
471  public Long getAlarmTotalDurationCriticalMillis()
472  {
473    return totalDurationCriticalMillis;
474  }
475
476
477
478  /**
479   * Retrieves the length of time in milliseconds the alarm has spent at the
480   * indeterminate severity, if available.
481   *
482   * @return  The length of time in milliseconds the alarm has spent at the
483   *          indeterminate severity, or {@code null} if it was not included in
484   *          the alarm entry.
485   */
486  public Long getAlarmTotalDurationIndeterminateMillis()
487  {
488    return totalDurationIndeterminateMillis;
489  }
490
491
492
493  /**
494   * Retrieves the X.733 event type for the alarm, if available.
495   *
496   * @return  The X.733 event type for the alarm, or {@code null} if it was not
497   *          included in the alarm entry.
498   */
499  public Integer getAlarmEventType()
500  {
501    return eventType;
502  }
503
504
505
506  /**
507   * Retrieves the X.733 probable cause for the alarm, if available.
508   *
509   * @return  The X.733 probable cause for the alarm, or {@code null} if it was
510   *          not included in the alarm entry.
511   */
512  public Integer getAlarmProbableCause()
513  {
514    return probableCause;
515  }
516}