blob: e2054f50f460185b357079c3031e17e52af560d0 [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:
19 * removedHostEvents, removedLinkEvents, removedPortEvents,
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070020 * removedSwitchEvents, removedMastershipEvents
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070021 * <p/>
22 * (c) The processing order of the "added" events should be:
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070023 * addedMastershipEvents, addedSwitchEvents, addedPortEvents, addedLinkEvents,
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070024 * addedHostEvents
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 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;
37 private final ImmutableList<SwitchEvent> addedSwitchEvents;
38 private final ImmutableList<SwitchEvent> removedSwitchEvents;
39 private final ImmutableList<PortEvent> addedPortEvents;
40 private final ImmutableList<PortEvent> removedPortEvents;
41 private final ImmutableList<LinkEvent> addedLinkEvents;
42 private final ImmutableList<LinkEvent> removedLinkEvents;
43 private final ImmutableList<HostEvent> addedHostEvents;
44 private final ImmutableList<HostEvent> removedHostEvents;
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.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070052 * @param addedSwitchEvents the collection of added Switch Events.
53 * @param removedSwitchEvents the collection of removed Switch Events.
54 * @param addedPortEvents the collection of added Port Events.
55 * @param removedPortEvents the collection of removed Port Events.
56 * @param addedLinkEvents the collection of added Link Events.
57 * @param removedLinkEvents the collection of removed Link Events.
58 * @param addedHostEvents the collection of added Host Events.
59 * @param removedHostEvents the collection of removed Host Events.
60 */
61 // CHECKSTYLE:OFF suppress the warning about too many parameters
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070062 public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
63 Collection<MastershipEvent> removedMastershipEvents,
64 Collection<SwitchEvent> addedSwitchEvents,
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070065 Collection<SwitchEvent> removedSwitchEvents,
66 Collection<PortEvent> addedPortEvents,
67 Collection<PortEvent> removedPortEvents,
68 Collection<LinkEvent> addedLinkEvents,
69 Collection<LinkEvent> removedLinkEvents,
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -070070 Collection<HostEvent> addedHostEvents,
71 Collection<HostEvent> removedHostEvents) {
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070072 // CHECKSTYLE:ON
Pavlin Radoslavov41633642014-08-11 14:24:52 -070073 this.addedMastershipEvents = ImmutableList.<MastershipEvent>copyOf(
74 checkNotNull(addedMastershipEvents));
75 this.removedMastershipEvents = ImmutableList.<MastershipEvent>copyOf(
76 checkNotNull(removedMastershipEvents));
77 this.addedSwitchEvents = ImmutableList.<SwitchEvent>copyOf(
78 checkNotNull(addedSwitchEvents));
79 this.removedSwitchEvents = ImmutableList.<SwitchEvent>copyOf(
80 checkNotNull(removedSwitchEvents));
81 this.addedPortEvents = ImmutableList.<PortEvent>copyOf(
82 checkNotNull(addedPortEvents));
83 this.removedPortEvents = ImmutableList.<PortEvent>copyOf(
84 checkNotNull(removedPortEvents));
85 this.addedLinkEvents = ImmutableList.<LinkEvent>copyOf(
86 checkNotNull(addedLinkEvents));
87 this.removedLinkEvents = ImmutableList.<LinkEvent>copyOf(
88 checkNotNull(removedLinkEvents));
89 this.addedHostEvents = ImmutableList.<HostEvent>copyOf(
90 checkNotNull(addedHostEvents));
91 this.removedHostEvents = ImmutableList.<HostEvent>copyOf(
92 checkNotNull(removedHostEvents));
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070093 }
94
95 /**
Pavlin Radoslavov054cd592014-08-07 20:57:16 -070096 * Constructor for added events only.
97 *
98 * @param addedMastershipEvents the collection of added Mastership Events.
99 * @param addedSwitchEvents the collection of added Switch Events.
100 * @param addedPortEvents the collection of added Port Events.
101 * @param addedLinkEvents the collection of added Link Events.
102 * @param addedHostEvents the collection of added Host Events.
103 */
104 public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
105 Collection<SwitchEvent> addedSwitchEvents,
106 Collection<PortEvent> addedPortEvents,
107 Collection<LinkEvent> addedLinkEvents,
108 Collection<HostEvent> addedHostEvents) {
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700109 this.addedMastershipEvents = ImmutableList.<MastershipEvent>copyOf(
110 checkNotNull(addedMastershipEvents));
111 this.addedSwitchEvents = ImmutableList.<SwitchEvent>copyOf(
112 checkNotNull(addedSwitchEvents));
113 this.addedPortEvents = ImmutableList.<PortEvent>copyOf(
114 checkNotNull(addedPortEvents));
115 this.addedLinkEvents = ImmutableList.<LinkEvent>copyOf(
116 checkNotNull(addedLinkEvents));
117 this.addedHostEvents = ImmutableList.<HostEvent>copyOf(
118 checkNotNull(addedHostEvents));
119
120 // Assign empty lists to the removed events
121 this.removedMastershipEvents = ImmutableList.<MastershipEvent>of();
122 this.removedSwitchEvents = ImmutableList.<SwitchEvent>of();
123 this.removedPortEvents = ImmutableList.<PortEvent>of();
124 this.removedLinkEvents = ImmutableList.<LinkEvent>of();
125 this.removedHostEvents = ImmutableList.<HostEvent>of();
Pavlin Radoslavov054cd592014-08-07 20:57:16 -0700126 }
127
128 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700129 * Gets the immutable collection of added Mastership Events.
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700130 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700131 * @return the immutable collection of added Mastership Events.
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700132 */
133 public Collection<MastershipEvent> getAddedMastershipEvents() {
134 return addedMastershipEvents;
135 }
136
137 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700138 * Gets the immutable collection of removed Mastership Events.
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700139 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700140 * @return the immutable collection of removed Mastership Events.
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700141 */
142 public Collection<MastershipEvent> getRemovedMastershipEvents() {
143 return removedMastershipEvents;
144 }
145
146 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700147 * Gets the immutable collection of added Switch Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700148 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700149 * @return the immutable collection of added Switch Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700150 */
151 public Collection<SwitchEvent> getAddedSwitchEvents() {
152 return addedSwitchEvents;
153 }
154
155 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700156 * Gets the immutable collection of removed Switch Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700157 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700158 * @return the immutable collection of removed Switch Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700159 */
160 public Collection<SwitchEvent> getRemovedSwitchEvents() {
161 return removedSwitchEvents;
162 }
163
164 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700165 * Gets the immutable collection of added Port Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700166 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700167 * @return the immutable collection of added Port Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700168 */
169 public Collection<PortEvent> getAddedPortEvents() {
170 return addedPortEvents;
171 }
172
173 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700174 * Gets the immutable collection of removed Port Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700175 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700176 * @return the immutable collection of removed Port Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700177 */
178 public Collection<PortEvent> getRemovedPortEvents() {
179 return removedPortEvents;
180 }
181
182 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700183 * Gets the immutable collection of added Link Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700184 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700185 * @return the immutable collection of added Link Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700186 */
187 public Collection<LinkEvent> getAddedLinkEvents() {
188 return addedLinkEvents;
189 }
190
191 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700192 * Gets the immutable collection of removed Link Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700193 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700194 * @return the immutable collection of removed Link Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700195 */
196 public Collection<LinkEvent> getRemovedLinkEvents() {
197 return removedLinkEvents;
198 }
199
200 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700201 * Gets the immutable collection of added Host Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700202 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700203 * @return the immutable collection of added Host Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700204 */
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -0700205 public Collection<HostEvent> getAddedHostEvents() {
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700206 return addedHostEvents;
207 }
208
209 /**
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700210 * Gets the immutable collection of removed Host Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700211 *
Pavlin Radoslavov41633642014-08-11 14:24:52 -0700212 * @return the immutable collection of removed Host Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700213 */
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -0700214 public Collection<HostEvent> getRemovedHostEvents() {
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700215 return removedHostEvents;
216 }
217}