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 | /** |
| 45 | * Constructor. |
| 46 | * |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 47 | * @param addedMastershipEvents the collection of added Mastership Events. |
| 48 | * @param removedMastershipEvents the collection of removed Mastership Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 49 | * @param addedSwitchEvents the collection of added Switch Events. |
| 50 | * @param removedSwitchEvents the collection of removed Switch Events. |
| 51 | * @param addedPortEvents the collection of added Port Events. |
| 52 | * @param removedPortEvents the collection of removed Port Events. |
| 53 | * @param addedLinkEvents the collection of added Link Events. |
| 54 | * @param removedLinkEvents the collection of removed Link Events. |
| 55 | * @param addedHostEvents the collection of added Host Events. |
| 56 | * @param removedHostEvents the collection of removed Host Events. |
| 57 | */ |
| 58 | // CHECKSTYLE:OFF suppress the warning about too many parameters |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 59 | public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents, |
| 60 | Collection<MastershipEvent> removedMastershipEvents, |
| 61 | Collection<SwitchEvent> addedSwitchEvents, |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 62 | Collection<SwitchEvent> removedSwitchEvents, |
| 63 | Collection<PortEvent> addedPortEvents, |
| 64 | Collection<PortEvent> removedPortEvents, |
| 65 | Collection<LinkEvent> addedLinkEvents, |
| 66 | Collection<LinkEvent> removedLinkEvents, |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 67 | Collection<HostEvent> addedHostEvents, |
| 68 | Collection<HostEvent> removedHostEvents) { |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 69 | // CHECKSTYLE:ON |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 70 | this.addedMastershipEvents = |
| 71 | Collections.unmodifiableCollection(addedMastershipEvents); |
| 72 | this.removedMastershipEvents = |
| 73 | Collections.unmodifiableCollection(removedMastershipEvents); |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 74 | this.addedSwitchEvents = |
| 75 | Collections.unmodifiableCollection(addedSwitchEvents); |
| 76 | this.removedSwitchEvents = |
| 77 | Collections.unmodifiableCollection(removedSwitchEvents); |
| 78 | this.addedPortEvents = |
| 79 | Collections.unmodifiableCollection(addedPortEvents); |
| 80 | this.removedPortEvents = |
| 81 | Collections.unmodifiableCollection(removedPortEvents); |
| 82 | this.addedLinkEvents = |
| 83 | Collections.unmodifiableCollection(addedLinkEvents); |
| 84 | this.removedLinkEvents = |
| 85 | Collections.unmodifiableCollection(removedLinkEvents); |
| 86 | this.addedHostEvents = |
| 87 | Collections.unmodifiableCollection(addedHostEvents); |
| 88 | this.removedHostEvents = |
| 89 | Collections.unmodifiableCollection(removedHostEvents); |
| 90 | } |
| 91 | |
| 92 | /** |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 93 | * Gets the collection of added Mastership Events. |
| 94 | * |
| 95 | * @return the collection of added Mastership Events. |
| 96 | */ |
| 97 | public Collection<MastershipEvent> getAddedMastershipEvents() { |
| 98 | return addedMastershipEvents; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Gets the collection of removed Mastership Events. |
| 103 | * |
| 104 | * @return the collection of removed Mastership Events. |
| 105 | */ |
| 106 | public Collection<MastershipEvent> getRemovedMastershipEvents() { |
| 107 | return removedMastershipEvents; |
| 108 | } |
| 109 | |
| 110 | /** |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 111 | * Gets the collection of added Switch Events. |
| 112 | * |
| 113 | * @return the collection of added Switch Events. |
| 114 | */ |
| 115 | public Collection<SwitchEvent> getAddedSwitchEvents() { |
| 116 | return addedSwitchEvents; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Gets the collection of removed Switch Events. |
| 121 | * |
| 122 | * @return the collection of removed Switch Events. |
| 123 | */ |
| 124 | public Collection<SwitchEvent> getRemovedSwitchEvents() { |
| 125 | return removedSwitchEvents; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Gets the collection of added Port Events. |
| 130 | * |
| 131 | * @return the collection of added Port Events. |
| 132 | */ |
| 133 | public Collection<PortEvent> getAddedPortEvents() { |
| 134 | return addedPortEvents; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Gets the collection of removed Port Events. |
| 139 | * |
| 140 | * @return the collection of removed Port Events. |
| 141 | */ |
| 142 | public Collection<PortEvent> getRemovedPortEvents() { |
| 143 | return removedPortEvents; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Gets the collection of added Link Events. |
| 148 | * |
| 149 | * @return the collection of added Link Events. |
| 150 | */ |
| 151 | public Collection<LinkEvent> getAddedLinkEvents() { |
| 152 | return addedLinkEvents; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Gets the collection of removed Link Events. |
| 157 | * |
| 158 | * @return the collection of removed Link Events. |
| 159 | */ |
| 160 | public Collection<LinkEvent> getRemovedLinkEvents() { |
| 161 | return removedLinkEvents; |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Gets the collection of added Host Events. |
| 166 | * |
| 167 | * @return the collection of added Host Events. |
| 168 | */ |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 169 | public Collection<HostEvent> getAddedHostEvents() { |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 170 | return addedHostEvents; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Gets the collection of removed Host Events. |
| 175 | * |
| 176 | * @return the collection of removed Host Events. |
| 177 | */ |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame] | 178 | public Collection<HostEvent> getRemovedHostEvents() { |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 179 | return removedHostEvents; |
| 180 | } |
| 181 | } |