Fix for duplicated event issue.
1) Waits for the end of the leader election;
2) Partially reverts 18417 - there is no always the need
to notify the delegate;
3) Reverts 18899, since 19904 partially reverted 16278
which was the original reason for 18899;
4) Removes offline timestamp after an admin-removal
patch2: introduces 4) to fix the issues of the previous patch
patch1: duplicated events are still present after an admin
removal (remove or wipe-out please) - the issue is not related
to the changes reported above.
Change-Id: I6e6b2ce21b08d08e8188dea362a904e6dc5505d4
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java
index 97d6e7b..b538a75 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java
@@ -167,13 +167,16 @@
descs.putDeviceDesc(deviceDescription);
Device newDevice = composeDevice(deviceId, providerDescs);
+ DeviceEvent event = null;
if (oldDevice == null) {
// ADD
- return createDevice(providerId, newDevice);
+ event = createDevice(providerId, newDevice);
} else {
// UPDATE or ignore (no change or stale)
- return updateDevice(providerId, oldDevice, newDevice);
+ event = updateDevice(providerId, oldDevice, newDevice);
}
+ notifyDelegateIfNotNull(event);
+ return event;
}
}
@@ -661,6 +664,12 @@
portDesc.portSpeed(), annotations);
}
+ private void notifyDelegateIfNotNull(DeviceEvent event) {
+ if (event != null) {
+ notifyDelegate(event);
+ }
+ }
+
/**
* @return primary ProviderID, or randomly chosen one if none exists
*/