blob: 7be4d806ae81bc4c1c25f5a4e4425964926d1315 [file] [log] [blame]
kmcpeake4fe18c82015-11-17 20:07:39 +00001/*
Thomas Vachuska52f2cd12018-11-08 21:20:04 -08002 * Copyright 2018-present Open Networking Foundation
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 */
Thomas Vachuska52f2cd12018-11-08 21:20:04 -080016package org.onosproject.alarm;
kmcpeake4fe18c82015-11-17 20:07:39 +000017
Andrea Campanella8e94b0c2016-04-12 13:58:07 -070018import org.onosproject.event.ListenerService;
kmcpeake4fe18c82015-11-17 20:07:39 +000019import org.onosproject.net.ConnectPoint;
20import org.onosproject.net.DeviceId;
21
Andrea Campanella8e94b0c2016-04-12 13:58:07 -070022import java.util.Map;
23import java.util.Set;
Andrea Campanella17f9ab62017-01-24 14:57:34 -080024import java.util.stream.Collectors;
Andrea Campanella8e94b0c2016-04-12 13:58:07 -070025
kmcpeake4fe18c82015-11-17 20:07:39 +000026/**
kmcpeakeb172d5f2015-12-10 11:30:43 +000027 * Service for interacting with the alarm handling of devices. Unless stated otherwise, getter methods
28 * return active AND recently-cleared alarms.
kmcpeake4fe18c82015-11-17 20:07:39 +000029 */
Andrea Campanella8e94b0c2016-04-12 13:58:07 -070030public interface AlarmService extends ListenerService<AlarmEvent, AlarmListener> {
kmcpeake4fe18c82015-11-17 20:07:39 +000031
32 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000033 * Update book-keeping (ie administrative) fields for the alarm matching the specified identifier.
kmcpeake4fe18c82015-11-17 20:07:39 +000034 *
Andrea Campanella8e94b0c2016-04-12 13:58:07 -070035 * @param id alarm identifier
Laszlo Papp85f0ace2018-06-15 13:09:20 +010036 * @param clear true if the alarm has to be cleared
Andrea Campanella65f9eb92017-05-02 11:36:14 -070037 * @param isAcknowledged new acknowledged state
38 * @param assignedUser new assigned user, null clear
39 * @return updated alarm (including any recent device-derived changes)
40 */
41 Alarm updateBookkeepingFields(AlarmId id, boolean clear, boolean isAcknowledged, String assignedUser);
42
43 /**
44 * Remove an alarm from ONOS.
45 *
46 * @param id alarm
47 */
48 void remove(AlarmId id);
49
50 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000051 * Returns summary of alarms on a given device.
kmcpeake4fe18c82015-11-17 20:07:39 +000052 *
53 * @param deviceId the device
kmcpeakeb172d5f2015-12-10 11:30:43 +000054 * @return map of severity (if applicable) vs alarm counts; empty map if either the device has no alarms or
55 * identified device is not managed.
kmcpeake4fe18c82015-11-17 20:07:39 +000056 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000057 Map<Alarm.SeverityLevel, Long> getAlarmCounts(DeviceId deviceId);
58
59 /**
60 * Returns summary of alarms on all devices.
61 *
62 * @return map of severity (if applicable) vs alarm counts; empty map if no alarms.
63 */
64 Map<Alarm.SeverityLevel, Long> getAlarmCounts();
kmcpeake4fe18c82015-11-17 20:07:39 +000065
66 /**
67 * Returns the alarm with the specified identifier.
68 *
69 * @param alarmId alarm identifier
kmcpeakeb172d5f2015-12-10 11:30:43 +000070 * @return alarm matching id; null if no alarm matches the identifier.
kmcpeake4fe18c82015-11-17 20:07:39 +000071 */
72 Alarm getAlarm(AlarmId alarmId);
73
74 /**
75 * Returns all of the alarms.
76 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000077 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +000078 */
79 Set<Alarm> getAlarms();
80
81 /**
82 * Returns all of the ACTIVE alarms. Recently cleared alarms excluded.
83 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000084 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +000085 */
86 Set<Alarm> getActiveAlarms();
87
88 /**
89 * Returns the alarms with the specified severity.
90 *
91 * @param severity the alarm severity
kmcpeakeb172d5f2015-12-10 11:30:43 +000092 * @return set of alarms with a particular severity; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +000093 */
94 Set<Alarm> getAlarms(Alarm.SeverityLevel severity);
95
96 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000097 * Returns the alarm matching a given device, regardless of source within that device.
kmcpeake4fe18c82015-11-17 20:07:39 +000098 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000099 * @param deviceId the device to use when searching alarms.
100 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000101 */
102 Set<Alarm> getAlarms(DeviceId deviceId);
103
104 /**
Andrea Campanella17f9ab62017-01-24 14:57:34 -0800105 * Returns all of the ACTIVE alarms for a specific device. Recently cleared alarms excluded.
106 *
107 * @param deviceId the device to use when searching alarms.
108 * @return set of alarms; empty set if no alarms
109 */
110 default Set<Alarm> getActiveAlarms(DeviceId deviceId) {
111 return getActiveAlarms().stream()
112 .filter(a -> deviceId.equals(a.deviceId()))
113 .collect(Collectors.toSet());
114 }
115
116 /**
kmcpeake4fe18c82015-11-17 20:07:39 +0000117 * Returns the alarm for a given device and source.
118 *
119 * @param deviceId the device
Andrea Campanella8e94b0c2016-04-12 13:58:07 -0700120 * @param source the source within the device
kmcpeakeb172d5f2015-12-10 11:30:43 +0000121 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000122 */
123 Set<Alarm> getAlarms(DeviceId deviceId, AlarmEntityId source);
124
125 /**
126 * Returns the alarm affecting a given link.
127 *
128 * @param src one end of the link
129 * @param dst one end of the link
kmcpeakeb172d5f2015-12-10 11:30:43 +0000130 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000131 */
132 Set<Alarm> getAlarmsForLink(ConnectPoint src, ConnectPoint dst);
133
134 /**
135 * Returns the alarm affecting a given flow.
136 *
137 * @param deviceId the device
Andrea Campanella8e94b0c2016-04-12 13:58:07 -0700138 * @param flowId the flow
kmcpeakeb172d5f2015-12-10 11:30:43 +0000139 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000140 */
141 Set<Alarm> getAlarmsForFlow(DeviceId deviceId, long flowId);
142
kmcpeakeb172d5f2015-12-10 11:30:43 +0000143 // TODO Support retrieving alarms affecting other entity types may be added in future release
kmcpeake4fe18c82015-11-17 20:07:39 +0000144}