blob: 000bfc960e91a2385a62e03182cade2f20f6c1f5 [file] [log] [blame]
kmcpeake4fe18c82015-11-17 20:07:39 +00001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
kmcpeake4fe18c82015-11-17 20:07:39 +00003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.incubator.net.faultmanagement.alarm;
17
kmcpeakeb172d5f2015-12-10 11:30:43 +000018import java.util.Set;
kmcpeake4fe18c82015-11-17 20:07:39 +000019import org.onosproject.event.AbstractEvent;
kmcpeakeb172d5f2015-12-10 11:30:43 +000020import org.onosproject.net.DeviceId;
kmcpeake4fe18c82015-11-17 20:07:39 +000021
22/**
kmcpeakeb172d5f2015-12-10 11:30:43 +000023 * Entity that represents Alarm events. Note: although the event will itself have a time, consumers may be more
24 * interested in the times embedded in the alarms themselves.
25 *
kmcpeake4fe18c82015-11-17 20:07:39 +000026 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000027public class AlarmEvent extends AbstractEvent<AlarmEvent.Type, Set<Alarm>> {
kmcpeake4fe18c82015-11-17 20:07:39 +000028
kmcpeakeb172d5f2015-12-10 11:30:43 +000029 private final DeviceId deviceRefreshed;
kmcpeake4fe18c82015-11-17 20:07:39 +000030
31 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000032 * Creates an event due to one or more notification.
kmcpeake4fe18c82015-11-17 20:07:39 +000033 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000034 * @param alarms the set one or more of alarms.
kmcpeake4fe18c82015-11-17 20:07:39 +000035 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000036 public AlarmEvent(Set<Alarm> alarms) {
37 super(Type.NOTIFICATION, alarms);
38 deviceRefreshed = null;
kmcpeake4fe18c82015-11-17 20:07:39 +000039 }
40
41 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000042 * Creates an event due to alarm discovery for a device.
kmcpeake4fe18c82015-11-17 20:07:39 +000043 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000044 * @param alarms the set of alarms.
45 * @param deviceRefreshed if of refreshed device, populated after a de-discovery
kmcpeake4fe18c82015-11-17 20:07:39 +000046 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000047 public AlarmEvent(Set<Alarm> alarms,
48 DeviceId deviceRefreshed) {
49 super(Type.DEVICE_DISCOVERY, alarms);
50 this.deviceRefreshed = deviceRefreshed;
51
kmcpeake4fe18c82015-11-17 20:07:39 +000052 }
53
54 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000055 * Gets which device was refreshed.
56 *
57 * @return the refreshed device, or null if event related to a asynchronous notification(s)
58 */
59 public DeviceId getDeviceRefreshed() {
60 return deviceRefreshed;
61 }
62
63 /**
64 * Type of alarm event.
kmcpeake4fe18c82015-11-17 20:07:39 +000065 */
66 public enum Type {
kmcpeake4fe18c82015-11-17 20:07:39 +000067
68 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000069 * Individual alarm(s) updated.
kmcpeake4fe18c82015-11-17 20:07:39 +000070 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000071 NOTIFICATION,
72 /**
73 * Alarm set updated for a given device.
74 */
75 DEVICE_DISCOVERY,
kmcpeake4fe18c82015-11-17 20:07:39 +000076 }
77
kmcpeake4fe18c82015-11-17 20:07:39 +000078}