blob: 9bb91844d76b1e476f609cf256289b07da1f3497 [file] [log] [blame]
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -07001package net.onrc.onos.core.topology;
2
3import java.util.Collection;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -07004
Pavlin Radoslavov41633642014-08-11 14:24:52 -07005import static com.google.common.base.Preconditions.checkNotNull;
6import com.google.common.collect.ImmutableList;
Pavlin Radoslavov5cf1fe02014-07-03 22:52:25 -07007import net.onrc.onos.core.topology.web.serializers.TopologyEventsSerializer;
8import org.codehaus.jackson.map.annotate.JsonSerialize;
9
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070010/**
11 * Class for encapsulating multiple topology events.
Pavlin Radoslavov41633642014-08-11 14:24:52 -070012 * This class is immutable.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070013 * <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 HIGUCHI93d35ea2014-08-31 23:26:13 -070019 * removedHostDataEntries, removedLinkDataEntries, removedPortDataEntries,
20 * removedSwitchDataEntries, removedMastershipEvents
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070021 * <p/>
22 * (c) The processing order of the "added" events should be:
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -070023 * addedMastershipEvents, addedSwitchDataEntries, addedPortDataEntries,
24 * addedLinkDataEntries, addedHostDataEntries
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070025 * <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 Radoslavov5cf1fe02014-07-03 22:52:25 -070033@JsonSerialize(using = TopologyEventsSerializer.class)
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070034public final class TopologyEvents {
Pavlin Radoslavov41633642014-08-11 14:24:52 -070035 private final ImmutableList<MastershipEvent> addedMastershipEvents;
36 private final ImmutableList<MastershipEvent> removedMastershipEvents;
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -070037 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 Radoslavov4eaab992014-07-03 18:39:42 -070045
46 /**
Pavlin Radoslavov054cd592014-08-07 20:57:16 -070047 * Constructor for added and removed events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070048 *
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070049 * @param addedMastershipEvents the collection of added Mastership Events.
Pavlin Radoslavov054cd592014-08-07 20:57:16 -070050 * @param removedMastershipEvents the collection of removed Mastership
51 * Events.
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -070052 * @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 Radoslavov4eaab992014-07-03 18:39:42 -070065 */
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070066 public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
67 Collection<MastershipEvent> removedMastershipEvents,
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -070068 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 Radoslavov41633642014-08-11 14:24:52 -070076 this.addedMastershipEvents = ImmutableList.<MastershipEvent>copyOf(
77 checkNotNull(addedMastershipEvents));
78 this.removedMastershipEvents = ImmutableList.<MastershipEvent>copyOf(
79 checkNotNull(removedMastershipEvents));
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -070080 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 Radoslavov4eaab992014-07-03 18:39:42 -070096 }
97
98 /**
Pavlin Radoslavov054cd592014-08-07 20:57:16 -070099 * Constructor for added events only.
100 *
101 * @param addedMastershipEvents the collection of added Mastership Events.
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700102 * @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 Radoslavov054cd592014-08-07 20:57:16 -0700106 */
107 public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700108 Collection<SwitchData> addedSwitchDataEntries,
109 Collection<PortData> addedPortDataEntries,
110 Collection<LinkData> addedLinkDataEntries,
111 Collection<HostData> addedHostDataEntries) {
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700112 this.addedMastershipEvents = ImmutableList.<MastershipEvent>copyOf(
113 checkNotNull(addedMastershipEvents));
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700114 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 Radoslavov41633642014-08-11 14:24:52 -0700122
123 // Assign empty lists to the removed events
124 this.removedMastershipEvents = ImmutableList.<MastershipEvent>of();
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700125 this.removedSwitchDataEntries = ImmutableList.<SwitchData>of();
126 this.removedPortDataEntries = ImmutableList.<PortData>of();
127 this.removedLinkDataEntries = ImmutableList.<LinkData>of();
128 this.removedHostDataEntries = ImmutableList.<HostData>of();
Pavlin Radoslavov054cd592014-08-07 20:57:16 -0700129 }
130
131 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700132 * Gets the immutable collection of added Mastership Events.
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700133 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700134 * @return the immutable collection of added Mastership Events.
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700135 */
136 public Collection<MastershipEvent> getAddedMastershipEvents() {
137 return addedMastershipEvents;
138 }
139
140 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700141 * Gets the immutable collection of removed Mastership Events.
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700142 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700143 * @return the immutable collection of removed Mastership Events.
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700144 */
145 public Collection<MastershipEvent> getRemovedMastershipEvents() {
146 return removedMastershipEvents;
147 }
148
149 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700150 * Gets the immutable collection of added Switch Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700151 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700152 * @return the immutable collection of added Switch Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700153 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700154 public Collection<SwitchData> getAddedSwitchDataEntries() {
155 return addedSwitchDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700156 }
157
158 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700159 * Gets the immutable collection of removed Switch Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700160 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700161 * @return the immutable collection of removed Switch Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700162 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700163 public Collection<SwitchData> getRemovedSwitchDataEntries() {
164 return removedSwitchDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700165 }
166
167 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700168 * Gets the immutable collection of added Port Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700169 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700170 * @return the immutable collection of added Port Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700171 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700172 public Collection<PortData> getAddedPortDataEntries() {
173 return addedPortDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700174 }
175
176 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700177 * Gets the immutable collection of removed Port Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700178 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700179 * @return the immutable collection of removed Port Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700180 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700181 public Collection<PortData> getRemovedPortDataEntries() {
182 return removedPortDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700183 }
184
185 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700186 * Gets the immutable collection of added Link Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700187 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700188 * @return the immutable collection of added Link Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700189 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700190 public Collection<LinkData> getAddedLinkDataEntries() {
191 return addedLinkDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700192 }
193
194 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700195 * Gets the immutable collection of removed Link Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700196 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700197 * @return the immutable collection of removed Link Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700198 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700199 public Collection<LinkData> getRemovedLinkDataEntries() {
200 return removedLinkDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700201 }
202
203 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700204 * Gets the immutable collection of added Host Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700205 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700206 * @return the immutable collection of added Host Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700207 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700208 public Collection<HostData> getAddedHostDataEntries() {
209 return addedHostDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700210 }
211
212 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700213 * Gets the immutable collection of removed Host Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700214 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700215 * @return the immutable collection of removed Host Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700216 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700217 public Collection<HostData> getRemovedHostDataEntries() {
218 return removedHostDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700219 }
220}