61a5a2abf304db0f3e0f01485a9d27059e4c20db
[vpnservice.git] / bgpmanager / bgpmanager-impl / src / main / java / org / opendaylight / bgpmanager / oam / BgpAlarmBroadcaster.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 /**
12  * Created by echiapt on 7/27/2015.
13  */
14
15  import javax.management.*;
16
17  import org.slf4j.Logger;
18  import org.slf4j.LoggerFactory;
19
20  import java.util.ArrayList;
21
22 public class BgpAlarmBroadcaster extends NotificationBroadcasterSupport implements BgpAlarmBroadcasterMBean {
23     private static final Logger LOGGER = LoggerFactory.getLogger(BgpAlarmBroadcaster.class);
24     private long sequenceNumber;
25     public BgpAlarmBroadcaster () {
26         this.sequenceNumber = 1;
27     }
28
29     public void sendBgpAlarmInfo(String pfx, int code , int subcode) {
30         Notification n;
31         String alarmAddText, alarmSrc = "BGP";
32         BgpAlarmErrorCodes userAlarm;
33         ArrayList<String> arrayList = new ArrayList<String>();
34
35         userAlarm = BgpAlarmErrorCodes.checkErrorSubcode(subcode);
36         alarmAddText = "Peer=" + pfx;
37         arrayList.clear();
38         arrayList.add(userAlarm.getAlarmType());
39         arrayList.add(alarmAddText);
40         arrayList.add(alarmSrc);
41         n = new AttributeChangeNotification(this, sequenceNumber++, System.currentTimeMillis(),
42                                             "raise Alarm Object notified", "raiseAlarmObject",
43                                             "ArrayList", "", arrayList);
44         sendNotification(n);
45         LOGGER.info("BGP: Alarm :"+ userAlarm.getAlarmType() + " has been posted.");
46         return;
47     }
48 }