Update ProtoBuf 3 & gRPC

- Protocol Buffers: 3.0.0
- gRPC: 1.0.0-pre2

Change-Id: Ic80d3f660d4a0aa37a99d4e6d4dc45e0b70b073b
diff --git a/incubator/protobuf/features.xml b/incubator/protobuf/features.xml
index 2d7d5c2..c19a13b 100644
--- a/incubator/protobuf/features.xml
+++ b/incubator/protobuf/features.xml
@@ -18,7 +18,7 @@
     <feature name="${project.artifactId}" version="${project.version}"
              description="${project.description}">
         <feature>onos-api</feature>
-        <bundle>mvn:com.google.protobuf/protobuf-java/3.0.0-beta-2</bundle>
+        <bundle>mvn:com.google.protobuf/protobuf-java/3.0.0</bundle>
         <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
     </feature>
 </features>
diff --git a/incubator/protobuf/pom.xml b/incubator/protobuf/pom.xml
index 4be8695..10246c4 100644
--- a/incubator/protobuf/pom.xml
+++ b/incubator/protobuf/pom.xml
@@ -30,9 +30,9 @@
 
     <properties>
         <onos.app.name>org.onosproject.incubator.protobuf</onos.app.name>
-        <onos.app.requires>org.onosproject.incubator.rpc</onos.app.requires>
+        <onos.app.title>ONOS Protocol Buffers models</onos.app.title>
         <!-- Note: update feature.xml when updating -->
-        <protobuf.version>3.0.0-beta-2</protobuf.version>
+        <protobuf.version>3.0.0</protobuf.version>
     </properties>
 
     <dependencies>
@@ -129,7 +129,6 @@
                         depend on protobuf-java directly, you will be transitively depending on the 
                         protobuf-java version that grpc depends on. -->
                     <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
-                    <checkStaleness>true</checkStaleness>
                 </configuration>
                 <executions>
                     <execution>
@@ -143,7 +142,7 @@
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>build-helper-maven-plugin</artifactId>
-                <version>1.10</version>
+                <version>1.11</version>
                 <executions>
                     <execution>
                         <id>add-source</id>
diff --git a/incubator/rpc-grpc/features.xml b/incubator/rpc-grpc/features.xml
index 72560ad..4061b6e 100644
--- a/incubator/rpc-grpc/features.xml
+++ b/incubator/rpc-grpc/features.xml
@@ -18,24 +18,25 @@
     <feature name="${project.artifactId}" version="${project.version}"
              description="${project.description}">
         <feature>onos-api</feature>
-        <bundle>mvn:com.google.protobuf/protobuf-java/3.0.0-beta-2</bundle>
-        <bundle>mvn:io.netty/netty-common/4.1.0.CR7</bundle>
-        <bundle>mvn:io.netty/netty-buffer/4.1.0.CR7</bundle>
-        <bundle>mvn:io.netty/netty-transport/4.1.0.CR7</bundle>
-        <bundle>mvn:io.netty/netty-handler/4.1.0.CR7</bundle>
-        <bundle>mvn:io.netty/netty-codec/4.1.0.CR7</bundle>
-        <bundle>mvn:io.netty/netty-codec-http/4.1.0.CR7</bundle>
-        <bundle>mvn:io.netty/netty-codec-http2/4.1.0.CR7</bundle>
-        <bundle>mvn:io.netty/netty-resolver/4.1.0.CR7</bundle>
+        <bundle>mvn:com.google.protobuf/protobuf-java/3.0.0</bundle>
+        <bundle>mvn:io.netty/netty-common/4.1.3.Final</bundle>
+        <bundle>mvn:io.netty/netty-buffer/4.1.3.Final</bundle>
+        <bundle>mvn:io.netty/netty-transport/4.1.3.Final</bundle>
+        <bundle>mvn:io.netty/netty-handler/4.1.3.Final</bundle>
+        <bundle>mvn:io.netty/netty-codec/4.1.3.Final</bundle>
+        <bundle>mvn:io.netty/netty-codec-http/4.1.3.Final</bundle>
+        <bundle>mvn:io.netty/netty-codec-http2/4.1.3.Final</bundle>
+        <bundle>mvn:io.netty/netty-resolver/4.1.3.Final</bundle>
         <!-- TODO: Create shaded jar for these. -->
-        <bundle>wrap:mvn:com.google.auth/google-auth-library-credentials/0.3.0$Bundle-SymbolicName=com.google.auth.google-auth-library-credentials&amp;Bundle-Version=0.3.0</bundle>
-        <bundle>wrap:mvn:com.google.auth/google-auth-library-oauth2-http/0.3.0$Bundle-SymbolicName=com.google.auth.google-auth-library-oauth2-http&amp;Bundle-Version=0.3.0</bundle>
-        <bundle>wrap:mvn:io.grpc/grpc-core/0.14.0$Bundle-SymbolicName=io.grpc.grpc-core&amp;Bundle-Version=0.14.0&amp;</bundle>
-        <bundle>wrap:mvn:io.grpc/grpc-protobuf-lite/0.14.0$Bundle-SymbolicName=io.grpc.grpc-protobuf-lite&amp;Bundle-Version=0.14.0&amp;</bundle>
-        <bundle>wrap:mvn:io.grpc/grpc-protobuf/0.14.0$Bundle-SymbolicName=io.grpc.grpc-protobuf&amp;Bundle-Version=0.14.0&amp;</bundle>
-        <bundle>wrap:mvn:io.grpc/grpc-stub/0.14.0$Bundle-SymbolicName=io.grpc.grpc-stub&amp;Bundle-Version=0.14.0&amp;</bundle>
-        <bundle>wrap:mvn:io.grpc/grpc-netty/0.14.0$Bundle-SymbolicName=io.grpc.grpc-netty&amp;Bundle-Version=0.14.0&amp;Import-Package=io.netty.*;version=4.1.0.CR7,*</bundle>
-        <bundle>wrap:mvn:io.grpc/grpc-auth/0.14.0$Bundle-SymbolicName=io.grpc.grpc-auth&amp;Bundle-Version=0.14.0&amp;Import-Package=javax.net.ssl,*</bundle>
+        <bundle>wrap:mvn:com.google.auth/google-auth-library-credentials/0.4.0$Bundle-SymbolicName=com.google.auth.google-auth-library-credentials&amp;Bundle-Version=0.4.0</bundle>
+        <bundle>wrap:mvn:com.google.auth/google-auth-library-oauth2-http/0.4.0$Bundle-SymbolicName=com.google.auth.google-auth-library-oauth2-http&amp;Bundle-Version=0.4.0</bundle>
+        <!-- io.grpc.internal required for DnsNameResolverProvider -->
+        <bundle>wrap:mvn:io.grpc/grpc-core/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-core&amp;Bundle-Version=1.0.0&amp;Export-Package=*;version=1.0.0,io.grpc.internal;version=1.0.0&amp;</bundle>
+        <bundle>wrap:mvn:io.grpc/grpc-protobuf-lite/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-protobuf-lite&amp;Bundle-Version=1.0.0&amp;</bundle>
+        <bundle>wrap:mvn:io.grpc/grpc-protobuf/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-protobuf&amp;Bundle-Version=1.0.0&amp;</bundle>
+        <bundle>wrap:mvn:io.grpc/grpc-stub/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-stub&amp;Bundle-Version=1.0.0&amp;</bundle>
+        <bundle>wrap:mvn:io.grpc/grpc-netty/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-netty&amp;Bundle-Version=1.0.0&amp;Import-Package=io.netty.*;version=4.1.3,*</bundle>
+        <bundle>wrap:mvn:io.grpc/grpc-auth/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-auth&amp;Bundle-Version=1.0.0&amp;Import-Package=javax.net.ssl,*</bundle>
         <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
     </feature>
 </features>
diff --git a/incubator/rpc-grpc/pom.xml b/incubator/rpc-grpc/pom.xml
index 6e672ad..4ae20f3 100644
--- a/incubator/rpc-grpc/pom.xml
+++ b/incubator/rpc-grpc/pom.xml
@@ -30,11 +30,15 @@
 
     <properties>
         <onos.app.name>org.onosproject.incubator.rpc.grpc</onos.app.name>
-        <onos.app.requires>org.onosproject.incubator.rpc,org.onosproject.incubator.protobuf</onos.app.requires>
-        <protobuf.version>3.0.0-beta-2</protobuf.version>
+        <onos.app.title>ONOS gRPC API</onos.app.title>
+        <onos.app.requires>
+            org.onosproject.incubator.rpc,
+            org.onosproject.incubator.protobuf
+        </onos.app.requires>
+        <protobuf.version>3.0.0</protobuf.version>
         <!-- Note: update feature.xml when updating -->
-        <grpc.version>0.14.0</grpc.version>
-        <grpc.netty.version>4.1.0.CR7</grpc.netty.version>
+        <grpc.version>1.0.0-pre2</grpc.version>
+        <grpc.netty.version>4.1.3.Final</grpc.netty.version>
     </properties>
 
     <dependencies>
@@ -211,7 +215,6 @@
                     <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
                     <pluginId>grpc-java</pluginId>
                     <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
-                    <checkStaleness>true</checkStaleness>
                 </configuration>
                 <executions>
                     <execution>
@@ -226,7 +229,7 @@
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>build-helper-maven-plugin</artifactId>
-                <version>1.10</version>
+                <version>1.11</version>
                 <executions>
                     <execution>
                         <id>add-source</id>
@@ -274,12 +277,6 @@
                 <artifactId>netty-common</artifactId>
                 <version>${grpc.netty.version}</version>
             </dependency>
-            <dependency>
-                <groupId>com.twitter</groupId>
-                <artifactId>hpack</artifactId>
-                <!-- 0.11.0 and later are published as a bundle -->
-                <version>0.11.0</version>
-            </dependency>
         </dependencies>
     </dependencyManagement>
 
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceProvider.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceProvider.java
index 5934939..9fe33f7 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceProvider.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceProvider.java
@@ -36,6 +36,7 @@
 import org.slf4j.LoggerFactory;
 
 import io.grpc.ManagedChannel;
+import io.grpc.internal.DnsNameResolverProvider;
 import io.grpc.netty.NegotiationType;
 import io.grpc.netty.NettyChannelBuilder;
 
@@ -62,7 +63,6 @@
 
     private RemoteServiceContextProviderService providerService;
 
-
     @Activate
     protected void activate() {
         providerService = rpcRegistry.register(this);
@@ -116,6 +116,10 @@
         }
         return NettyChannelBuilder.forAddress(uri.getHost(), port)
                 .negotiationType(NegotiationType.PLAINTEXT)
+                // TODO Not ideal fix, gRPC discovers name resolvers
+                // in the class path, but OSGi was preventing it.
+                // Manually specifying the default dns resolver for now.
+                .nameResolverFactory(new DnsNameResolverProvider())
                 .build();
     }
 
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java
index 260a709..2604d09 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java
@@ -39,8 +39,7 @@
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.onlab.util.Tools;
-import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc;
-import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc.DeviceProviderRegistryRpc;
+import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc.DeviceProviderRegistryRpcImplBase;
 import org.onosproject.grpc.net.device.DeviceService.DeviceConnected;
 import org.onosproject.grpc.net.device.DeviceService.DeviceDisconnected;
 import org.onosproject.grpc.net.device.DeviceService.DeviceProviderMsg;
@@ -51,7 +50,6 @@
 import org.onosproject.grpc.net.device.DeviceService.RegisterProvider;
 import org.onosproject.grpc.net.device.DeviceService.UpdatePortStatistics;
 import org.onosproject.grpc.net.device.DeviceService.UpdatePorts;
-import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc;
 import org.onosproject.incubator.protobuf.net.ProtobufUtils;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.MastershipRole;
@@ -123,8 +121,8 @@
         log.debug("Server starting on {}", listenPort);
         try {
             server  = NettyServerBuilder.forPort(listenPort)
-                    .addService(DeviceProviderRegistryRpcGrpc.bindService(new DeviceProviderRegistryServerProxy()))
-                    .addService(LinkProviderServiceRpcGrpc.bindService(new LinkProviderServiceServerProxy(this)))
+                    .addService(new DeviceProviderRegistryServerProxy())
+                    .addService(new LinkProviderServiceServerProxy(this))
                     .build().start();
         } catch (IOException e) {
             log.error("Failed to start gRPC server", e);
@@ -202,7 +200,7 @@
     /**
      * Relays DeviceProviderRegistry calls from RPC client.
      */
-    class DeviceProviderRegistryServerProxy implements DeviceProviderRegistryRpc {
+    class DeviceProviderRegistryServerProxy extends DeviceProviderRegistryRpcImplBase {
 
         @Override
         public StreamObserver<DeviceProviderServiceMsg> register(StreamObserver<DeviceProviderMsg> toDeviceProvider) {
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderRegistryClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderRegistryClientProxy.java
index 5df5a3d..abadf76 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderRegistryClientProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderRegistryClientProxy.java
@@ -22,7 +22,7 @@
 import org.onosproject.net.link.LinkProviderService;
 import org.onosproject.net.provider.AbstractProviderRegistry;
 
-import com.google.api.client.repackaged.com.google.common.annotations.Beta;
+import com.google.common.annotations.Beta;
 
 import io.grpc.Channel;
 
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
index b576033..0f43db2 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
@@ -38,7 +38,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.api.client.repackaged.com.google.common.annotations.Beta;
+import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.ListenableFuture;
 
 import io.grpc.Channel;
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
index 435c650..26210f6 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
@@ -27,7 +27,7 @@
 import org.apache.commons.lang3.tuple.Pair;
 import org.onosproject.grpc.net.Link.ConnectPoint.ElementIdCase;
 import org.onosproject.grpc.net.Link.LinkType;
-import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServiceRpc;
+import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServiceRpcImplBase;
 import org.onosproject.grpc.net.link.LinkService.LinkDetectedMsg;
 import org.onosproject.grpc.net.link.LinkService.LinkVanishedMsg;
 import org.onosproject.grpc.net.link.LinkService.Void;
@@ -44,10 +44,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.api.client.repackaged.com.google.common.annotations.Beta;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.RemovalNotification;
+import com.google.common.annotations.Beta;
 
 import io.grpc.stub.StreamObserver;
 
@@ -57,7 +57,7 @@
  */
 @Beta
 final class LinkProviderServiceServerProxy
-        implements LinkProviderServiceRpc {
+        extends LinkProviderServiceRpcImplBase {
 
     /**
      * Silence time in seconds, until link gets treated as vanished.
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/StubLinkProvider.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/StubLinkProvider.java
index 460b779..929881c 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/StubLinkProvider.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/StubLinkProvider.java
@@ -19,7 +19,7 @@
 import org.onosproject.net.provider.AbstractProvider;
 import org.onosproject.net.provider.ProviderId;
 
-import com.google.api.client.repackaged.com.google.common.annotations.Beta;
+import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
 
 /**