Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.topology; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.Collections; |
| 5 | |
Pavlin Radoslavov | 5cf1fe0 | 2014-07-03 22:52:25 -0700 | [diff] [blame] | 6 | import net.onrc.onos.core.topology.web.serializers.TopologyEventsSerializer; |
| 7 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
| 8 | |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 9 | /** |
| 10 | * Class for encapsulating multiple topology events. |
| 11 | * <p/> |
| 12 | * The recommended ordering rules for applying/processing the events are: |
| 13 | * <p/> |
| 14 | * (a) Process "removed" events before "added" events. |
| 15 | * <p/> |
| 16 | * (b) The processing order of the "removed" events should be: |
| 17 | * removedHostEvents, removedLinkEvents, removedPortEvents, |
| 18 | * removedSwitchEvents |
| 19 | * <p/> |
| 20 | * (c) The processing order of the "added" events should be: |
| 21 | * addedSwitchEvents, addedPortEvents, addedLinkEvents, |
| 22 | * addedHostEvents |
| 23 | * <p/> |
| 24 | * The above ordering guarantees that removing a port for example |
| 25 | * will be processed before the corresponding switch itself is |
| 26 | * removed. |
| 27 | * <p/> |
| 28 | * The above ordering guarantees that adding a port for example |
| 29 | * will be processed after the corresponding switch itself is added. |
| 30 | */ |
Pavlin Radoslavov | 5cf1fe0 | 2014-07-03 22:52:25 -0700 | [diff] [blame] | 31 | @JsonSerialize(using = TopologyEventsSerializer.class) |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 32 | public final class TopologyEvents { |
| 33 | private final long timestamp; |
| 34 | private final Collection<SwitchEvent> addedSwitchEvents; |
| 35 | private final Collection<SwitchEvent> removedSwitchEvents; |
| 36 | private final Collection<PortEvent> addedPortEvents; |
| 37 | private final Collection<PortEvent> removedPortEvents; |
| 38 | private final Collection<LinkEvent> addedLinkEvents; |
| 39 | private final Collection<LinkEvent> removedLinkEvents; |
| 40 | private final Collection<DeviceEvent> addedHostEvents; |
| 41 | private final Collection<DeviceEvent> removedHostEvents; |
| 42 | |
| 43 | /** |
| 44 | * Constructor. |
| 45 | * |
| 46 | * @param timestamp the timestamp for the event. |
| 47 | * @param addedSwitchEvents the collection of added Switch Events. |
| 48 | * @param removedSwitchEvents the collection of removed Switch Events. |
| 49 | * @param addedPortEvents the collection of added Port Events. |
| 50 | * @param removedPortEvents the collection of removed Port Events. |
| 51 | * @param addedLinkEvents the collection of added Link Events. |
| 52 | * @param removedLinkEvents the collection of removed Link Events. |
| 53 | * @param addedHostEvents the collection of added Host Events. |
| 54 | * @param removedHostEvents the collection of removed Host Events. |
| 55 | */ |
| 56 | // CHECKSTYLE:OFF suppress the warning about too many parameters |
| 57 | public TopologyEvents(long timestamp, |
| 58 | Collection<SwitchEvent> addedSwitchEvents, |
| 59 | Collection<SwitchEvent> removedSwitchEvents, |
| 60 | Collection<PortEvent> addedPortEvents, |
| 61 | Collection<PortEvent> removedPortEvents, |
| 62 | Collection<LinkEvent> addedLinkEvents, |
| 63 | Collection<LinkEvent> removedLinkEvents, |
| 64 | Collection<DeviceEvent> addedHostEvents, |
| 65 | Collection<DeviceEvent> removedHostEvents) { |
| 66 | // CHECKSTYLE:ON |
| 67 | this.timestamp = timestamp; |
| 68 | this.addedSwitchEvents = |
| 69 | Collections.unmodifiableCollection(addedSwitchEvents); |
| 70 | this.removedSwitchEvents = |
| 71 | Collections.unmodifiableCollection(removedSwitchEvents); |
| 72 | this.addedPortEvents = |
| 73 | Collections.unmodifiableCollection(addedPortEvents); |
| 74 | this.removedPortEvents = |
| 75 | Collections.unmodifiableCollection(removedPortEvents); |
| 76 | this.addedLinkEvents = |
| 77 | Collections.unmodifiableCollection(addedLinkEvents); |
| 78 | this.removedLinkEvents = |
| 79 | Collections.unmodifiableCollection(removedLinkEvents); |
| 80 | this.addedHostEvents = |
| 81 | Collections.unmodifiableCollection(addedHostEvents); |
| 82 | this.removedHostEvents = |
| 83 | Collections.unmodifiableCollection(removedHostEvents); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Gets the timestamp for the events. |
| 88 | * |
| 89 | * @return the timestamp for the events. |
| 90 | */ |
| 91 | public long getTimestamp() { |
| 92 | return timestamp; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Gets the collection of added Switch Events. |
| 97 | * |
| 98 | * @return the collection of added Switch Events. |
| 99 | */ |
| 100 | public Collection<SwitchEvent> getAddedSwitchEvents() { |
| 101 | return addedSwitchEvents; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Gets the collection of removed Switch Events. |
| 106 | * |
| 107 | * @return the collection of removed Switch Events. |
| 108 | */ |
| 109 | public Collection<SwitchEvent> getRemovedSwitchEvents() { |
| 110 | return removedSwitchEvents; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Gets the collection of added Port Events. |
| 115 | * |
| 116 | * @return the collection of added Port Events. |
| 117 | */ |
| 118 | public Collection<PortEvent> getAddedPortEvents() { |
| 119 | return addedPortEvents; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Gets the collection of removed Port Events. |
| 124 | * |
| 125 | * @return the collection of removed Port Events. |
| 126 | */ |
| 127 | public Collection<PortEvent> getRemovedPortEvents() { |
| 128 | return removedPortEvents; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Gets the collection of added Link Events. |
| 133 | * |
| 134 | * @return the collection of added Link Events. |
| 135 | */ |
| 136 | public Collection<LinkEvent> getAddedLinkEvents() { |
| 137 | return addedLinkEvents; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Gets the collection of removed Link Events. |
| 142 | * |
| 143 | * @return the collection of removed Link Events. |
| 144 | */ |
| 145 | public Collection<LinkEvent> getRemovedLinkEvents() { |
| 146 | return removedLinkEvents; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Gets the collection of added Host Events. |
| 151 | * |
| 152 | * @return the collection of added Host Events. |
| 153 | */ |
| 154 | public Collection<DeviceEvent> getAddedHostEvents() { |
| 155 | return addedHostEvents; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Gets the collection of removed Host Events. |
| 160 | * |
| 161 | * @return the collection of removed Host Events. |
| 162 | */ |
| 163 | public Collection<DeviceEvent> getRemovedHostEvents() { |
| 164 | return removedHostEvents; |
| 165 | } |
| 166 | } |