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