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 010 * docs/licenses/cddl.txt 011 * or http://www.opensource.org/licenses/cddl1.php. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * docs/licenses/cddl.txt. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2014 UnboundID Corp. 026 */ 027 package com.unboundid.directory.sdk.common.types; 028 029 import java.util.HashMap; 030 import java.util.Map; 031 032 /** 033 * Enumerates severity types for alarm conditions from least severe to most 034 * severe. 035 */ 036 public enum AlarmSeverity { 037 /** 038 * Indicates that an alarm has been cleared and the alarming condition 039 * has returned to normal. 040 * <p/> 041 * It should be noted that the x733 specification does not define a normal 042 * severity but rather lack of an alarm indicates normality. We use this 043 * severity for normalized alarms that are retained in the alarm backend as 044 * well as for indicating to the SNMP alert handler that an alarm has been 045 * cleared, either because its condition has abated or if the server is 046 * configured to send interim clear traps between severity changes. The 047 * latter use case does not imply that an alarm has returned to normal. 048 */ 049 NORMAL, 050 051 /** 052 * Indicates the existence of a potential or impending service 053 * affecting fault, before any significant effects have been felt. 054 * Action should be taken to further diagnose (if necessary) and 055 * correct the problem in order to prevent it from becoming a more 056 * serious service affecting fault. 057 */ 058 WARNING, 059 060 /** 061 * Indicates the existence of a non-service affecting fault condition 062 * and that corrective action should be taken in order to prevent a 063 * more serious (for example, service affecting) fault. Such a severity 064 * can be reported, for example, when the detected alarm condition is 065 * not currently degrading the capacity of the managed object. 066 */ 067 MINOR, 068 069 /** 070 * Indicates that a service affecting condition has developed and an 071 * urgent corrective action is required. Such a severity can be 072 * reported, for example, when there is a severe degradation in the 073 * capability of the managed object and its full capability must be 074 * restored. 075 */ 076 MAJOR, 077 078 /** 079 * Indicates that a service affecting condition has occurred and an 080 * immediate corrective action is required. Such a severity can be 081 * reported, for example, when a managed object becomes totally out 082 * of service and its capability must be restored. 083 */ 084 CRITICAL; 085 086 private static Map<String, AlarmSeverity> displayNameLookup; 087 static { 088 displayNameLookup = new HashMap<String, AlarmSeverity>(); 089 for (final AlarmSeverity severity : AlarmSeverity.values()) { 090 displayNameLookup.put( 091 severity.name().toLowerCase(), severity); 092 } 093 } 094 095 /** 096 * Returns the human-friendly name of this severity. 097 * 098 * @return name of this severity. 099 */ 100 public String getDisplayName() { 101 return name().toLowerCase(); 102 } 103 104 /** 105 * Get the alarm severity for the given display name. 106 * 107 * @param displayName Display name for which alarm severity is requested. 108 * @return The alarm severity. 109 */ 110 public static AlarmSeverity forDisplayName(final String displayName) { 111 return displayNameLookup.get(displayName.toLowerCase()); 112 } 113 }