blob: 543c1cb035798ea9babab9f0896942cf4614b767 [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 /**
45 * Constructor.
46 *
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070047 * @param addedMastershipEvents the collection of added Mastership Events.
48 * @param removedMastershipEvents the collection of removed Mastership Events.
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070049 * @param addedSwitchEvents the collection of added Switch Events.
50 * @param removedSwitchEvents the collection of removed Switch Events.
51 * @param addedPortEvents the collection of added Port Events.
52 * @param removedPortEvents the collection of removed Port Events.
53 * @param addedLinkEvents the collection of added Link Events.
54 * @param removedLinkEvents the collection of removed Link Events.
55 * @param addedHostEvents the collection of added Host Events.
56 * @param removedHostEvents the collection of removed Host Events.
57 */
58 // CHECKSTYLE:OFF suppress the warning about too many parameters
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070059 public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
60 Collection<MastershipEvent> removedMastershipEvents,
61 Collection<SwitchEvent> addedSwitchEvents,
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070062 Collection<SwitchEvent> removedSwitchEvents,
63 Collection<PortEvent> addedPortEvents,
64 Collection<PortEvent> removedPortEvents,
65 Collection<LinkEvent> addedLinkEvents,
66 Collection<LinkEvent> removedLinkEvents,
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -070067 Collection<HostEvent> addedHostEvents,
68 Collection<HostEvent> removedHostEvents) {
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070069 // CHECKSTYLE:ON
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070070 this.addedMastershipEvents =
71 Collections.unmodifiableCollection(addedMastershipEvents);
72 this.removedMastershipEvents =
73 Collections.unmodifiableCollection(removedMastershipEvents);
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070074 this.addedSwitchEvents =
75 Collections.unmodifiableCollection(addedSwitchEvents);
76 this.removedSwitchEvents =
77 Collections.unmodifiableCollection(removedSwitchEvents);
78 this.addedPortEvents =
79 Collections.unmodifiableCollection(addedPortEvents);
80 this.removedPortEvents =
81 Collections.unmodifiableCollection(removedPortEvents);
82 this.addedLinkEvents =
83 Collections.unmodifiableCollection(addedLinkEvents);
84 this.removedLinkEvents =
85 Collections.unmodifiableCollection(removedLinkEvents);
86 this.addedHostEvents =
87 Collections.unmodifiableCollection(addedHostEvents);
88 this.removedHostEvents =
89 Collections.unmodifiableCollection(removedHostEvents);
90 }
91
92 /**
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -070093 * Gets the collection of added Mastership Events.
94 *
95 * @return the collection of added Mastership Events.
96 */
97 public Collection<MastershipEvent> getAddedMastershipEvents() {
98 return addedMastershipEvents;
99 }
100
101 /**
102 * Gets the collection of removed Mastership Events.
103 *
104 * @return the collection of removed Mastership Events.
105 */
106 public Collection<MastershipEvent> getRemovedMastershipEvents() {
107 return removedMastershipEvents;
108 }
109
110 /**
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700111 * Gets the collection of added Switch Events.
112 *
113 * @return the collection of added Switch Events.
114 */
115 public Collection<SwitchEvent> getAddedSwitchEvents() {
116 return addedSwitchEvents;
117 }
118
119 /**
120 * Gets the collection of removed Switch Events.
121 *
122 * @return the collection of removed Switch Events.
123 */
124 public Collection<SwitchEvent> getRemovedSwitchEvents() {
125 return removedSwitchEvents;
126 }
127
128 /**
129 * Gets the collection of added Port Events.
130 *
131 * @return the collection of added Port Events.
132 */
133 public Collection<PortEvent> getAddedPortEvents() {
134 return addedPortEvents;
135 }
136
137 /**
138 * Gets the collection of removed Port Events.
139 *
140 * @return the collection of removed Port Events.
141 */
142 public Collection<PortEvent> getRemovedPortEvents() {
143 return removedPortEvents;
144 }
145
146 /**
147 * Gets the collection of added Link Events.
148 *
149 * @return the collection of added Link Events.
150 */
151 public Collection<LinkEvent> getAddedLinkEvents() {
152 return addedLinkEvents;
153 }
154
155 /**
156 * Gets the collection of removed Link Events.
157 *
158 * @return the collection of removed Link Events.
159 */
160 public Collection<LinkEvent> getRemovedLinkEvents() {
161 return removedLinkEvents;
162 }
163
164 /**
165 * Gets the collection of added Host Events.
166 *
167 * @return the collection of added Host Events.
168 */
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -0700169 public Collection<HostEvent> getAddedHostEvents() {
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700170 return addedHostEvents;
171 }
172
173 /**
174 * Gets the collection of removed Host Events.
175 *
176 * @return the collection of removed Host Events.
177 */
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -0700178 public Collection<HostEvent> getRemovedHostEvents() {
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700179 return removedHostEvents;
180 }
181}