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; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 4 | |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 5 | import static com.google.common.base.Preconditions.checkNotNull; |
| 6 | import com.google.common.collect.ImmutableList; |
Pavlin Radoslavov | 5cf1fe0 | 2014-07-03 22:52:25 -0700 | [diff] [blame] | 7 | import net.onrc.onos.core.topology.web.serializers.TopologyEventsSerializer; |
| 8 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
| 9 | |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 10 | /** |
| 11 | * Class for encapsulating multiple topology events. |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 12 | * This class is immutable. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 13 | * <p/> |
| 14 | * The recommended ordering rules for applying/processing the events are: |
| 15 | * <p/> |
| 16 | * (a) Process "removed" events before "added" events. |
| 17 | * <p/> |
| 18 | * (b) The processing order of the "removed" events should be: |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 19 | * removedHostDataEntries, removedLinkDataEntries, removedPortDataEntries, |
| 20 | * removedSwitchDataEntries, removedMastershipEvents |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 21 | * <p/> |
| 22 | * (c) The processing order of the "added" events should be: |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 23 | * addedMastershipEvents, addedSwitchDataEntries, addedPortDataEntries, |
| 24 | * addedLinkDataEntries, addedHostDataEntries |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 25 | * <p/> |
| 26 | * The above ordering guarantees that removing a port for example |
| 27 | * will be processed before the corresponding switch itself is |
| 28 | * removed. |
| 29 | * <p/> |
| 30 | * The above ordering guarantees that adding a port for example |
| 31 | * will be processed after the corresponding switch itself is added. |
| 32 | */ |
Pavlin Radoslavov | 5cf1fe0 | 2014-07-03 22:52:25 -0700 | [diff] [blame] | 33 | @JsonSerialize(using = TopologyEventsSerializer.class) |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 34 | public final class TopologyEvents { |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 35 | private final ImmutableList<MastershipEvent> addedMastershipEvents; |
| 36 | private final ImmutableList<MastershipEvent> removedMastershipEvents; |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 37 | private final ImmutableList<SwitchData> addedSwitchDataEntries; |
| 38 | private final ImmutableList<SwitchData> removedSwitchDataEntries; |
| 39 | private final ImmutableList<PortData> addedPortDataEntries; |
| 40 | private final ImmutableList<PortData> removedPortDataEntries; |
| 41 | private final ImmutableList<LinkData> addedLinkDataEntries; |
| 42 | private final ImmutableList<LinkData> removedLinkDataEntries; |
| 43 | private final ImmutableList<HostData> addedHostDataEntries; |
| 44 | private final ImmutableList<HostData> removedHostDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 47 | * Constructor for added and removed events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 48 | * |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 49 | * @param addedMastershipEvents the collection of added Mastership Events. |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 50 | * @param removedMastershipEvents the collection of removed Mastership |
| 51 | * Events. |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 52 | * @param addedSwitchDataEntries the collection of added Switch Data |
| 53 | * Entries. |
| 54 | * @param removedSwitchDataEntries the collection of removed Switch Data |
| 55 | * Entries. |
| 56 | * @param addedPortDataEntries the collection of added Port Data Entries. |
| 57 | * @param removedPortDataEntries the collection of removed Port Data |
| 58 | * Entries. |
| 59 | * @param addedLinkDataEntries the collection of added Link Data Entries. |
| 60 | * @param removedLinkDataEntries the collection of removed Link Data |
| 61 | * Entries. |
| 62 | * @param addedHostDataEntries the collection of added Host Data Entries. |
| 63 | * @param removedHostDataEntries the collection of removed Host Data |
| 64 | * Entries. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 65 | */ |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 66 | public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents, |
| 67 | Collection<MastershipEvent> removedMastershipEvents, |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 68 | Collection<SwitchData> addedSwitchDataEntries, |
| 69 | Collection<SwitchData> removedSwitchDataEntries, |
| 70 | Collection<PortData> addedPortDataEntries, |
| 71 | Collection<PortData> removedPortDataEntries, |
| 72 | Collection<LinkData> addedLinkDataEntries, |
| 73 | Collection<LinkData> removedLinkDataEntries, |
| 74 | Collection<HostData> addedHostDataEntries, |
| 75 | Collection<HostData> removedHostDataEntries) { |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 76 | this.addedMastershipEvents = ImmutableList.<MastershipEvent>copyOf( |
| 77 | checkNotNull(addedMastershipEvents)); |
| 78 | this.removedMastershipEvents = ImmutableList.<MastershipEvent>copyOf( |
| 79 | checkNotNull(removedMastershipEvents)); |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 80 | this.addedSwitchDataEntries = ImmutableList.<SwitchData>copyOf( |
| 81 | checkNotNull(addedSwitchDataEntries)); |
| 82 | this.removedSwitchDataEntries = ImmutableList.<SwitchData>copyOf( |
| 83 | checkNotNull(removedSwitchDataEntries)); |
| 84 | this.addedPortDataEntries = ImmutableList.<PortData>copyOf( |
| 85 | checkNotNull(addedPortDataEntries)); |
| 86 | this.removedPortDataEntries = ImmutableList.<PortData>copyOf( |
| 87 | checkNotNull(removedPortDataEntries)); |
| 88 | this.addedLinkDataEntries = ImmutableList.<LinkData>copyOf( |
| 89 | checkNotNull(addedLinkDataEntries)); |
| 90 | this.removedLinkDataEntries = ImmutableList.<LinkData>copyOf( |
| 91 | checkNotNull(removedLinkDataEntries)); |
| 92 | this.addedHostDataEntries = ImmutableList.<HostData>copyOf( |
| 93 | checkNotNull(addedHostDataEntries)); |
| 94 | this.removedHostDataEntries = ImmutableList.<HostData>copyOf( |
| 95 | checkNotNull(removedHostDataEntries)); |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | /** |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 99 | * Constructor for added events only. |
| 100 | * |
| 101 | * @param addedMastershipEvents the collection of added Mastership Events. |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 102 | * @param addedSwitchDataEntries the collection of added Switch Events. |
| 103 | * @param addedPortDataEntries the collection of added Port Events. |
| 104 | * @param addedLinkDataEntries the collection of added Link Events. |
| 105 | * @param addedHostDataEntries the collection of added Host Events. |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 106 | */ |
| 107 | public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents, |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 108 | Collection<SwitchData> addedSwitchDataEntries, |
| 109 | Collection<PortData> addedPortDataEntries, |
| 110 | Collection<LinkData> addedLinkDataEntries, |
| 111 | Collection<HostData> addedHostDataEntries) { |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 112 | this.addedMastershipEvents = ImmutableList.<MastershipEvent>copyOf( |
| 113 | checkNotNull(addedMastershipEvents)); |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 114 | this.addedSwitchDataEntries = ImmutableList.<SwitchData>copyOf( |
| 115 | checkNotNull(addedSwitchDataEntries)); |
| 116 | this.addedPortDataEntries = ImmutableList.<PortData>copyOf( |
| 117 | checkNotNull(addedPortDataEntries)); |
| 118 | this.addedLinkDataEntries = ImmutableList.<LinkData>copyOf( |
| 119 | checkNotNull(addedLinkDataEntries)); |
| 120 | this.addedHostDataEntries = ImmutableList.<HostData>copyOf( |
| 121 | checkNotNull(addedHostDataEntries)); |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 122 | |
| 123 | // Assign empty lists to the removed events |
| 124 | this.removedMastershipEvents = ImmutableList.<MastershipEvent>of(); |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 125 | this.removedSwitchDataEntries = ImmutableList.<SwitchData>of(); |
| 126 | this.removedPortDataEntries = ImmutableList.<PortData>of(); |
| 127 | this.removedLinkDataEntries = ImmutableList.<LinkData>of(); |
| 128 | this.removedHostDataEntries = ImmutableList.<HostData>of(); |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 132 | * Gets the immutable collection of added Mastership Events. |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 133 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 134 | * @return the immutable collection of added Mastership Events. |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 135 | */ |
| 136 | public Collection<MastershipEvent> getAddedMastershipEvents() { |
| 137 | return addedMastershipEvents; |
| 138 | } |
| 139 | |
| 140 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 141 | * Gets the immutable collection of removed Mastership Events. |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 142 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 143 | * @return the immutable collection of removed Mastership Events. |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 144 | */ |
| 145 | public Collection<MastershipEvent> getRemovedMastershipEvents() { |
| 146 | return removedMastershipEvents; |
| 147 | } |
| 148 | |
| 149 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 150 | * Gets the immutable collection of added Switch Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 151 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 152 | * @return the immutable collection of added Switch Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 153 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 154 | public Collection<SwitchData> getAddedSwitchDataEntries() { |
| 155 | return addedSwitchDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 159 | * Gets the immutable collection of removed Switch Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 160 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 161 | * @return the immutable collection of removed Switch Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 162 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 163 | public Collection<SwitchData> getRemovedSwitchDataEntries() { |
| 164 | return removedSwitchDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 168 | * Gets the immutable collection of added Port Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 169 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 170 | * @return the immutable collection of added Port Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 171 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 172 | public Collection<PortData> getAddedPortDataEntries() { |
| 173 | return addedPortDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 177 | * Gets the immutable collection of removed Port Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 178 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 179 | * @return the immutable collection of removed Port Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 180 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 181 | public Collection<PortData> getRemovedPortDataEntries() { |
| 182 | return removedPortDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 186 | * Gets the immutable collection of added Link Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 187 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 188 | * @return the immutable collection of added Link Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 189 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 190 | public Collection<LinkData> getAddedLinkDataEntries() { |
| 191 | return addedLinkDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 195 | * Gets the immutable collection of removed Link Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 196 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 197 | * @return the immutable collection of removed Link Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 198 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 199 | public Collection<LinkData> getRemovedLinkDataEntries() { |
| 200 | return removedLinkDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 204 | * Gets the immutable collection of added Host Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 205 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 206 | * @return the immutable collection of added Host Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 207 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 208 | public Collection<HostData> getAddedHostDataEntries() { |
| 209 | return addedHostDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 213 | * Gets the immutable collection of removed Host Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 214 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 215 | * @return the immutable collection of removed Host Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 216 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame^] | 217 | public Collection<HostData> getRemovedHostDataEntries() { |
| 218 | return removedHostDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 219 | } |
| 220 | } |