Rename MastershipEvent -> MastershipData
Change-Id: I24a290d65972cad0eaa1a1e687dc00adf5890cce
diff --git a/src/main/java/net/onrc/onos/core/topology/ImmutableTopologySnapshot.java b/src/main/java/net/onrc/onos/core/topology/ImmutableTopologySnapshot.java
index 20b3c48..e115127 100644
--- a/src/main/java/net/onrc/onos/core/topology/ImmutableTopologySnapshot.java
+++ b/src/main/java/net/onrc/onos/core/topology/ImmutableTopologySnapshot.java
@@ -52,7 +52,7 @@
// Mastership info
// Dpid -> [ (InstanceID, Role) ]
- private final Map<Dpid, SortedSet<MastershipEvent>> mastership;
+ private final Map<Dpid, SortedSet<MastershipData>> mastership;
// DPID -> Switch
private final Map<Dpid, SwitchData> switches;
@@ -354,18 +354,18 @@
/**
* Puts a mastership change event.
*
- * @param master MastershipEvent
+ * @param master MastershipData
* @return Builder
*/
- public Builder putSwitchMastershipEvent(MastershipEvent master) {
+ public Builder putSwitchMastershipData(MastershipData master) {
checkNotNull(master);
- SortedSet<MastershipEvent> candidates
+ SortedSet<MastershipData> candidates
= current.mastership.get(master.getDpid());
if (candidates == null) {
- // SortedSet, customized so that MASTER MastershipEvent appear
+ // SortedSet, customized so that MASTER MastershipData appear
// earlier during iteration.
- candidates = new TreeSet<>(new MastershipEvent.MasterFirstComparator());
+ candidates = new TreeSet<>(new MastershipData.MasterFirstComparator());
current.mastership.put(master.getDpid(), candidates);
}
@@ -379,15 +379,15 @@
* Removes a mastership change event.
* <p>
* Note: Only Dpid and OnosInstanceId will be used to identify the
- * {@link MastershipEvent} to remove.
+ * {@link MastershipData} to remove.
*
- * @param master {@link MastershipEvent} to remove. (Role is ignored)
+ * @param master {@link MastershipData} to remove. (Role is ignored)
* @return Builder
*/
- public Builder removeSwitchMastershipEvent(MastershipEvent master) {
+ public Builder removeSwitchMastershipData(MastershipData master) {
checkNotNull(master);
- SortedSet<MastershipEvent> candidates
+ SortedSet<MastershipData> candidates
= current.mastership.get(master.getDpid());
if (candidates == null) {
// nothing to do
@@ -429,7 +429,7 @@
// shallow copy Set in Map
this.mastership = new HashMap<>(builder.current.mastership.size());
- for (Entry<Dpid, SortedSet<MastershipEvent>> e
+ for (Entry<Dpid, SortedSet<MastershipData>> e
: builder.current.mastership.entrySet()) {
this.mastership.put(e.getKey(), new TreeSet<>(e.getValue()));
}
@@ -475,7 +475,7 @@
// shallow copy Set in Map
this.mastership = new HashMap<>(original.mastership.size());
- for (Entry<Dpid, SortedSet<MastershipEvent>> e
+ for (Entry<Dpid, SortedSet<MastershipData>> e
: original.mastership.entrySet()) {
this.mastership.put(e.getKey(), new TreeSet<>(e.getValue()));
}
@@ -672,11 +672,11 @@
*/
@Override
public OnosInstanceId getSwitchMaster(Dpid dpid) {
- final SortedSet<MastershipEvent> candidates = mastership.get(dpid);
+ final SortedSet<MastershipData> candidates = mastership.get(dpid);
if (candidates == null) {
return null;
}
- for (MastershipEvent candidate : candidates) {
+ for (MastershipData candidate : candidates) {
if (candidate.getRole() == Role.MASTER) {
return candidate.getOnosInstanceId();
}
diff --git a/src/main/java/net/onrc/onos/core/topology/MastershipEvent.java b/src/main/java/net/onrc/onos/core/topology/MastershipData.java
similarity index 74%
rename from src/main/java/net/onrc/onos/core/topology/MastershipEvent.java
rename to src/main/java/net/onrc/onos/core/topology/MastershipData.java
index d816376..9942f05 100644
--- a/src/main/java/net/onrc/onos/core/topology/MastershipEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/MastershipData.java
@@ -9,21 +9,17 @@
import java.util.Objects;
import net.floodlightcontroller.core.IFloodlightProviderService.Role;
-import net.onrc.onos.core.topology.web.serializers.MastershipEventSerializer;
+import net.onrc.onos.core.topology.web.serializers.MastershipDataSerializer;
import net.onrc.onos.core.util.Dpid;
import net.onrc.onos.core.util.OnosInstanceId;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
- * Self-contained Switch Mastership event object.
- * <p/>
- * TODO: Rename to match what it is. (Switch/Port/Link/Host)Snapshot?
- * FIXME: Current implementation directly use this object as
- * Replication message, but should be sending update operation info.
+ * Self-contained Switch Mastership object.
*/
-@JsonSerialize(using = MastershipEventSerializer.class)
-public class MastershipEvent extends TopologyElement<MastershipEvent> {
+@JsonSerialize(using = MastershipDataSerializer.class)
+public class MastershipData extends TopologyElement<MastershipData> {
private final Dpid dpid;
private final OnosInstanceId onosInstanceId;
private final Role role;
@@ -32,7 +28,7 @@
* Default constructor for Serializer to use.
*/
@Deprecated
- protected MastershipEvent() {
+ protected MastershipData() {
dpid = null;
onosInstanceId = null;
role = Role.SLAVE; // Default role is SLAVE
@@ -46,7 +42,7 @@
* @param onosInstanceId the ONOS Instance ID
* @param role the ONOS instance role for the switch
*/
- public MastershipEvent(Dpid dpid, OnosInstanceId onosInstanceId,
+ public MastershipData(Dpid dpid, OnosInstanceId onosInstanceId,
Role role) {
this.dpid = checkNotNull(dpid);
this.onosInstanceId = checkNotNull(onosInstanceId);
@@ -56,11 +52,11 @@
/**
* Copy constructor.
* <p>
- * Creates an unfrozen copy of the given Switch MastershipEvent object.
+ * Creates an unfrozen copy of the given Switch MastershipData object.
*
* @param original the object to make copy of
*/
- public MastershipEvent(MastershipEvent original) {
+ public MastershipData(MastershipData original) {
super(original);
this.dpid = original.dpid;
this.onosInstanceId = original.onosInstanceId;
@@ -113,8 +109,8 @@
}
/**
- * Compares two MastershipEvent objects.
- * MastershipEvent objects are equal if they have same DPID and same
+ * Compares two MastershipData objects.
+ * MastershipData objects are equal if they have same DPID and same
* ONOS Instance ID.
*
* @param o another object to compare to this
@@ -135,24 +131,24 @@
return false;
}
- MastershipEvent other = (MastershipEvent) o;
+ MastershipData other = (MastershipData) o;
return Objects.equals(dpid, other.dpid) &&
Objects.equals(onosInstanceId, other.onosInstanceId);
}
/**
- * Comparator to bring {@link MastershipEvent} with MASTER role up front.
+ * Comparator to bring {@link MastershipData} with MASTER role up front.
* <p>
- * Note: expected to be used against Collection of MastershipEvents
+ * Note: expected to be used against Collection of MastershipData
* about same Dpid.
*/
public static final class MasterFirstComparator
- implements Comparator<MastershipEvent>, Serializable {
+ implements Comparator<MastershipData>, Serializable {
@Override
- public int compare(MastershipEvent o1, MastershipEvent o2) {
- // MastershipEvent for same ONOS Instance
+ public int compare(MastershipData o1, MastershipData o2) {
+ // MastershipData for same ONOS Instance
// => treat as equal regardless of Role
- // Note: MastershipEvent#equals() does not use Role
+ // Note: MastershipData#equals() does not use Role
if (o1.equals(o2)) {
return 0;
}
@@ -173,7 +169,7 @@
@Override
public String toString() {
- return "[MastershipEvent " + getDpid() + "@" + getOnosInstanceId() +
+ return "[MastershipData " + getDpid() + "@" + getOnosInstanceId() +
"->" + getRole() + "]";
}
}
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java b/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
index 2c805e8..2df7114 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
@@ -59,13 +59,13 @@
/**
* Constructor for given Switch Mastership event.
*
- * @param mastershipEvent the Switch Mastership event to use.
+ * @param mastershipData the Switch Mastership event to use.
* @param onosInstanceId the ONOS Instance ID that originates the event.
*/
- TopologyEvent(MastershipEvent mastershipEvent,
+ TopologyEvent(MastershipData mastershipData,
OnosInstanceId onosInstanceId) {
this.eventType = Type.MASTERSHIP;
- this.event = checkNotNull(mastershipEvent);
+ this.event = checkNotNull(mastershipData);
this.onosInstanceId = checkNotNull(onosInstanceId);
}
@@ -131,12 +131,12 @@
*
* @return the Mastership event.
*/
- public MastershipEvent getMastershipEvent() {
+ public MastershipData getMastershipData() {
if (eventType != Type.MASTERSHIP) {
return null;
}
- MastershipEvent mastershipEvent = (MastershipEvent) event;
- return mastershipEvent;
+ MastershipData mastershipData = (MastershipData) event;
+ return mastershipData;
}
/**
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyEventPreprocessor.java b/src/main/java/net/onrc/onos/core/topology/TopologyEventPreprocessor.java
index a843fb5..ebdde8f 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyEventPreprocessor.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyEventPreprocessor.java
@@ -215,18 +215,18 @@
* @return a list of postponed events if the processed event is a
* Mastership Event for a new Master, otherwise an empty list.
*/
- private List<EventEntry<TopologyEvent>> processMastershipEvent(
+ private List<EventEntry<TopologyEvent>> processMastershipData(
OnosInstanceLastAddEvents instance,
EventEntry<TopologyEvent> event) {
TopologyEvent topologyEvent = event.eventData();
- MastershipEvent mastershipEvent = topologyEvent.getMastershipEvent();
+ MastershipData mastershipData = topologyEvent.getMastershipData();
- if (mastershipEvent == null) {
+ if (mastershipData == null) {
return Collections.emptyList(); // Not a Mastership Event
}
OnosInstanceId onosInstanceId = topologyEvent.getOnosInstanceId();
- Dpid dpid = mastershipEvent.getDpid();
+ Dpid dpid = mastershipData.getDpid();
boolean newMaster = false;
//
@@ -239,7 +239,7 @@
// the current MASTER.
//
if ((event.eventType() == EventEntry.Type.ENTRY_ADD) &&
- (mastershipEvent.getRole() == Role.MASTER)) {
+ (mastershipData.getRole() == Role.MASTER)) {
//
// Accept if explicitly configured, otherwise check
@@ -313,7 +313,7 @@
instanceState.put(onosInstanceId, instance);
}
- postponedEvents = processMastershipEvent(instance, event);
+ postponedEvents = processMastershipData(instance, event);
//
// Process the event and eventually store it in the
@@ -339,7 +339,7 @@
* <p/>
* The result events can be applied to the Topology in the following
* order: REMOVE events followed by ADD events. The ADD events are in the
- * natural order to build a Topology: MastershipEvent, SwitchData,
+ * natural order to build a Topology: MastershipData, SwitchData,
* PortData, LinkData, HostData. The REMOVE events are in the reverse
* order.
*
@@ -349,9 +349,9 @@
private List<EventEntry<TopologyEvent>> reorderEventsForTopology(
List<EventEntry<TopologyEvent>> events) {
// Local state for computing the final set of events
- Map<ByteBuffer, EventEntry<TopologyEvent>> addedMastershipEvents =
+ Map<ByteBuffer, EventEntry<TopologyEvent>> addedMastershipDataEntries =
new HashMap<>();
- Map<ByteBuffer, EventEntry<TopologyEvent>> removedMastershipEvents =
+ Map<ByteBuffer, EventEntry<TopologyEvent>> removedMastershipDataEntries =
new HashMap<>();
Map<ByteBuffer, EventEntry<TopologyEvent>> addedSwitchDataEntries =
new HashMap<>();
@@ -381,8 +381,8 @@
TopologyEvent topologyEvent = event.eventData();
// Get the event itself
- MastershipEvent mastershipEvent =
- topologyEvent.getMastershipEvent();
+ MastershipData mastershipData =
+ topologyEvent.getMastershipData();
SwitchData switchData = topologyEvent.getSwitchData();
PortData portData = topologyEvent.getPortData();
LinkData linkData = topologyEvent.getLinkData();
@@ -393,10 +393,10 @@
//
switch (event.eventType()) {
case ENTRY_ADD:
- if (mastershipEvent != null) {
- ByteBuffer id = mastershipEvent.getIDasByteBuffer();
- addedMastershipEvents.put(id, event);
- removedMastershipEvents.remove(id);
+ if (mastershipData != null) {
+ ByteBuffer id = mastershipData.getIDasByteBuffer();
+ addedMastershipDataEntries.put(id, event);
+ removedMastershipDataEntries.remove(id);
}
if (switchData != null) {
ByteBuffer id = switchData.getIDasByteBuffer();
@@ -420,10 +420,10 @@
}
break;
case ENTRY_REMOVE:
- if (mastershipEvent != null) {
- ByteBuffer id = mastershipEvent.getIDasByteBuffer();
- addedMastershipEvents.remove(id);
- removedMastershipEvents.put(id, event);
+ if (mastershipData != null) {
+ ByteBuffer id = mastershipData.getIDasByteBuffer();
+ addedMastershipDataEntries.remove(id);
+ removedMastershipDataEntries.put(id, event);
}
if (switchData != null) {
ByteBuffer id = switchData.getIDasByteBuffer();
@@ -463,9 +463,9 @@
result.addAll(removedLinkDataEntries.values());
result.addAll(removedPortDataEntries.values());
result.addAll(removedSwitchDataEntries.values());
- result.addAll(removedMastershipEvents.values());
+ result.addAll(removedMastershipDataEntries.values());
//
- result.addAll(addedMastershipEvents.values());
+ result.addAll(addedMastershipDataEntries.values());
result.addAll(addedSwitchDataEntries.values());
result.addAll(addedPortDataEntries.values());
result.addAll(addedLinkDataEntries.values());
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyEvents.java b/src/main/java/net/onrc/onos/core/topology/TopologyEvents.java
index 9bb9184..bd346e6 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyEvents.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyEvents.java
@@ -17,10 +17,10 @@
* <p/>
* (b) The processing order of the "removed" events should be:
* removedHostDataEntries, removedLinkDataEntries, removedPortDataEntries,
- * removedSwitchDataEntries, removedMastershipEvents
+ * removedSwitchDataEntries, removedMastershipDataEntries
* <p/>
* (c) The processing order of the "added" events should be:
- * addedMastershipEvents, addedSwitchDataEntries, addedPortDataEntries,
+ * addedMastershipDataEntries, addedSwitchDataEntries, addedPortDataEntries,
* addedLinkDataEntries, addedHostDataEntries
* <p/>
* The above ordering guarantees that removing a port for example
@@ -32,8 +32,8 @@
*/
@JsonSerialize(using = TopologyEventsSerializer.class)
public final class TopologyEvents {
- private final ImmutableList<MastershipEvent> addedMastershipEvents;
- private final ImmutableList<MastershipEvent> removedMastershipEvents;
+ private final ImmutableList<MastershipData> addedMastershipDataEntries;
+ private final ImmutableList<MastershipData> removedMastershipDataEntries;
private final ImmutableList<SwitchData> addedSwitchDataEntries;
private final ImmutableList<SwitchData> removedSwitchDataEntries;
private final ImmutableList<PortData> addedPortDataEntries;
@@ -46,25 +46,21 @@
/**
* Constructor for added and removed events.
*
- * @param addedMastershipEvents the collection of added Mastership Events.
- * @param removedMastershipEvents the collection of removed Mastership
- * Events.
- * @param addedSwitchDataEntries the collection of added Switch Data
- * Entries.
- * @param removedSwitchDataEntries the collection of removed Switch Data
- * Entries.
- * @param addedPortDataEntries the collection of added Port Data Entries.
- * @param removedPortDataEntries the collection of removed Port Data
- * Entries.
- * @param addedLinkDataEntries the collection of added Link Data Entries.
- * @param removedLinkDataEntries the collection of removed Link Data
- * Entries.
- * @param addedHostDataEntries the collection of added Host Data Entries.
- * @param removedHostDataEntries the collection of removed Host Data
- * Entries.
+ * @param addedMastershipDataEntries the collection of added Mastership
+ * Events
+ * @param removedMastershipDataEntries the collection of removed Mastership
+ * Events
+ * @param addedSwitchDataEntries the collection of added Switch Events
+ * @param removedSwitchDataEntries the collection of removed Switch Events
+ * @param addedPortDataEntries the collection of added Port Events
+ * @param removedPortDataEntries the collection of removed Port Events
+ * @param addedLinkDataEntries the collection of added Link Events
+ * @param removedLinkDataEntries the collection of removed Link Events
+ * @param addedHostDataEntries the collection of added Host Events
+ * @param removedHostDataEntries the collection of removed Host Events
*/
- public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
- Collection<MastershipEvent> removedMastershipEvents,
+ public TopologyEvents(Collection<MastershipData> addedMastershipDataEntries,
+ Collection<MastershipData> removedMastershipDataEntries,
Collection<SwitchData> addedSwitchDataEntries,
Collection<SwitchData> removedSwitchDataEntries,
Collection<PortData> addedPortDataEntries,
@@ -73,10 +69,10 @@
Collection<LinkData> removedLinkDataEntries,
Collection<HostData> addedHostDataEntries,
Collection<HostData> removedHostDataEntries) {
- this.addedMastershipEvents = ImmutableList.<MastershipEvent>copyOf(
- checkNotNull(addedMastershipEvents));
- this.removedMastershipEvents = ImmutableList.<MastershipEvent>copyOf(
- checkNotNull(removedMastershipEvents));
+ this.addedMastershipDataEntries = ImmutableList.<MastershipData>copyOf(
+ checkNotNull(addedMastershipDataEntries));
+ this.removedMastershipDataEntries = ImmutableList.<MastershipData>copyOf(
+ checkNotNull(removedMastershipDataEntries));
this.addedSwitchDataEntries = ImmutableList.<SwitchData>copyOf(
checkNotNull(addedSwitchDataEntries));
this.removedSwitchDataEntries = ImmutableList.<SwitchData>copyOf(
@@ -98,19 +94,20 @@
/**
* Constructor for added events only.
*
- * @param addedMastershipEvents the collection of added Mastership Events.
- * @param addedSwitchDataEntries the collection of added Switch Events.
- * @param addedPortDataEntries the collection of added Port Events.
- * @param addedLinkDataEntries the collection of added Link Events.
- * @param addedHostDataEntries the collection of added Host Events.
+ * @param addedMastershipDataEntries the collection of added Mastership
+ * Events
+ * @param addedSwitchDataEntries the collection of added Switch Events
+ * @param addedPortDataEntries the collection of added Port Events
+ * @param addedLinkDataEntries the collection of added Link Events
+ * @param addedHostDataEntries the collection of added Host Events
*/
- public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
+ public TopologyEvents(Collection<MastershipData> addedMastershipDataEntries,
Collection<SwitchData> addedSwitchDataEntries,
Collection<PortData> addedPortDataEntries,
Collection<LinkData> addedLinkDataEntries,
Collection<HostData> addedHostDataEntries) {
- this.addedMastershipEvents = ImmutableList.<MastershipEvent>copyOf(
- checkNotNull(addedMastershipEvents));
+ this.addedMastershipDataEntries = ImmutableList.<MastershipData>copyOf(
+ checkNotNull(addedMastershipDataEntries));
this.addedSwitchDataEntries = ImmutableList.<SwitchData>copyOf(
checkNotNull(addedSwitchDataEntries));
this.addedPortDataEntries = ImmutableList.<PortData>copyOf(
@@ -121,7 +118,7 @@
checkNotNull(addedHostDataEntries));
// Assign empty lists to the removed events
- this.removedMastershipEvents = ImmutableList.<MastershipEvent>of();
+ this.removedMastershipDataEntries = ImmutableList.<MastershipData>of();
this.removedSwitchDataEntries = ImmutableList.<SwitchData>of();
this.removedPortDataEntries = ImmutableList.<PortData>of();
this.removedLinkDataEntries = ImmutableList.<LinkData>of();
@@ -133,8 +130,8 @@
*
* @return the immutable collection of added Mastership Events.
*/
- public Collection<MastershipEvent> getAddedMastershipEvents() {
- return addedMastershipEvents;
+ public Collection<MastershipData> getAddedMastershipDataEntries() {
+ return addedMastershipDataEntries;
}
/**
@@ -142,8 +139,8 @@
*
* @return the immutable collection of removed Mastership Events.
*/
- public Collection<MastershipEvent> getRemovedMastershipEvents() {
- return removedMastershipEvents;
+ public Collection<MastershipData> getRemovedMastershipDataEntries() {
+ return removedMastershipDataEntries;
}
/**
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java b/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java
index c27a247..2ceb2d9 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java
@@ -49,7 +49,7 @@
// Mastership info
// Dpid -> [ (InstanceID, Role) ]
- private final Map<Dpid, SortedSet<MastershipEvent>> mastership;
+ private final Map<Dpid, SortedSet<MastershipData>> mastership;
// DPID -> Switch
private final ConcurrentMap<Dpid, SwitchData> switches;
@@ -93,7 +93,7 @@
try {
// shallow copy Set in Map
this.mastership = new HashMap<>(original.mastership.size());
- for (Entry<Dpid, SortedSet<MastershipEvent>> e
+ for (Entry<Dpid, SortedSet<MastershipData>> e
: original.mastership.entrySet()) {
this.mastership.put(e.getKey(), new TreeSet<>(e.getValue()));
}
@@ -514,11 +514,11 @@
@Override
public OnosInstanceId getSwitchMaster(Dpid dpid) {
- final SortedSet<MastershipEvent> candidates = mastership.get(dpid);
+ final SortedSet<MastershipData> candidates = mastership.get(dpid);
if (candidates == null) {
return null;
}
- for (MastershipEvent candidate : candidates) {
+ for (MastershipData candidate : candidates) {
if (candidate.getRole() == Role.MASTER) {
return candidate.getOnosInstanceId();
}
@@ -718,18 +718,18 @@
/**
* Puts a mastership change event.
*
- * @param master MastershipEvent
+ * @param master MastershipData
*/
@GuardedBy("writeLock")
- protected void putSwitchMastershipEvent(MastershipEvent master) {
+ protected void putSwitchMastershipData(MastershipData master) {
checkNotNull(master);
- SortedSet<MastershipEvent> candidates
+ SortedSet<MastershipData> candidates
= mastership.get(master.getDpid());
if (candidates == null) {
- // SortedSet, customized so that MASTER MastershipEvent appear
+ // SortedSet, customized so that MASTER MastershipData appear
// earlier during iteration.
- candidates = new TreeSet<>(new MastershipEvent.MasterFirstComparator());
+ candidates = new TreeSet<>(new MastershipData.MasterFirstComparator());
}
// always replace
@@ -741,15 +741,15 @@
* Removes a mastership change event.
* <p>
* Note: Only Dpid and OnosInstanceId will be used to identify the
- * {@link MastershipEvent} to remove.
+ * {@link MastershipData} to remove.
*
- * @param master {@link MastershipEvent} to remove. (Role is ignored)
+ * @param master {@link MastershipData} to remove. (Role is ignored)
*/
@GuardedBy("writeLock")
- protected void removeSwitchMastershipEvent(MastershipEvent master) {
+ protected void removeSwitchMastershipData(MastershipData master) {
checkNotNull(master);
- SortedSet<MastershipEvent> candidates
+ SortedSet<MastershipData> candidates
= mastership.get(master.getDpid());
if (candidates == null) {
// nothing to do
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
index 47cdcff..9092e98 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
@@ -97,7 +97,7 @@
// Local state for keeping the last ADD Mastership Event entries.
// TODO: In the future, we might have to keep this state somewhere else.
//
- private Map<ByteBuffer, MastershipEvent> lastAddMastershipEvents =
+ private Map<ByteBuffer, MastershipData> lastAddMastershipDataEntries =
new HashMap<>();
//
@@ -106,9 +106,9 @@
// - Queue of events, which will be dispatched to local listeners
// on next notification.
- private List<MastershipEvent> apiAddedMastershipEvents =
+ private List<MastershipData> apiAddedMastershipDataEntries =
new LinkedList<>();
- private List<MastershipEvent> apiRemovedMastershipEvents =
+ private List<MastershipData> apiRemovedMastershipDataEntries =
new LinkedList<>();
private List<SwitchData> apiAddedSwitchDataEntries = new LinkedList<>();
private List<SwitchData> apiRemovedSwitchDataEntries = new LinkedList<>();
@@ -233,8 +233,8 @@
TopologyEvent topologyEvent = event.eventData();
// Get the event itself
- MastershipEvent mastershipEvent =
- topologyEvent.getMastershipEvent();
+ MastershipData mastershipData =
+ topologyEvent.getMastershipData();
SwitchData switchData = topologyEvent.getSwitchData();
PortData portData = topologyEvent.getPortData();
LinkData linkData = topologyEvent.getLinkData();
@@ -246,8 +246,8 @@
//
switch (event.eventType()) {
case ENTRY_ADD:
- if (mastershipEvent != null) {
- wasAdded = addMastershipEvent(mastershipEvent);
+ if (mastershipData != null) {
+ wasAdded = addMastershipData(mastershipData);
}
if (switchData != null) {
wasAdded = addSwitch(switchData);
@@ -268,8 +268,8 @@
}
break;
case ENTRY_REMOVE:
- if (mastershipEvent != null) {
- removeMastershipEvent(mastershipEvent);
+ if (mastershipData != null) {
+ removeMastershipData(mastershipData);
}
if (switchData != null) {
removeSwitch(switchData);
@@ -411,18 +411,18 @@
// Create the Topology Snapshot Event
//
TopologyEvents events = null;
- Collection<MastershipEvent> mastershipEvents =
- lastAddMastershipEvents.values();
+ Collection<MastershipData> mastershipDataEntries =
+ lastAddMastershipDataEntries.values();
Collection<SwitchData> switchDataEntries = topology.getAllSwitchDataEntries();
Collection<PortData> portDataEntries = topology.getAllPortDataEntries();
Collection<LinkData> linkDataEntries = topology.getAllLinkDataEntries();
Collection<HostData> hostDataEntries = topology.getAllHostDataEntries();
- if (!(mastershipEvents.isEmpty() &&
+ if (!(mastershipDataEntries.isEmpty() &&
switchDataEntries.isEmpty() &&
portDataEntries.isEmpty() &&
linkDataEntries.isEmpty() &&
hostDataEntries.isEmpty())) {
- events = new TopologyEvents(mastershipEvents,
+ events = new TopologyEvents(mastershipDataEntries,
switchDataEntries,
portDataEntries,
linkDataEntries,
@@ -455,8 +455,8 @@
* Dispatch Topology Events to the listeners.
*/
private void dispatchTopologyEvents() {
- if (apiAddedMastershipEvents.isEmpty() &&
- apiRemovedMastershipEvents.isEmpty() &&
+ if (apiAddedMastershipDataEntries.isEmpty() &&
+ apiRemovedMastershipDataEntries.isEmpty() &&
apiAddedSwitchDataEntries.isEmpty() &&
apiRemovedSwitchDataEntries.isEmpty() &&
apiAddedPortDataEntries.isEmpty() &&
@@ -473,13 +473,13 @@
// Debug statements
// TODO: Those statements should be removed in the future
//
- for (MastershipEvent mastershipEvent : apiAddedMastershipEvents) {
+ for (MastershipData mastershipData : apiAddedMastershipDataEntries) {
log.debug("Dispatch Topology Event: ADDED {}",
- mastershipEvent);
+ mastershipData);
}
- for (MastershipEvent mastershipEvent : apiRemovedMastershipEvents) {
+ for (MastershipData mastershipData : apiRemovedMastershipDataEntries) {
log.debug("Dispatch Topology Event: REMOVED {}",
- mastershipEvent);
+ mastershipData);
}
for (SwitchData switchData : apiAddedSwitchDataEntries) {
log.debug("Dispatch Topology Event: ADDED {}", switchData);
@@ -511,7 +511,7 @@
// Update the metrics
//
long totalEvents =
- apiAddedMastershipEvents.size() + apiRemovedMastershipEvents.size() +
+ apiAddedMastershipDataEntries.size() + apiRemovedMastershipDataEntries.size() +
apiAddedSwitchDataEntries.size() + apiRemovedSwitchDataEntries.size() +
apiAddedPortDataEntries.size() + apiRemovedPortDataEntries.size() +
apiAddedLinkDataEntries.size() + apiRemovedLinkDataEntries.size() +
@@ -523,8 +523,8 @@
// Allocate the events to deliver.
//
TopologyEvents events = new TopologyEvents(
- apiAddedMastershipEvents,
- apiRemovedMastershipEvents,
+ apiAddedMastershipDataEntries,
+ apiRemovedMastershipDataEntries,
apiAddedSwitchDataEntries,
apiRemovedSwitchDataEntries,
apiAddedPortDataEntries,
@@ -544,8 +544,8 @@
//
// Cleanup
//
- apiAddedMastershipEvents.clear();
- apiRemovedMastershipEvents.clear();
+ apiAddedMastershipDataEntries.clear();
+ apiRemovedMastershipDataEntries.clear();
apiAddedSwitchDataEntries.clear();
apiRemovedSwitchDataEntries.clear();
apiAddedPortDataEntries.clear();
@@ -563,28 +563,28 @@
/**
* Adds Switch Mastership event.
*
- * @param mastershipEvent the MastershipEvent to process.
+ * @param mastershipData the MastershipData to process.
* @return true if the item was successfully added, otherwise false.
*/
@GuardedBy("topology.writeLock")
- private boolean addMastershipEvent(MastershipEvent mastershipEvent) {
- log.debug("Added Mastership event {}", mastershipEvent);
- lastAddMastershipEvents.put(mastershipEvent.getIDasByteBuffer(),
- mastershipEvent);
- apiAddedMastershipEvents.add(mastershipEvent);
+ private boolean addMastershipData(MastershipData mastershipData) {
+ log.debug("Added Mastership event {}", mastershipData);
+ lastAddMastershipDataEntries.put(mastershipData.getIDasByteBuffer(),
+ mastershipData);
+ apiAddedMastershipDataEntries.add(mastershipData);
return true;
}
/**
* Removes Switch Mastership event.
*
- * @param mastershipEvent the MastershipEvent to process.
+ * @param mastershipData the MastershipData to process.
*/
@GuardedBy("topology.writeLock")
- private void removeMastershipEvent(MastershipEvent mastershipEvent) {
- log.debug("Removed Mastership event {}", mastershipEvent);
- lastAddMastershipEvents.remove(mastershipEvent.getIDasByteBuffer());
- apiRemovedMastershipEvents.add(mastershipEvent);
+ private void removeMastershipData(MastershipData mastershipData) {
+ log.debug("Removed Mastership event {}", mastershipData);
+ lastAddMastershipDataEntries.remove(mastershipData.getIDasByteBuffer());
+ apiRemovedMastershipDataEntries.add(mastershipData);
}
/**
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
index e2bdb77..be47051 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
@@ -99,7 +99,7 @@
// TODO: What to do if the Mastership changes?
// - Cleanup state from publishedFoo maps, but do not send REMOVE events?
//
- private ConcurrentMap<Dpid, MastershipEvent> publishedMastershipEvents =
+ private ConcurrentMap<Dpid, MastershipData> publishedMastershipDataEntries =
new ConcurrentHashMap<>();
private ConcurrentMap<Dpid, SwitchData> publishedSwitchDataEntries =
new ConcurrentHashMap<>();
@@ -398,15 +398,15 @@
Role role = Role.SLAVE; // TODO: Should be Role.UNKNOWN
- MastershipEvent mastershipEvent =
- new MastershipEvent(dpid, getOnosInstanceId(), role);
+ MastershipData mastershipData =
+ new MastershipData(dpid, getOnosInstanceId(), role);
// FIXME should be merging, with existing attrs, etc..
// TODO define attr name as constant somewhere.
// TODO populate appropriate attributes.
- mastershipEvent.createStringAttribute(TopologyElement.TYPE,
+ mastershipData.createStringAttribute(TopologyElement.TYPE,
TopologyElement.TYPE_ALL_LAYERS);
- mastershipEvent.freeze();
- publishRemoveSwitchMastershipEvent(mastershipEvent);
+ mastershipData.freeze();
+ publishRemoveSwitchMastershipEvent(mastershipData);
}
@Override
@@ -625,52 +625,52 @@
private void controllerRoleChanged(Dpid dpid, Role role) {
log.debug("Local switch controller mastership role changed: dpid = {} role = {}",
dpid, role);
- MastershipEvent mastershipEvent =
- new MastershipEvent(dpid, getOnosInstanceId(), role);
+ MastershipData mastershipData =
+ new MastershipData(dpid, getOnosInstanceId(), role);
// FIXME should be merging, with existing attrs, etc..
// TODO define attr name as constant somewhere.
// TODO populate appropriate attributes.
- mastershipEvent.createStringAttribute(TopologyElement.TYPE,
+ mastershipData.createStringAttribute(TopologyElement.TYPE,
TopologyElement.TYPE_ALL_LAYERS);
- mastershipEvent.freeze();
- publishAddSwitchMastershipEvent(mastershipEvent);
+ mastershipData.freeze();
+ publishAddSwitchMastershipEvent(mastershipData);
}
/**
* Publishes ADD Mastership Event.
*
- * @param mastershipEvent the mastership event to publish
+ * @param mastershipData the mastership event to publish
*/
private void publishAddSwitchMastershipEvent(
- MastershipEvent mastershipEvent) {
+ MastershipData mastershipData) {
// Publish the information
TopologyBatchOperation tbo = new TopologyBatchOperation();
TopologyEvent topologyEvent =
- new TopologyEvent(mastershipEvent, getOnosInstanceId());
+ new TopologyEvent(mastershipData, getOnosInstanceId());
tbo.appendAddOperation(topologyEvent);
publishTopologyOperations(tbo);
- publishedMastershipEvents.put(mastershipEvent.getDpid(),
- mastershipEvent);
+ publishedMastershipDataEntries.put(mastershipData.getDpid(),
+ mastershipData);
}
/**
* Publishes REMOVE Mastership Event.
*
- * @param mastershipEvent the mastership event to publish
+ * @param mastershipData the mastership event to publish
*/
private void publishRemoveSwitchMastershipEvent(
- MastershipEvent mastershipEvent) {
- if (publishedMastershipEvents.get(mastershipEvent.getDpid()) == null) {
+ MastershipData mastershipData) {
+ if (publishedMastershipDataEntries.get(mastershipData.getDpid()) == null) {
return; // Nothing to do
}
// Publish the information
TopologyBatchOperation tbo = new TopologyBatchOperation();
TopologyEvent topologyEvent =
- new TopologyEvent(mastershipEvent, getOnosInstanceId());
+ new TopologyEvent(mastershipData, getOnosInstanceId());
tbo.appendRemoveOperation(topologyEvent);
publishTopologyOperations(tbo);
- publishedMastershipEvents.remove(mastershipEvent.getDpid());
+ publishedMastershipDataEntries.remove(mastershipData.getDpid());
}
/**
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/MastershipEventSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/MastershipDataSerializer.java
similarity index 66%
rename from src/main/java/net/onrc/onos/core/topology/web/serializers/MastershipEventSerializer.java
rename to src/main/java/net/onrc/onos/core/topology/web/serializers/MastershipDataSerializer.java
index d8c8da7..f147f0c 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/MastershipEventSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/MastershipDataSerializer.java
@@ -3,7 +3,7 @@
import java.io.IOException;
import java.util.Map.Entry;
-import net.onrc.onos.core.topology.MastershipEvent;
+import net.onrc.onos.core.topology.MastershipData;
import net.onrc.onos.core.topology.TopologyElement;
import org.codehaus.jackson.JsonGenerator;
@@ -11,27 +11,27 @@
import org.codehaus.jackson.map.ser.std.SerializerBase;
/**
- * JSON serializer for MastershipEvent objects.
+ * JSON serializer for MastershipData objects.
*/
-public class MastershipEventSerializer extends SerializerBase<MastershipEvent> {
+public class MastershipDataSerializer extends SerializerBase<MastershipData> {
/**
* Default constructor.
*/
- public MastershipEventSerializer() {
- super(MastershipEvent.class);
+ public MastershipDataSerializer() {
+ super(MastershipData.class);
}
/**
- * Serializes a MastershipEvent object in JSON.
+ * Serializes a MastershipData object in JSON.
*
- * @param mastershipEvent the MastershipEvent that is being converted to
+ * @param mastershipData the MastershipData that is being converted to
* JSON
* @param jsonGenerator generator to place the serialized JSON into
* @param serializerProvider unused but required for method override
* @throws IOException if the JSON serialization process fails
*/
@Override
- public void serialize(final MastershipEvent mastershipEvent,
+ public void serialize(final MastershipData mastershipData,
final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider)
throws IOException {
@@ -44,15 +44,15 @@
//
jsonGenerator.writeStartObject();
- jsonGenerator.writeStringField(TopologyElement.TYPE, mastershipEvent.getType());
+ jsonGenerator.writeStringField(TopologyElement.TYPE, mastershipData.getType());
jsonGenerator.writeStringField("dpid",
- mastershipEvent.getDpid().toString());
+ mastershipData.getDpid().toString());
jsonGenerator.writeStringField("onosInstanceId",
- mastershipEvent.getOnosInstanceId().toString());
+ mastershipData.getOnosInstanceId().toString());
jsonGenerator.writeStringField("role",
- mastershipEvent.getRole().name());
+ mastershipData.getRole().name());
jsonGenerator.writeObjectFieldStart("stringAttributes");
- for (Entry<String, String> entry : mastershipEvent.getAllStringAttributes().entrySet()) {
+ for (Entry<String, String> entry : mastershipData.getAllStringAttributes().entrySet()) {
jsonGenerator.writeStringField(entry.getKey(), entry.getValue());
}
jsonGenerator.writeEndObject(); // stringAttributes
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/TopologyEventsSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/TopologyEventsSerializer.java
index 2737ec7..477fc45 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/TopologyEventsSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/TopologyEventsSerializer.java
@@ -4,7 +4,7 @@
import net.onrc.onos.core.topology.HostData;
import net.onrc.onos.core.topology.LinkData;
-import net.onrc.onos.core.topology.MastershipEvent;
+import net.onrc.onos.core.topology.MastershipData;
import net.onrc.onos.core.topology.PortData;
import net.onrc.onos.core.topology.SwitchData;
import net.onrc.onos.core.topology.TopologyEvents;
@@ -43,15 +43,15 @@
// Output the added switch mastership array
jsonGenerator.writeArrayFieldStart("addedSwitchMasterships");
- for (final MastershipEvent mastershipEvent : topologyEvents.getAddedMastershipEvents()) {
- jsonGenerator.writeObject(mastershipEvent);
+ for (final MastershipData mastershipData : topologyEvents.getAddedMastershipDataEntries()) {
+ jsonGenerator.writeObject(mastershipData);
}
jsonGenerator.writeEndArray();
// Output the removed switch mastership array
jsonGenerator.writeArrayFieldStart("removedSwitchMasterships");
- for (final MastershipEvent mastershipEvent : topologyEvents.getRemovedMastershipEvents()) {
- jsonGenerator.writeObject(mastershipEvent);
+ for (final MastershipData mastershipData : topologyEvents.getRemovedMastershipDataEntries()) {
+ jsonGenerator.writeObject(mastershipData);
}
jsonGenerator.writeEndArray();
diff --git a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
index 7f67289..fbb7999 100644
--- a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
+++ b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
@@ -64,7 +64,7 @@
import net.onrc.onos.core.topology.ConfigState;
import net.onrc.onos.core.topology.HostData;
import net.onrc.onos.core.topology.LinkData;
-import net.onrc.onos.core.topology.MastershipEvent;
+import net.onrc.onos.core.topology.MastershipData;
import net.onrc.onos.core.topology.PortData;
import net.onrc.onos.core.topology.SwitchData;
import net.onrc.onos.core.topology.TopologyBatchOperation;
@@ -203,7 +203,7 @@
kryo.register(HostData.class);
kryo.register(LinkedList.class);
kryo.register(LinkData.class);
- kryo.register(MastershipEvent.class);
+ kryo.register(MastershipData.class);
kryo.register(OnosInstanceId.class);
kryo.register(PortData.class);
kryo.register(Role.class);