blob: bd346e63954fae5770a93a951f68bb4129215bfd [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,
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -070020 * removedSwitchDataEntries, removedMastershipDataEntries
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -070021 * <p/>
22 * (c) The processing order of the "added" events should be:
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -070023 * addedMastershipDataEntries, addedSwitchDataEntries, addedPortDataEntries,
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -070024 * 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 {
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -070035 private final ImmutableList<MastershipData> addedMastershipDataEntries;
36 private final ImmutableList<MastershipData> removedMastershipDataEntries;
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 *
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -070049 * @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 Radoslavov4eaab992014-07-03 18:39:42 -070061 */
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -070062 public TopologyEvents(Collection<MastershipData> addedMastershipDataEntries,
63 Collection<MastershipData> removedMastershipDataEntries,
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -070064 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 HIGUCHId8fd2f52014-09-01 23:19:45 -070072 this.addedMastershipDataEntries = ImmutableList.<MastershipData>copyOf(
73 checkNotNull(addedMastershipDataEntries));
74 this.removedMastershipDataEntries = ImmutableList.<MastershipData>copyOf(
75 checkNotNull(removedMastershipDataEntries));
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -070076 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 Radoslavov4eaab992014-07-03 18:39:42 -070092 }
93
94 /**
Pavlin Radoslavov054cd592014-08-07 20:57:16 -070095 * Constructor for added events only.
96 *
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -070097 * @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 Radoslavov054cd592014-08-07 20:57:16 -0700103 */
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -0700104 public TopologyEvents(Collection<MastershipData> addedMastershipDataEntries,
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700105 Collection<SwitchData> addedSwitchDataEntries,
106 Collection<PortData> addedPortDataEntries,
107 Collection<LinkData> addedLinkDataEntries,
108 Collection<HostData> addedHostDataEntries) {
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -0700109 this.addedMastershipDataEntries = ImmutableList.<MastershipData>copyOf(
110 checkNotNull(addedMastershipDataEntries));
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700111 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 Radoslavov41633642014-08-11 14:24:52 -0700119
120 // Assign empty lists to the removed events
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -0700121 this.removedMastershipDataEntries = ImmutableList.<MastershipData>of();
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700122 this.removedSwitchDataEntries = ImmutableList.<SwitchData>of();
123 this.removedPortDataEntries = ImmutableList.<PortData>of();
124 this.removedLinkDataEntries = ImmutableList.<LinkData>of();
125 this.removedHostDataEntries = ImmutableList.<HostData>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 */
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -0700133 public Collection<MastershipData> getAddedMastershipDataEntries() {
134 return addedMastershipDataEntries;
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700135 }
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 */
Yuta HIGUCHId8fd2f52014-09-01 23:19:45 -0700142 public Collection<MastershipData> getRemovedMastershipDataEntries() {
143 return removedMastershipDataEntries;
Pavlin Radoslavovcac157d2014-07-31 13:54:08 -0700144 }
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 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700151 public Collection<SwitchData> getAddedSwitchDataEntries() {
152 return addedSwitchDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700153 }
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 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700160 public Collection<SwitchData> getRemovedSwitchDataEntries() {
161 return removedSwitchDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700162 }
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 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700169 public Collection<PortData> getAddedPortDataEntries() {
170 return addedPortDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700171 }
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 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700178 public Collection<PortData> getRemovedPortDataEntries() {
179 return removedPortDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700180 }
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 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700187 public Collection<LinkData> getAddedLinkDataEntries() {
188 return addedLinkDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700189 }
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 */
Yuta HIGUCHI93d35ea2014-08-31 23:26:13 -0700196 public Collection<LinkData> getRemovedLinkDataEntries() {
197 return removedLinkDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700198 }
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 HIGUCHI93d35ea2014-08-31 23:26:13 -0700205 public Collection<HostData> getAddedHostDataEntries() {
206 return addedHostDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700207 }
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 HIGUCHI93d35ea2014-08-31 23:26:13 -0700214 public Collection<HostData> getRemovedHostDataEntries() {
215 return removedHostDataEntries;
Pavlin Radoslavov4eaab992014-07-03 18:39:42 -0700216 }
217}