blob: 4cee1ca3f5e30604e7b68e837ad788d9ee53f21c [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
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)
kmcpeake4fe18c82015-11-17 20:07:39 +000039 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000040 Alarm updateBookkeepingFields(AlarmId id, boolean isAcknowledged, String assignedUser);
kmcpeake4fe18c82015-11-17 20:07:39 +000041
42 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000043 * Returns summary of alarms on a given device.
kmcpeake4fe18c82015-11-17 20:07:39 +000044 *
45 * @param deviceId the device
kmcpeakeb172d5f2015-12-10 11:30:43 +000046 * @return map of severity (if applicable) vs alarm counts; empty map if either the device has no alarms or
47 * identified device is not managed.
kmcpeake4fe18c82015-11-17 20:07:39 +000048 */
kmcpeakeb172d5f2015-12-10 11:30:43 +000049 Map<Alarm.SeverityLevel, Long> getAlarmCounts(DeviceId deviceId);
50
51 /**
52 * Returns summary of alarms on all devices.
53 *
54 * @return map of severity (if applicable) vs alarm counts; empty map if no alarms.
55 */
56 Map<Alarm.SeverityLevel, Long> getAlarmCounts();
kmcpeake4fe18c82015-11-17 20:07:39 +000057
58 /**
59 * Returns the alarm with the specified identifier.
60 *
61 * @param alarmId alarm identifier
kmcpeakeb172d5f2015-12-10 11:30:43 +000062 * @return alarm matching id; null if no alarm matches the identifier.
kmcpeake4fe18c82015-11-17 20:07:39 +000063 */
64 Alarm getAlarm(AlarmId alarmId);
65
66 /**
67 * Returns all of the alarms.
68 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000069 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +000070 */
71 Set<Alarm> getAlarms();
72
73 /**
74 * Returns all of the ACTIVE alarms. Recently cleared alarms excluded.
75 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000076 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +000077 */
78 Set<Alarm> getActiveAlarms();
79
80 /**
81 * Returns the alarms with the specified severity.
82 *
83 * @param severity the alarm severity
kmcpeakeb172d5f2015-12-10 11:30:43 +000084 * @return set of alarms with a particular severity; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +000085 */
86 Set<Alarm> getAlarms(Alarm.SeverityLevel severity);
87
88 /**
kmcpeakeb172d5f2015-12-10 11:30:43 +000089 * Returns the alarm matching a given device, regardless of source within that device.
kmcpeake4fe18c82015-11-17 20:07:39 +000090 *
kmcpeakeb172d5f2015-12-10 11:30:43 +000091 * @param deviceId the device to use when searching alarms.
92 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +000093 */
94 Set<Alarm> getAlarms(DeviceId deviceId);
95
96 /**
Andrea Campanella17f9ab62017-01-24 14:57:34 -080097 * Returns all of the ACTIVE alarms for a specific device. Recently cleared alarms excluded.
98 *
99 * @param deviceId the device to use when searching alarms.
100 * @return set of alarms; empty set if no alarms
101 */
102 default Set<Alarm> getActiveAlarms(DeviceId deviceId) {
103 return getActiveAlarms().stream()
104 .filter(a -> deviceId.equals(a.deviceId()))
105 .collect(Collectors.toSet());
106 }
107
108 /**
kmcpeake4fe18c82015-11-17 20:07:39 +0000109 * Returns the alarm for a given device and source.
110 *
111 * @param deviceId the device
Andrea Campanella8e94b0c2016-04-12 13:58:07 -0700112 * @param source the source within the device
kmcpeakeb172d5f2015-12-10 11:30:43 +0000113 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000114 */
115 Set<Alarm> getAlarms(DeviceId deviceId, AlarmEntityId source);
116
117 /**
118 * Returns the alarm affecting a given link.
119 *
120 * @param src one end of the link
121 * @param dst one end of the link
kmcpeakeb172d5f2015-12-10 11:30:43 +0000122 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000123 */
124 Set<Alarm> getAlarmsForLink(ConnectPoint src, ConnectPoint dst);
125
126 /**
127 * Returns the alarm affecting a given flow.
128 *
129 * @param deviceId the device
Andrea Campanella8e94b0c2016-04-12 13:58:07 -0700130 * @param flowId the flow
kmcpeakeb172d5f2015-12-10 11:30:43 +0000131 * @return set of alarms; empty set if no alarms
kmcpeake4fe18c82015-11-17 20:07:39 +0000132 */
133 Set<Alarm> getAlarmsForFlow(DeviceId deviceId, long flowId);
134
kmcpeakeb172d5f2015-12-10 11:30:43 +0000135 // TODO Support retrieving alarms affecting other entity types may be added in future release
kmcpeake4fe18c82015-11-17 20:07:39 +0000136}