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