Improve scalability of P4Runtime subsystem
The P4Runtime client was hanging (deadlock) on a master arbitration
request. As such, all other requests (e.g. table write) were waiting
for the client's request lock to become available.
Apart from fixing those deadlocks, this patch brings a number of
improvements that all together allow to run networks of 100+ P4Runtime
devices on a single ONOS instance (before only ~20 devices)
Includes:
- Asynchrounous mastership handling in DevicHandshaker (as defined in
the P4Runtime and OpenFlow spec)
- Refactored arbitration handling in the P4RuntimeClient
to be consistent with the P4Runtime spec
- Report suspect deadlocks in P4RuntimeClientImpl
- Exploit write errors in P4RuntimeClient to quickly report
channel/mastership errors to upper layers
- Complete all futures with deadlines in P4Runtime driver
- Dump all tables in one request
- Re-purposed ChannelEvent to DeviceAgentEvent to carry also mastership
response events
- Fixed IntelliJ warnings
- Various code and log clean-ups
Change-Id: I9376793a9fe69d8eddf7e8ac2ef0ee4c14fbd198
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMeterProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMeterProgrammable.java
index d7a204e..39ed84d 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMeterProgrammable.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMeterProgrammable.java
@@ -16,9 +16,9 @@
package org.onosproject.drivers.p4runtime;
-import com.google.common.cache.LoadingCache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
import org.onosproject.drivers.p4runtime.mirror.P4RuntimeMeterMirror;
import org.onosproject.net.meter.Band;
import org.onosproject.net.meter.DefaultBand;
@@ -37,11 +37,11 @@
import java.util.Collection;
import java.util.Collections;
-import java.util.Set;
import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
@@ -108,18 +108,13 @@
final PiMeterHandle handle = PiMeterHandle.of(deviceId, piMeterCellConfig);
ENTRY_LOCKS.getUnchecked(handle).lock();
- boolean result = false;
- try {
- if (client.writeMeterCells(newArrayList(piMeterCellConfig), pipeconf).get()) {
- meterMirror.put(handle, piMeterCellConfig);
- result = true;
- }
-
- } catch (InterruptedException | ExecutionException e) {
- log.warn("Exception while modify meter entry:", e);
- } finally {
- ENTRY_LOCKS.getUnchecked(handle).unlock();
+ final boolean result = getFutureWithDeadline(
+ client.writeMeterCells(newArrayList(piMeterCellConfig), pipeconf),
+ "writing meter cells", false);
+ if (result) {
+ meterMirror.put(handle, piMeterCellConfig);
}
+ ENTRY_LOCKS.getUnchecked(handle).unlock();
return result;
}
@@ -162,4 +157,4 @@
return CompletableFuture.completedFuture(meters);
}
-}
\ No newline at end of file
+}