Cherry pick gNMI and Stratum related changes to this branch
Cherry picked commits:
20211 Update gNMI version and build script
20247 [ONOS-7829] Implement AbstractGrpcClient and AbstractGrpcClientControl
20233 [ONOS-7141][ONOS-7142] Add GnmiClient and GnmiController
20234 Refactor OpenConfig gNMI device description descovery
20260 [ONOS-7831] Implement GnmiHandshaker
20270 Add Stratum driver
Change-Id: I81ad8bce45251af5909cfcac0edbcfd11c8ebf1d
diff --git a/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/AbstractGrpcClient.java b/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/AbstractGrpcClient.java
index 4764a56..05e2978 100644
--- a/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/AbstractGrpcClient.java
+++ b/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/AbstractGrpcClient.java
@@ -17,7 +17,6 @@
package org.onosproject.grpc.ctl;
import io.grpc.Context;
-import io.grpc.ManagedChannel;
import io.grpc.StatusRuntimeException;
import org.onlab.util.SharedExecutors;
import org.onosproject.grpc.api.GrpcClient;
@@ -25,7 +24,6 @@
import org.onosproject.net.DeviceId;
import org.slf4j.Logger;
-
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
@@ -45,26 +43,24 @@
public abstract class AbstractGrpcClient implements GrpcClient {
// Timeout in seconds to obtain the request lock.
- protected static final int LOCK_TIMEOUT = 60;
+ private static final int LOCK_TIMEOUT = 60;
private static final int DEFAULT_THREAD_POOL_SIZE = 10;
protected final Logger log = getLogger(getClass());
- protected final Lock requestLock = new ReentrantLock();
- protected final Context.CancellableContext cancellableContext =
+ private final Lock requestLock = new ReentrantLock();
+ private final Context.CancellableContext cancellableContext =
Context.current().withCancellation();
+ private final Executor contextExecutor;
+
protected final ExecutorService executorService;
- protected final Executor contextExecutor;
+ protected final DeviceId deviceId;
- protected ManagedChannel channel;
- protected DeviceId deviceId;
-
- protected AbstractGrpcClient(GrpcClientKey clientKey, ManagedChannel channel) {
+ protected AbstractGrpcClient(GrpcClientKey clientKey) {
this.deviceId = clientKey.deviceId();
this.executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE, groupedThreads(
"onos-grpc-" + clientKey.serviceName() + "-client-" + deviceId.toString(), "%d"));
this.contextExecutor = this.cancellableContext.fixedContextExecutor(executorService);
- this.channel = channel;
}
@Override
@@ -112,7 +108,7 @@
* @param executor the executor to execute this supplier
* @return CompletableFuture includes the result of supplier
*/
- protected <U> CompletableFuture<U> supplyWithExecutor(
+ private <U> CompletableFuture<U> supplyWithExecutor(
Supplier<U> supplier, String opDescription, Executor executor) {
return CompletableFuture.supplyAsync(() -> {
// TODO: explore a more relaxed locking strategy.
diff --git a/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/AbstractGrpcClientController.java b/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/AbstractGrpcClientController.java
index 36e453c..bf2bbf1 100644
--- a/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/AbstractGrpcClientController.java
+++ b/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/AbstractGrpcClientController.java
@@ -21,7 +21,6 @@
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.netty.NettyChannelBuilder;
-
import org.onosproject.event.AbstractListenerManager;
import org.onosproject.event.Event;
import org.onosproject.event.EventListener;
@@ -152,7 +151,7 @@
return withDeviceLock(() -> doGetClient(deviceId), deviceId);
}
- protected C doGetClient(DeviceId deviceId) {
+ private C doGetClient(DeviceId deviceId) {
if (!clientKeys.containsKey(deviceId)) {
return null;
}
@@ -183,7 +182,7 @@
return withDeviceLock(() -> doIsReachable(deviceId), deviceId);
}
- protected boolean doIsReachable(DeviceId deviceId) {
+ private boolean doIsReachable(DeviceId deviceId) {
// Default behaviour checks only the gRPC channel, should
// check according to different gRPC service
if (!clientKeys.containsKey(deviceId)) {