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, |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 18 | * removedSwitchEvents, removedMastershipEvents |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 19 | * <p/> |
| 20 | * (c) The processing order of the "added" events should be: |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 21 | * addedMastershipEvents, addedSwitchEvents, addedPortEvents, addedLinkEvents, |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 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 { |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 33 | private final Collection<MastershipEvent> addedMastershipEvents; |
| 34 | private final Collection<MastershipEvent> removedMastershipEvents; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 35 | private final Collection<SwitchEvent> addedSwitchEvents; |
| 36 | private final Collection<SwitchEvent> removedSwitchEvents; |
| 37 | private final Collection<PortEvent> addedPortEvents; |
| 38 | private final Collection<PortEvent> removedPortEvents; |
| 39 | private final Collection<LinkEvent> addedLinkEvents; |
| 40 | private final Collection<LinkEvent> removedLinkEvents; |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 41 | private final Collection<HostEvent> addedHostEvents; |
| 42 | private final Collection<HostEvent> removedHostEvents; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 45 | * Constructor for added and removed events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 46 | * |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 47 | * @param addedMastershipEvents the collection of added Mastership Events. |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 48 | * @param removedMastershipEvents the collection of removed Mastership |
| 49 | * Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 50 | * @param addedSwitchEvents the collection of added Switch Events. |
| 51 | * @param removedSwitchEvents the collection of removed Switch Events. |
| 52 | * @param addedPortEvents the collection of added Port Events. |
| 53 | * @param removedPortEvents the collection of removed Port Events. |
| 54 | * @param addedLinkEvents the collection of added Link Events. |
| 55 | * @param removedLinkEvents the collection of removed Link Events. |
| 56 | * @param addedHostEvents the collection of added Host Events. |
| 57 | * @param removedHostEvents the collection of removed Host Events. |
| 58 | */ |
| 59 | // CHECKSTYLE:OFF suppress the warning about too many parameters |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 60 | public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents, |
| 61 | Collection<MastershipEvent> removedMastershipEvents, |
| 62 | Collection<SwitchEvent> addedSwitchEvents, |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 63 | Collection<SwitchEvent> removedSwitchEvents, |
| 64 | Collection<PortEvent> addedPortEvents, |
| 65 | Collection<PortEvent> removedPortEvents, |
| 66 | Collection<LinkEvent> addedLinkEvents, |
| 67 | Collection<LinkEvent> removedLinkEvents, |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 68 | Collection<HostEvent> addedHostEvents, |
| 69 | Collection<HostEvent> removedHostEvents) { |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 70 | // CHECKSTYLE:ON |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 71 | this.addedMastershipEvents = |
| 72 | Collections.unmodifiableCollection(addedMastershipEvents); |
| 73 | this.removedMastershipEvents = |
| 74 | Collections.unmodifiableCollection(removedMastershipEvents); |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 75 | this.addedSwitchEvents = |
| 76 | Collections.unmodifiableCollection(addedSwitchEvents); |
| 77 | this.removedSwitchEvents = |
| 78 | Collections.unmodifiableCollection(removedSwitchEvents); |
| 79 | this.addedPortEvents = |
| 80 | Collections.unmodifiableCollection(addedPortEvents); |
| 81 | this.removedPortEvents = |
| 82 | Collections.unmodifiableCollection(removedPortEvents); |
| 83 | this.addedLinkEvents = |
| 84 | Collections.unmodifiableCollection(addedLinkEvents); |
| 85 | this.removedLinkEvents = |
| 86 | Collections.unmodifiableCollection(removedLinkEvents); |
| 87 | this.addedHostEvents = |
| 88 | Collections.unmodifiableCollection(addedHostEvents); |
| 89 | this.removedHostEvents = |
| 90 | Collections.unmodifiableCollection(removedHostEvents); |
| 91 | } |
| 92 | |
| 93 | /** |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 94 | * Constructor for added events only. |
| 95 | * |
| 96 | * @param addedMastershipEvents the collection of added Mastership Events. |
| 97 | * @param addedSwitchEvents the collection of added Switch Events. |
| 98 | * @param addedPortEvents the collection of added Port Events. |
| 99 | * @param addedLinkEvents the collection of added Link Events. |
| 100 | * @param addedHostEvents the collection of added Host Events. |
| 101 | */ |
| 102 | public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents, |
| 103 | Collection<SwitchEvent> addedSwitchEvents, |
| 104 | Collection<PortEvent> addedPortEvents, |
| 105 | Collection<LinkEvent> addedLinkEvents, |
| 106 | Collection<HostEvent> addedHostEvents) { |
| 107 | this.addedMastershipEvents = |
| 108 | Collections.unmodifiableCollection(addedMastershipEvents); |
| 109 | this.removedMastershipEvents = Collections.emptyList(); |
| 110 | this.addedSwitchEvents = |
| 111 | Collections.unmodifiableCollection(addedSwitchEvents); |
| 112 | this.removedSwitchEvents = Collections.emptyList(); |
| 113 | this.addedPortEvents = |
| 114 | Collections.unmodifiableCollection(addedPortEvents); |
| 115 | this.removedPortEvents = Collections.emptyList(); |
| 116 | this.addedLinkEvents = |
| 117 | Collections.unmodifiableCollection(addedLinkEvents); |
| 118 | this.removedLinkEvents = Collections.emptyList(); |
| 119 | this.addedHostEvents = |
| 120 | Collections.unmodifiableCollection(addedHostEvents); |
| 121 | this.removedHostEvents = Collections.emptyList(); |
| 122 | } |
| 123 | |
| 124 | /** |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 125 | * Gets the collection of added Mastership Events. |
| 126 | * |
| 127 | * @return the collection of added Mastership Events. |
| 128 | */ |
| 129 | public Collection<MastershipEvent> getAddedMastershipEvents() { |
| 130 | return addedMastershipEvents; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Gets the collection of removed Mastership Events. |
| 135 | * |
| 136 | * @return the collection of removed Mastership Events. |
| 137 | */ |
| 138 | public Collection<MastershipEvent> getRemovedMastershipEvents() { |
| 139 | return removedMastershipEvents; |
| 140 | } |
| 141 | |
| 142 | /** |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 143 | * Gets the collection of added Switch Events. |
| 144 | * |
| 145 | * @return the collection of added Switch Events. |
| 146 | */ |
| 147 | public Collection<SwitchEvent> getAddedSwitchEvents() { |
| 148 | return addedSwitchEvents; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Gets the collection of removed Switch Events. |
| 153 | * |
| 154 | * @return the collection of removed Switch Events. |
| 155 | */ |
| 156 | public Collection<SwitchEvent> getRemovedSwitchEvents() { |
| 157 | return removedSwitchEvents; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Gets the collection of added Port Events. |
| 162 | * |
| 163 | * @return the collection of added Port Events. |
| 164 | */ |
| 165 | public Collection<PortEvent> getAddedPortEvents() { |
| 166 | return addedPortEvents; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Gets the collection of removed Port Events. |
| 171 | * |
| 172 | * @return the collection of removed Port Events. |
| 173 | */ |
| 174 | public Collection<PortEvent> getRemovedPortEvents() { |
| 175 | return removedPortEvents; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Gets the collection of added Link Events. |
| 180 | * |
| 181 | * @return the collection of added Link Events. |
| 182 | */ |
| 183 | public Collection<LinkEvent> getAddedLinkEvents() { |
| 184 | return addedLinkEvents; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Gets the collection of removed Link Events. |
| 189 | * |
| 190 | * @return the collection of removed Link Events. |
| 191 | */ |
| 192 | public Collection<LinkEvent> getRemovedLinkEvents() { |
| 193 | return removedLinkEvents; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Gets the collection of added Host Events. |
| 198 | * |
| 199 | * @return the collection of added Host Events. |
| 200 | */ |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 201 | public Collection<HostEvent> getAddedHostEvents() { |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 202 | return addedHostEvents; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Gets the collection of removed Host Events. |
| 207 | * |
| 208 | * @return the collection of removed Host Events. |
| 209 | */ |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 210 | public Collection<HostEvent> getRemovedHostEvents() { |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 211 | return removedHostEvents; |
| 212 | } |
| 213 | } |