Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.topology; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.event.AbstractEvent; |
| 19 | import org.onosproject.event.Event; |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 20 | |
| 21 | import java.util.List; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Describes network topology event. |
| 25 | */ |
| 26 | public class TopologyEvent extends AbstractEvent<TopologyEvent.Type, Topology> { |
| 27 | |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 28 | private final List<Event> reasons; |
| 29 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 30 | /** |
| 31 | * Type of topology events. |
| 32 | */ |
| 33 | public enum Type { |
| 34 | /** |
| 35 | * Signifies that topology has changed. |
| 36 | */ |
| 37 | TOPOLOGY_CHANGED |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Creates an event of a given type and for the specified topology and the |
| 42 | * current time. |
| 43 | * |
| 44 | * @param type topology event type |
| 45 | * @param topology event topology subject |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 46 | * @param reasons list of events that triggered topology change |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 47 | */ |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 48 | public TopologyEvent(Type type, Topology topology, List<Event> reasons) { |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 49 | super(type, topology); |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 50 | this.reasons = reasons; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Creates an event of a given type and for the specified topology and time. |
| 55 | * |
| 56 | * @param type link event type |
| 57 | * @param topology event topology subject |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 58 | * @param reasons list of events that triggered topology change |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 59 | * @param time occurrence time |
| 60 | */ |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 61 | public TopologyEvent(Type type, Topology topology, List<Event> reasons, |
| 62 | long time) { |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 63 | super(type, topology, time); |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 64 | this.reasons = reasons; |
| 65 | } |
| 66 | |
| 67 | |
| 68 | /** |
| 69 | * Returns the list of events that triggered the topology change. |
| 70 | * |
| 71 | * @return list of events responsible for change in topology; null if |
| 72 | * initial topology computation |
| 73 | */ |
| 74 | public List<Event> reasons() { |
| 75 | return reasons; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | } |