kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 3 | * |
| 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 | */ |
| 16 | package org.onosproject.incubator.net.faultmanagement.alarm; |
| 17 | |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 18 | import java.util.Set; |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 19 | import org.onosproject.event.AbstractEvent; |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 20 | import org.onosproject.net.DeviceId; |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 21 | |
| 22 | /** |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 23 | * 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 | * |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 26 | */ |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 27 | public class AlarmEvent extends AbstractEvent<AlarmEvent.Type, Set<Alarm>> { |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 28 | |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 29 | private final DeviceId deviceRefreshed; |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 30 | |
| 31 | /** |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 32 | * Creates an event due to one or more notification. |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 33 | * |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 34 | * @param alarms the set one or more of alarms. |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 35 | */ |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 36 | public AlarmEvent(Set<Alarm> alarms) { |
| 37 | super(Type.NOTIFICATION, alarms); |
| 38 | deviceRefreshed = null; |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | /** |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 42 | * Creates an event due to alarm discovery for a device. |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 43 | * |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 44 | * @param alarms the set of alarms. |
| 45 | * @param deviceRefreshed if of refreshed device, populated after a de-discovery |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 46 | */ |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 47 | public AlarmEvent(Set<Alarm> alarms, |
| 48 | DeviceId deviceRefreshed) { |
| 49 | super(Type.DEVICE_DISCOVERY, alarms); |
| 50 | this.deviceRefreshed = deviceRefreshed; |
| 51 | |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /** |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 55 | * 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. |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 65 | */ |
| 66 | public enum Type { |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 67 | |
| 68 | /** |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 69 | * Individual alarm(s) updated. |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 70 | */ |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame^] | 71 | NOTIFICATION, |
| 72 | /** |
| 73 | * Alarm set updated for a given device. |
| 74 | */ |
| 75 | DEVICE_DISCOVERY, |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 76 | } |
| 77 | |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 78 | } |