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