BMv2 performance improvements
- Implemented a non-blocking Thrift server for the controller (before it
was limiting the number of active connections)
- Improved configuration swap times by forcing it
- Minor bugfixes and polishing
- Update onos-bmv2 repo URL in thrift-api pom.xml
Change-Id: I13b61f5aa22558c395768e3b445f302b20c5bd33
diff --git a/protocols/bmv2/ctl/src/main/java/org/onosproject/bmv2/ctl/Bmv2DeviceContextServiceImpl.java b/protocols/bmv2/ctl/src/main/java/org/onosproject/bmv2/ctl/Bmv2DeviceContextServiceImpl.java
index c6f3d04..e077b6d 100644
--- a/protocols/bmv2/ctl/src/main/java/org/onosproject/bmv2/ctl/Bmv2DeviceContextServiceImpl.java
+++ b/protocols/bmv2/ctl/src/main/java/org/onosproject/bmv2/ctl/Bmv2DeviceContextServiceImpl.java
@@ -171,6 +171,17 @@
return defaultContext;
}
+ @Override
+ public void setDefaultContext(DeviceId deviceId) {
+ Versioned<Bmv2DeviceContext> previous = contexts.put(deviceId, defaultContext);
+ if (mastershipService.getMasterFor(deviceId) == null) {
+ // Checking for who is the master here is ugly but necessary, as this method is called by Bmv2DeviceProvider
+ // prior to master election. A solution could be to use a separate leadership contest instead of the
+ // mastership service.
+ triggerConfigCheck(deviceId, defaultContext);
+ }
+ }
+
private void configCheck(DeviceId deviceId, Bmv2DeviceContext storedContext) {
if (storedContext == null) {
return;
@@ -206,14 +217,14 @@
}
private void triggerConfigCheck(DeviceId deviceId, Bmv2DeviceContext context) {
- if (mastershipService.isLocalMaster(deviceId)) {
scheduledExecutor.schedule(() -> configCheck(deviceId, context), 0, TimeUnit.SECONDS);
- }
}
private void checkDevices() {
deviceService.getAvailableDevices().forEach(device -> {
- triggerConfigCheck(device.id(), getContext(device.id()));
+ if (mastershipService.isLocalMaster(device.id())) {
+ triggerConfigCheck(device.id(), getContext(device.id()));
+ }
});
}
@@ -235,8 +246,10 @@
public void event(MapEvent<DeviceId, Bmv2DeviceContext> event) {
DeviceId deviceId = event.key();
if (event.type().equals(INSERT) || event.type().equals(UPDATE)) {
- log.trace("Context {} for {}", event.type().name(), deviceId);
- triggerConfigCheck(deviceId, event.newValue().value());
+ if (mastershipService.isLocalMaster(deviceId)) {
+ log.trace("Context {} for {}", event.type().name(), deviceId);
+ triggerConfigCheck(deviceId, event.newValue().value());
+ }
}
}
}