blob: 71b7fb50b7687aca89986ba37d541feb1f2517af [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
6/**
7 * Class for encapsulating multiple topology events.
8 * <p/>
9 * The recommended ordering rules for applying/processing the events are:
10 * <p/>
11 * (a) Process "removed" events before "added" events.
12 * <p/>
13 * (b) The processing order of the "removed" events should be:
14 * removedHostEvents, removedLinkEvents, removedPortEvents,
15 * removedSwitchEvents
16 * <p/>
17 * (c) The processing order of the "added" events should be:
18 * addedSwitchEvents, addedPortEvents, addedLinkEvents,
19 * addedHostEvents
20 * <p/>
21 * The above ordering guarantees that removing a port for example
22 * will be processed before the corresponding switch itself is
23 * removed.
24 * <p/>
25 * The above ordering guarantees that adding a port for example
26 * will be processed after the corresponding switch itself is added.
27 */
28public final class TopologyEvents {
29 private final long timestamp;
30 private final Collection<SwitchEvent> addedSwitchEvents;
31 private final Collection<SwitchEvent> removedSwitchEvents;
32 private final Collection<PortEvent> addedPortEvents;
33 private final Collection<PortEvent> removedPortEvents;
34 private final Collection<LinkEvent> addedLinkEvents;
35 private final Collection<LinkEvent> removedLinkEvents;
36 private final Collection<DeviceEvent> addedHostEvents;
37 private final Collection<DeviceEvent> removedHostEvents;
38
39 /**
40 * Constructor.
41 *
42 * @param timestamp the timestamp for the event.
43 * @param addedSwitchEvents the collection of added Switch Events.
44 * @param removedSwitchEvents the collection of removed Switch Events.
45 * @param addedPortEvents the collection of added Port Events.
46 * @param removedPortEvents the collection of removed Port Events.
47 * @param addedLinkEvents the collection of added Link Events.
48 * @param removedLinkEvents the collection of removed Link Events.
49 * @param addedHostEvents the collection of added Host Events.
50 * @param removedHostEvents the collection of removed Host Events.
51 */
52 // CHECKSTYLE:OFF suppress the warning about too many parameters
53 public TopologyEvents(long timestamp,
54 Collection<SwitchEvent> addedSwitchEvents,
55 Collection<SwitchEvent> removedSwitchEvents,
56 Collection<PortEvent> addedPortEvents,
57 Collection<PortEvent> removedPortEvents,
58 Collection<LinkEvent> addedLinkEvents,
59 Collection<LinkEvent> removedLinkEvents,
60 Collection<DeviceEvent> addedHostEvents,
61 Collection<DeviceEvent> removedHostEvents) {
62 // CHECKSTYLE:ON
63 this.timestamp = timestamp;
64 this.addedSwitchEvents =
65 Collections.unmodifiableCollection(addedSwitchEvents);
66 this.removedSwitchEvents =
67 Collections.unmodifiableCollection(removedSwitchEvents);
68 this.addedPortEvents =
69 Collections.unmodifiableCollection(addedPortEvents);
70 this.removedPortEvents =
71 Collections.unmodifiableCollection(removedPortEvents);
72 this.addedLinkEvents =
73 Collections.unmodifiableCollection(addedLinkEvents);
74 this.removedLinkEvents =
75 Collections.unmodifiableCollection(removedLinkEvents);
76 this.addedHostEvents =
77 Collections.unmodifiableCollection(addedHostEvents);
78 this.removedHostEvents =
79 Collections.unmodifiableCollection(removedHostEvents);
80 }
81
82 /**
83 * Gets the timestamp for the events.
84 *
85 * @return the timestamp for the events.
86 */
87 public long getTimestamp() {
88 return timestamp;
89 }
90
91 /**
92 * Gets the collection of added Switch Events.
93 *
94 * @return the collection of added Switch Events.
95 */
96 public Collection<SwitchEvent> getAddedSwitchEvents() {
97 return addedSwitchEvents;
98 }
99
100 /**
101 * Gets the collection of removed Switch Events.
102 *
103 * @return the collection of removed Switch Events.
104 */
105 public Collection<SwitchEvent> getRemovedSwitchEvents() {
106 return removedSwitchEvents;
107 }
108
109 /**
110 * Gets the collection of added Port Events.
111 *
112 * @return the collection of added Port Events.
113 */
114 public Collection<PortEvent> getAddedPortEvents() {
115 return addedPortEvents;
116 }
117
118 /**
119 * Gets the collection of removed Port Events.
120 *
121 * @return the collection of removed Port Events.
122 */
123 public Collection<PortEvent> getRemovedPortEvents() {
124 return removedPortEvents;
125 }
126
127 /**
128 * Gets the collection of added Link Events.
129 *
130 * @return the collection of added Link Events.
131 */
132 public Collection<LinkEvent> getAddedLinkEvents() {
133 return addedLinkEvents;
134 }
135
136 /**
137 * Gets the collection of removed Link Events.
138 *
139 * @return the collection of removed Link Events.
140 */
141 public Collection<LinkEvent> getRemovedLinkEvents() {
142 return removedLinkEvents;
143 }
144
145 /**
146 * Gets the collection of added Host Events.
147 *
148 * @return the collection of added Host Events.
149 */
150 public Collection<DeviceEvent> getAddedHostEvents() {
151 return addedHostEvents;
152 }
153
154 /**
155 * Gets the collection of removed Host Events.
156 *
157 * @return the collection of removed Host Events.
158 */
159 public Collection<DeviceEvent> getRemovedHostEvents() {
160 return removedHostEvents;
161 }
162}