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, |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 20 | * removedSwitchDataEntries, removedMastershipDataEntries |
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 | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 23 | * addedMastershipDataEntries, addedSwitchDataEntries, addedPortDataEntries, |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 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 { |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 35 | private final ImmutableList<MastershipData> addedMastershipDataEntries; |
| 36 | private final ImmutableList<MastershipData> removedMastershipDataEntries; |
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 | * |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 49 | * @param addedMastershipDataEntries the collection of added Mastership |
| 50 | * Events |
| 51 | * @param removedMastershipDataEntries the collection of removed Mastership |
| 52 | * Events |
| 53 | * @param addedSwitchDataEntries the collection of added Switch Events |
| 54 | * @param removedSwitchDataEntries the collection of removed Switch Events |
| 55 | * @param addedPortDataEntries the collection of added Port Events |
| 56 | * @param removedPortDataEntries the collection of removed Port Events |
| 57 | * @param addedLinkDataEntries the collection of added Link Events |
| 58 | * @param removedLinkDataEntries the collection of removed Link Events |
| 59 | * @param addedHostDataEntries the collection of added Host Events |
| 60 | * @param removedHostDataEntries the collection of removed Host Events |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 61 | */ |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 62 | public TopologyEvents(Collection<MastershipData> addedMastershipDataEntries, |
| 63 | Collection<MastershipData> removedMastershipDataEntries, |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 64 | Collection<SwitchData> addedSwitchDataEntries, |
| 65 | Collection<SwitchData> removedSwitchDataEntries, |
| 66 | Collection<PortData> addedPortDataEntries, |
| 67 | Collection<PortData> removedPortDataEntries, |
| 68 | Collection<LinkData> addedLinkDataEntries, |
| 69 | Collection<LinkData> removedLinkDataEntries, |
| 70 | Collection<HostData> addedHostDataEntries, |
| 71 | Collection<HostData> removedHostDataEntries) { |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 72 | this.addedMastershipDataEntries = ImmutableList.<MastershipData>copyOf( |
| 73 | checkNotNull(addedMastershipDataEntries)); |
| 74 | this.removedMastershipDataEntries = ImmutableList.<MastershipData>copyOf( |
| 75 | checkNotNull(removedMastershipDataEntries)); |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 76 | this.addedSwitchDataEntries = ImmutableList.<SwitchData>copyOf( |
| 77 | checkNotNull(addedSwitchDataEntries)); |
| 78 | this.removedSwitchDataEntries = ImmutableList.<SwitchData>copyOf( |
| 79 | checkNotNull(removedSwitchDataEntries)); |
| 80 | this.addedPortDataEntries = ImmutableList.<PortData>copyOf( |
| 81 | checkNotNull(addedPortDataEntries)); |
| 82 | this.removedPortDataEntries = ImmutableList.<PortData>copyOf( |
| 83 | checkNotNull(removedPortDataEntries)); |
| 84 | this.addedLinkDataEntries = ImmutableList.<LinkData>copyOf( |
| 85 | checkNotNull(addedLinkDataEntries)); |
| 86 | this.removedLinkDataEntries = ImmutableList.<LinkData>copyOf( |
| 87 | checkNotNull(removedLinkDataEntries)); |
| 88 | this.addedHostDataEntries = ImmutableList.<HostData>copyOf( |
| 89 | checkNotNull(addedHostDataEntries)); |
| 90 | this.removedHostDataEntries = ImmutableList.<HostData>copyOf( |
| 91 | checkNotNull(removedHostDataEntries)); |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | /** |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 95 | * Constructor for added events only. |
| 96 | * |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 97 | * @param addedMastershipDataEntries the collection of added Mastership |
| 98 | * Events |
| 99 | * @param addedSwitchDataEntries the collection of added Switch Events |
| 100 | * @param addedPortDataEntries the collection of added Port Events |
| 101 | * @param addedLinkDataEntries the collection of added Link Events |
| 102 | * @param addedHostDataEntries the collection of added Host Events |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 103 | */ |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 104 | public TopologyEvents(Collection<MastershipData> addedMastershipDataEntries, |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 105 | Collection<SwitchData> addedSwitchDataEntries, |
| 106 | Collection<PortData> addedPortDataEntries, |
| 107 | Collection<LinkData> addedLinkDataEntries, |
| 108 | Collection<HostData> addedHostDataEntries) { |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 109 | this.addedMastershipDataEntries = ImmutableList.<MastershipData>copyOf( |
| 110 | checkNotNull(addedMastershipDataEntries)); |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 111 | this.addedSwitchDataEntries = ImmutableList.<SwitchData>copyOf( |
| 112 | checkNotNull(addedSwitchDataEntries)); |
| 113 | this.addedPortDataEntries = ImmutableList.<PortData>copyOf( |
| 114 | checkNotNull(addedPortDataEntries)); |
| 115 | this.addedLinkDataEntries = ImmutableList.<LinkData>copyOf( |
| 116 | checkNotNull(addedLinkDataEntries)); |
| 117 | this.addedHostDataEntries = ImmutableList.<HostData>copyOf( |
| 118 | checkNotNull(addedHostDataEntries)); |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 119 | |
| 120 | // Assign empty lists to the removed events |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 121 | this.removedMastershipDataEntries = ImmutableList.<MastershipData>of(); |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 122 | this.removedSwitchDataEntries = ImmutableList.<SwitchData>of(); |
| 123 | this.removedPortDataEntries = ImmutableList.<PortData>of(); |
| 124 | this.removedLinkDataEntries = ImmutableList.<LinkData>of(); |
| 125 | this.removedHostDataEntries = ImmutableList.<HostData>of(); |
Pavlin Radoslavov | 054cd59 | 2014-08-07 20:57:16 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 129 | * Gets the immutable collection of added Mastership Events. |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 130 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 131 | * @return the immutable collection of added Mastership Events. |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 132 | */ |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 133 | public Collection<MastershipData> getAddedMastershipDataEntries() { |
| 134 | return addedMastershipDataEntries; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 138 | * Gets the immutable collection of removed Mastership Events. |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 139 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 140 | * @return the immutable collection of removed Mastership Events. |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 141 | */ |
Yuta HIGUCHI | d8fd2f5 | 2014-09-01 23:19:45 -0700 | [diff] [blame^] | 142 | public Collection<MastershipData> getRemovedMastershipDataEntries() { |
| 143 | return removedMastershipDataEntries; |
Pavlin Radoslavov | cac157d | 2014-07-31 13:54:08 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 147 | * Gets the immutable collection of added Switch Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 148 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 149 | * @return the immutable collection of added Switch Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 150 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 151 | public Collection<SwitchData> getAddedSwitchDataEntries() { |
| 152 | return addedSwitchDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 156 | * Gets the immutable collection of removed Switch Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 157 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 158 | * @return the immutable collection of removed Switch Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 159 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 160 | public Collection<SwitchData> getRemovedSwitchDataEntries() { |
| 161 | return removedSwitchDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 165 | * Gets the immutable collection of added Port Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 166 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 167 | * @return the immutable collection of added Port Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 168 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 169 | public Collection<PortData> getAddedPortDataEntries() { |
| 170 | return addedPortDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 174 | * Gets the immutable collection of removed Port Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 175 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 176 | * @return the immutable collection of removed Port Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 177 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 178 | public Collection<PortData> getRemovedPortDataEntries() { |
| 179 | return removedPortDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 183 | * Gets the immutable collection of added Link Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 184 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 185 | * @return the immutable collection of added Link Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 186 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 187 | public Collection<LinkData> getAddedLinkDataEntries() { |
| 188 | return addedLinkDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 192 | * Gets the immutable collection of removed Link Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 193 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 194 | * @return the immutable collection of removed Link Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 195 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 196 | public Collection<LinkData> getRemovedLinkDataEntries() { |
| 197 | return removedLinkDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 201 | * Gets the immutable collection of added Host Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 202 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 203 | * @return the immutable collection of added Host Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 204 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 205 | public Collection<HostData> getAddedHostDataEntries() { |
| 206 | return addedHostDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /** |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 210 | * Gets the immutable collection of removed Host Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 211 | * |
Pavlin Radoslavov | 4163364 | 2014-08-11 14:24:52 -0700 | [diff] [blame] | 212 | * @return the immutable collection of removed Host Events. |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 213 | */ |
Yuta HIGUCHI | 93d35ea | 2014-08-31 23:26:13 -0700 | [diff] [blame] | 214 | public Collection<HostData> getRemovedHostDataEntries() { |
| 215 | return removedHostDataEntries; |
Pavlin Radoslavov | 4eaab99 | 2014-07-03 18:39:42 -0700 | [diff] [blame] | 216 | } |
| 217 | } |