be3349542e426355924afc3f0058982e1bf95160
[vpnservice.git] / bgpmanager / bgpmanager-impl / src / main / java / org / opendaylight / bgpmanager / oam / BgpAlarmErrorCodes.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.bgpmanager.oam;
10
11 import java.util.HashMap;
12 import java.util.Map;
13
14 /**
15  * Created by echiapt on 7/27/2015.
16  */
17 public enum BgpAlarmErrorCodes {
18     CEASE_MAX_PREFIX            (1, "BgpMaxPrefixesFailure"),
19     CEASE_PEER_UNCONFIG         (3, "BgpPeerUnconfigFailure") ,
20     CEASE_CONNECT_REJECT        (5, "BgpConnRejectFailure"),
21     CEASE_COLLISION_RESOLUTION  (7, "BgpCollisionResolutionFailure"),
22     CEASE_OUT_OF_RESOURCE       (8, "BgpOutOfResourcesFailure"),
23     ERROR_IGNORE                (-1,"UnknownErr");
24
25     private final int error;
26     private final String alarmType;
27
28     BgpAlarmErrorCodes(int error, String alarmType) {
29         this.error = error;
30         this.alarmType = alarmType;
31     }
32
33     private static final Map<Integer, BgpAlarmErrorCodes> intToTypeMap = new HashMap<Integer, BgpAlarmErrorCodes>();
34     static {
35         for (BgpAlarmErrorCodes type : BgpAlarmErrorCodes.values()) {
36             intToTypeMap.put(type.error, type);
37         }
38
39     }
40
41     public String getAlarmType() {
42         return this.alarmType;
43     }
44
45     public static BgpAlarmErrorCodes checkErrorSubcode(int i) {
46         BgpAlarmErrorCodes type = intToTypeMap.get(Integer.valueOf(i));
47         if (type == null)
48             return BgpAlarmErrorCodes.ERROR_IGNORE;
49         return type;
50     }
51 }