blob: 0c8c255659cd79097232475f3a36bbf94a918c81 [file] [log] [blame]
kmcpeake4fe18c82015-11-17 20:07:39 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-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 */
16package org.onosproject.incubator.net.faultmanagement.alarm;
17
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
kmcpeakeb172d5f2015-12-10 11:30:43 +000036 * @param isAcknowledged new acknowledged state
Andrea Campanella8e94b0c2016-04-12 13:58:07 -070037 * @param assignedUser new assigned user, null clear
kmcpeakeb172d5f2015-12-10 11:30:43 +000038 * @return updated alarm (including any recent device-derived changes)
Andrea Campanella65f9eb92017-05-02 11:36:14 -070039 * @deprecated 1.10.0 Kingfisher
kmcpeake4fe18c82015-11-17 20:07:39 +000040 */
Andrea Campanella65f9eb92017-05-02 11:36:14 -070041 @Deprecated
kmcpeakeb172d5f2015-12-10 11:30:43 +000042 Alarm updateBookkeepingFields(AlarmId id, boolean isAcknowledged, String assignedUser);
kmcpeake4fe18c82015-11-17 20:07:39 +000043
44 /**
Andrea Campanella65f9eb92017-05-02 11:36:14 -070045 * Update book-keeping (ie administrative) fields for the alarm matching the specified identifier.
46 *
47 * @param id alarm identifier
48 * @param clear ture if the alarm has to be cleared
49 * @param isAcknowledged new acknowledged state
50 * @param assignedUser new assigned user, null clear
51 * @return updated alarm (including any recent device-derived changes)
52 */
53 Alarm updateBookkeepingFields(AlarmId id, boolean clear, boolean isAcknowledged, String assignedUser);
54
55 /**
56 * Remove an alarm from ONOS.
57 *
58 * @param id alarm
59 */
60 void remove(AlarmId id);
61
62 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000063 * Returns summary of alarms on a given device.
kmcpeake4fe18c82015-11-17 20:07:39 +000064 *
65 * @param deviceId the device
kmcpeakeb172d5f2015-12-10 11:30:43 +000066 * @return map of severity (if applicable) vs alarm counts; empty map if either the device has no alarms or
67 * identified device is not managed.
kmcpeake4fe18c82015-11-17 20:07:39 +000068 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000069 Map<Alarm.SeverityLevel, Long> getAlarmCounts(DeviceId deviceId);
70
71 /**
72 * Returns summary of alarms on all devices.
73 *
74 * @return map of severity (if applicable) vs alarm counts; empty map if no alarms.
75 */
76 Map<Alarm.SeverityLevel, Long> getAlarmCounts();
kmcpeake4fe18c82015-11-17 20:07:39 +000077
78 /**
79 * Returns the alarm with the specified identifier.
80 *
81 * @param alarmId alarm identifier
kmcpeakeb172d5f2015-12-10 11:30:43 +000082 * @return alarm matching id; null if no alarm matches the identifier.
kmcpeake4fe18c82015-11-17 20:07:39 +000083 */
84 Alarm getAlarm(AlarmId alarmId);
85
86 /**
87 * Returns all of the alarms.
88 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000089 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +000090 */
91 Set<Alarm> getAlarms();
92
93 /**
94 * Returns all of the ACTIVE alarms. Recently cleared alarms excluded.
95 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000096 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +000097 */
98 Set<Alarm> getActiveAlarms();
99
100 /**
101 * Returns the alarms with the specified severity.
102 *
103 * @param severity the alarm severity
kmcpeakeb172d5f2015-12-10 11:30:43 +0000104 * @return set of alarms with a particular severity; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000105 */
106 Set<Alarm> getAlarms(Alarm.SeverityLevel severity);
107
108 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +0000109 * Returns the alarm matching a given device, regardless of source within that device.
kmcpeake4fe18c82015-11-17 20:07:39 +0000110 *
kmcpeakeb172d5f2015-12-10 11:30:43 +0000111 * @param deviceId the device to use when searching alarms.
112 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000113 */
114 Set<Alarm> getAlarms(DeviceId deviceId);
115
116 /**
Andrea Campanella17f9ab62017-01-24 14:57:34 -0800117 * Returns all of the ACTIVE alarms for a specific device. Recently cleared alarms excluded.
118 *
119 * @param deviceId the device to use when searching alarms.
120 * @return set of alarms; empty set if no alarms
121 */
122 default Set<Alarm> getActiveAlarms(DeviceId deviceId) {
123 return getActiveAlarms().stream()
124 .filter(a -> deviceId.equals(a.deviceId()))
125 .collect(Collectors.toSet());
126 }
127
128 /**
kmcpeake4fe18c82015-11-17 20:07:39 +0000129 * Returns the alarm for a given device and source.
130 *
131 * @param deviceId the device
Andrea Campanella8e94b0c2016-04-12 13:58:07 -0700132 * @param source the source within the device
kmcpeakeb172d5f2015-12-10 11:30:43 +0000133 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000134 */
135 Set<Alarm> getAlarms(DeviceId deviceId, AlarmEntityId source);
136
137 /**
138 * Returns the alarm affecting a given link.
139 *
140 * @param src one end of the link
141 * @param dst one end of the link
kmcpeakeb172d5f2015-12-10 11:30:43 +0000142 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000143 */
144 Set<Alarm> getAlarmsForLink(ConnectPoint src, ConnectPoint dst);
145
146 /**
147 * Returns the alarm affecting a given flow.
148 *
149 * @param deviceId the device
Andrea Campanella8e94b0c2016-04-12 13:58:07 -0700150 * @param flowId the flow
kmcpeakeb172d5f2015-12-10 11:30:43 +0000151 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000152 */
153 Set<Alarm> getAlarmsForFlow(DeviceId deviceId, long flowId);
154
kmcpeakeb172d5f2015-12-10 11:30:43 +0000155 // TODO Support retrieving alarms affecting other entity types may be added in future release
kmcpeake4fe18c82015-11-17 20:07:39 +0000156}