Fix P4RuntimeClientImpl sending empty stream RPC messages
Change-Id: I31e010144585a0cb9e054e773b7a7e4380919d75
diff --git a/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimeClient.java b/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimeClient.java
index 93adf11..32b1f9f 100644
--- a/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimeClient.java
+++ b/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimeClient.java
@@ -54,7 +54,8 @@
}
/**
- * Starts the client by starting the Stream RPC with the device.
+ * Starts the client by starting the Stream RPC with the device. The
+ * implementation of this method is equivalent to {@link #becomeMaster()}.
*
* @return completable future containing true if the operation was
* successful, false otherwise.
diff --git a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeClientImpl.java b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeClientImpl.java
index b4d88a7..a5c3c13 100644
--- a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeClientImpl.java
+++ b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeClientImpl.java
@@ -207,7 +207,7 @@
@Override
public CompletableFuture<Boolean> start() {
- return supplyInContext(this::doInitStreamChannel,
+ return supplyInContext(this::doBecomeMaster,
"start-initStreamChannel");
}
@@ -356,20 +356,6 @@
return false;
}
- private boolean doInitStreamChannel() {
- // To listen for packets and other events, we need to start the RPC.
- // Here we send an empty StreamMessageRequest.
- try {
- log.info("Starting stream channel with {}...", deviceId);
- streamRequestObserver.onNext(StreamMessageRequest.newBuilder().build());
- return true;
- } catch (StatusRuntimeException e) {
- log.error("Unable to start stream channel with {}: {}",
- deviceId, e.getMessage());
- return false;
- }
- }
-
private boolean doSetPipelineConfig(PiPipeconf pipeconf, ByteBuffer deviceData) {
log.info("Setting pipeline config for {} to {}...", deviceId, pipeconf.id());