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/api/src/main/java/org/onosproject/grpc/api/GrpcClientController.java b/protocols/grpc/api/src/main/java/org/onosproject/grpc/api/GrpcClientController.java
index 2e3ea5d..3cdbcd1 100644
--- a/protocols/grpc/api/src/main/java/org/onosproject/grpc/api/GrpcClientController.java
+++ b/protocols/grpc/api/src/main/java/org/onosproject/grpc/api/GrpcClientController.java
@@ -20,8 +20,8 @@
 import org.onosproject.net.DeviceId;
 
 /**
- * Abstraction of a gRPC controller which controls specific gRPC
- * client {@link C} with specific client key {@link K}.
+ * Abstraction of a gRPC controller which controls specific gRPC client {@link
+ * C} with specific client key {@link K}.
  *
  * @param <K> the gRPC client key
  * @param <C> the gRPC client type
@@ -30,19 +30,19 @@
 public interface GrpcClientController<K extends GrpcClientKey, C extends GrpcClient> {
 
     /**
-     * Instantiates a new client to operate on a gRPC server identified by
-     * the given information. As a result of this method, a client can be later
+     * Instantiates a new client to operate on a gRPC server identified by the
+     * given information. As a result of this method, a client can be later
      * obtained by invoking {@link #getClient(DeviceId)}.
-     *
-     * Only one client can exist for the same device ID. Calls to this method are
-     * idempotent fot the same client key, i.e. returns true
-     * if such client already exists but a new one is not created.
-     * If there exists a client with same device ID but different address and port,
-     * removes old one and recreate new one.
+     * <p>
+     * Only one client can exist for the same device ID. Calls to this method
+     * are idempotent fot the same client key, i.e. returns true if such client
+     * already exists but a new one is not created. If there exists a client
+     * with same device ID but different address and port, removes old one and
+     * recreate new one.
      *
      * @param clientKey the client key
-     * @return true if the client was created and the channel to the server is open;
-     *         false otherwise
+     * @return true if the client was created and the channel to the server is
+     * open; false otherwise
      */
     boolean createClient(K clientKey);
 
@@ -55,8 +55,8 @@
     C getClient(DeviceId deviceId);
 
     /**
-     * Removes the gRPC client for the given device. If no client
-     * exists for the given device, the result is a no-op.
+     * Removes the gRPC client for the given device. If no client exists for the
+     * given device, the result is a no-op.
      *
      * @param deviceId the device identifier
      */
@@ -64,15 +64,15 @@
 
     /**
      * Check reachability of the gRPC server running on the given device.
-     * Reachability can be tested only if a client is previously created
-     * using {@link #createClient(GrpcClientKey)}.
-     * Note that this only checks the reachability instead of checking service
-     * availability, different gRPC client checks service availability with
+     * Reachability can be tested only if a client is previously created using
+     * {@link #createClient(GrpcClientKey)}. Note that this only checks the
+     * reachability instead of checking service availability, different
+     * service-specific gRPC clients might check service availability in a
      * different way.
      *
      * @param deviceId the device identifier
-     * @return true if client was created and is able to contact the gNMI server;
-     *         false otherwise
+     * @return true if client was created and is able to contact the gNMI
+     * server; false otherwise
      */
     boolean isReachable(DeviceId deviceId);
 }
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)) {