blob: c930714d1351e770074d02618400ea582300341d [file] [log] [blame]
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -07001package net.onrc.onos.core.topology;
2
3import java.util.Collection;
4import java.util.Collections;
5
Pavlin Radoslavov5cf1fe02014-07-03 22:52:25 -07006import net.onrc.onos.core.topology.web.serializers.TopologyEventsSerializer;
7import org.codehaus.jackson.map.annotate.JsonSerialize;
8
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -07009/**
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 Radoslavovcac157d2014-07-31 13:54:08 -070018 * removedSwitchEvents, removedMastershipEvents
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070019 * <p/>
20 * (c) The processing order of the "added" events should be:
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070021 * addedMastershipEvents, addedSwitchEvents, addedPortEvents, addedLinkEvents,
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070022 * 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 Radoslavov5cf1fe02014-07-03 22:52:25 -070031@JsonSerialize(using = TopologyEventsSerializer.class)
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070032public final class TopologyEvents {
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070033 private final Collection<MastershipEvent> addedMastershipEvents;
34 private final Collection<MastershipEvent> removedMastershipEvents;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070035 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 HIGUCHIbfc77f02014-07-14 22:50:25 -070041 private final Collection<HostEvent> addedHostEvents;
42 private final Collection<HostEvent> removedHostEvents;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070043
44 /**
Pavlin Radoslavov054cd592014-08-07 20:57:16 -070045 * Constructor for added and removed events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070046 *
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070047 * @param addedMastershipEvents the collection of added Mastership Events.
Pavlin Radoslavov054cd592014-08-07 20:57:16 -070048 * @param removedMastershipEvents the collection of removed Mastership
49 * Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070050 * @param addedSwitchEvents the collection of added Switch Events.
51 * @param removedSwitchEvents the collection of removed Switch Events.
52 * @param addedPortEvents the collection of added Port Events.
53 * @param removedPortEvents the collection of removed Port Events.
54 * @param addedLinkEvents the collection of added Link Events.
55 * @param removedLinkEvents the collection of removed Link Events.
56 * @param addedHostEvents the collection of added Host Events.
57 * @param removedHostEvents the collection of removed Host Events.
58 */
59 // CHECKSTYLE:OFF suppress the warning about too many parameters
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070060 public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
61 Collection<MastershipEvent> removedMastershipEvents,
62 Collection<SwitchEvent> addedSwitchEvents,
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070063 Collection<SwitchEvent> removedSwitchEvents,
64 Collection<PortEvent> addedPortEvents,
65 Collection<PortEvent> removedPortEvents,
66 Collection<LinkEvent> addedLinkEvents,
67 Collection<LinkEvent> removedLinkEvents,
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -070068 Collection<HostEvent> addedHostEvents,
69 Collection<HostEvent> removedHostEvents) {
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070070 // CHECKSTYLE:ON
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070071 this.addedMastershipEvents =
72 Collections.unmodifiableCollection(addedMastershipEvents);
73 this.removedMastershipEvents =
74 Collections.unmodifiableCollection(removedMastershipEvents);
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070075 this.addedSwitchEvents =
76 Collections.unmodifiableCollection(addedSwitchEvents);
77 this.removedSwitchEvents =
78 Collections.unmodifiableCollection(removedSwitchEvents);
79 this.addedPortEvents =
80 Collections.unmodifiableCollection(addedPortEvents);
81 this.removedPortEvents =
82 Collections.unmodifiableCollection(removedPortEvents);
83 this.addedLinkEvents =
84 Collections.unmodifiableCollection(addedLinkEvents);
85 this.removedLinkEvents =
86 Collections.unmodifiableCollection(removedLinkEvents);
87 this.addedHostEvents =
88 Collections.unmodifiableCollection(addedHostEvents);
89 this.removedHostEvents =
90 Collections.unmodifiableCollection(removedHostEvents);
91 }
92
93 /**
Pavlin Radoslavov054cd592014-08-07 20:57:16 -070094 * Constructor for added events only.
95 *
96 * @param addedMastershipEvents the collection of added Mastership Events.
97 * @param addedSwitchEvents the collection of added Switch Events.
98 * @param addedPortEvents the collection of added Port Events.
99 * @param addedLinkEvents the collection of added Link Events.
100 * @param addedHostEvents the collection of added Host Events.
101 */
102 public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
103 Collection<SwitchEvent> addedSwitchEvents,
104 Collection<PortEvent> addedPortEvents,
105 Collection<LinkEvent> addedLinkEvents,
106 Collection<HostEvent> addedHostEvents) {
107 this.addedMastershipEvents =
108 Collections.unmodifiableCollection(addedMastershipEvents);
109 this.removedMastershipEvents = Collections.emptyList();
110 this.addedSwitchEvents =
111 Collections.unmodifiableCollection(addedSwitchEvents);
112 this.removedSwitchEvents = Collections.emptyList();
113 this.addedPortEvents =
114 Collections.unmodifiableCollection(addedPortEvents);
115 this.removedPortEvents = Collections.emptyList();
116 this.addedLinkEvents =
117 Collections.unmodifiableCollection(addedLinkEvents);
118 this.removedLinkEvents = Collections.emptyList();
119 this.addedHostEvents =
120 Collections.unmodifiableCollection(addedHostEvents);
121 this.removedHostEvents = Collections.emptyList();
122 }
123
124 /**
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700125 * Gets the collection of added Mastership Events.
126 *
127 * @return the collection of added Mastership Events.
128 */
129 public Collection<MastershipEvent> getAddedMastershipEvents() {
130 return addedMastershipEvents;
131 }
132
133 /**
134 * Gets the collection of removed Mastership Events.
135 *
136 * @return the collection of removed Mastership Events.
137 */
138 public Collection<MastershipEvent> getRemovedMastershipEvents() {
139 return removedMastershipEvents;
140 }
141
142 /**
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700143 * Gets the collection of added Switch Events.
144 *
145 * @return the collection of added Switch Events.
146 */
147 public Collection<SwitchEvent> getAddedSwitchEvents() {
148 return addedSwitchEvents;
149 }
150
151 /**
152 * Gets the collection of removed Switch Events.
153 *
154 * @return the collection of removed Switch Events.
155 */
156 public Collection<SwitchEvent> getRemovedSwitchEvents() {
157 return removedSwitchEvents;
158 }
159
160 /**
161 * Gets the collection of added Port Events.
162 *
163 * @return the collection of added Port Events.
164 */
165 public Collection<PortEvent> getAddedPortEvents() {
166 return addedPortEvents;
167 }
168
169 /**
170 * Gets the collection of removed Port Events.
171 *
172 * @return the collection of removed Port Events.
173 */
174 public Collection<PortEvent> getRemovedPortEvents() {
175 return removedPortEvents;
176 }
177
178 /**
179 * Gets the collection of added Link Events.
180 *
181 * @return the collection of added Link Events.
182 */
183 public Collection<LinkEvent> getAddedLinkEvents() {
184 return addedLinkEvents;
185 }
186
187 /**
188 * Gets the collection of removed Link Events.
189 *
190 * @return the collection of removed Link Events.
191 */
192 public Collection<LinkEvent> getRemovedLinkEvents() {
193 return removedLinkEvents;
194 }
195
196 /**
197 * Gets the collection of added Host Events.
198 *
199 * @return the collection of added Host Events.
200 */
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -0700201 public Collection<HostEvent> getAddedHostEvents() {
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700202 return addedHostEvents;
203 }
204
205 /**
206 * Gets the collection of removed Host Events.
207 *
208 * @return the collection of removed Host Events.
209 */
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -0700210 public Collection<HostEvent> getRemovedHostEvents() {
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700211 return removedHostEvents;
212 }
213}