You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/08/28 14:39:25 UTC

[dubbo] branch cloud-native updated (e2f0983 -> 374899c)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a change to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git.


    from e2f0983  Dubbo cloud native (#4958)
     new 4b71c84  gRPC framework support
     new 374899c  add gRPC framework support

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |    6 +-
 LICENSE                                            |    3 +
 NOTICE                                             |   10 +
 dubbo-all/pom.xml                                  |    8 +
 dubbo-bom/pom.xml                                  |    5 +
 .../dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml |    4 +
 dubbo-demo/dubbo-demo-xml/pom.xml                  |    8 +
 dubbo-dependencies-bom/pom.xml                     |   17 +
 dubbo-distribution/src/assembly/source-release.xml |    1 +
 .../.gradle/4.3/fileChanges/last-build.bin         |  Bin 0 -> 1 bytes
 .../4.3/fileContent/annotation-processors.bin      |  Bin 0 -> 19793 bytes
 .../.gradle/4.3/fileContent/fileContent.lock       |  Bin 0 -> 17 bytes
 .../compiler/.gradle/4.3/fileHashes/fileHashes.bin |  Bin 0 -> 523091 bytes
 .../.gradle/4.3/fileHashes/fileHashes.lock         |  Bin 0 -> 17 bytes
 .../.gradle/4.3/fileHashes/resourceHashesCache.bin |  Bin 0 -> 193707 bytes
 .../.gradle/4.3/nativeCompile/nativeCompile.bin    |  Bin 0 -> 18497 bytes
 .../.gradle/4.3/nativeCompile/nativeCompile.lock   |  Bin 0 -> 17 bytes
 .../.gradle/4.3/taskHistory/taskHistory.bin        |  Bin 0 -> 5498488 bytes
 .../.gradle/4.3/taskHistory/taskHistory.lock       |  Bin 0 -> 17 bytes
 .../.gradle/4.9/fileChanges/last-build.bin         |  Bin 0 -> 1 bytes
 .../4.9/fileContent/annotation-processors.bin      |  Bin 0 -> 19064 bytes
 .../.gradle/4.9/fileContent/fileContent.lock       |  Bin 0 -> 17 bytes
 .../.gradle/4.9/fileContent/parsedCSource.bin      |  Bin 0 -> 4542342 bytes
 .../compiler/.gradle/4.9/fileHashes/fileHashes.bin |  Bin 0 -> 882335 bytes
 .../.gradle/4.9/fileHashes/fileHashes.lock         |  Bin 0 -> 17 bytes
 .../.gradle/4.9/fileHashes/resourceHashesCache.bin |  Bin 0 -> 397477 bytes
 .../.gradle/4.9/nativeCompile/nativeCompile.bin    |  Bin 0 -> 50817 bytes
 .../.gradle/4.9/nativeCompile/nativeCompile.lock   |  Bin 0 -> 17 bytes
 .../.gradle/4.9/taskHistory/taskHistory.bin        |  Bin 0 -> 12054698 bytes
 .../.gradle/4.9/taskHistory/taskHistory.lock       |  Bin 0 -> 17 bytes
 .../buildOutputCleanup/buildOutputCleanup.lock     |  Bin 0 -> 17 bytes
 .../.gradle/buildOutputCleanup/cache.properties    |    2 +
 .../.gradle/buildOutputCleanup/outputFiles.bin     |  Bin 0 -> 57533 bytes
 .../compiler/.gradle/vcsWorkingDirs/gc.properties  |    0
 dubbo-rpc/dubbo-rpc-grpc/compiler/BUILD.bazel      |   12 +
 dubbo-rpc/dubbo-rpc-grpc/compiler/README.md        |  171 +++
 dubbo-rpc/dubbo-rpc-grpc/compiler/build.gradle     |  405 +++++
 .../dubbo-rpc-grpc/compiler/check-artifact.sh      |  131 ++
 .../gradle/wrapper/gradle-wrapper.properties       |    5 +
 dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew          |  172 +++
 dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew.bat      |   84 ++
 .../src/java_plugin/cpp/java_generator.cpp         | 1553 ++++++++++++++++++++
 .../compiler/src/java_plugin/cpp/java_generator.h  |   57 +
 .../compiler/src/java_plugin/cpp/java_plugin.cpp   |   70 +
 .../src/test/golden/TestDeprecatedService.java.txt |  316 ++++
 .../compiler/src/test/golden/TestService.java.txt  |  665 +++++++++
 .../test/proto/grpc/testing/compiler/test.proto    |   83 ++
 .../testLite/golden/TestDeprecatedService.java.txt |  279 ++++
 .../src/testLite/golden/TestService.java.txt       |  623 ++++++++
 .../testNano/golden/TestDeprecatedService.java.txt |  305 ++++
 .../src/testNano/golden/TestService.java.txt       |  664 +++++++++
 .../{dubbo-rpc-http => dubbo-rpc-grpc}/pom.xml     |   22 +-
 .../rpc/protocol/grpc/DubboHandlerRegistry.java    |   70 +
 .../dubbo/rpc/protocol/grpc/GrpcProtocol.java      |  200 +++
 .../dubbo/internal/org.apache.dubbo.rpc.Protocol   |    1 +
 dubbo-rpc/pom.xml                                  |    1 +
 pom.xml                                            |   24 +-
 57 files changed, 5954 insertions(+), 23 deletions(-)
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileChanges/last-build.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileContent/annotation-processors.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileContent/fileContent.lock
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/fileHashes.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/fileHashes.lock
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/resourceHashesCache.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/nativeCompile/nativeCompile.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/nativeCompile/nativeCompile.lock
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/taskHistory/taskHistory.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/taskHistory/taskHistory.lock
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileChanges/last-build.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/annotation-processors.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/fileContent.lock
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/parsedCSource.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/fileHashes.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/fileHashes.lock
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/resourceHashesCache.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/nativeCompile/nativeCompile.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/nativeCompile/nativeCompile.lock
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/taskHistory/taskHistory.bin
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/taskHistory/taskHistory.lock
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/buildOutputCleanup.lock
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/cache.properties
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/outputFiles.bin
 copy dubbo-common/src/test/resources/META-INF/dubbo/internal/org.apache.dubbo.common.extension.ext9_empty.Ext9Empty => dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/vcsWorkingDirs/gc.properties (100%)
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/BUILD.bazel
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/README.md
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/build.gradle
 create mode 100755 dubbo-rpc/dubbo-rpc-grpc/compiler/check-artifact.sh
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/gradle/wrapper/gradle-wrapper.properties
 create mode 100755 dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew.bat
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_generator.cpp
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_generator.h
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_plugin.cpp
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/golden/TestDeprecatedService.java.txt
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/golden/TestService.java.txt
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/proto/grpc/testing/compiler/test.proto
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/testLite/golden/TestDeprecatedService.java.txt
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/testLite/golden/TestService.java.txt
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/testNano/golden/TestDeprecatedService.java.txt
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/compiler/src/testNano/golden/TestService.java.txt
 copy dubbo-rpc/{dubbo-rpc-http => dubbo-rpc-grpc}/pom.xml (80%)
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/DubboHandlerRegistry.java
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
 create mode 100644 dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol


[dubbo] 01/02: gRPC framework support

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 4b71c84e215219355e75d96023c345c8467a9f34
Author: ken.lj <ke...@gmail.com>
AuthorDate: Wed Aug 28 17:34:54 2019 +0800

    gRPC framework support
---
 dubbo-all/pom.xml                                  |   8 +
 dubbo-bom/pom.xml                                  |   5 +
 .../dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml |   4 +
 dubbo-demo/dubbo-demo-xml/pom.xml                  |   8 +
 dubbo-dependencies-bom/pom.xml                     |  17 ++
 dubbo-rpc/{ => dubbo-rpc-grpc}/pom.xml             |  56 +++---
 .../rpc/protocol/grpc/DubboHandlerRegistry.java    |  70 ++++++++
 .../dubbo/rpc/protocol/grpc/GrpcProtocol.java      | 200 +++++++++++++++++++++
 .../dubbo/internal/org.apache.dubbo.rpc.Protocol   |   1 +
 dubbo-rpc/pom.xml                                  |   1 +
 pom.xml                                            |  24 +--
 11 files changed, 360 insertions(+), 34 deletions(-)

diff --git a/dubbo-all/pom.xml b/dubbo-all/pom.xml
index 35790a4..bbacb73 100644
--- a/dubbo-all/pom.xml
+++ b/dubbo-all/pom.xml
@@ -221,6 +221,13 @@
         </dependency>
         <dependency>
             <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-rpc-grpc</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo-registry-api</artifactId>
             <version>${project.version}</version>
             <scope>compile</scope>
@@ -593,6 +600,7 @@
                                     <include>org.apache.dubbo:dubbo-rpc-redis</include>
                                     <include>org.apache.dubbo:dubbo-rpc-rest</include>
                                     <include>org.apache.dubbo:dubbo-rpc-xml</include>
+                                    <include>org.apache.dubbo:dubbo-rpc-grpc</include>
                                     <include>org.apache.dubbo:dubbo-filter-validation</include>
                                     <include>org.apache.dubbo:dubbo-filter-cache</include>
                                     <include>org.apache.dubbo:dubbo-cluster</include>
diff --git a/dubbo-bom/pom.xml b/dubbo-bom/pom.xml
index 0b0bd1a..6ccbc1b 100644
--- a/dubbo-bom/pom.xml
+++ b/dubbo-bom/pom.xml
@@ -230,6 +230,11 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-rpc-grpc</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
                 <artifactId>dubbo-registry-api</artifactId>
                 <version>${project.version}</version>
             </dependency>
diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
index 63ed1b8..b3a4acc 100644
--- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
+++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
@@ -32,6 +32,10 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-metadata-report-zookeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo-demo-interface</artifactId>
             <version>${project.parent.version}</version>
         </dependency>
diff --git a/dubbo-demo/dubbo-demo-xml/pom.xml b/dubbo-demo/dubbo-demo-xml/pom.xml
index 858d359..8438d25 100644
--- a/dubbo-demo/dubbo-demo-xml/pom.xml
+++ b/dubbo-demo/dubbo-demo-xml/pom.xml
@@ -40,6 +40,14 @@
         <module>dubbo-demo-xml-consumer</module>
     </modules>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-metadata-report-zookeeper</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+    </dependencies>
+
     <build>
         <plugins>
             <plugin>
diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml
index c335104..8cd3ca8 100644
--- a/dubbo-dependencies-bom/pom.xml
+++ b/dubbo-dependencies-bom/pom.xml
@@ -130,6 +130,7 @@
         <tomcat_embed_version>8.5.31</tomcat_embed_version>
         <jetcd_version>0.3.0</jetcd_version>
         <nacos_version>1.1.1</nacos_version>
+        <grpc.version>1.22.1</grpc.version>
         <!-- Log libs -->
         <slf4j_version>1.7.25</slf4j_version>
         <jcl_version>1.2</jcl_version>
@@ -646,6 +647,22 @@
                 <artifactId>nacos-client</artifactId>
                 <version>${nacos_version}</version>
             </dependency>
+            <!-- grpc related dependencies -->
+            <dependency>
+                <groupId>io.grpc</groupId>
+                <artifactId>grpc-netty-shaded</artifactId>
+                <version>${grpc.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.grpc</groupId>
+                <artifactId>grpc-protobuf</artifactId>
+                <version>${grpc.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.grpc</groupId>
+                <artifactId>grpc-stub</artifactId>
+                <version>${grpc.version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
diff --git a/dubbo-rpc/pom.xml b/dubbo-rpc/dubbo-rpc-grpc/pom.xml
similarity index 51%
copy from dubbo-rpc/pom.xml
copy to dubbo-rpc/dubbo-rpc-grpc/pom.xml
index 1388b50..53f6978 100644
--- a/dubbo-rpc/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-grpc/pom.xml
@@ -18,31 +18,43 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.dubbo</groupId>
-        <artifactId>dubbo-parent</artifactId>
+        <artifactId>dubbo-rpc</artifactId>
         <version>${revision}</version>
-        <relativePath>../pom.xml</relativePath>
     </parent>
-    <artifactId>dubbo-rpc</artifactId>
-    <packaging>pom</packaging>
+    <artifactId>dubbo-rpc-grpc</artifactId>
+    <packaging>jar</packaging>
     <name>${project.artifactId}</name>
-    <description>The rpc module of dubbo project</description>
+    <description>The gRPC integration module</description>
     <properties>
         <skip_maven_deploy>false</skip_maven_deploy>
     </properties>
-    <modules>
-        <module>dubbo-rpc-api</module>
-        <module>dubbo-rpc-dubbo</module>
-        <module>dubbo-rpc-injvm</module>
-        <module>dubbo-rpc-jsonrpc</module>
-        <module>dubbo-rpc-rmi</module>
-        <module>dubbo-rpc-hessian</module>
-        <module>dubbo-rpc-http</module>
-        <module>dubbo-rpc-webservice</module>
-        <module>dubbo-rpc-native-thrift</module>
-        <module>dubbo-rpc-thrift</module>
-        <module>dubbo-rpc-memcached</module>
-        <module>dubbo-rpc-redis</module>
-        <module>dubbo-rpc-rest</module>
-        <module>dubbo-rpc-xml</module>
-    </modules>
-</project>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-rpc-api</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-remoting-http</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-netty-shaded</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-protobuf</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-stub</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/DubboHandlerRegistry.java b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/DubboHandlerRegistry.java
new file mode 100644
index 0000000..aa9a17b
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/DubboHandlerRegistry.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.rpc.protocol.grpc;
+
+import io.grpc.BindableService;
+import io.grpc.HandlerRegistry;
+import io.grpc.ServerMethodDefinition;
+import io.grpc.ServerServiceDefinition;
+
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ *
+ */
+public class DubboHandlerRegistry extends HandlerRegistry {
+
+    private final Map<String, ServerServiceDefinition> services = new ConcurrentHashMap<>();
+    private final Map<String, ServerMethodDefinition<?, ?>> methods = new ConcurrentHashMap<>();
+
+    public DubboHandlerRegistry() {}
+
+    /**
+     * Returns the service definitions in this registry.
+     */
+    @Override
+    public List<ServerServiceDefinition> getServices() {
+        return Collections.unmodifiableList(new ArrayList<>(services.values()));
+    }
+
+    @Nullable
+    @Override
+    public ServerMethodDefinition<?, ?> lookupMethod(String methodName, @Nullable String authority) {
+        // TODO (carl-mastrangelo): honor authority header.
+        return methods.get(methodName);
+    }
+
+    void addService(BindableService bindableService, String key) {
+        ServerServiceDefinition service = bindableService.bindService();
+        services.put(key, service);
+        for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
+            methods.put(method.getMethodDescriptor().getFullMethodName(), method);
+        }
+    }
+
+    void removeService(String serviceKey) {
+        ServerServiceDefinition service = services.remove(serviceKey);
+        for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
+            methods.remove(method.getMethodDescriptor().getFullMethodName(), method);
+        }
+    }
+}
diff --git a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
new file mode 100644
index 0000000..5d78cf9
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
@@ -0,0 +1,200 @@
+package org.apache.dubbo.rpc.protocol.grpc;/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.StringUtils;
+import org.apache.dubbo.rpc.Exporter;
+import org.apache.dubbo.rpc.Invocation;
+import org.apache.dubbo.rpc.Invoker;
+import org.apache.dubbo.rpc.Result;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.rpc.protocol.AbstractProxyProtocol;
+
+import io.grpc.BindableService;
+import io.grpc.Channel;
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+import io.grpc.Server;
+import io.grpc.ServerBuilder;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.dubbo.rpc.Constants.INTERFACES;
+
+/**
+ *
+ */
+public class GrpcProtocol extends AbstractProxyProtocol {
+
+    private static final Logger logger = LoggerFactory.getLogger(GrpcProtocol.class);
+
+    public final static int DEFAULT_PORT = 50051;
+
+    private final Map<String, GrpcServer> serverMap = new ConcurrentHashMap<>();
+
+    private final Map<String, ManagedChannel> channelMap = new ConcurrentHashMap<>();
+
+    /**
+     * 传进来的impl implements DubboInterface, DubboInterface包含特定的3个通用方法就可以了
+     * @param impl
+     * @param type
+     * @param url
+     * @param <T>
+     * @return
+     * @throws RpcException
+     */
+    @Override
+    protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
+        String key = url.getAddress();
+        GrpcServer grpcServer = serverMap.computeIfAbsent(key, k -> {
+            DubboHandlerRegistry registry = new DubboHandlerRegistry();
+            Server originalServer = ServerBuilder
+                    .forPort(url.getPort())
+                    .fallbackHandlerRegistry(registry)
+                    .build();
+            GrpcServer server = new GrpcServer(originalServer, registry);
+            return server;
+        });
+
+        grpcServer.getRegistry().addService((BindableService) impl, url.getServiceKey());
+
+        return () -> grpcServer.getRegistry().removeService(url.getServiceKey());
+    }
+
+    @Override
+    public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
+        return super.export(new GrpcInvoker<>(invoker));
+    }
+
+    /**
+     * 这里返回的impl必须要有所有的方法, Stub BlockingStube FutureStub
+     * @param type
+     * @param url
+     * @param <T>
+     * @return
+     * @throws RpcException
+     */
+    @Override
+    protected <T> T doRefer(Class<T> type, URL url) throws RpcException {
+        Class<?> enclosingClass = type.getEnclosingClass();
+
+        if (enclosingClass == null) {
+            throw new IllegalArgumentException(type.getName() + " must be declared inside protobuf generated classes, " +
+                    "should be something like ServiceNameGrpc.IServiceName.");
+        }
+
+        final Method dubboStubMethod;
+        try {
+            dubboStubMethod = enclosingClass.getDeclaredMethod("getDubboStub", Channel.class);
+        } catch (NoSuchMethodException e) {
+            throw new IllegalArgumentException("Does not find getDubboStub in " + enclosingClass.getName() + ", please use the customized protoc-gen-grpc-dubbo-java to update the generated classes.");
+        }
+
+        Channel channel = channelMap.computeIfAbsent(url.getServiceKey(),
+                k -> ManagedChannelBuilder.forAddress(url.getHost(), url.getPort()).usePlaintext(true).build()
+        );
+
+        try {
+            @SuppressWarnings("unchecked")
+            final T stub = (T) dubboStubMethod.invoke(null, channel);
+            return stub;
+        } catch (IllegalAccessException | InvocationTargetException e) {
+            throw new IllegalStateException("Could not create stub through reflection.", e);
+        }
+    }
+
+    @Override
+    public int getDefaultPort() {
+        return DEFAULT_PORT;
+    }
+
+    @Override
+    public void destroy() {
+        // FIXME
+    }
+
+    private class GrpcServer {
+        private Server server;
+        private DubboHandlerRegistry registry;
+
+        public GrpcServer(Server server, DubboHandlerRegistry registry) {
+            try {
+                server.start();
+            } catch (IOException e) {
+                throw new IllegalStateException("Failed to start gRPC server.", e);
+            }
+            this.server = server;
+            this.registry = registry;
+        }
+
+        public Server getServer() {
+            return server;
+        }
+
+        public DubboHandlerRegistry getRegistry() {
+            return registry;
+        }
+    }
+
+    private class GrpcInvoker<T> implements Invoker<T> {
+
+        private Invoker<T> invoker;
+
+        public GrpcInvoker(Invoker<T> invoker) {
+            this.invoker = invoker;
+        }
+
+        @Override
+        public Class<T> getInterface() {
+            return invoker.getInterface();
+        }
+
+        @Override
+        public Result invoke(Invocation invocation) throws RpcException {
+            return invoker.invoke(invocation);
+        }
+
+        @Override
+        public URL getUrl() {
+            URL url = invoker.getUrl();
+            String interfaces = url.getParameter(INTERFACES);
+            if (StringUtils.isNotEmpty(interfaces)) {
+                interfaces += ("," + BindableService.class.getName());
+            } else {
+                interfaces = BindableService.class.getName();
+            }
+            return url.addParameter(INTERFACES, interfaces);
+        }
+
+        @Override
+        public boolean isAvailable() {
+            return invoker.isAvailable();
+        }
+
+        @Override
+        public void destroy() {
+            invoker.destroy();
+        }
+    }
+
+}
diff --git a/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol b/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
new file mode 100644
index 0000000..f7acbba
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
@@ -0,0 +1 @@
+grpc=org.apache.dubbo.rpc.protocol.grpc.GrpcProtocol
\ No newline at end of file
diff --git a/dubbo-rpc/pom.xml b/dubbo-rpc/pom.xml
index 1388b50..109338f 100644
--- a/dubbo-rpc/pom.xml
+++ b/dubbo-rpc/pom.xml
@@ -44,5 +44,6 @@
         <module>dubbo-rpc-redis</module>
         <module>dubbo-rpc-rest</module>
         <module>dubbo-rpc-xml</module>
+        <module>dubbo-rpc-grpc</module>
     </modules>
 </project>
diff --git a/pom.xml b/pom.xml
index f3df034..e93d6eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -284,6 +284,18 @@
             <build>
                 <plugins>
                     <plugin>
+                        <artifactId>maven-source-plugin</artifactId>
+                        <version>${maven_source_version}</version>
+                        <executions>
+                            <execution>
+                                <id>attach-sources</id>
+                                <goals>
+                                    <goal>jar</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
                         <artifactId>maven-javadoc-plugin</artifactId>
                         <version>${maven_javadoc_version}</version>
                         <executions>
@@ -390,18 +402,6 @@
         </resources>
         <plugins>
             <plugin>
-                <artifactId>maven-source-plugin</artifactId>
-                <version>${maven_source_version}</version>
-                <executions>
-                    <execution>
-                        <id>attach-sources</id>
-                        <goals>
-                            <goal>jar</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
                 <artifactId>maven-jar-plugin</artifactId>
                 <version>${maven_jar_version}</version>
                 <configuration>


[dubbo] 02/02: add gRPC framework support

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 374899c83908248a6d38a7619093337831e853c7
Author: ken.lj <ke...@gmail.com>
AuthorDate: Wed Aug 28 22:38:00 2019 +0800

    add gRPC framework support
---
 .gitignore                                         |    6 +-
 LICENSE                                            |    3 +
 NOTICE                                             |   10 +
 dubbo-distribution/src/assembly/source-release.xml |    1 +
 .../.gradle/4.3/fileChanges/last-build.bin         |  Bin 0 -> 1 bytes
 .../4.3/fileContent/annotation-processors.bin      |  Bin 0 -> 19793 bytes
 .../.gradle/4.3/fileContent/fileContent.lock       |  Bin 0 -> 17 bytes
 .../compiler/.gradle/4.3/fileHashes/fileHashes.bin |  Bin 0 -> 523091 bytes
 .../.gradle/4.3/fileHashes/fileHashes.lock         |  Bin 0 -> 17 bytes
 .../.gradle/4.3/fileHashes/resourceHashesCache.bin |  Bin 0 -> 193707 bytes
 .../.gradle/4.3/nativeCompile/nativeCompile.bin    |  Bin 0 -> 18497 bytes
 .../.gradle/4.3/nativeCompile/nativeCompile.lock   |  Bin 0 -> 17 bytes
 .../.gradle/4.3/taskHistory/taskHistory.bin        |  Bin 0 -> 5498488 bytes
 .../.gradle/4.3/taskHistory/taskHistory.lock       |  Bin 0 -> 17 bytes
 .../.gradle/4.9/fileChanges/last-build.bin         |  Bin 0 -> 1 bytes
 .../4.9/fileContent/annotation-processors.bin      |  Bin 0 -> 19064 bytes
 .../.gradle/4.9/fileContent/fileContent.lock       |  Bin 0 -> 17 bytes
 .../.gradle/4.9/fileContent/parsedCSource.bin      |  Bin 0 -> 4542342 bytes
 .../compiler/.gradle/4.9/fileHashes/fileHashes.bin |  Bin 0 -> 882335 bytes
 .../.gradle/4.9/fileHashes/fileHashes.lock         |  Bin 0 -> 17 bytes
 .../.gradle/4.9/fileHashes/resourceHashesCache.bin |  Bin 0 -> 397477 bytes
 .../.gradle/4.9/nativeCompile/nativeCompile.bin    |  Bin 0 -> 50817 bytes
 .../.gradle/4.9/nativeCompile/nativeCompile.lock   |  Bin 0 -> 17 bytes
 .../.gradle/4.9/taskHistory/taskHistory.bin        |  Bin 0 -> 12054698 bytes
 .../.gradle/4.9/taskHistory/taskHistory.lock       |  Bin 0 -> 17 bytes
 .../buildOutputCleanup/buildOutputCleanup.lock     |  Bin 0 -> 17 bytes
 .../.gradle/buildOutputCleanup/cache.properties    |    2 +
 .../.gradle/buildOutputCleanup/outputFiles.bin     |  Bin 0 -> 57533 bytes
 .../compiler/.gradle/vcsWorkingDirs/gc.properties  |    0
 dubbo-rpc/dubbo-rpc-grpc/compiler/BUILD.bazel      |   12 +
 dubbo-rpc/dubbo-rpc-grpc/compiler/README.md        |  171 +++
 dubbo-rpc/dubbo-rpc-grpc/compiler/build.gradle     |  405 +++++
 .../dubbo-rpc-grpc/compiler/check-artifact.sh      |  131 ++
 .../gradle/wrapper/gradle-wrapper.properties       |    5 +
 dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew          |  172 +++
 dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew.bat      |   84 ++
 .../src/java_plugin/cpp/java_generator.cpp         | 1553 ++++++++++++++++++++
 .../compiler/src/java_plugin/cpp/java_generator.h  |   57 +
 .../compiler/src/java_plugin/cpp/java_plugin.cpp   |   70 +
 .../src/test/golden/TestDeprecatedService.java.txt |  316 ++++
 .../compiler/src/test/golden/TestService.java.txt  |  665 +++++++++
 .../test/proto/grpc/testing/compiler/test.proto    |   83 ++
 .../testLite/golden/TestDeprecatedService.java.txt |  279 ++++
 .../src/testLite/golden/TestService.java.txt       |  623 ++++++++
 .../testNano/golden/TestDeprecatedService.java.txt |  305 ++++
 .../src/testNano/golden/TestService.java.txt       |  664 +++++++++
 46 files changed, 5616 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 8989935..f5360c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,4 +34,8 @@ Thumbs.db
 .flattened-pom.xml
 
 # license check result
-license-list.txt
\ No newline at end of file
+license-list.txt
+
+# grpc compiler
+dubbo-rpc/dubbo-rpc-grpc/compiler/gradle.properties
+dubbo-rpc/dubbo-rpc-grpc/compiler/build/*
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 11eea3b..38ba090 100644
--- a/LICENSE
+++ b/LICENSE
@@ -225,3 +225,6 @@ For the org.apache.dubbo.common.utils.CIDRUtils :
 This product contains a modified portion of 'edazdarevic.commons.net.CIDRUtils',
  under a "MIT License" license, see https://github.com/edazdarevic/CIDRUtils/blob/master/CIDRUtils.java
 
+This product contains a modified portion of 'proto-gen-grpc-java' - a protobuf plugin used to generate grpc-java stubs,
+ under a "Apache License 2.0" license, see https://github.com/grpc/grpc-java/blob/v1.22.1/NOTICE.txt. All files are placed
+ under '/dubbo/dubbo-rpc/dubbo-rpc-grpc/compiler'
diff --git a/NOTICE b/NOTICE
index 743868e..8d33f86 100644
--- a/NOTICE
+++ b/NOTICE
@@ -12,3 +12,13 @@ Please visit the Netty web site for more information:
   * http://netty.io/
 
 Copyright 2014 The Netty Project
+
+
+This product contains code for the gRPC Project:
+
+The gRPC Project
+=================
+Please visit the gRPC web site for more information:
+  * http://grpc.io/
+
+Copyright 2014 The gRPC Project
diff --git a/dubbo-distribution/src/assembly/source-release.xml b/dubbo-distribution/src/assembly/source-release.xml
index 2f26516..e79afe2 100644
--- a/dubbo-distribution/src/assembly/source-release.xml
+++ b/dubbo-distribution/src/assembly/source-release.xml
@@ -51,6 +51,7 @@
                 <exclude>**/*.jar</exclude>
                 <exclude>**/mvnw*</exclude>
                 <exclude>**/.flattened-pom.xml</exclude>
+                <exclude>**/dubbo-rpc-grpc/compiler/**</exclude>
             </excludes>
         </fileSet>
     </fileSets>
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileChanges/last-build.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileChanges/last-build.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileContent/annotation-processors.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileContent/annotation-processors.bin
new file mode 100644
index 0000000..aa6e57c
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileContent/annotation-processors.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileContent/fileContent.lock b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileContent/fileContent.lock
new file mode 100644
index 0000000..f0536e6
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileContent/fileContent.lock differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/fileHashes.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..d219abd
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/fileHashes.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/fileHashes.lock b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..067763a
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/fileHashes.lock differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/resourceHashesCache.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..827d8b9
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/fileHashes/resourceHashesCache.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/nativeCompile/nativeCompile.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/nativeCompile/nativeCompile.bin
new file mode 100644
index 0000000..7c2e6cd
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/nativeCompile/nativeCompile.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/nativeCompile/nativeCompile.lock b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/nativeCompile/nativeCompile.lock
new file mode 100644
index 0000000..91ced25
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/nativeCompile/nativeCompile.lock differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/taskHistory/taskHistory.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/taskHistory/taskHistory.bin
new file mode 100644
index 0000000..70d6d25
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/taskHistory/taskHistory.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/taskHistory/taskHistory.lock b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/taskHistory/taskHistory.lock
new file mode 100644
index 0000000..a68d1b7
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.3/taskHistory/taskHistory.lock differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileChanges/last-build.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileChanges/last-build.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/annotation-processors.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/annotation-processors.bin
new file mode 100644
index 0000000..ea3f5e8
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/annotation-processors.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/fileContent.lock b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/fileContent.lock
new file mode 100644
index 0000000..2c23b32
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/fileContent.lock differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/parsedCSource.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/parsedCSource.bin
new file mode 100644
index 0000000..b88fb7d
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileContent/parsedCSource.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/fileHashes.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..940cd1b
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/fileHashes.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/fileHashes.lock b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..4930517
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/fileHashes.lock differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/resourceHashesCache.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..fa0f984
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/fileHashes/resourceHashesCache.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/nativeCompile/nativeCompile.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/nativeCompile/nativeCompile.bin
new file mode 100644
index 0000000..d95131f
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/nativeCompile/nativeCompile.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/nativeCompile/nativeCompile.lock b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/nativeCompile/nativeCompile.lock
new file mode 100644
index 0000000..e83e9f9
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/nativeCompile/nativeCompile.lock differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/taskHistory/taskHistory.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/taskHistory/taskHistory.bin
new file mode 100644
index 0000000..343bd6e
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/taskHistory/taskHistory.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/taskHistory/taskHistory.lock b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/taskHistory/taskHistory.lock
new file mode 100644
index 0000000..46a3559
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/4.9/taskHistory/taskHistory.lock differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/buildOutputCleanup.lock
new file mode 100644
index 0000000..bdc02da
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/cache.properties b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/cache.properties
new file mode 100644
index 0000000..0a57826
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/cache.properties
@@ -0,0 +1,2 @@
+#Tue Oct 09 11:40:48 CST 2018
+gradle.version=4.9
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/outputFiles.bin b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/outputFiles.bin
new file mode 100644
index 0000000..6da938c
Binary files /dev/null and b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/vcsWorkingDirs/gc.properties b/dubbo-rpc/dubbo-rpc-grpc/compiler/.gradle/vcsWorkingDirs/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/BUILD.bazel b/dubbo-rpc/dubbo-rpc-grpc/compiler/BUILD.bazel
new file mode 100644
index 0000000..1a2f2f3
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/BUILD.bazel
@@ -0,0 +1,12 @@
+cc_binary(
+    name = "grpc_java_plugin",
+    srcs = [
+        "src/java_plugin/cpp/java_generator.cpp",
+        "src/java_plugin/cpp/java_generator.h",
+        "src/java_plugin/cpp/java_plugin.cpp",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        "@com_google_protobuf//:protoc_lib",
+    ],
+)
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/README.md b/dubbo-rpc/dubbo-rpc-grpc/compiler/README.md
new file mode 100644
index 0000000..11db768
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/README.md
@@ -0,0 +1,171 @@
+# Dubbo customized version
+
+## 修改内容
+
+1. Dubbo Interface
+```java
+public interface IGreeter {
+
+    default public io.grpc.examples.helloworld.HelloReply sayHello(io.grpc.examples.helloworld.HelloRequest request) {
+       throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows.");
+    }
+    
+    default public com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.helloworld.HelloReply> sayHelloAsync(
+        io.grpc.examples.helloworld.HelloRequest request) {
+       throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows.");
+    }
+    
+    public void sayHello(io.grpc.examples.helloworld.HelloRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> responseObserver);
+
+}
+```
+
+2. Dubbo Stub
+```java
+public static DubboGreeterStub getDubboStub(io.grpc.Channel channel) {
+  return new DubboGreeterStub(channel);
+}
+
+public static class DubboGreeterStub implements IGreeter {
+
+    private GreeterBlockingStub blockingStub;
+    private GreeterFutureStub futureStub;
+    private GreeterStub stub;
+    
+    public DubboGreeterStub(io.grpc.Channel channel) {
+       blockingStub = GreeterGrpc.newBlockingStub(channel);
+       futureStub = GreeterGrpc.newFutureStub(channel);
+       stub = GreeterGrpc.newStub(channel);
+    }
+    
+    public io.grpc.examples.helloworld.HelloReply sayHello(io.grpc.examples.helloworld.HelloRequest request) {
+        return blockingStub.sayHello(request);
+    }
+    
+    public com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.helloworld.HelloReply> sayHelloAsync(
+        io.grpc.examples.helloworld.HelloRequest request) {
+        return futureStub.sayHello(requesthttps://github.com/apache/dubbo-samples.git);
+    }
+    
+    public void sayHello(io.grpc.examples.helloworld.HelloRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> responseObserver){
+        stub.sayHello(request, responseObserver);
+    }
+
+}
+
+```
+
+3. XxxImplBase implements DubboInterface
+```java
+public static abstract class GreeterImplBase implements io.grpc.BindableService, IGreeter {
+
+  @java.lang.Override
+  public final io.grpc.examples.helloworld.HelloReply sayHello(io.grpc.examples.helloworld.HelloRequest request) {
+     throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows.");
+  }
+
+  @java.lang.Override
+  public final com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.helloworld.HelloReply> sayHelloAsync(
+      io.grpc.examples.helloworld.HelloRequest request) {
+     throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows.");
+  }
+
+  public void sayHello(io.grpc.examples.helloworld.HelloRequest request,
+      io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> responseObserver) {
+      asyncUnimplementedUnaryCall(getSayHelloMethod(), responseObserver);
+  }
+  
+  ...
+}
+```
+
+## 如何构建
+
+To compile the plugin:
+```
+$ ../gradlew java_pluginExecutable
+```
+
+To publish to local repository
+```
+$ ../gradlew publishToMavenLocal
+```
+
+## 远程发布
+
+Add gradle.properties
+```properties
+repositoryUser=user
+repositoryPasword=pwd
+```
+
+Then, run
+```
+$ ../gradlew publishMavenPublicationToDubboRepository
+```
+Notice current groupId is `com.alibaba`.
+
+
+gRPC Java Codegen Plugin for Protobuf Compiler
+==============================================
+
+This generates the Java interfaces out of the service definition from a
+`.proto` file. It works with the Protobuf Compiler (``protoc``).
+
+Normally you don't need to compile the codegen by yourself, since pre-compiled
+binaries for common platforms are available on Maven Central. However, if the
+pre-compiled binaries are not compatible with your system, you may want to
+build your own codegen.
+
+## System requirement
+
+* Linux, Mac OS X with Clang, or Windows with MSYS2
+* Java 7 or up
+* [Protobuf](https://github.com/google/protobuf) 3.0.0-beta-3 or up
+
+## Compiling and testing the codegen
+Change to the `compiler` directory:
+```
+$ cd $GRPC_JAVA_ROOT/compiler
+```
+
+To compile the plugin:
+```
+$ ../gradlew java_pluginExecutable
+```
+
+To test the plugin with the compiler:
+```
+$ ../gradlew test
+```
+You will see a `PASS` if the test succeeds.
+
+To compile a proto file and generate Java interfaces out of the service definitions:
+```
+$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
+  --grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
+```
+To generate Java interfaces with protobuf lite:
+```
+$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
+  --grpc-java_out=lite:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
+```
+To generate Java interfaces with protobuf nano:
+```
+$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
+  --grpc-java_out=nano:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
+```
+
+## Installing the codegen to Maven local repository
+This will compile a codegen and put it under your ``~/.m2/repository``. This
+will make it available to any build tool that pulls codegens from Maven
+repostiories.
+```
+$ ../gradlew publishToMavenLocal
+```
+
+## Creating a release of GRPC Java
+Please follow the instructions in ``RELEASING.md`` under the root directory for
+details on how to create a new release.
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/build.gradle b/dubbo-rpc/dubbo-rpc-grpc/compiler/build.gradle
new file mode 100644
index 0000000..56dfc7f
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/build.gradle
@@ -0,0 +1,405 @@
+apply plugin: "cpp"
+apply plugin: "com.google.protobuf"
+
+group = "org.apache.dubbo"
+version = "1.19.0-SNAPSHOT" // CURRENT_GRPC_VERSION
+
+description = 'The protoc plugin for gRPC Java'
+
+apply plugin: "checkstyle"
+apply plugin: "java"
+apply plugin: "maven"
+apply plugin: "maven-publish"
+apply plugin: "idea"
+apply plugin: "signing"
+apply plugin: "jacoco"
+
+apply plugin: "me.champeau.gradle.jmh"
+apply plugin: "com.google.osdetector"
+// The plugin only has an effect if a signature is specified
+apply plugin: "ru.vyarus.animalsniffer"
+
+apply plugin: "net.ltgt.errorprone"
+
+buildscript {
+    repositories {
+        maven { // The google mirror is less flaky than mavenCentral()
+            url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
+        mavenLocal()
+        maven { url "https://plugins.gradle.org/m2/" }
+    }
+    dependencies {
+        classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.5"
+        classpath "com.diffplug.spotless:spotless-plugin-gradle:3.13.0"
+        classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
+        classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.5'
+        classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.6'
+        classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
+        classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.2.5'
+    }
+}
+
+import net.ltgt.gradle.errorprone.CheckSeverity
+
+def artifactStagingPath = "$buildDir/artifacts" as File
+// Adds space-delimited arguments from the environment variable env to the
+// argList.
+def addEnvArgs = { env, argList ->
+    def value = System.getenv(env)
+    if (value != null) {
+        value.split(' +').each() { it -> argList.add(it) }
+    }
+}
+
+// Adds corresponding "-l" option to the argList if libName is not found in
+// LDFLAGS. This is only used for Mac because when building for uploadArchives
+// artifacts, we add the ".a" files directly to LDFLAGS and without "-l" in
+// order to get statically linked, otherwise we add the libraries through "-l"
+// so that they can be searched for in default search paths.
+def addLibraryIfNotLinked = { libName, argList ->
+    def ldflags = System.env.LDFLAGS
+    if (ldflags == null || !ldflags.contains('lib' + libName + '.a')) {
+        argList.add('-l' + libName)
+    }
+}
+
+def String arch = rootProject.hasProperty('targetArch') ? rootProject.targetArch : osdetector.arch
+def boolean vcDisable = rootProject.hasProperty('vcDisable') ? rootProject.vcDisable : false
+def boolean usingVisualCpp // Whether VisualCpp is actually available and selected
+
+ext{
+    def exeSuffix = osdetector.os == 'windows' ? ".exe" : ""
+    protocPluginBaseName = 'protoc-gen-grpc-java'
+    javaPluginPath = "$rootDir/build/exe/java_plugin/$protocPluginBaseName$exeSuffix"
+
+    nettyVersion = '4.1.32.Final'
+    googleauthVersion = '0.9.0'
+    guavaVersion = '26.0-android'
+    protobufVersion = '3.6.1'
+    protocVersion = protobufVersion
+    protobufNanoVersion = '3.0.0-alpha-5'
+    opencensusVersion = '0.19.2'
+
+    libraries = [
+            animalsniffer_annotations: "org.codehaus.mojo:animal-sniffer-annotations:1.17",
+            errorprone: "com.google.errorprone:error_prone_annotations:2.2.0",
+            gson: "com.google.code.gson:gson:2.7",
+            guava: "com.google.guava:guava:26.0-android",
+            hpack: 'com.twitter:hpack:0.10.1',
+            javax_annotation: 'javax.annotation:javax.annotation-api:1.2',
+            jsr305: 'com.google.code.findbugs:jsr305:3.0.2',
+            google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.12.0',
+
+            // Keep the following references of tcnative version in sync whenever it's updated
+            // SECURITY.md (multiple occurrences)
+            // examples/example-tls/build.gradle
+            // examples/example-tls/pom.xml
+            netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.20.Final',
+
+            conscrypt: 'org.conscrypt:conscrypt-openjdk-uber:1.0.1',
+            re2j: 'com.google.re2j:re2j:1.2'
+    ]
+}
+
+model {
+    toolChains {
+        // If you have both VC and Gcc installed, VC will be selected, unless you
+        // set 'vcDisable=true'
+        if (!vcDisable) {
+            visualCpp(VisualCpp) {
+                // Prefer vcvars-provided environment over registry-discovered environment
+                def String vsDir = System.getenv("VSINSTALLDIR")
+                def String winDir = System.getenv("WindowsSdkDir")
+                if (vsDir != null && winDir != null) {
+                    installDir = vsDir
+                    windowsSdkDir = winDir
+                }
+            }
+        }
+        gcc(Gcc) {
+            target("ppcle_64")
+            target("aarch_64")
+        }
+        clang(Clang) {
+        }
+    }
+
+    platforms {
+        x86_32 { architecture "x86" }
+        x86_64 { architecture "x86_64" }
+        ppcle_64 { architecture "ppcle_64" }
+        aarch_64 { architecture "aarch_64" }
+    }
+
+    components {
+        java_plugin(NativeExecutableSpec) {
+            if (arch in [
+                'x86_32',
+                'x86_64',
+                'ppcle_64',
+                'aarch_64'
+            ]) {
+                // If arch is not within the defined platforms, we do not specify the
+                // targetPlatform so that Gradle will choose what is appropriate.
+                targetPlatform arch
+            }
+            baseName "$protocPluginBaseName"
+        }
+    }
+
+    binaries {
+        all {
+            if (toolChain in Gcc || toolChain in Clang) {
+                cppCompiler.define("GRPC_VERSION", version)
+                cppCompiler.args "--std=c++0x"
+                addEnvArgs("CXXFLAGS", cppCompiler.args)
+                addEnvArgs("CPPFLAGS", cppCompiler.args)
+                if (osdetector.os == "osx") {
+                    cppCompiler.args "-mmacosx-version-min=10.7", "-stdlib=libc++"
+                    addLibraryIfNotLinked('protoc', linker.args)
+                    addLibraryIfNotLinked('protobuf', linker.args)
+                } else if (osdetector.os == "windows") {
+                    linker.args "-static", "-lprotoc", "-lprotobuf", "-static-libgcc", "-static-libstdc++",
+                            "-s"
+                } else {
+                    // Link protoc, protobuf, libgcc and libstdc++ statically.
+                    // Link other (system) libraries dynamically.
+                    // Clang under OSX doesn't support these options.
+                    linker.args "-Wl,-Bstatic", "-lprotoc", "-lprotobuf", "-static-libgcc",
+                            "-static-libstdc++",
+                            "-Wl,-Bdynamic", "-lpthread", "-s"
+                }
+                addEnvArgs("LDFLAGS", linker.args)
+            } else if (toolChain in VisualCpp) {
+                usingVisualCpp = true
+                cppCompiler.define("GRPC_VERSION", version)
+                cppCompiler.args "/EHsc", "/MT"
+                if (rootProject.hasProperty('vcProtobufInclude')) {
+                    cppCompiler.args "/I${rootProject.vcProtobufInclude}"
+                }
+                linker.args "libprotobuf.lib", "libprotoc.lib"
+                if (rootProject.hasProperty('vcProtobufLibs')) {
+                    linker.args "/LIBPATH:${rootProject.vcProtobufLibs}"
+                }
+            }
+        }
+    }
+}
+
+configurations {
+    testLiteCompile
+    testNanoCompile
+}
+
+//dependencies {
+//    testCompile "io.grpc:grpc-protobuf:1.22.1",
+//            "io.grpc:grpc-stub:1.22.1",
+//            "javax.annotation:javax.annotation-api:1.2"
+//}
+
+sourceSets {
+    testLite {
+        proto { setSrcDirs(['src/test/proto']) }
+    }
+    testNano {
+        proto { setSrcDirs(['src/test/proto']) }
+    }
+}
+
+
+compileTestJava {
+    options.compilerArgs += [
+        "-Xlint:-cast"
+    ]
+    options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
+}
+
+compileTestLiteJava {
+    options.compilerArgs = compileTestJava.options.compilerArgs
+    // Protobuf-generated Lite produces quite a few warnings.
+    options.compilerArgs += [
+        "-Xlint:-rawtypes",
+        "-Xlint:-unchecked",
+        "-Xlint:-fallthrough"
+    ]
+    options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
+}
+
+compileTestNanoJava {
+    options.compilerArgs = compileTestJava.options.compilerArgs
+    options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
+}
+
+protobuf {
+    protoc {
+        if (project.hasProperty('protoc')) {
+            path = project.protoc
+        } else {
+            // Since nano is removed from newer versions of protoc, use an older version for the
+            // while. This means we won't be able to test any descriptor.proto additions, but that
+            // should be fine for a while.
+            artifact = libraries.protoc_nano
+        }
+    }
+    plugins {
+        javalite {
+            if (project.hasProperty('protoc-gen-javalite')) {
+                path = project['protoc-gen-javalite']
+            } else {
+                artifact = libraries.protoc_lite
+            }
+        }
+        grpc { path = javaPluginPath }
+    }
+    generateProtoTasks {
+        all().each { task ->
+            task.dependsOn 'java_pluginExecutable'
+            task.inputs.file javaPluginPath
+        }
+        ofSourceSet('test')*.plugins { grpc {} }
+        ofSourceSet('testLite')*.each { task ->
+            task.builtins { remove java }
+            task.plugins {
+                javalite {}
+                grpc { option 'lite' }
+            }
+        }
+        ofSourceSet('testNano').each { task ->
+            task.builtins {
+                remove java
+                javanano { option 'ignore_services=true' }
+            }
+            task.plugins { grpc { option 'nano' } }
+        }
+    }
+}
+
+checkstyleTestNano {
+    source = fileTree(dir: "src/testNano", include: "**/*.java")
+}
+
+println "*** Building codegen requires Protobuf version ${protocVersion}"
+println "*** Please refer to https://github.com/grpc/grpc-java/blob/master/COMPILING.md#how-to-build-code-generation-plugin"
+
+task buildArtifacts(type: Copy) {
+    dependsOn 'java_pluginExecutable'
+    from("$buildDir/exe") {
+        if (osdetector.os != 'windows') {
+            rename 'protoc-gen-grpc-java', '$0.exe'
+        }
+    }
+    into artifactStagingPath
+}
+
+archivesBaseName = "$protocPluginBaseName"
+
+task checkArtifacts {
+    dependsOn buildArtifacts
+    doLast {
+        if (!usingVisualCpp) {
+            def ret = exec {
+                executable 'bash'
+                args 'check-artifact.sh', osdetector.os, arch
+            }
+            if (ret.exitValue != 0) {
+                throw new GradleException("check-artifact.sh exited with " + ret.exitValue)
+            }
+        } else {
+            def exeName = "$artifactStagingPath/java_plugin/${protocPluginBaseName}.exe"
+            def os = new ByteArrayOutputStream()
+            def ret = exec {
+                executable 'dumpbin'
+                args '/nologo', '/dependents', exeName
+                standardOutput = os
+            }
+            if (ret.exitValue != 0) {
+                throw new GradleException("dumpbin exited with " + ret.exitValue)
+            }
+            def dlls = os.toString() =~ /Image has the following dependencies:\s+(.*)\s+Summary/
+            if (dlls[0][1] != "KERNEL32.dll") {
+                throw new Exception("unexpected dll deps: " + dlls[0][1]);
+            }
+            os.reset()
+            ret = exec {
+                executable 'dumpbin'
+                args '/nologo', '/headers', exeName
+                standardOutput = os
+            }
+            if (ret.exitValue != 0) {
+                throw new GradleException("dumpbin exited with " + ret.exitValue)
+            }
+            def machine = os.toString() =~ / machine \(([^)]+)\)/
+            def expectedArch = [x86_32: "x86", x86_64: "x64"][arch]
+            if (machine[0][1] != expectedArch) {
+                throw new Exception("unexpected architecture: " + machine[0][1]);
+            }
+        }
+    }
+}
+
+// Exe files are skipped by Maven by default. Override it.
+// Also skip jar files that is generated by the java plugin.
+publishing {
+    repositories {
+        maven {
+            name "dubbo"
+            credentials {
+                username repositoryUser // 仓库发布用户名
+                password repositoryPassword // 仓库发布用户密码
+            }
+            if(project.version.endsWith('-SNAPSHOT')) {
+                url "https://repository.apache.org/content/repositories/snapshots"
+            } else {
+                url 'https://repository.apache.org/service/local/staging/deploy/maven2' // 仓库地址
+            }
+        }
+    }
+
+    publications {
+        maven(MavenPublication) {
+            // Removes all artifacts since grpc-compiler doesn't generates any Jar
+            artifacts = []
+            artifactId 'protoc-gen-grpc-java'
+            artifact("$artifactStagingPath/java_plugin/${protocPluginBaseName}.exe" as File) {
+                classifier osdetector.os + "-" + arch
+                extension "exe"
+                builtBy checkArtifacts
+            }
+            pom.withXml {
+                // This isn't any sort of Java archive artifact, and OSSRH doesn't enforce
+                // javadoc for 'pom' packages. 'exe' would be a more appropriate packaging
+                // value, but it isn't clear how that will be interpreted. In addition,
+                // 'pom' is typically the value used when building an exe with Maven.
+                asNode().project.packaging*.value = 'pom'
+            }
+        }
+    }
+}
+
+def configureTestTask(Task task, String dep, String extraPackage, String serviceName) {
+    test.dependsOn task
+    task.dependsOn "generateTest${dep}Proto"
+    if (osdetector.os != 'windows') {
+        task.executable "diff"
+        task.args "-u"
+    } else {
+        task.executable "fc"
+    }
+    // File isn't found on Windows if last slash is forward-slash
+    def slash = System.getProperty("file.separator")
+    task.args "$buildDir/generated/source/proto/test${dep}/grpc/io/grpc/testing/compiler${extraPackage}${slash}${serviceName}Grpc.java",
+            "$projectDir/src/test${dep}/golden/${serviceName}.java.txt"
+}
+
+task testGolden(type: Exec)
+task testLiteGolden(type: Exec)
+task testNanoGolden(type: Exec)
+task testDeprecatedGolden(type: Exec)
+task testDeprecatedLiteGolden(type: Exec)
+task testDeprecatedNanoGolden(type: Exec)
+configureTestTask(testGolden, '', '', 'TestService')
+configureTestTask(testLiteGolden, 'Lite', '', 'TestService')
+configureTestTask(testNanoGolden, 'Nano', '/nano', 'TestService')
+configureTestTask(testDeprecatedGolden, '', '', 'TestDeprecatedService')
+configureTestTask(testDeprecatedLiteGolden, 'Lite', '', 'TestDeprecatedService')
+configureTestTask(testDeprecatedNanoGolden, 'Nano', '/nano', 'TestDeprecatedService')
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/check-artifact.sh b/dubbo-rpc/dubbo-rpc-grpc/compiler/check-artifact.sh
new file mode 100755
index 0000000..b06492e
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/check-artifact.sh
@@ -0,0 +1,131 @@
+#!/bin/bash
+
+# Check that the codegen artifacts are of correct architecture and don't have
+# unexpected dependencies.
+# To be run from Gradle.
+# Usage: check-artifact <OS> <ARCH>
+# <OS> and <ARCH> are ${os.detected.name} and ${os.detected.arch} from
+# osdetector-gradle-plugin
+OS=$1
+ARCH=$2
+
+if [[ $# < 2 ]]; then
+  echo "No arguments provided. This script is intended to be run from Gradle."
+  exit 1
+fi
+
+# Under Cygwin, bash doesn't have these in PATH when called from Gradle which
+# runs in Windows version of Java.
+export PATH="/bin:/usr/bin:$PATH"
+
+E_PARAM_ERR=98
+E_ASSERT_FAILED=99
+
+# Usage: fail ERROR_MSG
+fail()
+{
+  echo "ERROR: $1"
+  echo
+  exit $E_ASSERT_FAILED
+}
+
+# Usage: assertEq VAL1 VAL2 $LINENO
+assertEq ()
+{
+  lineno=$3
+  if [ -z "$lineno" ]; then
+    echo "lineno not given"
+    exit $E_PARAM_ERR
+  fi
+
+  if [[ "$1" != "$2" ]]; then
+    echo "Assertion failed:  \"$1\" == \"$2\""
+    echo "File \"$0\", line $lineno"    # Give name of file and line number.
+    exit $E_ASSERT_FAILED
+  fi
+}
+
+# Checks the artifact is for the expected architecture
+# Usage: checkArch <path-to-protoc>
+checkArch ()
+{
+  echo
+  echo "Checking format of $1"
+  if [[ "$OS" == windows || "$OS" == linux ]]; then
+    format="$(objdump -f "$1" | grep -o "file format .*$" | grep -o "[^ ]*$")"
+    echo Format=$format
+    if [[ "$OS" == linux ]]; then
+      if [[ "$ARCH" == x86_32 ]]; then
+        assertEq "$format" "elf32-i386" $LINENO
+      elif [[ "$ARCH" == x86_64 ]]; then
+        assertEq "$format" "elf64-x86-64" $LINENO
+      else
+        fail "Unsupported arch: $ARCH"
+      fi
+    else
+      # $OS == windows
+      if [[ "$ARCH" == x86_32 ]]; then
+        assertEq "$format" "pei-i386" $LINENO
+      elif [[ "$ARCH" == x86_64 ]]; then
+        assertEq "$format" "pei-x86-64" $LINENO
+      else
+        fail "Unsupported arch: $ARCH"
+      fi
+    fi
+  elif [[ "$OS" == osx ]]; then
+    format="$(file -b "$1" | grep -o "[^ ]*$")"
+    echo Format=$format
+    if [[ "$ARCH" == x86_32 ]]; then
+      assertEq "$format" "i386" $LINENO
+    elif [[ "$ARCH" == x86_64 ]]; then
+      assertEq "$format" "x86_64" $LINENO
+    else
+      fail "Unsupported arch: $ARCH"
+    fi
+  else
+    fail "Unsupported system: $OS"
+  fi
+  echo
+}
+
+# Checks the dependencies of the artifact. Artifacts should only depend on
+# system libraries.
+# Usage: checkDependencies <path-to-protoc>
+checkDependencies ()
+{
+  echo "Checking dependencies of $1"
+  if [[ "$OS" == windows ]]; then
+    dump_cmd='objdump -x '"$1"' | fgrep "DLL Name"'
+    white_list="KERNEL32\.dll\|msvcrt\.dll\|USER32\.dll"
+  elif [[ "$OS" == linux ]]; then
+    dump_cmd='ldd '"$1"
+    if [[ "$ARCH" == x86_32 ]]; then
+      white_list="linux-gate\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux\.so\.2"
+    elif [[ "$ARCH" == x86_64 ]]; then
+      white_list="linux-vdso\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux-x86-64\.so\.2"
+    fi
+  elif [[ "$OS" == osx ]]; then
+    set +x
+    dump_cmd='otool -L '"$1"' | fgrep dylib'
+    white_list="libz\.1\.dylib\|libc++.1.dylib\|libstdc++\.6\.dylib\|libSystem\.B\.dylib"
+    set -x
+  fi
+  if [[ -z "$white_list" || -z "$dump_cmd" ]]; then
+    fail "Unsupported platform $OS-$ARCH."
+  fi
+  echo "Checking for expected dependencies ..."
+  eval $dump_cmd | grep -i "$white_list" || fail "doesn't show any expected dependencies"
+  echo "Checking for unexpected dependencies ..."
+  eval $dump_cmd | grep -i -v "$white_list"
+  ret=$?
+  if [[ $ret == 0 ]]; then
+    fail "found unexpected dependencies (listed above)."
+  elif [[ $ret != 1 ]]; then
+    fail "Error when checking dependencies."
+  fi  # grep returns 1 when "not found", which is what we expect
+  echo "Dependencies look good."
+  echo
+}
+
+FILE="build/artifacts/java_plugin/protoc-gen-grpc-java.exe"
+checkArch "$FILE" && checkDependencies "$FILE"
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/gradle/wrapper/gradle-wrapper.properties b/dubbo-rpc/dubbo-rpc-grpc/compiler/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..a95009c
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew b/dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew
new file mode 100755
index 0000000..cccdd3d
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew.bat b/dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew.bat
new file mode 100644
index 0000000..f955316
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_generator.cpp b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_generator.cpp
new file mode 100644
index 0000000..224ccb5
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_generator.cpp
@@ -0,0 +1,1553 @@
+#include "java_generator.h"
+
+#include <algorithm>
+#include <iostream>
+#include <iterator>
+#include <map>
+#include <set>
+#include <vector>
+#include <google/protobuf/compiler/java/java_names.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/io/zero_copy_stream.h>
+
+// Stringify helpers used solely to cast GRPC_VERSION
+#ifndef STR
+#define STR(s) #s
+#endif
+
+#ifndef XSTR
+#define XSTR(s) STR(s)
+#endif
+
+#ifndef FALLTHROUGH_INTENDED
+#define FALLTHROUGH_INTENDED
+#endif
+
+namespace java_grpc_generator {
+
+using google::protobuf::FileDescriptor;
+using google::protobuf::ServiceDescriptor;
+using google::protobuf::MethodDescriptor;
+using google::protobuf::Descriptor;
+using google::protobuf::io::Printer;
+using google::protobuf::SourceLocation;
+using std::to_string;
+
+// java keywords from: https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.9
+static std::set<string> java_keywords = {
+  "abstract",
+  "assert",
+  "boolean",
+  "break",
+  "byte",
+  "case",
+  "catch",
+  "char",
+  "class",
+  "const",
+  "continue",
+  "default",
+  "do",
+  "double",
+  "else",
+  "enum",
+  "extends",
+  "final",
+  "finally",
+  "float",
+  "for",
+  "goto",
+  "if",
+  "implements",
+  "import",
+  "instanceof",
+  "int",
+  "interface",
+  "long",
+  "native",
+  "new",
+  "package",
+  "private",
+  "protected",
+  "public",
+  "return",
+  "short",
+  "static",
+  "strictfp",
+  "super",
+  "switch",
+  "synchronized",
+  "this",
+  "throw",
+  "throws",
+  "transient",
+  "try",
+  "void",
+  "volatile",
+  "while",
+  // additional ones added by us
+  "true",
+  "false",
+};
+
+// Adjust a method name prefix identifier to follow the JavaBean spec:
+//   - decapitalize the first letter
+//   - remove embedded underscores & capitalize the following letter
+//  Finally, if the result is a reserved java keyword, append an underscore.
+static string MixedLower(const string& word) {
+  string w;
+  w += tolower(word[0]);
+  bool after_underscore = false;
+  for (size_t i = 1; i < word.length(); ++i) {
+    if (word[i] == '_') {
+      after_underscore = true;
+    } else {
+      w += after_underscore ? toupper(word[i]) : word[i];
+      after_underscore = false;
+    }
+  }
+  if (java_keywords.find(w) != java_keywords.end()) {
+    return w + "_";
+  }
+  return w;
+}
+
+// Converts to the identifier to the ALL_UPPER_CASE format.
+//   - An underscore is inserted where a lower case letter is followed by an
+//     upper case letter.
+//   - All letters are converted to upper case
+static string ToAllUpperCase(const string& word) {
+  string w;
+  for (size_t i = 0; i < word.length(); ++i) {
+    w += toupper(word[i]);
+    if ((i < word.length() - 1) && islower(word[i]) && isupper(word[i + 1])) {
+      w += '_';
+    }
+  }
+  return w;
+}
+
+static inline string LowerMethodName(const MethodDescriptor* method) {
+  return MixedLower(method->name());
+}
+
+static inline string MethodPropertiesFieldName(const MethodDescriptor* method) {
+  return "METHOD_" + ToAllUpperCase(method->name());
+}
+
+static inline string MethodPropertiesGetterName(const MethodDescriptor* method) {
+  return MixedLower("get_" + method->name() + "_method");
+}
+
+static inline string MethodIdFieldName(const MethodDescriptor* method) {
+  return "METHODID_" + ToAllUpperCase(method->name());
+}
+
+static inline bool ShouldGenerateAsLite(const Descriptor* desc) {
+  return false;
+}
+
+static inline string MessageFullJavaName(bool nano, const Descriptor* desc) {
+  string name = google::protobuf::compiler::java::ClassName(desc);
+  if (nano && !ShouldGenerateAsLite(desc)) {
+    // XXX: Add "nano" to the original package
+    // (https://github.com/grpc/grpc-java/issues/900)
+    if (isupper(name[0])) {
+      // No java package specified.
+      return "nano." + name;
+    }
+    for (size_t i = 0; i < name.size(); ++i) {
+      if ((name[i] == '.') && (i < (name.size() - 1)) && isupper(name[i + 1])) {
+        return name.substr(0, i + 1) + "nano." + name.substr(i + 1);
+      }
+    }
+  }
+  return name;
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+template <typename ITR>
+static void GrpcSplitStringToIteratorUsing(const string& full,
+                                       const char* delim,
+                                       ITR& result) {
+  // Optimize the common case where delim is a single character.
+  if (delim[0] != '\0' && delim[1] == '\0') {
+    char c = delim[0];
+    const char* p = full.data();
+    const char* end = p + full.size();
+    while (p != end) {
+      if (*p == c) {
+        ++p;
+      } else {
+        const char* start = p;
+        while (++p != end && *p != c);
+        *result++ = string(start, p - start);
+      }
+    }
+    return;
+  }
+
+  string::size_type begin_index, end_index;
+  begin_index = full.find_first_not_of(delim);
+  while (begin_index != string::npos) {
+    end_index = full.find_first_of(delim, begin_index);
+    if (end_index == string::npos) {
+      *result++ = full.substr(begin_index);
+      return;
+    }
+    *result++ = full.substr(begin_index, (end_index - begin_index));
+    begin_index = full.find_first_not_of(delim, end_index);
+  }
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+static void GrpcSplitStringUsing(const string& full,
+                             const char* delim,
+                             std::vector<string>* result) {
+  std::back_insert_iterator< std::vector<string> > it(*result);
+  GrpcSplitStringToIteratorUsing(full, delim, it);
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+static std::vector<string> GrpcSplit(const string& full, const char* delim) {
+  std::vector<string> result;
+  GrpcSplitStringUsing(full, delim, &result);
+  return result;
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+static string GrpcEscapeJavadoc(const string& input) {
+  string result;
+  result.reserve(input.size() * 2);
+
+  char prev = '*';
+
+  for (string::size_type i = 0; i < input.size(); i++) {
+    char c = input[i];
+    switch (c) {
+      case '*':
+        // Avoid "/*".
+        if (prev == '/') {
+          result.append("&#42;");
+        } else {
+          result.push_back(c);
+        }
+        break;
+      case '/':
+        // Avoid "*/".
+        if (prev == '*') {
+          result.append("&#47;");
+        } else {
+          result.push_back(c);
+        }
+        break;
+      case '@':
+        // '@' starts javadoc tags including the @deprecated tag, which will
+        // cause a compile-time error if inserted before a declaration that
+        // does not have a corresponding @Deprecated annotation.
+        result.append("&#64;");
+        break;
+      case '<':
+        // Avoid interpretation as HTML.
+        result.append("&lt;");
+        break;
+      case '>':
+        // Avoid interpretation as HTML.
+        result.append("&gt;");
+        break;
+      case '&':
+        // Avoid interpretation as HTML.
+        result.append("&amp;");
+        break;
+      case '\\':
+        // Java interprets Unicode escape sequences anywhere!
+        result.append("&#92;");
+        break;
+      default:
+        result.push_back(c);
+        break;
+    }
+
+    prev = c;
+  }
+
+  return result;
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+template <typename DescriptorType>
+static string GrpcGetCommentsForDescriptor(const DescriptorType* descriptor) {
+  SourceLocation location;
+  if (descriptor->GetSourceLocation(&location)) {
+    return location.leading_comments.empty() ?
+      location.trailing_comments : location.leading_comments;
+  }
+  return string();
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+static std::vector<string> GrpcGetDocLines(const string& comments) {
+  if (!comments.empty()) {
+    // TODO(kenton):  Ideally we should parse the comment text as Markdown and
+    //   write it back as HTML, but this requires a Markdown parser.  For now
+    //   we just use <pre> to get fixed-width text formatting.
+
+    // If the comment itself contains block comment start or end markers,
+    // HTML-escape them so that they don't accidentally close the doc comment.
+    string escapedComments = GrpcEscapeJavadoc(comments);
+
+    std::vector<string> lines = GrpcSplit(escapedComments, "\n");
+    while (!lines.empty() && lines.back().empty()) {
+      lines.pop_back();
+    }
+    return lines;
+  }
+  return std::vector<string>();
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+template <typename DescriptorType>
+static std::vector<string> GrpcGetDocLinesForDescriptor(const DescriptorType* descriptor) {
+  return GrpcGetDocLines(GrpcGetCommentsForDescriptor(descriptor));
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+static void GrpcWriteDocCommentBody(Printer* printer,
+                                    const std::vector<string>& lines,
+                                    bool surroundWithPreTag) {
+  if (!lines.empty()) {
+    if (surroundWithPreTag) {
+      printer->Print(" * <pre>\n");
+    }
+
+    for (size_t i = 0; i < lines.size(); i++) {
+      // Most lines should start with a space.  Watch out for lines that start
+      // with a /, since putting that right after the leading asterisk will
+      // close the comment.
+      if (!lines[i].empty() && lines[i][0] == '/') {
+        printer->Print(" * $line$\n", "line", lines[i]);
+      } else {
+        printer->Print(" *$line$\n", "line", lines[i]);
+      }
+    }
+
+    if (surroundWithPreTag) {
+      printer->Print(" * </pre>\n");
+    }
+  }
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+static void GrpcWriteDocComment(Printer* printer, const string& comments) {
+  printer->Print("/**\n");
+  std::vector<string> lines = GrpcGetDocLines(comments);
+  GrpcWriteDocCommentBody(printer, lines, false);
+  printer->Print(" */\n");
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+static void GrpcWriteServiceDocComment(Printer* printer,
+                                       const ServiceDescriptor* service) {
+  // Deviating from protobuf to avoid extraneous docs
+  // (see https://github.com/google/protobuf/issues/1406);
+  printer->Print("/**\n");
+  std::vector<string> lines = GrpcGetDocLinesForDescriptor(service);
+  GrpcWriteDocCommentBody(printer, lines, true);
+  printer->Print(" */\n");
+}
+
+// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
+void GrpcWriteMethodDocComment(Printer* printer,
+                           const MethodDescriptor* method) {
+  // Deviating from protobuf to avoid extraneous docs
+  // (see https://github.com/google/protobuf/issues/1406);
+  printer->Print("/**\n");
+  std::vector<string> lines = GrpcGetDocLinesForDescriptor(method);
+  GrpcWriteDocCommentBody(printer, lines, true);
+  printer->Print(" */\n");
+}
+
+static void PrintMethodFields(
+    const ServiceDescriptor* service, std::map<string, string>* vars,
+    Printer* p, ProtoFlavor flavor) {
+  p->Print("// Static method descriptors that strictly reflect the proto.\n");
+  (*vars)["service_name"] = service->name();
+  for (int i = 0; i < service->method_count(); ++i) {
+    const MethodDescriptor* method = service->method(i);
+    (*vars)["arg_in_id"] = to_string(2 * i);
+    (*vars)["arg_out_id"] = to_string(2 * i + 1);
+    (*vars)["method_name"] = method->name();
+    (*vars)["input_type"] = MessageFullJavaName(flavor == ProtoFlavor::NANO,
+                                                method->input_type());
+    (*vars)["output_type"] = MessageFullJavaName(flavor == ProtoFlavor::NANO,
+                                                 method->output_type());
+    (*vars)["method_field_name"] = MethodPropertiesFieldName(method);
+    (*vars)["method_new_field_name"] = MethodPropertiesGetterName(method);
+    (*vars)["method_method_name"] = MethodPropertiesGetterName(method);
+    bool client_streaming = method->client_streaming();
+    bool server_streaming = method->server_streaming();
+    if (client_streaming) {
+      if (server_streaming) {
+        (*vars)["method_type"] = "BIDI_STREAMING";
+      } else {
+        (*vars)["method_type"] = "CLIENT_STREAMING";
+      }
+    } else {
+      if (server_streaming) {
+        (*vars)["method_type"] = "SERVER_STREAMING";
+      } else {
+        (*vars)["method_type"] = "UNARY";
+      }
+    }
+
+    if (flavor == ProtoFlavor::NANO) {
+      // TODO(zsurocking): we're creating two NanoFactories for each method right now.
+      // We could instead create static NanoFactories and reuse them if some methods
+      // share the same request or response messages.
+      if (!ShouldGenerateAsLite(method->input_type())) {
+        p->Print(
+            *vars,
+            "private static final int ARG_IN_$method_field_name$ = $arg_in_id$;\n");
+      }
+      if (!ShouldGenerateAsLite(method->output_type())) {
+        p->Print(
+            *vars,
+            "private static final int ARG_OUT_$method_field_name$ = $arg_out_id$;\n");
+      }
+      p->Print(
+          *vars,
+          "private static volatile $MethodDescriptor$<$input_type$,\n"
+          "    $output_type$> $method_new_field_name$;\n"
+          "\n"
+          "public static $MethodDescriptor$<$input_type$,\n"
+          "    $output_type$> $method_method_name$() {\n"
+          "  $MethodDescriptor$<$input_type$, $output_type$> $method_new_field_name$;\n"
+          "  if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
+          "    synchronized ($service_class_name$.class) {\n"
+          "      if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
+          "        $service_class_name$.$method_new_field_name$ = $method_new_field_name$ = \n"
+          "            $MethodDescriptor$.<$input_type$, $output_type$>newBuilder()\n"
+          "            .setType($MethodType$.$method_type$)\n"
+          "            .setFullMethodName(generateFullMethodName(\n"
+          "                \"$Package$$service_name$\", \"$method_name$\"))\n"
+          "            .setSampledToLocalTracing(true)\n");
+
+      (*vars)["ProtoLiteUtils"] = "io.grpc.protobuf.lite.ProtoLiteUtils";
+
+      if (ShouldGenerateAsLite(method->input_type())) {
+        p->Print(
+            *vars,
+            "            .setRequestMarshaller($ProtoLiteUtils$.marshaller(\n"
+            "                $input_type$.getDefaultInstance()))\n");
+      } else {
+        p->Print(
+            *vars,
+            "            .setRequestMarshaller($NanoUtils$.<$input_type$>marshaller(\n"
+            "                new NanoFactory<$input_type$>(ARG_IN_$method_field_name$)))\n");
+      }
+      if (ShouldGenerateAsLite(method->output_type())) {
+        p->Print(
+            *vars,
+            "            .setResponseMarshaller($ProtoLiteUtils$.marshaller(\n"
+            "                $output_type$.getDefaultInstance()))\n");
+      } else {
+        p->Print(
+            *vars,
+            "            .setResponseMarshaller($NanoUtils$.<$output_type$>marshaller(\n"
+            "                new NanoFactory<$output_type$>(ARG_OUT_$method_field_name$)))\n");
+      }
+      p->Print(
+          *vars,
+          "            .build();\n"
+          "      }\n"
+          "    }\n"
+          "  }\n"
+          "  return $method_new_field_name$;\n"
+          "}\n"
+          "\n");
+    } else {
+      if (flavor == ProtoFlavor::LITE) {
+        (*vars)["ProtoUtils"] = "io.grpc.protobuf.lite.ProtoLiteUtils";
+      } else {
+        (*vars)["ProtoUtils"] = "io.grpc.protobuf.ProtoUtils";
+      }
+      p->Print(
+          *vars,
+          "private static volatile $MethodDescriptor$<$input_type$,\n"
+          "    $output_type$> $method_new_field_name$;\n"
+          "\n"
+          "@$RpcMethod$(\n"
+          "    fullMethodName = SERVICE_NAME + '/' + \"$method_name$\",\n"
+          "    requestType = $input_type$.class,\n"
+          "    responseType = $output_type$.class,\n"
+          "    methodType = $MethodType$.$method_type$)\n"
+          "public static $MethodDescriptor$<$input_type$,\n"
+          "    $output_type$> $method_method_name$() {\n"
+          "  $MethodDescriptor$<$input_type$, $output_type$> $method_new_field_name$;\n"
+          "  if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
+          "    synchronized ($service_class_name$.class) {\n"
+          "      if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
+          "        $service_class_name$.$method_new_field_name$ = $method_new_field_name$ = \n"
+          "            $MethodDescriptor$.<$input_type$, $output_type$>newBuilder()\n"
+          "            .setType($MethodType$.$method_type$)\n"
+          "            .setFullMethodName(generateFullMethodName(\n"
+          "                \"$Package$$service_name$\", \"$method_name$\"))\n"
+          "            .setSampledToLocalTracing(true)\n"
+          "            .setRequestMarshaller($ProtoUtils$.marshaller(\n"
+          "                $input_type$.getDefaultInstance()))\n"
+          "            .setResponseMarshaller($ProtoUtils$.marshaller(\n"
+          "                $output_type$.getDefaultInstance()))\n");
+
+      (*vars)["proto_method_descriptor_supplier"] = service->name() + "MethodDescriptorSupplier";
+      if (flavor == ProtoFlavor::NORMAL) {
+        p->Print(
+            *vars,
+          "                .setSchemaDescriptor(new $proto_method_descriptor_supplier$(\"$method_name$\"))\n");
+      }
+
+      p->Print(
+          *vars,
+          "                .build();\n");
+      p->Print(*vars,
+          "        }\n"
+          "      }\n"
+          "   }\n"
+          "   return $method_new_field_name$;\n"
+          "}\n"
+          "\n");
+    }
+  }
+
+  if (flavor == ProtoFlavor::NANO) {
+    p->Print(
+        *vars,
+        "private static final class NanoFactory<T extends com.google.protobuf.nano.MessageNano>\n"
+        "    implements io.grpc.protobuf.nano.MessageNanoFactory<T> {\n"
+        "  private final int id;\n"
+        "\n"
+        "  NanoFactory(int id) {\n"
+        "    this.id = id;\n"
+        "  }\n"
+        "\n"
+        "  @$Override$\n"
+        "  public T newInstance() {\n"
+        "    Object o;\n"
+        "    switch (id) {\n");
+    bool generate_nano = true;
+    for (int i = 0; i < service->method_count(); ++i) {
+      const MethodDescriptor* method = service->method(i);
+      (*vars)["input_type"] = MessageFullJavaName(generate_nano,
+                                                  method->input_type());
+      (*vars)["output_type"] = MessageFullJavaName(generate_nano,
+                                                   method->output_type());
+      (*vars)["method_field_name"] = MethodPropertiesFieldName(method);
+      if (!ShouldGenerateAsLite(method->input_type())) {
+        p->Print(
+            *vars,
+            "    case ARG_IN_$method_field_name$:\n"
+            "      o = new $input_type$();\n"
+            "      break;\n");
+      }
+      if (!ShouldGenerateAsLite(method->output_type())) {
+        p->Print(
+            *vars,
+            "    case ARG_OUT_$method_field_name$:\n"
+            "      o = new $output_type$();\n"
+            "      break;\n");
+      }
+    }
+    p->Print(
+        "    default:\n"
+        "      throw new AssertionError();\n"
+        "    }\n"
+        "    @java.lang.SuppressWarnings(\"unchecked\")\n"
+        "    T t = (T) o;\n"
+        "    return t;\n"
+        "  }\n"
+        "}\n"
+        "\n");
+  }
+}
+
+enum StubType {
+  ASYNC_INTERFACE = 0,
+  BLOCKING_CLIENT_INTERFACE = 1,
+  FUTURE_CLIENT_INTERFACE = 2,
+  BLOCKING_SERVER_INTERFACE = 3,
+  ASYNC_CLIENT_IMPL = 4,
+  BLOCKING_CLIENT_IMPL = 5,
+  FUTURE_CLIENT_IMPL = 6,
+  ABSTRACT_CLASS = 7,
+};
+
+enum CallType {
+  ASYNC_CALL = 0,
+  BLOCKING_CALL = 1,
+  FUTURE_CALL = 2
+};
+
+static void PrintBindServiceMethodBody(const ServiceDescriptor* service,
+                                   std::map<string, string>* vars,
+                                   Printer* p,
+                                   bool generate_nano);
+
+// Prints a client interface or implementation class, or a server interface.
+static void PrintStub(
+    const ServiceDescriptor* service,
+    std::map<string, string>* vars,
+    Printer* p, StubType type, bool generate_nano) {
+  const string service_name = service->name();
+  (*vars)["service_name"] = service_name;
+  string stub_name = service_name;
+  string client_name = service_name;
+  CallType call_type;
+  bool interface = false;
+  switch (type) {
+    case ASYNC_CLIENT_IMPL:
+      call_type = ASYNC_CALL;
+      stub_name += "Stub";
+      break;
+    case BLOCKING_CLIENT_INTERFACE:
+      interface = true;
+      FALLTHROUGH_INTENDED;
+    case BLOCKING_CLIENT_IMPL:
+      call_type = BLOCKING_CALL;
+      stub_name += "BlockingStub";
+      client_name += "BlockingClient";
+      break;
+    case FUTURE_CLIENT_INTERFACE:
+      interface = true;
+      FALLTHROUGH_INTENDED;
+    case FUTURE_CLIENT_IMPL:
+      call_type = FUTURE_CALL;
+      stub_name += "FutureStub";
+      client_name += "FutureClient";
+      break;
+    case ASYNC_INTERFACE:
+      call_type = ASYNC_CALL;
+      interface = true;
+      break;
+    default:
+      GRPC_CODEGEN_FAIL << "Cannot determine class name for StubType: " << type;
+  }
+  (*vars)["stub_name"] = stub_name;
+  (*vars)["client_name"] = client_name;
+
+  // Class head
+  if (!interface) {
+    GrpcWriteServiceDocComment(p, service);
+  }
+
+  if (service->options().deprecated()) {
+    p->Print(*vars, "@$Deprecated$\n");
+  }
+
+
+  p->Print(
+      *vars,
+      "public static final class $stub_name$ extends $AbstractStub$<$stub_name$> {\n");
+
+  p->Indent();
+
+  // Constructor and build() method
+  if (!interface) {
+    p->Print(
+        *vars,
+        "private $stub_name$($Channel$ channel) {\n");
+    p->Indent();
+    p->Print("super(channel);\n");
+    p->Outdent();
+    p->Print("}\n\n");
+    p->Print(
+        *vars,
+        "private $stub_name$($Channel$ channel,\n"
+        "    $CallOptions$ callOptions) {\n");
+    p->Indent();
+    p->Print("super(channel, callOptions);\n");
+    p->Outdent();
+    p->Print("}\n\n");
+    p->Print(
+        *vars,
+        "@$Override$\n"
+        "protected $stub_name$ build($Channel$ channel,\n"
+        "    $CallOptions$ callOptions) {\n");
+    p->Indent();
+    p->Print(
+        *vars,
+        "return new $stub_name$(channel, callOptions);\n");
+    p->Outdent();
+    p->Print("}\n");
+  }
+
+  // RPC methods
+  for (int i = 0; i < service->method_count(); ++i) {
+    const MethodDescriptor* method = service->method(i);
+    (*vars)["input_type"] = MessageFullJavaName(generate_nano,
+                                                method->input_type());
+    (*vars)["output_type"] = MessageFullJavaName(generate_nano,
+                                                 method->output_type());
+    (*vars)["lower_method_name"] = LowerMethodName(method);
+    (*vars)["method_method_name"] = MethodPropertiesGetterName(method);
+    bool client_streaming = method->client_streaming();
+    bool server_streaming = method->server_streaming();
+
+    if (call_type == BLOCKING_CALL && client_streaming) {
+      // Blocking client interface with client streaming is not available
+      continue;
+    }
+
+    if (call_type == FUTURE_CALL && (client_streaming || server_streaming)) {
+      // Future interface doesn't support streaming.
+      continue;
+    }
+
+    // Method signature
+    p->Print("\n");
+    // TODO(nmittler): Replace with WriteMethodDocComment once included by the protobuf distro.
+    if (!interface) {
+      GrpcWriteMethodDocComment(p, method);
+    }
+
+    if (method->options().deprecated()) {
+      p->Print(*vars, "@$Deprecated$\n");
+    }
+
+    p->Print("public ");
+    switch (call_type) {
+      case BLOCKING_CALL:
+        GRPC_CODEGEN_CHECK(!client_streaming)
+            << "Blocking client interface with client streaming is unavailable";
+        if (server_streaming) {
+          // Server streaming
+          p->Print(
+              *vars,
+              "$Iterator$<$output_type$> $lower_method_name$(\n"
+              "    $input_type$ request)");
+        } else {
+          // Simple RPC
+          p->Print(
+              *vars,
+              "$output_type$ $lower_method_name$($input_type$ request)");
+        }
+        break;
+      case ASYNC_CALL:
+        if (client_streaming) {
+          // Bidirectional streaming or client streaming
+          p->Print(
+              *vars,
+              "$StreamObserver$<$input_type$> $lower_method_name$(\n"
+              "    $StreamObserver$<$output_type$> responseObserver)");
+        } else {
+          // Server streaming or simple RPC
+          p->Print(
+              *vars,
+              "void $lower_method_name$($input_type$ request,\n"
+              "    $StreamObserver$<$output_type$> responseObserver)");
+        }
+        break;
+      case FUTURE_CALL:
+        GRPC_CODEGEN_CHECK(!client_streaming && !server_streaming)
+            << "Future interface doesn't support streaming. "
+            << "client_streaming=" << client_streaming << ", "
+            << "server_streaming=" << server_streaming;
+        p->Print(
+            *vars,
+            "$ListenableFuture$<$output_type$> $lower_method_name$(\n"
+            "    $input_type$ request)");
+        break;
+    }
+
+    if (interface) {
+      p->Print(";\n");
+      continue;
+    }
+    // Method body.
+    p->Print(" {\n");
+    p->Indent();
+    if (!interface) {
+      switch (call_type) {
+        case BLOCKING_CALL:
+          GRPC_CODEGEN_CHECK(!client_streaming)
+              << "Blocking client streaming interface is not available";
+          if (server_streaming) {
+            (*vars)["calls_method"] = "blockingServerStreamingCall";
+            (*vars)["params"] = "request";
+          } else {
+            (*vars)["calls_method"] = "blockingUnaryCall";
+            (*vars)["params"] = "request";
+          }
+          p->Print(
+              *vars,
+              "return $calls_method$(\n"
+              "    getChannel(), $method_method_name$(), getCallOptions(), $params$);\n");
+          break;
+        case ASYNC_CALL:
+          if (server_streaming) {
+            if (client_streaming) {
+              (*vars)["calls_method"] = "asyncBidiStreamingCall";
+              (*vars)["params"] = "responseObserver";
+            } else {
+              (*vars)["calls_method"] = "asyncServerStreamingCall";
+              (*vars)["params"] = "request, responseObserver";
+            }
+          } else {
+            if (client_streaming) {
+              (*vars)["calls_method"] = "asyncClientStreamingCall";
+              (*vars)["params"] = "responseObserver";
+            } else {
+              (*vars)["calls_method"] = "asyncUnaryCall";
+              (*vars)["params"] = "request, responseObserver";
+            }
+          }
+          (*vars)["last_line_prefix"] = client_streaming ? "return " : "";
+          p->Print(
+              *vars,
+              "$last_line_prefix$$calls_method$(\n"
+              "    getChannel().newCall($method_method_name$(), getCallOptions()), $params$);\n");
+          break;
+        case FUTURE_CALL:
+          GRPC_CODEGEN_CHECK(!client_streaming && !server_streaming)
+              << "Future interface doesn't support streaming. "
+              << "client_streaming=" << client_streaming << ", "
+              << "server_streaming=" << server_streaming;
+          (*vars)["calls_method"] = "futureUnaryCall";
+          p->Print(
+              *vars,
+              "return $calls_method$(\n"
+              "    getChannel().newCall($method_method_name$(), getCallOptions()), request);\n");
+          break;
+      }
+    }
+    p->Outdent();
+    p->Print("}\n");
+  }
+
+  p->Outdent();
+  p->Print("}\n\n");
+}
+
+static void PrintImplBase(
+    const ServiceDescriptor* service,
+    std::map<string, string>* vars,
+    Printer* p, bool generate_nano) {
+  const string service_name = service->name();
+  (*vars)["service_name"] = service_name;
+  (*vars)["abstract_name"] = service_name + "ImplBase";
+  string stub_name = service_name;
+  string client_name = service_name;
+  CallType call_type;
+
+  (*vars)["dubbo_interface"] = "I" + service_name;
+
+  p->Print(
+        *vars,
+        "public static abstract class $abstract_name$ implements $BindableService$, $dubbo_interface$ {\n\n");
+
+  // RPC methods
+  for (int i = 0; i < service->method_count(); ++i) {
+    const MethodDescriptor* method = service->method(i);
+    (*vars)["input_type"] = MessageFullJavaName(generate_nano,
+                                                method->input_type());
+    (*vars)["output_type"] = MessageFullJavaName(generate_nano,
+                                                 method->output_type());
+    (*vars)["lower_method_name"] = LowerMethodName(method);
+    (*vars)["method_method_name"] = MethodPropertiesGetterName(method);
+    bool client_streaming = method->client_streaming();
+    bool server_streaming = method->server_streaming();
+
+    if (client_streaming) {
+        p->Print(
+            *vars,
+            "public $StreamObserver$<$input_type$> $lower_method_name$(\n"
+            "    $StreamObserver$<$output_type$> responseObserver) {\n"
+            "    return asyncUnimplementedStreamingCall($method_method_name$(), responseObserver);\n"
+            "}\n\n");
+
+    } else if (server_streaming) {
+        p->Print(
+            *vars,
+            "@$Override$\n"
+            "public final $Iterator$<$output_type$> $lower_method_name$(\n"
+            "    $input_type$ request) {\n$default_method_body$\n}\n\n");
+        p->Print(
+            *vars,
+            "public void $lower_method_name$($input_type$ request,\n"
+            "    $StreamObserver$<$output_type$> responseObserver) {\n"
+            "    asyncUnimplementedUnaryCall($method_method_name$(), responseObserver);\n\n"
+            "}\n");
+    } else {
+       // Simple RPC
+        p->Print(
+            *vars,
+            "@$Override$\n"
+            "public final $output_type$ $lower_method_name$"
+            "($input_type$ request) {\n$default_method_body$\n}\n\n");
+       // Simple Future RPC
+        p->Print(
+            *vars,
+            "@$Override$\n"
+            "public final $ListenableFuture$<$output_type$> $lower_method_name$Async(\n"
+            "    $input_type$ request) {\n$default_method_body$\n}\n\n");
+       // Simple Stream RPC
+        p->Print(
+            *vars,
+            "public void $lower_method_name$($input_type$ request,\n"
+            "    $StreamObserver$<$output_type$> responseObserver) {\n"
+            "    asyncUnimplementedUnaryCall($method_method_name$(), responseObserver);\n"
+            "}\n\n");
+    }
+    p->Outdent();
+  }
+
+    p->Print("\n");
+    p->Print(
+        *vars,
+        "@$Override$\n public final $ServerServiceDefinition$ bindService() {\n");
+    (*vars)["instance"] = "this";
+    PrintBindServiceMethodBody(service, vars, p, generate_nano);
+    p->Print("}\n");
+    p->Outdent();
+    p->Print("}\n\n");
+}
+
+static void PrintDubboInterface(
+    const ServiceDescriptor* service,
+    std::map<string, string>* vars,
+    Printer* p, bool interface, bool generate_nano) {
+    const string service_name = service->name();
+    (*vars)["service_name"] = service_name;
+    (*vars)["dubbo_interface"] = "I" + service_name;
+    if (interface) {
+        p->Print(
+            "/**\n "
+            "* Code generated for Dubbo\n "
+            "*/\n"
+        );
+        p->Print(
+        *vars,
+        "public interface $dubbo_interface$ {\n\n");
+
+        for (int i = 0; i < service->method_count(); ++i) {
+            const MethodDescriptor* method = service->method(i);
+            (*vars)["input_type"] = MessageFullJavaName(generate_nano,
+                                                        method->input_type());
+            (*vars)["output_type"] = MessageFullJavaName(generate_nano,
+                                                         method->output_type());
+            (*vars)["lower_method_name"] = LowerMethodName(method);
+            (*vars)["method_method_name"] = MethodPropertiesGetterName(method);
+            bool client_streaming = method->client_streaming();
+            bool server_streaming = method->server_streaming();
+
+            if (client_streaming) {
+                p->Print(
+                    *vars,
+                    "public $StreamObserver$<$input_type$> $lower_method_name$(\n"
+                    "    $StreamObserver$<$output_type$> responseObserver);\n\n");
+
+            } else if (server_streaming) {
+                p->Print(
+                    *vars,
+                    "default public $Iterator$<$output_type$> $lower_method_name$(\n"
+                    "    $input_type$ request) {\n$default_method_body$\n}\n\n");
+                p->Print(
+                    *vars,
+                    "public void $lower_method_name$($input_type$ request,\n"
+                    "    $StreamObserver$<$output_type$> responseObserver);\n\n");
+            } else {
+               // Simple RPC
+                p->Print(
+                    *vars,
+                    "default public $output_type$ $lower_method_name$"
+                    "($input_type$ request) {\n$default_method_body$\n}\n\n");
+               // Simple Future RPC
+                p->Print(
+                    *vars,
+                    "default public $ListenableFuture$<$output_type$> $lower_method_name$Async(\n"
+                    "    $input_type$ request) {\n$default_method_body$\n}\n\n");
+               // Simple Stream RPC
+                p->Print(
+                    *vars,
+                    "public void $lower_method_name$($input_type$ request,\n"
+                    "    $StreamObserver$<$output_type$> responseObserver);\n\n");
+            }
+            p->Outdent();
+        }
+
+        p->Outdent();
+        p->Print("}\n\n");
+    }
+    // Dubbo Stub
+    else {
+        (*vars)["dubbo_stub"] = "Dubbo" + service_name + "Stub";
+        p->Print(*vars, "public static class $dubbo_stub$ implements $dubbo_interface$ {\n\n");
+
+        // Properties
+        p->Print("private "); p->Print(service_name.c_str()); p->Print("BlockingStub blockingStub;\n");
+        p->Print("private "); p->Print(service_name.c_str()); p->Print("FutureStub futureStub;\n");
+        p->Print("private "); p->Print(service_name.c_str()); p->Print("Stub stub;\n\n");
+
+        // Consustor
+        p->Print(*vars, "public $dubbo_stub$($Channel$ channel) {\n"
+        "   blockingStub = $service_class_name$.newBlockingStub(channel);\n"
+        "   futureStub = $service_class_name$.newFutureStub(channel);\n"
+        "   stub = $service_class_name$.newStub(channel);\n"
+        "}\n\n");
+
+        for (int i = 0; i < service->method_count(); ++i) {
+            const MethodDescriptor* method = service->method(i);
+            (*vars)["input_type"] = MessageFullJavaName(generate_nano,
+                                                        method->input_type());
+            (*vars)["output_type"] = MessageFullJavaName(generate_nano,
+                                                         method->output_type());
+            (*vars)["lower_method_name"] = LowerMethodName(method);
+            (*vars)["method_method_name"] = MethodPropertiesGetterName(method);
+            bool client_streaming = method->client_streaming();
+            bool server_streaming = method->server_streaming();
+
+            if (client_streaming) {
+                p->Print(
+                    *vars,
+                    "public $StreamObserver$<$input_type$> $lower_method_name$(\n"
+                    "    $StreamObserver$<$output_type$> responseObserver) {\n"
+                    "    return stub.$lower_method_name$(responseObserver);\n"
+                    "}\n\n");
+
+            } else if (server_streaming) {
+                p->Print(
+                    *vars,
+                    "public $Iterator$<$output_type$> $lower_method_name$(\n"
+                    "    $input_type$ request) {\n"
+                    "    return blockingStub.$lower_method_name$(request);\n"
+                    "}\n\n");
+                p->Print(
+                    *vars,
+                    "public void $lower_method_name$($input_type$ request,\n"
+                    "    $StreamObserver$<$output_type$> responseObserver) {\n"
+                    "    stub.$lower_method_name$(request, responseObserver);\n"
+                    "}\n\n");
+            } else {
+               // Simple RPC
+                p->Print(
+                    *vars,
+                    "public $output_type$ $lower_method_name$"
+                    "($input_type$ request) {\n"
+                    "    return blockingStub.$lower_method_name$(request);\n"
+                    "}\n\n");
+               // Simple Future RPC
+                p->Print(
+                    *vars,
+                    "public $ListenableFuture$<$output_type$> $lower_method_name$Async(\n"
+                    "    $input_type$ request) {\n"
+                    "    return futureStub.$lower_method_name$(request);\n"
+                    "}\n\n");
+               // Simple Stream RPC
+                p->Print(
+                    *vars,
+                    "public void $lower_method_name$($input_type$ request,\n"
+                    "    $StreamObserver$<$output_type$> responseObserver){\n"
+                    "    stub.$lower_method_name$(request, responseObserver);\n"
+                    "}\n\n");
+            }
+            p->Outdent();
+        }
+        p->Outdent();
+        p->Print("}\n\n");
+
+        p->Print(*vars, "public static $dubbo_stub$ getDubboStub($Channel$ channel) {\n\n");
+        p->Print(*vars, "  return new $dubbo_stub$(channel);");
+        p->Print("}\n\n");
+    }
+    p->Outdent();
+}
+
+static bool CompareMethodClientStreaming(const MethodDescriptor* method1,
+                                         const MethodDescriptor* method2)
+{
+  return method1->client_streaming() < method2->client_streaming();
+}
+
+// Place all method invocations into a single class to reduce memory footprint
+// on Android.
+static void PrintMethodHandlerClass(const ServiceDescriptor* service,
+                                   std::map<string, string>* vars,
+                                   Printer* p,
+                                   bool generate_nano) {
+  // Sort method ids based on client_streaming() so switch tables are compact.
+  std::vector<const MethodDescriptor*> sorted_methods(service->method_count());
+  for (int i = 0; i < service->method_count(); ++i) {
+    sorted_methods[i] = service->method(i);
+  }
+  stable_sort(sorted_methods.begin(), sorted_methods.end(),
+              CompareMethodClientStreaming);
+  for (size_t i = 0; i < sorted_methods.size(); i++) {
+    const MethodDescriptor* method = sorted_methods[i];
+    (*vars)["method_id"] = to_string(i);
+    (*vars)["method_id_name"] = MethodIdFieldName(method);
+    p->Print(
+        *vars,
+        "private static final int $method_id_name$ = $method_id$;\n");
+  }
+  p->Print("\n");
+  (*vars)["service_name"] = service->name() + "ImplBase";
+  p->Print(
+      *vars,
+      "private static final class MethodHandlers<Req, Resp> implements\n"
+      "    io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,\n"
+      "    io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,\n"
+      "    io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,\n"
+      "    io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {\n"
+      "  private final $service_name$ serviceImpl;\n"
+      "  private final int methodId;\n"
+      "\n"
+      "  MethodHandlers($service_name$ serviceImpl, int methodId) {\n"
+      "    this.serviceImpl = serviceImpl;\n"
+      "    this.methodId = methodId;\n"
+      "  }\n\n");
+  p->Indent();
+  p->Print(
+      *vars,
+      "@$Override$\n"
+      "@java.lang.SuppressWarnings(\"unchecked\")\n"
+      "public void invoke(Req request, $StreamObserver$<Resp> responseObserver) {\n"
+      "  switch (methodId) {\n");
+  p->Indent();
+  p->Indent();
+
+  for (int i = 0; i < service->method_count(); ++i) {
+    const MethodDescriptor* method = service->method(i);
+    if (method->client_streaming()) {
+      continue;
+    }
+    (*vars)["method_id_name"] = MethodIdFieldName(method);
+    (*vars)["lower_method_name"] = LowerMethodName(method);
+    (*vars)["input_type"] = MessageFullJavaName(generate_nano,
+                                                method->input_type());
+    (*vars)["output_type"] = MessageFullJavaName(generate_nano,
+                                                 method->output_type());
+    p->Print(
+        *vars,
+        "case $method_id_name$:\n"
+        "  serviceImpl.$lower_method_name$(($input_type$) request,\n"
+        "      ($StreamObserver$<$output_type$>) responseObserver);\n"
+        "  break;\n");
+  }
+  p->Print("default:\n"
+           "  throw new AssertionError();\n");
+
+  p->Outdent();
+  p->Outdent();
+  p->Print("  }\n"
+           "}\n\n");
+
+  p->Print(
+      *vars,
+      "@$Override$\n"
+      "@java.lang.SuppressWarnings(\"unchecked\")\n"
+      "public $StreamObserver$<Req> invoke(\n"
+      "    $StreamObserver$<Resp> responseObserver) {\n"
+      "  switch (methodId) {\n");
+  p->Indent();
+  p->Indent();
+
+  for (int i = 0; i < service->method_count(); ++i) {
+    const MethodDescriptor* method = service->method(i);
+    if (!method->client_streaming()) {
+      continue;
+    }
+    (*vars)["method_id_name"] = MethodIdFieldName(method);
+    (*vars)["lower_method_name"] = LowerMethodName(method);
+    (*vars)["input_type"] = MessageFullJavaName(generate_nano,
+                                                method->input_type());
+    (*vars)["output_type"] = MessageFullJavaName(generate_nano,
+                                                 method->output_type());
+    p->Print(
+        *vars,
+        "case $method_id_name$:\n"
+        "  return ($StreamObserver$<Req>) serviceImpl.$lower_method_name$(\n"
+        "      ($StreamObserver$<$output_type$>) responseObserver);\n");
+  }
+  p->Print("default:\n"
+           "  throw new AssertionError();\n");
+
+  p->Outdent();
+  p->Outdent();
+  p->Print("  }\n"
+           "}\n");
+
+
+  p->Outdent();
+  p->Print("}\n\n");
+}
+
+static void PrintGetServiceDescriptorMethod(const ServiceDescriptor* service,
+                                   std::map<string, string>* vars,
+                                   Printer* p,
+                                   ProtoFlavor flavor) {
+  (*vars)["service_name"] = service->name();
+
+
+  if (flavor == ProtoFlavor::NORMAL) {
+    (*vars)["proto_base_descriptor_supplier"] = service->name() + "BaseDescriptorSupplier";
+    (*vars)["proto_file_descriptor_supplier"] = service->name() + "FileDescriptorSupplier";
+    (*vars)["proto_method_descriptor_supplier"] = service->name() + "MethodDescriptorSupplier";
+    (*vars)["proto_class_name"] = google::protobuf::compiler::java::ClassName(service->file());
+    p->Print(
+        *vars,
+        "private static abstract class $proto_base_descriptor_supplier$\n"
+        "    implements $ProtoFileDescriptorSupplier$, $ProtoServiceDescriptorSupplier$ {\n"
+        "  $proto_base_descriptor_supplier$() {}\n"
+        "\n"
+        "  @$Override$\n"
+        "  public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {\n"
+        "    return $proto_class_name$.getDescriptor();\n"
+        "  }\n"
+        "\n"
+        "  @$Override$\n"
+        "  public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {\n"
+        "    return getFileDescriptor().findServiceByName(\"$service_name$\");\n"
+        "  }\n"
+        "}\n"
+        "\n"
+        "private static final class $proto_file_descriptor_supplier$\n"
+        "    extends $proto_base_descriptor_supplier$ {\n"
+        "  $proto_file_descriptor_supplier$() {}\n"
+        "}\n"
+        "\n"
+        "private static final class $proto_method_descriptor_supplier$\n"
+        "    extends $proto_base_descriptor_supplier$\n"
+        "    implements $ProtoMethodDescriptorSupplier$ {\n"
+        "  private final String methodName;\n"
+        "\n"
+        "  $proto_method_descriptor_supplier$(String methodName) {\n"
+        "    this.methodName = methodName;\n"
+        "  }\n"
+        "\n"
+        "  @$Override$\n"
+        "  public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {\n"
+        "    return getServiceDescriptor().findMethodByName(methodName);\n"
+        "  }\n"
+        "}\n\n");
+  }
+
+  p->Print(
+      *vars,
+      "private static volatile $ServiceDescriptor$ serviceDescriptor;\n\n");
+
+  p->Print(
+      *vars,
+      "public static $ServiceDescriptor$ getServiceDescriptor() {\n");
+  p->Indent();
+  p->Print(
+      *vars,
+      "$ServiceDescriptor$ result = serviceDescriptor;\n");
+  p->Print("if (result == null) {\n");
+  p->Indent();
+  p->Print(
+      *vars,
+      "synchronized ($service_class_name$.class) {\n");
+  p->Indent();
+  p->Print("result = serviceDescriptor;\n");
+  p->Print("if (result == null) {\n");
+  p->Indent();
+
+  p->Print(
+      *vars,
+      "serviceDescriptor = result = $ServiceDescriptor$.newBuilder(SERVICE_NAME)");
+  p->Indent();
+  p->Indent();
+  if (flavor == ProtoFlavor::NORMAL) {
+    p->Print(
+        *vars,
+        "\n.setSchemaDescriptor(new $proto_file_descriptor_supplier$())");
+  }
+  for (int i = 0; i < service->method_count(); ++i) {
+    const MethodDescriptor* method = service->method(i);
+    (*vars)["method_method_name"] = MethodPropertiesGetterName(method);
+    p->Print(*vars, "\n.addMethod($method_method_name$())");
+  }
+  p->Print("\n.build();\n");
+  p->Outdent();
+  p->Outdent();
+
+  p->Outdent();
+  p->Print("}\n");
+  p->Outdent();
+  p->Print("}\n");
+  p->Outdent();
+  p->Print("}\n");
+  p->Print("return result;\n");
+  p->Outdent();
+  p->Print("}\n");
+}
+
+static void PrintBindServiceMethodBody(const ServiceDescriptor* service,
+                                   std::map<string, string>* vars,
+                                   Printer* p,
+                                   bool generate_nano) {
+  (*vars)["service_name"] = service->name();
+  p->Indent();
+  p->Print(*vars,
+           "return "
+           "$ServerServiceDefinition$.builder(getServiceDescriptor())\n");
+  p->Indent();
+  p->Indent();
+  for (int i = 0; i < service->method_count(); ++i) {
+    const MethodDescriptor* method = service->method(i);
+    (*vars)["lower_method_name"] = LowerMethodName(method);
+    (*vars)["method_method_name"] = MethodPropertiesGetterName(method);
+    (*vars)["input_type"] = MessageFullJavaName(generate_nano,
+                                                method->input_type());
+    (*vars)["output_type"] = MessageFullJavaName(generate_nano,
+                                                 method->output_type());
+    (*vars)["method_id_name"] = MethodIdFieldName(method);
+    bool client_streaming = method->client_streaming();
+    bool server_streaming = method->server_streaming();
+    if (client_streaming) {
+      if (server_streaming) {
+        (*vars)["calls_method"] = "asyncBidiStreamingCall";
+      } else {
+        (*vars)["calls_method"] = "asyncClientStreamingCall";
+      }
+    } else {
+      if (server_streaming) {
+        (*vars)["calls_method"] = "asyncServerStreamingCall";
+      } else {
+        (*vars)["calls_method"] = "asyncUnaryCall";
+      }
+    }
+    p->Print(*vars, ".addMethod(\n");
+    p->Indent();
+    p->Print(
+        *vars,
+        "$method_method_name$(),\n"
+        "$calls_method$(\n");
+    p->Indent();
+    p->Print(
+        *vars,
+        "new MethodHandlers<\n"
+        "  $input_type$,\n"
+        "  $output_type$>(\n"
+        "    $instance$, $method_id_name$)))\n");
+    p->Outdent();
+    p->Outdent();
+  }
+  p->Print(".build();\n");
+  p->Outdent();
+  p->Outdent();
+  p->Outdent();
+}
+
+static void PrintService(const ServiceDescriptor* service,
+                         std::map<string, string>* vars,
+                         Printer* p,
+                         ProtoFlavor flavor,
+                         bool disable_version) {
+  (*vars)["service_name"] = service->name();
+  (*vars)["file_name"] = service->file()->name();
+  (*vars)["service_class_name"] = ServiceClassName(service);
+  (*vars)["grpc_version"] = "";
+  #ifdef GRPC_VERSION
+  if (!disable_version) {
+    (*vars)["grpc_version"] = " (version " XSTR(GRPC_VERSION) ")";
+  }
+  #endif
+  // TODO(nmittler): Replace with WriteServiceDocComment once included by protobuf distro.
+  GrpcWriteServiceDocComment(p, service);
+  p->Print(
+      *vars,
+      "@$Generated$(\n"
+      "    value = \"by gRPC proto compiler$grpc_version$\",\n"
+      "    comments = \"Source: $file_name$\")\n");
+
+  if (service->options().deprecated()) {
+    p->Print(*vars, "@$Deprecated$\n");
+  }
+
+  p->Print(
+      *vars,
+      "public final class $service_class_name$ {\n\n");
+  p->Indent();
+  p->Print(
+      *vars,
+      "private $service_class_name$() {}\n\n");
+
+  p->Print(
+      *vars,
+      "public static final String SERVICE_NAME = "
+      "\"$Package$$service_name$\";\n\n");
+
+  PrintMethodFields(service, vars, p, flavor);
+
+  // TODO(nmittler): Replace with WriteDocComment once included by protobuf distro.
+  GrpcWriteDocComment(p, " Creates a new async stub that supports all call types for the service");
+  p->Print(
+      *vars,
+      "public static $service_name$Stub newStub($Channel$ channel) {\n");
+  p->Indent();
+  p->Print(
+      *vars,
+      "return new $service_name$Stub(channel);\n");
+  p->Outdent();
+  p->Print("}\n\n");
+
+  // TODO(nmittler): Replace with WriteDocComment once included by protobuf distro.
+  GrpcWriteDocComment(p, " Creates a new blocking-style stub that supports unary and streaming "
+                         "output calls on the service");
+  p->Print(
+      *vars,
+      "public static $service_name$BlockingStub newBlockingStub(\n"
+      "    $Channel$ channel) {\n");
+  p->Indent();
+  p->Print(
+      *vars,
+      "return new $service_name$BlockingStub(channel);\n");
+  p->Outdent();
+  p->Print("}\n\n");
+
+  // TODO(nmittler): Replace with WriteDocComment once included by protobuf distro.
+  GrpcWriteDocComment(p, " Creates a new ListenableFuture-style stub that supports unary calls "
+                         "on the service");
+  p->Print(
+      *vars,
+      "public static $service_name$FutureStub newFutureStub(\n"
+      "    $Channel$ channel) {\n");
+  p->Indent();
+  p->Print(
+      *vars,
+      "return new $service_name$FutureStub(channel);\n");
+  p->Outdent();
+  p->Print("}\n\n");
+
+  bool generate_nano = flavor == ProtoFlavor::NANO;
+//  PrintStub(service, vars, p, ABSTRACT_CLASS, generate_nano);
+  PrintStub(service, vars, p, ASYNC_CLIENT_IMPL, generate_nano);
+  PrintStub(service, vars, p, BLOCKING_CLIENT_IMPL, generate_nano);
+  PrintStub(service, vars, p, FUTURE_CLIENT_IMPL, generate_nano);
+
+  PrintImplBase(service, vars, p, generate_nano);
+  PrintDubboInterface(service, vars, p, true, generate_nano);
+  PrintDubboInterface(service, vars, p, false, generate_nano);
+
+  PrintMethodHandlerClass(service, vars, p, generate_nano);
+  PrintGetServiceDescriptorMethod(service, vars, p, flavor);
+  p->Outdent();
+  p->Print("}\n");
+}
+
+void PrintImports(Printer* p, bool generate_nano) {
+  p->Print(
+      "import static "
+      "io.grpc.MethodDescriptor.generateFullMethodName;\n"
+      "import static "
+      "io.grpc.stub.ClientCalls.asyncBidiStreamingCall;\n"
+      "import static "
+      "io.grpc.stub.ClientCalls.asyncClientStreamingCall;\n"
+      "import static "
+      "io.grpc.stub.ClientCalls.asyncServerStreamingCall;\n"
+      "import static "
+      "io.grpc.stub.ClientCalls.asyncUnaryCall;\n"
+      "import static "
+      "io.grpc.stub.ClientCalls.blockingServerStreamingCall;\n"
+      "import static "
+      "io.grpc.stub.ClientCalls.blockingUnaryCall;\n"
+      "import static "
+      "io.grpc.stub.ClientCalls.futureUnaryCall;\n"
+      "import static "
+      "io.grpc.stub.ServerCalls.asyncBidiStreamingCall;\n"
+      "import static "
+      "io.grpc.stub.ServerCalls.asyncClientStreamingCall;\n"
+      "import static "
+      "io.grpc.stub.ServerCalls.asyncServerStreamingCall;\n"
+      "import static "
+      "io.grpc.stub.ServerCalls.asyncUnaryCall;\n"
+      "import static "
+      "io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;\n"
+      "import static "
+      "io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;\n\n");
+  if (generate_nano) {
+    p->Print("import java.io.IOException;\n\n");
+  }
+}
+
+void GenerateService(const ServiceDescriptor* service,
+                     google::protobuf::io::ZeroCopyOutputStream* out,
+                     ProtoFlavor flavor,
+                     bool disable_version) {
+  // All non-generated classes must be referred by fully qualified names to
+  // avoid collision with generated classes.
+  std::map<string, string> vars;
+  vars["String"] = "java.lang.String";
+  vars["Deprecated"] = "java.lang.Deprecated";
+  vars["Override"] = "java.lang.Override";
+  vars["Channel"] = "io.grpc.Channel";
+  vars["CallOptions"] = "io.grpc.CallOptions";
+  vars["MethodType"] = "io.grpc.MethodDescriptor.MethodType";
+  vars["ServerMethodDefinition"] =
+      "io.grpc.ServerMethodDefinition";
+  vars["BindableService"] = "io.grpc.BindableService";
+  vars["ServerServiceDefinition"] =
+      "io.grpc.ServerServiceDefinition";
+  vars["ServiceDescriptor"] =
+      "io.grpc.ServiceDescriptor";
+  vars["ProtoFileDescriptorSupplier"] =
+      "io.grpc.protobuf.ProtoFileDescriptorSupplier";
+  vars["ProtoServiceDescriptorSupplier"] =
+      "io.grpc.protobuf.ProtoServiceDescriptorSupplier";
+  vars["ProtoMethodDescriptorSupplier"] =
+      "io.grpc.protobuf.ProtoMethodDescriptorSupplier";
+  vars["AbstractStub"] = "io.grpc.stub.AbstractStub";
+  vars["RpcMethod"] = "io.grpc.stub.annotations.RpcMethod";
+  vars["MethodDescriptor"] = "io.grpc.MethodDescriptor";
+  vars["NanoUtils"] = "io.grpc.protobuf.nano.NanoUtils";
+  vars["StreamObserver"] = "io.grpc.stub.StreamObserver";
+  vars["Iterator"] = "java.util.Iterator";
+  vars["Generated"] = "javax.annotation.Generated";
+  vars["ListenableFuture"] =
+      "com.google.common.util.concurrent.ListenableFuture";
+  vars["default_method_body"] = "   throw new UnsupportedOperationException(\""
+             "No need to override this method, extend XxxImplBase and override "
+             "all methods it allows.\");";
+
+  Printer printer(out, '$');
+  string package_name = ServiceJavaPackage(service->file(),
+                                           flavor == ProtoFlavor::NANO);
+  if (!package_name.empty()) {
+    printer.Print(
+        "package $package_name$;\n\n",
+        "package_name", package_name);
+  }
+
+  PrintImports(&printer, flavor == ProtoFlavor::NANO);
+
+  // Package string is used to fully qualify method names.
+  vars["Package"] = service->file()->package();
+  if (!vars["Package"].empty()) {
+    vars["Package"].append(".");
+  }
+  PrintService(service, &vars, &printer, flavor, disable_version);
+}
+
+string ServiceJavaPackage(const FileDescriptor* file, bool nano) {
+  string result = google::protobuf::compiler::java::ClassName(file);
+  size_t last_dot_pos = result.find_last_of('.');
+  if (last_dot_pos != string::npos) {
+    result.resize(last_dot_pos);
+  } else {
+    result = "";
+  }
+  if (nano) {
+    if (!result.empty()) {
+      result += ".";
+    }
+    result += "nano";
+  }
+  return result;
+}
+
+string ServiceClassName(const google::protobuf::ServiceDescriptor* service) {
+  return service->name() + "Grpc";
+}
+
+}  // namespace java_grpc_generator
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_generator.h b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_generator.h
new file mode 100644
index 0000000..ab265d0
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_generator.h
@@ -0,0 +1,57 @@
+#ifndef NET_GRPC_COMPILER_JAVA_GENERATOR_H_
+#define NET_GRPC_COMPILER_JAVA_GENERATOR_H_
+
+#include <stdlib.h>  // for abort()
+#include <iostream>
+#include <string>
+
+#include <google/protobuf/io/zero_copy_stream.h>
+#include <google/protobuf/descriptor.h>
+
+class LogHelper {
+  std::ostream* os;
+
+ public:
+  LogHelper(std::ostream* os) : os(os) {}
+  ~LogHelper() {
+    *os << std::endl;
+    ::abort();
+  }
+  std::ostream& get_os() {
+    return *os;
+  }
+};
+
+// Abort the program after logging the mesage if the given condition is not
+// true. Otherwise, do nothing.
+#define GRPC_CODEGEN_CHECK(x) !(x) && LogHelper(&std::cerr).get_os() \
+                             << "CHECK FAILED: " << __FILE__ << ":" \
+                             << __LINE__ << ": "
+
+// Abort the program after logging the mesage.
+#define GRPC_CODEGEN_FAIL GRPC_CODEGEN_CHECK(false)
+
+using namespace std;
+
+namespace java_grpc_generator {
+
+enum ProtoFlavor {
+  NORMAL, LITE, NANO
+};
+
+// Returns the package name of the gRPC services defined in the given file.
+string ServiceJavaPackage(const google::protobuf::FileDescriptor* file, bool nano);
+
+// Returns the name of the outer class that wraps in all the generated code for
+// the given service.
+string ServiceClassName(const google::protobuf::ServiceDescriptor* service);
+
+// Writes the generated service interface into the given ZeroCopyOutputStream
+void GenerateService(const google::protobuf::ServiceDescriptor* service,
+                     google::protobuf::io::ZeroCopyOutputStream* out,
+                     ProtoFlavor flavor,
+                     bool disable_version);
+
+}  // namespace java_grpc_generator
+
+#endif  // NET_GRPC_COMPILER_JAVA_GENERATOR_H_
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_plugin.cpp b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_plugin.cpp
new file mode 100644
index 0000000..b2cbd0b
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/java_plugin/cpp/java_plugin.cpp
@@ -0,0 +1,70 @@
+// Generates Java gRPC service interface out of Protobuf IDL.
+//
+// This is a Proto2 compiler plugin.  See net/proto2/compiler/proto/plugin.proto
+// and net/proto2/compiler/public/plugin.h for more information on plugins.
+
+#include <memory>
+
+#include "java_generator.h"
+#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/compiler/plugin.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/io/zero_copy_stream.h>
+
+static string JavaPackageToDir(const string& package_name) {
+  string package_dir = package_name;
+  for (size_t i = 0; i < package_dir.size(); ++i) {
+    if (package_dir[i] == '.') {
+      package_dir[i] = '/';
+    }
+  }
+  if (!package_dir.empty()) package_dir += "/";
+  return package_dir;
+}
+
+class JavaGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
+ public:
+  JavaGrpcGenerator() {}
+  virtual ~JavaGrpcGenerator() {}
+
+  virtual bool Generate(const google::protobuf::FileDescriptor* file,
+                        const string& parameter,
+                        google::protobuf::compiler::GeneratorContext* context,
+                        string* error) const {
+    std::vector<std::pair<string, string> > options;
+    google::protobuf::compiler::ParseGeneratorParameter(parameter, &options);
+
+    java_grpc_generator::ProtoFlavor flavor =
+        java_grpc_generator::ProtoFlavor::NORMAL;
+
+    bool disable_version = false;
+    for (size_t i = 0; i < options.size(); i++) {
+      if (options[i].first == "nano") {
+        flavor = java_grpc_generator::ProtoFlavor::NANO;
+      } else if (options[i].first == "lite") {
+        flavor = java_grpc_generator::ProtoFlavor::LITE;
+      } else if (options[i].first == "noversion") {
+        disable_version = true;
+      }
+    }
+
+    string package_name = java_grpc_generator::ServiceJavaPackage(
+        file, flavor == java_grpc_generator::ProtoFlavor::NANO);
+    string package_filename = JavaPackageToDir(package_name);
+    for (int i = 0; i < file->service_count(); ++i) {
+      const google::protobuf::ServiceDescriptor* service = file->service(i);
+      string filename = package_filename
+          + java_grpc_generator::ServiceClassName(service) + ".java";
+      std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
+          context->Open(filename));
+      java_grpc_generator::GenerateService(
+          service, output.get(), flavor, disable_version);
+    }
+    return true;
+  }
+};
+
+int main(int argc, char* argv[]) {
+  JavaGrpcGenerator generator;
+  return google::protobuf::compiler::PluginMain(argc, argv, &generator);
+}
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/golden/TestDeprecatedService.java.txt b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/golden/TestDeprecatedService.java.txt
new file mode 100644
index 0000000..197c93e
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/golden/TestDeprecatedService.java.txt
@@ -0,0 +1,316 @@
+package io.grpc.testing.compiler;
+
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+/**
+ * <pre>
+ * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+ * </pre>
+ */
+@javax.annotation.Generated(
+    value = "by gRPC proto compiler (version 1.19.0)",
+    comments = "Source: grpc/testing/compiler/test.proto")
+@java.lang.Deprecated
+public final class TestDeprecatedServiceGrpc {
+
+  private TestDeprecatedServiceGrpc() {}
+
+  public static final String SERVICE_NAME = "grpc.testing.compiler.TestDeprecatedService";
+
+  // Static method descriptors that strictly reflect the proto.
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
+      io.grpc.testing.compiler.Test.SimpleResponse> getDeprecatedMethodMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "DeprecatedMethod",
+      requestType = io.grpc.testing.compiler.Test.SimpleRequest.class,
+      responseType = io.grpc.testing.compiler.Test.SimpleResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
+      io.grpc.testing.compiler.Test.SimpleResponse> getDeprecatedMethodMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse> getDeprecatedMethodMethod;
+    if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
+      synchronized (TestDeprecatedServiceGrpc.class) {
+        if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
+          TestDeprecatedServiceGrpc.getDeprecatedMethodMethod = getDeprecatedMethodMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestDeprecatedService", "DeprecatedMethod"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.SimpleRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.SimpleResponse.getDefaultInstance()))
+                  .setSchemaDescriptor(new TestDeprecatedServiceMethodDescriptorSupplier("DeprecatedMethod"))
+                  .build();
+          }
+        }
+     }
+     return getDeprecatedMethodMethod;
+  }
+
+  /**
+   * Creates a new async stub that supports all call types for the service
+   */
+  public static TestDeprecatedServiceStub newStub(io.grpc.Channel channel) {
+    return new TestDeprecatedServiceStub(channel);
+  }
+
+  /**
+   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+   */
+  public static TestDeprecatedServiceBlockingStub newBlockingStub(
+      io.grpc.Channel channel) {
+    return new TestDeprecatedServiceBlockingStub(channel);
+  }
+
+  /**
+   * Creates a new ListenableFuture-style stub that supports unary calls on the service
+   */
+  public static TestDeprecatedServiceFutureStub newFutureStub(
+      io.grpc.Channel channel) {
+    return new TestDeprecatedServiceFutureStub(channel);
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static abstract class TestDeprecatedServiceImplBase implements io.grpc.BindableService {
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public void deprecatedMethod(io.grpc.testing.compiler.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
+      asyncUnimplementedUnaryCall(getDeprecatedMethodMethod(), responseObserver);
+    }
+
+    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
+      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+          .addMethod(
+            getDeprecatedMethodMethod(),
+            asyncUnaryCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.SimpleRequest,
+                io.grpc.testing.compiler.Test.SimpleResponse>(
+                  this, METHODID_DEPRECATED_METHOD)))
+          .build();
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static final class TestDeprecatedServiceStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceStub> {
+    private TestDeprecatedServiceStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestDeprecatedServiceStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestDeprecatedServiceStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestDeprecatedServiceStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public void deprecatedMethod(io.grpc.testing.compiler.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
+      asyncUnaryCall(
+          getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request, responseObserver);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static final class TestDeprecatedServiceBlockingStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceBlockingStub> {
+    private TestDeprecatedServiceBlockingStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestDeprecatedServiceBlockingStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestDeprecatedServiceBlockingStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestDeprecatedServiceBlockingStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public io.grpc.testing.compiler.Test.SimpleResponse deprecatedMethod(io.grpc.testing.compiler.Test.SimpleRequest request) {
+      return blockingUnaryCall(
+          getChannel(), getDeprecatedMethodMethod(), getCallOptions(), request);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static final class TestDeprecatedServiceFutureStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceFutureStub> {
+    private TestDeprecatedServiceFutureStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestDeprecatedServiceFutureStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestDeprecatedServiceFutureStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestDeprecatedServiceFutureStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.compiler.Test.SimpleResponse> deprecatedMethod(
+        io.grpc.testing.compiler.Test.SimpleRequest request) {
+      return futureUnaryCall(
+          getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request);
+    }
+  }
+
+  private static final int METHODID_DEPRECATED_METHOD = 0;
+
+  private static final class MethodHandlers<Req, Resp> implements
+      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
+    private final TestDeprecatedServiceImplBase serviceImpl;
+    private final int methodId;
+
+    MethodHandlers(TestDeprecatedServiceImplBase serviceImpl, int methodId) {
+      this.serviceImpl = serviceImpl;
+      this.methodId = methodId;
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        case METHODID_DEPRECATED_METHOD:
+          serviceImpl.deprecatedMethod((io.grpc.testing.compiler.Test.SimpleRequest) request,
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse>) responseObserver);
+          break;
+        default:
+          throw new AssertionError();
+      }
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public io.grpc.stub.StreamObserver<Req> invoke(
+        io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        default:
+          throw new AssertionError();
+      }
+    }
+  }
+
+  private static abstract class TestDeprecatedServiceBaseDescriptorSupplier
+      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
+    TestDeprecatedServiceBaseDescriptorSupplier() {}
+
+    @java.lang.Override
+    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
+      return io.grpc.testing.compiler.Test.getDescriptor();
+    }
+
+    @java.lang.Override
+    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
+      return getFileDescriptor().findServiceByName("TestDeprecatedService");
+    }
+  }
+
+  private static final class TestDeprecatedServiceFileDescriptorSupplier
+      extends TestDeprecatedServiceBaseDescriptorSupplier {
+    TestDeprecatedServiceFileDescriptorSupplier() {}
+  }
+
+  private static final class TestDeprecatedServiceMethodDescriptorSupplier
+      extends TestDeprecatedServiceBaseDescriptorSupplier
+      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
+    private final String methodName;
+
+    TestDeprecatedServiceMethodDescriptorSupplier(String methodName) {
+      this.methodName = methodName;
+    }
+
+    @java.lang.Override
+    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
+      return getServiceDescriptor().findMethodByName(methodName);
+    }
+  }
+
+  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+    io.grpc.ServiceDescriptor result = serviceDescriptor;
+    if (result == null) {
+      synchronized (TestDeprecatedServiceGrpc.class) {
+        result = serviceDescriptor;
+        if (result == null) {
+          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+              .setSchemaDescriptor(new TestDeprecatedServiceFileDescriptorSupplier())
+              .addMethod(getDeprecatedMethodMethod())
+              .build();
+        }
+      }
+    }
+    return result;
+  }
+}
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/golden/TestService.java.txt b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/golden/TestService.java.txt
new file mode 100644
index 0000000..0507f3f
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/golden/TestService.java.txt
@@ -0,0 +1,665 @@
+package io.grpc.testing.compiler;
+
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+/**
+ * <pre>
+ * Test service that supports all call types.
+ * </pre>
+ */
+@javax.annotation.Generated(
+    value = "by gRPC proto compiler (version 1.19.0)",
+    comments = "Source: grpc/testing/compiler/test.proto")
+public final class TestServiceGrpc {
+
+  private TestServiceGrpc() {}
+
+  public static final String SERVICE_NAME = "grpc.testing.compiler.TestService";
+
+  // Static method descriptors that strictly reflect the proto.
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
+      io.grpc.testing.compiler.Test.SimpleResponse> getUnaryCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "UnaryCall",
+      requestType = io.grpc.testing.compiler.Test.SimpleRequest.class,
+      responseType = io.grpc.testing.compiler.Test.SimpleResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
+      io.grpc.testing.compiler.Test.SimpleResponse> getUnaryCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse> getUnaryCallMethod;
+    if ((getUnaryCallMethod = TestServiceGrpc.getUnaryCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getUnaryCallMethod = TestServiceGrpc.getUnaryCallMethod) == null) {
+          TestServiceGrpc.getUnaryCallMethod = getUnaryCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "UnaryCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.SimpleRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.SimpleResponse.getDefaultInstance()))
+                  .setSchemaDescriptor(new TestServiceMethodDescriptorSupplier("UnaryCall"))
+                  .build();
+          }
+        }
+     }
+     return getUnaryCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "StreamingOutputCall",
+      requestType = io.grpc.testing.compiler.Test.StreamingOutputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingOutputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod;
+    if ((getStreamingOutputCallMethod = TestServiceGrpc.getStreamingOutputCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getStreamingOutputCallMethod = TestServiceGrpc.getStreamingOutputCallMethod) == null) {
+          TestServiceGrpc.getStreamingOutputCallMethod = getStreamingOutputCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "StreamingOutputCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallResponse.getDefaultInstance()))
+                  .setSchemaDescriptor(new TestServiceMethodDescriptorSupplier("StreamingOutputCall"))
+                  .build();
+          }
+        }
+     }
+     return getStreamingOutputCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingInputCallResponse> getStreamingInputCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "StreamingInputCall",
+      requestType = io.grpc.testing.compiler.Test.StreamingInputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingInputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingInputCallResponse> getStreamingInputCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest, io.grpc.testing.compiler.Test.StreamingInputCallResponse> getStreamingInputCallMethod;
+    if ((getStreamingInputCallMethod = TestServiceGrpc.getStreamingInputCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getStreamingInputCallMethod = TestServiceGrpc.getStreamingInputCallMethod) == null) {
+          TestServiceGrpc.getStreamingInputCallMethod = getStreamingInputCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingInputCallRequest, io.grpc.testing.compiler.Test.StreamingInputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "StreamingInputCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingInputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingInputCallResponse.getDefaultInstance()))
+                  .setSchemaDescriptor(new TestServiceMethodDescriptorSupplier("StreamingInputCall"))
+                  .build();
+          }
+        }
+     }
+     return getStreamingInputCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getFullBidiCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "FullBidiCall",
+      requestType = io.grpc.testing.compiler.Test.StreamingOutputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingOutputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getFullBidiCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getFullBidiCallMethod;
+    if ((getFullBidiCallMethod = TestServiceGrpc.getFullBidiCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getFullBidiCallMethod = TestServiceGrpc.getFullBidiCallMethod) == null) {
+          TestServiceGrpc.getFullBidiCallMethod = getFullBidiCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "FullBidiCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallResponse.getDefaultInstance()))
+                  .setSchemaDescriptor(new TestServiceMethodDescriptorSupplier("FullBidiCall"))
+                  .build();
+          }
+        }
+     }
+     return getFullBidiCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getHalfBidiCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "HalfBidiCall",
+      requestType = io.grpc.testing.compiler.Test.StreamingOutputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingOutputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getHalfBidiCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getHalfBidiCallMethod;
+    if ((getHalfBidiCallMethod = TestServiceGrpc.getHalfBidiCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getHalfBidiCallMethod = TestServiceGrpc.getHalfBidiCallMethod) == null) {
+          TestServiceGrpc.getHalfBidiCallMethod = getHalfBidiCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "HalfBidiCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallResponse.getDefaultInstance()))
+                  .setSchemaDescriptor(new TestServiceMethodDescriptorSupplier("HalfBidiCall"))
+                  .build();
+          }
+        }
+     }
+     return getHalfBidiCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingInputCallResponse> getImportMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "Import",
+      requestType = io.grpc.testing.compiler.Test.StreamingInputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingInputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingInputCallResponse> getImportMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest, io.grpc.testing.compiler.Test.StreamingInputCallResponse> getImportMethod;
+    if ((getImportMethod = TestServiceGrpc.getImportMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getImportMethod = TestServiceGrpc.getImportMethod) == null) {
+          TestServiceGrpc.getImportMethod = getImportMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingInputCallRequest, io.grpc.testing.compiler.Test.StreamingInputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "Import"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingInputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingInputCallResponse.getDefaultInstance()))
+                  .setSchemaDescriptor(new TestServiceMethodDescriptorSupplier("Import"))
+                  .build();
+          }
+        }
+     }
+     return getImportMethod;
+  }
+
+  /**
+   * Creates a new async stub that supports all call types for the service
+   */
+  public static TestServiceStub newStub(io.grpc.Channel channel) {
+    return new TestServiceStub(channel);
+  }
+
+  /**
+   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+   */
+  public static TestServiceBlockingStub newBlockingStub(
+      io.grpc.Channel channel) {
+    return new TestServiceBlockingStub(channel);
+  }
+
+  /**
+   * Creates a new ListenableFuture-style stub that supports unary calls on the service
+   */
+  public static TestServiceFutureStub newFutureStub(
+      io.grpc.Channel channel) {
+    return new TestServiceFutureStub(channel);
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static abstract class TestServiceImplBase implements io.grpc.BindableService {
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public void unaryCall(io.grpc.testing.compiler.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
+      asyncUnimplementedUnaryCall(getUnaryCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * One request followed by a sequence of responses (streamed download).
+     * The server returns the payload with client desired type and sizes.
+     * </pre>
+     */
+    public void streamingOutputCall(io.grpc.testing.compiler.Test.StreamingOutputCallRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      asyncUnimplementedUnaryCall(getStreamingOutputCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by one response (streamed upload).
+     * The server returns the aggregated size of client payload as the result.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallRequest> streamingInputCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getStreamingInputCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests with each request served by the server immediately.
+     * As one request could lead to multiple responses, this interface
+     * demonstrates the idea of full bidirectionality.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallRequest> fullBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getFullBidiCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by a sequence of responses.
+     * The server buffers all the client requests and then serves them in order. A
+     * stream of responses are returned to the client when the server starts with
+     * first request.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallRequest> halfBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getHalfBidiCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * An RPC method whose Java name collides with a keyword, and whose generated
+     * method should have a '_' appended.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallRequest> import_(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getImportMethod(), responseObserver);
+    }
+
+    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
+      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+          .addMethod(
+            getUnaryCallMethod(),
+            asyncUnaryCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.SimpleRequest,
+                io.grpc.testing.compiler.Test.SimpleResponse>(
+                  this, METHODID_UNARY_CALL)))
+          .addMethod(
+            getStreamingOutputCallMethod(),
+            asyncServerStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingOutputCallResponse>(
+                  this, METHODID_STREAMING_OUTPUT_CALL)))
+          .addMethod(
+            getStreamingInputCallMethod(),
+            asyncClientStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingInputCallResponse>(
+                  this, METHODID_STREAMING_INPUT_CALL)))
+          .addMethod(
+            getFullBidiCallMethod(),
+            asyncBidiStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingOutputCallResponse>(
+                  this, METHODID_FULL_BIDI_CALL)))
+          .addMethod(
+            getHalfBidiCallMethod(),
+            asyncBidiStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingOutputCallResponse>(
+                  this, METHODID_HALF_BIDI_CALL)))
+          .addMethod(
+            getImportMethod(),
+            asyncBidiStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingInputCallResponse>(
+                  this, METHODID_IMPORT)))
+          .build();
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static final class TestServiceStub extends io.grpc.stub.AbstractStub<TestServiceStub> {
+    private TestServiceStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestServiceStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestServiceStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestServiceStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public void unaryCall(io.grpc.testing.compiler.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
+      asyncUnaryCall(
+          getChannel().newCall(getUnaryCallMethod(), getCallOptions()), request, responseObserver);
+    }
+
+    /**
+     * <pre>
+     * One request followed by a sequence of responses (streamed download).
+     * The server returns the payload with client desired type and sizes.
+     * </pre>
+     */
+    public void streamingOutputCall(io.grpc.testing.compiler.Test.StreamingOutputCallRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      asyncServerStreamingCall(
+          getChannel().newCall(getStreamingOutputCallMethod(), getCallOptions()), request, responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by one response (streamed upload).
+     * The server returns the aggregated size of client payload as the result.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallRequest> streamingInputCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncClientStreamingCall(
+          getChannel().newCall(getStreamingInputCallMethod(), getCallOptions()), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests with each request served by the server immediately.
+     * As one request could lead to multiple responses, this interface
+     * demonstrates the idea of full bidirectionality.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallRequest> fullBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncBidiStreamingCall(
+          getChannel().newCall(getFullBidiCallMethod(), getCallOptions()), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by a sequence of responses.
+     * The server buffers all the client requests and then serves them in order. A
+     * stream of responses are returned to the client when the server starts with
+     * first request.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallRequest> halfBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncBidiStreamingCall(
+          getChannel().newCall(getHalfBidiCallMethod(), getCallOptions()), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * An RPC method whose Java name collides with a keyword, and whose generated
+     * method should have a '_' appended.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallRequest> import_(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncBidiStreamingCall(
+          getChannel().newCall(getImportMethod(), getCallOptions()), responseObserver);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static final class TestServiceBlockingStub extends io.grpc.stub.AbstractStub<TestServiceBlockingStub> {
+    private TestServiceBlockingStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestServiceBlockingStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestServiceBlockingStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestServiceBlockingStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public io.grpc.testing.compiler.Test.SimpleResponse unaryCall(io.grpc.testing.compiler.Test.SimpleRequest request) {
+      return blockingUnaryCall(
+          getChannel(), getUnaryCallMethod(), getCallOptions(), request);
+    }
+
+    /**
+     * <pre>
+     * One request followed by a sequence of responses (streamed download).
+     * The server returns the payload with client desired type and sizes.
+     * </pre>
+     */
+    public java.util.Iterator<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> streamingOutputCall(
+        io.grpc.testing.compiler.Test.StreamingOutputCallRequest request) {
+      return blockingServerStreamingCall(
+          getChannel(), getStreamingOutputCallMethod(), getCallOptions(), request);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static final class TestServiceFutureStub extends io.grpc.stub.AbstractStub<TestServiceFutureStub> {
+    private TestServiceFutureStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestServiceFutureStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestServiceFutureStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestServiceFutureStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.compiler.Test.SimpleResponse> unaryCall(
+        io.grpc.testing.compiler.Test.SimpleRequest request) {
+      return futureUnaryCall(
+          getChannel().newCall(getUnaryCallMethod(), getCallOptions()), request);
+    }
+  }
+
+  private static final int METHODID_UNARY_CALL = 0;
+  private static final int METHODID_STREAMING_OUTPUT_CALL = 1;
+  private static final int METHODID_STREAMING_INPUT_CALL = 2;
+  private static final int METHODID_FULL_BIDI_CALL = 3;
+  private static final int METHODID_HALF_BIDI_CALL = 4;
+  private static final int METHODID_IMPORT = 5;
+
+  private static final class MethodHandlers<Req, Resp> implements
+      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
+    private final TestServiceImplBase serviceImpl;
+    private final int methodId;
+
+    MethodHandlers(TestServiceImplBase serviceImpl, int methodId) {
+      this.serviceImpl = serviceImpl;
+      this.methodId = methodId;
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        case METHODID_UNARY_CALL:
+          serviceImpl.unaryCall((io.grpc.testing.compiler.Test.SimpleRequest) request,
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse>) responseObserver);
+          break;
+        case METHODID_STREAMING_OUTPUT_CALL:
+          serviceImpl.streamingOutputCall((io.grpc.testing.compiler.Test.StreamingOutputCallRequest) request,
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse>) responseObserver);
+          break;
+        default:
+          throw new AssertionError();
+      }
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public io.grpc.stub.StreamObserver<Req> invoke(
+        io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        case METHODID_STREAMING_INPUT_CALL:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.streamingInputCall(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse>) responseObserver);
+        case METHODID_FULL_BIDI_CALL:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.fullBidiCall(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse>) responseObserver);
+        case METHODID_HALF_BIDI_CALL:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.halfBidiCall(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse>) responseObserver);
+        case METHODID_IMPORT:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.import_(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse>) responseObserver);
+        default:
+          throw new AssertionError();
+      }
+    }
+  }
+
+  private static abstract class TestServiceBaseDescriptorSupplier
+      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
+    TestServiceBaseDescriptorSupplier() {}
+
+    @java.lang.Override
+    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
+      return io.grpc.testing.compiler.Test.getDescriptor();
+    }
+
+    @java.lang.Override
+    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
+      return getFileDescriptor().findServiceByName("TestService");
+    }
+  }
+
+  private static final class TestServiceFileDescriptorSupplier
+      extends TestServiceBaseDescriptorSupplier {
+    TestServiceFileDescriptorSupplier() {}
+  }
+
+  private static final class TestServiceMethodDescriptorSupplier
+      extends TestServiceBaseDescriptorSupplier
+      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
+    private final String methodName;
+
+    TestServiceMethodDescriptorSupplier(String methodName) {
+      this.methodName = methodName;
+    }
+
+    @java.lang.Override
+    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
+      return getServiceDescriptor().findMethodByName(methodName);
+    }
+  }
+
+  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+    io.grpc.ServiceDescriptor result = serviceDescriptor;
+    if (result == null) {
+      synchronized (TestServiceGrpc.class) {
+        result = serviceDescriptor;
+        if (result == null) {
+          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+              .setSchemaDescriptor(new TestServiceFileDescriptorSupplier())
+              .addMethod(getUnaryCallMethod())
+              .addMethod(getStreamingOutputCallMethod())
+              .addMethod(getStreamingInputCallMethod())
+              .addMethod(getFullBidiCallMethod())
+              .addMethod(getHalfBidiCallMethod())
+              .addMethod(getImportMethod())
+              .build();
+        }
+      }
+    }
+    return result;
+  }
+}
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/proto/grpc/testing/compiler/test.proto b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/proto/grpc/testing/compiler/test.proto
new file mode 100644
index 0000000..62cf6c8
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/test/proto/grpc/testing/compiler/test.proto
@@ -0,0 +1,83 @@
+// Copyright 2015 The gRPC Authors
+// All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// A simple service definition for testing the protoc plugin.
+syntax = "proto3";
+
+package grpc.testing.compiler;
+
+option java_package = "io.grpc.testing.compiler";
+
+message SimpleRequest {
+}
+
+message SimpleResponse {
+}
+
+message StreamingInputCallRequest {
+}
+
+message StreamingInputCallResponse {
+}
+
+message StreamingOutputCallRequest {
+}
+
+message StreamingOutputCallResponse {
+}
+
+// Test service that supports all call types.
+service TestService {
+  // One request followed by one response.
+  // The server returns the client payload as-is.
+  rpc UnaryCall(SimpleRequest) returns (SimpleResponse);
+
+  // One request followed by a sequence of responses (streamed download).
+  // The server returns the payload with client desired type and sizes.
+  rpc StreamingOutputCall(StreamingOutputCallRequest)
+      returns (stream StreamingOutputCallResponse);
+
+  // A sequence of requests followed by one response (streamed upload).
+  // The server returns the aggregated size of client payload as the result.
+  rpc StreamingInputCall(stream StreamingInputCallRequest)
+      returns (StreamingInputCallResponse);
+
+  // A sequence of requests with each request served by the server immediately.
+  // As one request could lead to multiple responses, this interface
+  // demonstrates the idea of full bidirectionality.
+  rpc FullBidiCall(stream StreamingOutputCallRequest)
+      returns (stream StreamingOutputCallResponse);
+
+  // A sequence of requests followed by a sequence of responses.
+  // The server buffers all the client requests and then serves them in order. A
+  // stream of responses are returned to the client when the server starts with
+  // first request.
+  rpc HalfBidiCall(stream StreamingOutputCallRequest)
+      returns (stream StreamingOutputCallResponse);
+
+  // An RPC method whose Java name collides with a keyword, and whose generated
+  // method should have a '_' appended.
+  rpc Import(stream StreamingInputCallRequest) returns (stream StreamingInputCallResponse);
+}
+
+// Test service that has been deprecated and should generate with Java's @Deprecated annotation
+service TestDeprecatedService {
+  option deprecated = true;
+
+  // An RPC method that has been deprecated and should generate with Java's @Deprecated annotation
+  rpc DeprecatedMethod(SimpleRequest) returns (SimpleResponse) {
+    option deprecated = true;
+  }
+}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testLite/golden/TestDeprecatedService.java.txt b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testLite/golden/TestDeprecatedService.java.txt
new file mode 100644
index 0000000..a2faeb1
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testLite/golden/TestDeprecatedService.java.txt
@@ -0,0 +1,279 @@
+package io.grpc.testing.compiler;
+
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+/**
+ * <pre>
+ * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+ * </pre>
+ */
+@javax.annotation.Generated(
+    value = "by gRPC proto compiler (version 1.19.0)",
+    comments = "Source: grpc/testing/compiler/test.proto")
+@java.lang.Deprecated
+public final class TestDeprecatedServiceGrpc {
+
+  private TestDeprecatedServiceGrpc() {}
+
+  public static final String SERVICE_NAME = "grpc.testing.compiler.TestDeprecatedService";
+
+  // Static method descriptors that strictly reflect the proto.
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
+      io.grpc.testing.compiler.Test.SimpleResponse> getDeprecatedMethodMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "DeprecatedMethod",
+      requestType = io.grpc.testing.compiler.Test.SimpleRequest.class,
+      responseType = io.grpc.testing.compiler.Test.SimpleResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
+      io.grpc.testing.compiler.Test.SimpleResponse> getDeprecatedMethodMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse> getDeprecatedMethodMethod;
+    if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
+      synchronized (TestDeprecatedServiceGrpc.class) {
+        if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
+          TestDeprecatedServiceGrpc.getDeprecatedMethodMethod = getDeprecatedMethodMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestDeprecatedService", "DeprecatedMethod"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.SimpleRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.SimpleResponse.getDefaultInstance()))
+                  .build();
+          }
+        }
+     }
+     return getDeprecatedMethodMethod;
+  }
+
+  /**
+   * Creates a new async stub that supports all call types for the service
+   */
+  public static TestDeprecatedServiceStub newStub(io.grpc.Channel channel) {
+    return new TestDeprecatedServiceStub(channel);
+  }
+
+  /**
+   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+   */
+  public static TestDeprecatedServiceBlockingStub newBlockingStub(
+      io.grpc.Channel channel) {
+    return new TestDeprecatedServiceBlockingStub(channel);
+  }
+
+  /**
+   * Creates a new ListenableFuture-style stub that supports unary calls on the service
+   */
+  public static TestDeprecatedServiceFutureStub newFutureStub(
+      io.grpc.Channel channel) {
+    return new TestDeprecatedServiceFutureStub(channel);
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static abstract class TestDeprecatedServiceImplBase implements io.grpc.BindableService {
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public void deprecatedMethod(io.grpc.testing.compiler.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
+      asyncUnimplementedUnaryCall(getDeprecatedMethodMethod(), responseObserver);
+    }
+
+    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
+      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+          .addMethod(
+            getDeprecatedMethodMethod(),
+            asyncUnaryCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.SimpleRequest,
+                io.grpc.testing.compiler.Test.SimpleResponse>(
+                  this, METHODID_DEPRECATED_METHOD)))
+          .build();
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static final class TestDeprecatedServiceStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceStub> {
+    private TestDeprecatedServiceStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestDeprecatedServiceStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestDeprecatedServiceStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestDeprecatedServiceStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public void deprecatedMethod(io.grpc.testing.compiler.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
+      asyncUnaryCall(
+          getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request, responseObserver);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static final class TestDeprecatedServiceBlockingStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceBlockingStub> {
+    private TestDeprecatedServiceBlockingStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestDeprecatedServiceBlockingStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestDeprecatedServiceBlockingStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestDeprecatedServiceBlockingStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public io.grpc.testing.compiler.Test.SimpleResponse deprecatedMethod(io.grpc.testing.compiler.Test.SimpleRequest request) {
+      return blockingUnaryCall(
+          getChannel(), getDeprecatedMethodMethod(), getCallOptions(), request);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static final class TestDeprecatedServiceFutureStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceFutureStub> {
+    private TestDeprecatedServiceFutureStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestDeprecatedServiceFutureStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestDeprecatedServiceFutureStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestDeprecatedServiceFutureStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.compiler.Test.SimpleResponse> deprecatedMethod(
+        io.grpc.testing.compiler.Test.SimpleRequest request) {
+      return futureUnaryCall(
+          getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request);
+    }
+  }
+
+  private static final int METHODID_DEPRECATED_METHOD = 0;
+
+  private static final class MethodHandlers<Req, Resp> implements
+      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
+    private final TestDeprecatedServiceImplBase serviceImpl;
+    private final int methodId;
+
+    MethodHandlers(TestDeprecatedServiceImplBase serviceImpl, int methodId) {
+      this.serviceImpl = serviceImpl;
+      this.methodId = methodId;
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        case METHODID_DEPRECATED_METHOD:
+          serviceImpl.deprecatedMethod((io.grpc.testing.compiler.Test.SimpleRequest) request,
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse>) responseObserver);
+          break;
+        default:
+          throw new AssertionError();
+      }
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public io.grpc.stub.StreamObserver<Req> invoke(
+        io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        default:
+          throw new AssertionError();
+      }
+    }
+  }
+
+  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+    io.grpc.ServiceDescriptor result = serviceDescriptor;
+    if (result == null) {
+      synchronized (TestDeprecatedServiceGrpc.class) {
+        result = serviceDescriptor;
+        if (result == null) {
+          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+              .addMethod(getDeprecatedMethodMethod())
+              .build();
+        }
+      }
+    }
+    return result;
+  }
+}
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testLite/golden/TestService.java.txt b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testLite/golden/TestService.java.txt
new file mode 100644
index 0000000..6697006
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testLite/golden/TestService.java.txt
@@ -0,0 +1,623 @@
+package io.grpc.testing.compiler;
+
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+/**
+ * <pre>
+ * Test service that supports all call types.
+ * </pre>
+ */
+@javax.annotation.Generated(
+    value = "by gRPC proto compiler (version 1.19.0)",
+    comments = "Source: grpc/testing/compiler/test.proto")
+public final class TestServiceGrpc {
+
+  private TestServiceGrpc() {}
+
+  public static final String SERVICE_NAME = "grpc.testing.compiler.TestService";
+
+  // Static method descriptors that strictly reflect the proto.
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
+      io.grpc.testing.compiler.Test.SimpleResponse> getUnaryCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "UnaryCall",
+      requestType = io.grpc.testing.compiler.Test.SimpleRequest.class,
+      responseType = io.grpc.testing.compiler.Test.SimpleResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
+      io.grpc.testing.compiler.Test.SimpleResponse> getUnaryCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse> getUnaryCallMethod;
+    if ((getUnaryCallMethod = TestServiceGrpc.getUnaryCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getUnaryCallMethod = TestServiceGrpc.getUnaryCallMethod) == null) {
+          TestServiceGrpc.getUnaryCallMethod = getUnaryCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "UnaryCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.SimpleRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.SimpleResponse.getDefaultInstance()))
+                  .build();
+          }
+        }
+     }
+     return getUnaryCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "StreamingOutputCall",
+      requestType = io.grpc.testing.compiler.Test.StreamingOutputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingOutputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod;
+    if ((getStreamingOutputCallMethod = TestServiceGrpc.getStreamingOutputCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getStreamingOutputCallMethod = TestServiceGrpc.getStreamingOutputCallMethod) == null) {
+          TestServiceGrpc.getStreamingOutputCallMethod = getStreamingOutputCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "StreamingOutputCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallResponse.getDefaultInstance()))
+                  .build();
+          }
+        }
+     }
+     return getStreamingOutputCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingInputCallResponse> getStreamingInputCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "StreamingInputCall",
+      requestType = io.grpc.testing.compiler.Test.StreamingInputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingInputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingInputCallResponse> getStreamingInputCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest, io.grpc.testing.compiler.Test.StreamingInputCallResponse> getStreamingInputCallMethod;
+    if ((getStreamingInputCallMethod = TestServiceGrpc.getStreamingInputCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getStreamingInputCallMethod = TestServiceGrpc.getStreamingInputCallMethod) == null) {
+          TestServiceGrpc.getStreamingInputCallMethod = getStreamingInputCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingInputCallRequest, io.grpc.testing.compiler.Test.StreamingInputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "StreamingInputCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingInputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingInputCallResponse.getDefaultInstance()))
+                  .build();
+          }
+        }
+     }
+     return getStreamingInputCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getFullBidiCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "FullBidiCall",
+      requestType = io.grpc.testing.compiler.Test.StreamingOutputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingOutputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getFullBidiCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getFullBidiCallMethod;
+    if ((getFullBidiCallMethod = TestServiceGrpc.getFullBidiCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getFullBidiCallMethod = TestServiceGrpc.getFullBidiCallMethod) == null) {
+          TestServiceGrpc.getFullBidiCallMethod = getFullBidiCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "FullBidiCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallResponse.getDefaultInstance()))
+                  .build();
+          }
+        }
+     }
+     return getFullBidiCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getHalfBidiCallMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "HalfBidiCall",
+      requestType = io.grpc.testing.compiler.Test.StreamingOutputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingOutputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getHalfBidiCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse> getHalfBidiCallMethod;
+    if ((getHalfBidiCallMethod = TestServiceGrpc.getHalfBidiCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getHalfBidiCallMethod = TestServiceGrpc.getHalfBidiCallMethod) == null) {
+          TestServiceGrpc.getHalfBidiCallMethod = getHalfBidiCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.Test.StreamingOutputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "HalfBidiCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingOutputCallResponse.getDefaultInstance()))
+                  .build();
+          }
+        }
+     }
+     return getHalfBidiCallMethod;
+  }
+
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingInputCallResponse> getImportMethod;
+
+  @io.grpc.stub.annotations.RpcMethod(
+      fullMethodName = SERVICE_NAME + '/' + "Import",
+      requestType = io.grpc.testing.compiler.Test.StreamingInputCallRequest.class,
+      responseType = io.grpc.testing.compiler.Test.StreamingInputCallResponse.class,
+      methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.Test.StreamingInputCallResponse> getImportMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.StreamingInputCallRequest, io.grpc.testing.compiler.Test.StreamingInputCallResponse> getImportMethod;
+    if ((getImportMethod = TestServiceGrpc.getImportMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getImportMethod = TestServiceGrpc.getImportMethod) == null) {
+          TestServiceGrpc.getImportMethod = getImportMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.StreamingInputCallRequest, io.grpc.testing.compiler.Test.StreamingInputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "Import"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingInputCallRequest.getDefaultInstance()))
+              .setResponseMarshaller(io.grpc.protobuf.lite.ProtoLiteUtils.marshaller(
+                  io.grpc.testing.compiler.Test.StreamingInputCallResponse.getDefaultInstance()))
+                  .build();
+          }
+        }
+     }
+     return getImportMethod;
+  }
+
+  /**
+   * Creates a new async stub that supports all call types for the service
+   */
+  public static TestServiceStub newStub(io.grpc.Channel channel) {
+    return new TestServiceStub(channel);
+  }
+
+  /**
+   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+   */
+  public static TestServiceBlockingStub newBlockingStub(
+      io.grpc.Channel channel) {
+    return new TestServiceBlockingStub(channel);
+  }
+
+  /**
+   * Creates a new ListenableFuture-style stub that supports unary calls on the service
+   */
+  public static TestServiceFutureStub newFutureStub(
+      io.grpc.Channel channel) {
+    return new TestServiceFutureStub(channel);
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static abstract class TestServiceImplBase implements io.grpc.BindableService {
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public void unaryCall(io.grpc.testing.compiler.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
+      asyncUnimplementedUnaryCall(getUnaryCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * One request followed by a sequence of responses (streamed download).
+     * The server returns the payload with client desired type and sizes.
+     * </pre>
+     */
+    public void streamingOutputCall(io.grpc.testing.compiler.Test.StreamingOutputCallRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      asyncUnimplementedUnaryCall(getStreamingOutputCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by one response (streamed upload).
+     * The server returns the aggregated size of client payload as the result.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallRequest> streamingInputCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getStreamingInputCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests with each request served by the server immediately.
+     * As one request could lead to multiple responses, this interface
+     * demonstrates the idea of full bidirectionality.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallRequest> fullBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getFullBidiCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by a sequence of responses.
+     * The server buffers all the client requests and then serves them in order. A
+     * stream of responses are returned to the client when the server starts with
+     * first request.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallRequest> halfBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getHalfBidiCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * An RPC method whose Java name collides with a keyword, and whose generated
+     * method should have a '_' appended.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallRequest> import_(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getImportMethod(), responseObserver);
+    }
+
+    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
+      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+          .addMethod(
+            getUnaryCallMethod(),
+            asyncUnaryCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.SimpleRequest,
+                io.grpc.testing.compiler.Test.SimpleResponse>(
+                  this, METHODID_UNARY_CALL)))
+          .addMethod(
+            getStreamingOutputCallMethod(),
+            asyncServerStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingOutputCallResponse>(
+                  this, METHODID_STREAMING_OUTPUT_CALL)))
+          .addMethod(
+            getStreamingInputCallMethod(),
+            asyncClientStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingInputCallResponse>(
+                  this, METHODID_STREAMING_INPUT_CALL)))
+          .addMethod(
+            getFullBidiCallMethod(),
+            asyncBidiStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingOutputCallResponse>(
+                  this, METHODID_FULL_BIDI_CALL)))
+          .addMethod(
+            getHalfBidiCallMethod(),
+            asyncBidiStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingOutputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingOutputCallResponse>(
+                  this, METHODID_HALF_BIDI_CALL)))
+          .addMethod(
+            getImportMethod(),
+            asyncBidiStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.Test.StreamingInputCallRequest,
+                io.grpc.testing.compiler.Test.StreamingInputCallResponse>(
+                  this, METHODID_IMPORT)))
+          .build();
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static final class TestServiceStub extends io.grpc.stub.AbstractStub<TestServiceStub> {
+    private TestServiceStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestServiceStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestServiceStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestServiceStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public void unaryCall(io.grpc.testing.compiler.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
+      asyncUnaryCall(
+          getChannel().newCall(getUnaryCallMethod(), getCallOptions()), request, responseObserver);
+    }
+
+    /**
+     * <pre>
+     * One request followed by a sequence of responses (streamed download).
+     * The server returns the payload with client desired type and sizes.
+     * </pre>
+     */
+    public void streamingOutputCall(io.grpc.testing.compiler.Test.StreamingOutputCallRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      asyncServerStreamingCall(
+          getChannel().newCall(getStreamingOutputCallMethod(), getCallOptions()), request, responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by one response (streamed upload).
+     * The server returns the aggregated size of client payload as the result.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallRequest> streamingInputCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncClientStreamingCall(
+          getChannel().newCall(getStreamingInputCallMethod(), getCallOptions()), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests with each request served by the server immediately.
+     * As one request could lead to multiple responses, this interface
+     * demonstrates the idea of full bidirectionality.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallRequest> fullBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncBidiStreamingCall(
+          getChannel().newCall(getFullBidiCallMethod(), getCallOptions()), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by a sequence of responses.
+     * The server buffers all the client requests and then serves them in order. A
+     * stream of responses are returned to the client when the server starts with
+     * first request.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallRequest> halfBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncBidiStreamingCall(
+          getChannel().newCall(getHalfBidiCallMethod(), getCallOptions()), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * An RPC method whose Java name collides with a keyword, and whose generated
+     * method should have a '_' appended.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallRequest> import_(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncBidiStreamingCall(
+          getChannel().newCall(getImportMethod(), getCallOptions()), responseObserver);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static final class TestServiceBlockingStub extends io.grpc.stub.AbstractStub<TestServiceBlockingStub> {
+    private TestServiceBlockingStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestServiceBlockingStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestServiceBlockingStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestServiceBlockingStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public io.grpc.testing.compiler.Test.SimpleResponse unaryCall(io.grpc.testing.compiler.Test.SimpleRequest request) {
+      return blockingUnaryCall(
+          getChannel(), getUnaryCallMethod(), getCallOptions(), request);
+    }
+
+    /**
+     * <pre>
+     * One request followed by a sequence of responses (streamed download).
+     * The server returns the payload with client desired type and sizes.
+     * </pre>
+     */
+    public java.util.Iterator<io.grpc.testing.compiler.Test.StreamingOutputCallResponse> streamingOutputCall(
+        io.grpc.testing.compiler.Test.StreamingOutputCallRequest request) {
+      return blockingServerStreamingCall(
+          getChannel(), getStreamingOutputCallMethod(), getCallOptions(), request);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static final class TestServiceFutureStub extends io.grpc.stub.AbstractStub<TestServiceFutureStub> {
+    private TestServiceFutureStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestServiceFutureStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestServiceFutureStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestServiceFutureStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.compiler.Test.SimpleResponse> unaryCall(
+        io.grpc.testing.compiler.Test.SimpleRequest request) {
+      return futureUnaryCall(
+          getChannel().newCall(getUnaryCallMethod(), getCallOptions()), request);
+    }
+  }
+
+  private static final int METHODID_UNARY_CALL = 0;
+  private static final int METHODID_STREAMING_OUTPUT_CALL = 1;
+  private static final int METHODID_STREAMING_INPUT_CALL = 2;
+  private static final int METHODID_FULL_BIDI_CALL = 3;
+  private static final int METHODID_HALF_BIDI_CALL = 4;
+  private static final int METHODID_IMPORT = 5;
+
+  private static final class MethodHandlers<Req, Resp> implements
+      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
+    private final TestServiceImplBase serviceImpl;
+    private final int methodId;
+
+    MethodHandlers(TestServiceImplBase serviceImpl, int methodId) {
+      this.serviceImpl = serviceImpl;
+      this.methodId = methodId;
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        case METHODID_UNARY_CALL:
+          serviceImpl.unaryCall((io.grpc.testing.compiler.Test.SimpleRequest) request,
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse>) responseObserver);
+          break;
+        case METHODID_STREAMING_OUTPUT_CALL:
+          serviceImpl.streamingOutputCall((io.grpc.testing.compiler.Test.StreamingOutputCallRequest) request,
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse>) responseObserver);
+          break;
+        default:
+          throw new AssertionError();
+      }
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public io.grpc.stub.StreamObserver<Req> invoke(
+        io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        case METHODID_STREAMING_INPUT_CALL:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.streamingInputCall(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse>) responseObserver);
+        case METHODID_FULL_BIDI_CALL:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.fullBidiCall(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse>) responseObserver);
+        case METHODID_HALF_BIDI_CALL:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.halfBidiCall(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingOutputCallResponse>) responseObserver);
+        case METHODID_IMPORT:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.import_(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.StreamingInputCallResponse>) responseObserver);
+        default:
+          throw new AssertionError();
+      }
+    }
+  }
+
+  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+    io.grpc.ServiceDescriptor result = serviceDescriptor;
+    if (result == null) {
+      synchronized (TestServiceGrpc.class) {
+        result = serviceDescriptor;
+        if (result == null) {
+          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+              .addMethod(getUnaryCallMethod())
+              .addMethod(getStreamingOutputCallMethod())
+              .addMethod(getStreamingInputCallMethod())
+              .addMethod(getFullBidiCallMethod())
+              .addMethod(getHalfBidiCallMethod())
+              .addMethod(getImportMethod())
+              .build();
+        }
+      }
+    }
+    return result;
+  }
+}
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testNano/golden/TestDeprecatedService.java.txt b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testNano/golden/TestDeprecatedService.java.txt
new file mode 100644
index 0000000..3c1c89e
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testNano/golden/TestDeprecatedService.java.txt
@@ -0,0 +1,305 @@
+package io.grpc.testing.compiler.nano;
+
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+import java.io.IOException;
+
+/**
+ * <pre>
+ * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+ * </pre>
+ */
+@javax.annotation.Generated(
+    value = "by gRPC proto compiler (version 1.19.0)",
+    comments = "Source: grpc/testing/compiler/test.proto")
+@java.lang.Deprecated
+public final class TestDeprecatedServiceGrpc {
+
+  private TestDeprecatedServiceGrpc() {}
+
+  public static final String SERVICE_NAME = "grpc.testing.compiler.TestDeprecatedService";
+
+  // Static method descriptors that strictly reflect the proto.
+  private static final int ARG_IN_METHOD_DEPRECATED_METHOD = 0;
+  private static final int ARG_OUT_METHOD_DEPRECATED_METHOD = 1;
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest,
+      io.grpc.testing.compiler.nano.Test.SimpleResponse> getDeprecatedMethodMethod;
+
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest,
+      io.grpc.testing.compiler.nano.Test.SimpleResponse> getDeprecatedMethodMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest, io.grpc.testing.compiler.nano.Test.SimpleResponse> getDeprecatedMethodMethod;
+    if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
+      synchronized (TestDeprecatedServiceGrpc.class) {
+        if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
+          TestDeprecatedServiceGrpc.getDeprecatedMethodMethod = getDeprecatedMethodMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.SimpleRequest, io.grpc.testing.compiler.nano.Test.SimpleResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestDeprecatedService", "DeprecatedMethod"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.SimpleRequest>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.SimpleRequest>(ARG_IN_METHOD_DEPRECATED_METHOD)))
+              .setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.SimpleResponse>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.SimpleResponse>(ARG_OUT_METHOD_DEPRECATED_METHOD)))
+              .build();
+        }
+      }
+    }
+    return getDeprecatedMethodMethod;
+  }
+
+  private static final class NanoFactory<T extends com.google.protobuf.nano.MessageNano>
+      implements io.grpc.protobuf.nano.MessageNanoFactory<T> {
+    private final int id;
+
+    NanoFactory(int id) {
+      this.id = id;
+    }
+
+    @java.lang.Override
+    public T newInstance() {
+      Object o;
+      switch (id) {
+      case ARG_IN_METHOD_DEPRECATED_METHOD:
+        o = new io.grpc.testing.compiler.nano.Test.SimpleRequest();
+        break;
+      case ARG_OUT_METHOD_DEPRECATED_METHOD:
+        o = new io.grpc.testing.compiler.nano.Test.SimpleResponse();
+        break;
+      default:
+        throw new AssertionError();
+      }
+      @java.lang.SuppressWarnings("unchecked")
+      T t = (T) o;
+      return t;
+    }
+  }
+
+  /**
+   * Creates a new async stub that supports all call types for the service
+   */
+  public static TestDeprecatedServiceStub newStub(io.grpc.Channel channel) {
+    return new TestDeprecatedServiceStub(channel);
+  }
+
+  /**
+   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+   */
+  public static TestDeprecatedServiceBlockingStub newBlockingStub(
+      io.grpc.Channel channel) {
+    return new TestDeprecatedServiceBlockingStub(channel);
+  }
+
+  /**
+   * Creates a new ListenableFuture-style stub that supports unary calls on the service
+   */
+  public static TestDeprecatedServiceFutureStub newFutureStub(
+      io.grpc.Channel channel) {
+    return new TestDeprecatedServiceFutureStub(channel);
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static abstract class TestDeprecatedServiceImplBase implements io.grpc.BindableService {
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public void deprecatedMethod(io.grpc.testing.compiler.nano.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse> responseObserver) {
+      asyncUnimplementedUnaryCall(getDeprecatedMethodMethod(), responseObserver);
+    }
+
+    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
+      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+          .addMethod(
+            getDeprecatedMethodMethod(),
+            asyncUnaryCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.nano.Test.SimpleRequest,
+                io.grpc.testing.compiler.nano.Test.SimpleResponse>(
+                  this, METHODID_DEPRECATED_METHOD)))
+          .build();
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static final class TestDeprecatedServiceStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceStub> {
+    private TestDeprecatedServiceStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestDeprecatedServiceStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestDeprecatedServiceStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestDeprecatedServiceStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public void deprecatedMethod(io.grpc.testing.compiler.nano.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse> responseObserver) {
+      asyncUnaryCall(
+          getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request, responseObserver);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static final class TestDeprecatedServiceBlockingStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceBlockingStub> {
+    private TestDeprecatedServiceBlockingStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestDeprecatedServiceBlockingStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestDeprecatedServiceBlockingStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestDeprecatedServiceBlockingStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public io.grpc.testing.compiler.nano.Test.SimpleResponse deprecatedMethod(io.grpc.testing.compiler.nano.Test.SimpleRequest request) {
+      return blockingUnaryCall(
+          getChannel(), getDeprecatedMethodMethod(), getCallOptions(), request);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
+   * </pre>
+   */
+  @java.lang.Deprecated
+  public static final class TestDeprecatedServiceFutureStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceFutureStub> {
+    private TestDeprecatedServiceFutureStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestDeprecatedServiceFutureStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestDeprecatedServiceFutureStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestDeprecatedServiceFutureStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
+     * </pre>
+     */
+    @java.lang.Deprecated
+    public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.compiler.nano.Test.SimpleResponse> deprecatedMethod(
+        io.grpc.testing.compiler.nano.Test.SimpleRequest request) {
+      return futureUnaryCall(
+          getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request);
+    }
+  }
+
+  private static final int METHODID_DEPRECATED_METHOD = 0;
+
+  private static final class MethodHandlers<Req, Resp> implements
+      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
+    private final TestDeprecatedServiceImplBase serviceImpl;
+    private final int methodId;
+
+    MethodHandlers(TestDeprecatedServiceImplBase serviceImpl, int methodId) {
+      this.serviceImpl = serviceImpl;
+      this.methodId = methodId;
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        case METHODID_DEPRECATED_METHOD:
+          serviceImpl.deprecatedMethod((io.grpc.testing.compiler.nano.Test.SimpleRequest) request,
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse>) responseObserver);
+          break;
+        default:
+          throw new AssertionError();
+      }
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public io.grpc.stub.StreamObserver<Req> invoke(
+        io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        default:
+          throw new AssertionError();
+      }
+    }
+  }
+
+  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+    io.grpc.ServiceDescriptor result = serviceDescriptor;
+    if (result == null) {
+      synchronized (TestDeprecatedServiceGrpc.class) {
+        result = serviceDescriptor;
+        if (result == null) {
+          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+              .addMethod(getDeprecatedMethodMethod())
+              .build();
+        }
+      }
+    }
+    return result;
+  }
+}
diff --git a/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testNano/golden/TestService.java.txt b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testNano/golden/TestService.java.txt
new file mode 100644
index 0000000..948b58b
--- /dev/null
+++ b/dubbo-rpc/dubbo-rpc-grpc/compiler/src/testNano/golden/TestService.java.txt
@@ -0,0 +1,664 @@
+package io.grpc.testing.compiler.nano;
+
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+import java.io.IOException;
+
+/**
+ * <pre>
+ * Test service that supports all call types.
+ * </pre>
+ */
+@javax.annotation.Generated(
+    value = "by gRPC proto compiler (version 1.19.0)",
+    comments = "Source: grpc/testing/compiler/test.proto")
+public final class TestServiceGrpc {
+
+  private TestServiceGrpc() {}
+
+  public static final String SERVICE_NAME = "grpc.testing.compiler.TestService";
+
+  // Static method descriptors that strictly reflect the proto.
+  private static final int ARG_IN_METHOD_UNARY_CALL = 0;
+  private static final int ARG_OUT_METHOD_UNARY_CALL = 1;
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest,
+      io.grpc.testing.compiler.nano.Test.SimpleResponse> getUnaryCallMethod;
+
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest,
+      io.grpc.testing.compiler.nano.Test.SimpleResponse> getUnaryCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest, io.grpc.testing.compiler.nano.Test.SimpleResponse> getUnaryCallMethod;
+    if ((getUnaryCallMethod = TestServiceGrpc.getUnaryCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getUnaryCallMethod = TestServiceGrpc.getUnaryCallMethod) == null) {
+          TestServiceGrpc.getUnaryCallMethod = getUnaryCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.SimpleRequest, io.grpc.testing.compiler.nano.Test.SimpleResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "UnaryCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.SimpleRequest>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.SimpleRequest>(ARG_IN_METHOD_UNARY_CALL)))
+              .setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.SimpleResponse>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.SimpleResponse>(ARG_OUT_METHOD_UNARY_CALL)))
+              .build();
+        }
+      }
+    }
+    return getUnaryCallMethod;
+  }
+
+  private static final int ARG_IN_METHOD_STREAMING_OUTPUT_CALL = 2;
+  private static final int ARG_OUT_METHOD_STREAMING_OUTPUT_CALL = 3;
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod;
+
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod;
+    if ((getStreamingOutputCallMethod = TestServiceGrpc.getStreamingOutputCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getStreamingOutputCallMethod = TestServiceGrpc.getStreamingOutputCallMethod) == null) {
+          TestServiceGrpc.getStreamingOutputCallMethod = getStreamingOutputCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "StreamingOutputCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>(ARG_IN_METHOD_STREAMING_OUTPUT_CALL)))
+              .setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(ARG_OUT_METHOD_STREAMING_OUTPUT_CALL)))
+              .build();
+        }
+      }
+    }
+    return getStreamingOutputCallMethod;
+  }
+
+  private static final int ARG_IN_METHOD_STREAMING_INPUT_CALL = 4;
+  private static final int ARG_OUT_METHOD_STREAMING_INPUT_CALL = 5;
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getStreamingInputCallMethod;
+
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getStreamingInputCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getStreamingInputCallMethod;
+    if ((getStreamingInputCallMethod = TestServiceGrpc.getStreamingInputCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getStreamingInputCallMethod = TestServiceGrpc.getStreamingInputCallMethod) == null) {
+          TestServiceGrpc.getStreamingInputCallMethod = getStreamingInputCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "StreamingInputCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest>(ARG_IN_METHOD_STREAMING_INPUT_CALL)))
+              .setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>(ARG_OUT_METHOD_STREAMING_INPUT_CALL)))
+              .build();
+        }
+      }
+    }
+    return getStreamingInputCallMethod;
+  }
+
+  private static final int ARG_IN_METHOD_FULL_BIDI_CALL = 6;
+  private static final int ARG_OUT_METHOD_FULL_BIDI_CALL = 7;
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getFullBidiCallMethod;
+
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getFullBidiCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getFullBidiCallMethod;
+    if ((getFullBidiCallMethod = TestServiceGrpc.getFullBidiCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getFullBidiCallMethod = TestServiceGrpc.getFullBidiCallMethod) == null) {
+          TestServiceGrpc.getFullBidiCallMethod = getFullBidiCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "FullBidiCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>(ARG_IN_METHOD_FULL_BIDI_CALL)))
+              .setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(ARG_OUT_METHOD_FULL_BIDI_CALL)))
+              .build();
+        }
+      }
+    }
+    return getFullBidiCallMethod;
+  }
+
+  private static final int ARG_IN_METHOD_HALF_BIDI_CALL = 8;
+  private static final int ARG_OUT_METHOD_HALF_BIDI_CALL = 9;
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getHalfBidiCallMethod;
+
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getHalfBidiCallMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getHalfBidiCallMethod;
+    if ((getHalfBidiCallMethod = TestServiceGrpc.getHalfBidiCallMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getHalfBidiCallMethod = TestServiceGrpc.getHalfBidiCallMethod) == null) {
+          TestServiceGrpc.getHalfBidiCallMethod = getHalfBidiCallMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "HalfBidiCall"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>(ARG_IN_METHOD_HALF_BIDI_CALL)))
+              .setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(ARG_OUT_METHOD_HALF_BIDI_CALL)))
+              .build();
+        }
+      }
+    }
+    return getHalfBidiCallMethod;
+  }
+
+  private static final int ARG_IN_METHOD_IMPORT = 10;
+  private static final int ARG_OUT_METHOD_IMPORT = 11;
+  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getImportMethod;
+
+  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
+      io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getImportMethod() {
+    io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getImportMethod;
+    if ((getImportMethod = TestServiceGrpc.getImportMethod) == null) {
+      synchronized (TestServiceGrpc.class) {
+        if ((getImportMethod = TestServiceGrpc.getImportMethod) == null) {
+          TestServiceGrpc.getImportMethod = getImportMethod = 
+              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>newBuilder()
+              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+              .setFullMethodName(generateFullMethodName(
+                  "grpc.testing.compiler.TestService", "Import"))
+              .setSampledToLocalTracing(true)
+              .setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest>(ARG_IN_METHOD_IMPORT)))
+              .setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>marshaller(
+                  new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>(ARG_OUT_METHOD_IMPORT)))
+              .build();
+        }
+      }
+    }
+    return getImportMethod;
+  }
+
+  private static final class NanoFactory<T extends com.google.protobuf.nano.MessageNano>
+      implements io.grpc.protobuf.nano.MessageNanoFactory<T> {
+    private final int id;
+
+    NanoFactory(int id) {
+      this.id = id;
+    }
+
+    @java.lang.Override
+    public T newInstance() {
+      Object o;
+      switch (id) {
+      case ARG_IN_METHOD_UNARY_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.SimpleRequest();
+        break;
+      case ARG_OUT_METHOD_UNARY_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.SimpleResponse();
+        break;
+      case ARG_IN_METHOD_STREAMING_OUTPUT_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest();
+        break;
+      case ARG_OUT_METHOD_STREAMING_OUTPUT_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse();
+        break;
+      case ARG_IN_METHOD_STREAMING_INPUT_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest();
+        break;
+      case ARG_OUT_METHOD_STREAMING_INPUT_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse();
+        break;
+      case ARG_IN_METHOD_FULL_BIDI_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest();
+        break;
+      case ARG_OUT_METHOD_FULL_BIDI_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse();
+        break;
+      case ARG_IN_METHOD_HALF_BIDI_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest();
+        break;
+      case ARG_OUT_METHOD_HALF_BIDI_CALL:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse();
+        break;
+      case ARG_IN_METHOD_IMPORT:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest();
+        break;
+      case ARG_OUT_METHOD_IMPORT:
+        o = new io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse();
+        break;
+      default:
+        throw new AssertionError();
+      }
+      @java.lang.SuppressWarnings("unchecked")
+      T t = (T) o;
+      return t;
+    }
+  }
+
+  /**
+   * Creates a new async stub that supports all call types for the service
+   */
+  public static TestServiceStub newStub(io.grpc.Channel channel) {
+    return new TestServiceStub(channel);
+  }
+
+  /**
+   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+   */
+  public static TestServiceBlockingStub newBlockingStub(
+      io.grpc.Channel channel) {
+    return new TestServiceBlockingStub(channel);
+  }
+
+  /**
+   * Creates a new ListenableFuture-style stub that supports unary calls on the service
+   */
+  public static TestServiceFutureStub newFutureStub(
+      io.grpc.Channel channel) {
+    return new TestServiceFutureStub(channel);
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static abstract class TestServiceImplBase implements io.grpc.BindableService {
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public void unaryCall(io.grpc.testing.compiler.nano.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse> responseObserver) {
+      asyncUnimplementedUnaryCall(getUnaryCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * One request followed by a sequence of responses (streamed download).
+     * The server returns the payload with client desired type and sizes.
+     * </pre>
+     */
+    public void streamingOutputCall(io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
+      asyncUnimplementedUnaryCall(getStreamingOutputCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by one response (streamed upload).
+     * The server returns the aggregated size of client payload as the result.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest> streamingInputCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getStreamingInputCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests with each request served by the server immediately.
+     * As one request could lead to multiple responses, this interface
+     * demonstrates the idea of full bidirectionality.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest> fullBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getFullBidiCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by a sequence of responses.
+     * The server buffers all the client requests and then serves them in order. A
+     * stream of responses are returned to the client when the server starts with
+     * first request.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest> halfBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getHalfBidiCallMethod(), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * An RPC method whose Java name collides with a keyword, and whose generated
+     * method should have a '_' appended.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest> import_(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncUnimplementedStreamingCall(getImportMethod(), responseObserver);
+    }
+
+    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
+      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+          .addMethod(
+            getUnaryCallMethod(),
+            asyncUnaryCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.nano.Test.SimpleRequest,
+                io.grpc.testing.compiler.nano.Test.SimpleResponse>(
+                  this, METHODID_UNARY_CALL)))
+          .addMethod(
+            getStreamingOutputCallMethod(),
+            asyncServerStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
+                io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(
+                  this, METHODID_STREAMING_OUTPUT_CALL)))
+          .addMethod(
+            getStreamingInputCallMethod(),
+            asyncClientStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
+                io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>(
+                  this, METHODID_STREAMING_INPUT_CALL)))
+          .addMethod(
+            getFullBidiCallMethod(),
+            asyncBidiStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
+                io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(
+                  this, METHODID_FULL_BIDI_CALL)))
+          .addMethod(
+            getHalfBidiCallMethod(),
+            asyncBidiStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
+                io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(
+                  this, METHODID_HALF_BIDI_CALL)))
+          .addMethod(
+            getImportMethod(),
+            asyncBidiStreamingCall(
+              new MethodHandlers<
+                io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
+                io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>(
+                  this, METHODID_IMPORT)))
+          .build();
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static final class TestServiceStub extends io.grpc.stub.AbstractStub<TestServiceStub> {
+    private TestServiceStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestServiceStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestServiceStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestServiceStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public void unaryCall(io.grpc.testing.compiler.nano.Test.SimpleRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse> responseObserver) {
+      asyncUnaryCall(
+          getChannel().newCall(getUnaryCallMethod(), getCallOptions()), request, responseObserver);
+    }
+
+    /**
+     * <pre>
+     * One request followed by a sequence of responses (streamed download).
+     * The server returns the payload with client desired type and sizes.
+     * </pre>
+     */
+    public void streamingOutputCall(io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest request,
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
+      asyncServerStreamingCall(
+          getChannel().newCall(getStreamingOutputCallMethod(), getCallOptions()), request, responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by one response (streamed upload).
+     * The server returns the aggregated size of client payload as the result.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest> streamingInputCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncClientStreamingCall(
+          getChannel().newCall(getStreamingInputCallMethod(), getCallOptions()), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests with each request served by the server immediately.
+     * As one request could lead to multiple responses, this interface
+     * demonstrates the idea of full bidirectionality.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest> fullBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncBidiStreamingCall(
+          getChannel().newCall(getFullBidiCallMethod(), getCallOptions()), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * A sequence of requests followed by a sequence of responses.
+     * The server buffers all the client requests and then serves them in order. A
+     * stream of responses are returned to the client when the server starts with
+     * first request.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest> halfBidiCall(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
+      return asyncBidiStreamingCall(
+          getChannel().newCall(getHalfBidiCallMethod(), getCallOptions()), responseObserver);
+    }
+
+    /**
+     * <pre>
+     * An RPC method whose Java name collides with a keyword, and whose generated
+     * method should have a '_' appended.
+     * </pre>
+     */
+    public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest> import_(
+        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> responseObserver) {
+      return asyncBidiStreamingCall(
+          getChannel().newCall(getImportMethod(), getCallOptions()), responseObserver);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static final class TestServiceBlockingStub extends io.grpc.stub.AbstractStub<TestServiceBlockingStub> {
+    private TestServiceBlockingStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestServiceBlockingStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestServiceBlockingStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestServiceBlockingStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public io.grpc.testing.compiler.nano.Test.SimpleResponse unaryCall(io.grpc.testing.compiler.nano.Test.SimpleRequest request) {
+      return blockingUnaryCall(
+          getChannel(), getUnaryCallMethod(), getCallOptions(), request);
+    }
+
+    /**
+     * <pre>
+     * One request followed by a sequence of responses (streamed download).
+     * The server returns the payload with client desired type and sizes.
+     * </pre>
+     */
+    public java.util.Iterator<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> streamingOutputCall(
+        io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest request) {
+      return blockingServerStreamingCall(
+          getChannel(), getStreamingOutputCallMethod(), getCallOptions(), request);
+    }
+  }
+
+  /**
+   * <pre>
+   * Test service that supports all call types.
+   * </pre>
+   */
+  public static final class TestServiceFutureStub extends io.grpc.stub.AbstractStub<TestServiceFutureStub> {
+    private TestServiceFutureStub(io.grpc.Channel channel) {
+      super(channel);
+    }
+
+    private TestServiceFutureStub(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      super(channel, callOptions);
+    }
+
+    @java.lang.Override
+    protected TestServiceFutureStub build(io.grpc.Channel channel,
+        io.grpc.CallOptions callOptions) {
+      return new TestServiceFutureStub(channel, callOptions);
+    }
+
+    /**
+     * <pre>
+     * One request followed by one response.
+     * The server returns the client payload as-is.
+     * </pre>
+     */
+    public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.compiler.nano.Test.SimpleResponse> unaryCall(
+        io.grpc.testing.compiler.nano.Test.SimpleRequest request) {
+      return futureUnaryCall(
+          getChannel().newCall(getUnaryCallMethod(), getCallOptions()), request);
+    }
+  }
+
+  private static final int METHODID_UNARY_CALL = 0;
+  private static final int METHODID_STREAMING_OUTPUT_CALL = 1;
+  private static final int METHODID_STREAMING_INPUT_CALL = 2;
+  private static final int METHODID_FULL_BIDI_CALL = 3;
+  private static final int METHODID_HALF_BIDI_CALL = 4;
+  private static final int METHODID_IMPORT = 5;
+
+  private static final class MethodHandlers<Req, Resp> implements
+      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
+      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
+    private final TestServiceImplBase serviceImpl;
+    private final int methodId;
+
+    MethodHandlers(TestServiceImplBase serviceImpl, int methodId) {
+      this.serviceImpl = serviceImpl;
+      this.methodId = methodId;
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        case METHODID_UNARY_CALL:
+          serviceImpl.unaryCall((io.grpc.testing.compiler.nano.Test.SimpleRequest) request,
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse>) responseObserver);
+          break;
+        case METHODID_STREAMING_OUTPUT_CALL:
+          serviceImpl.streamingOutputCall((io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest) request,
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>) responseObserver);
+          break;
+        default:
+          throw new AssertionError();
+      }
+    }
+
+    @java.lang.Override
+    @java.lang.SuppressWarnings("unchecked")
+    public io.grpc.stub.StreamObserver<Req> invoke(
+        io.grpc.stub.StreamObserver<Resp> responseObserver) {
+      switch (methodId) {
+        case METHODID_STREAMING_INPUT_CALL:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.streamingInputCall(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>) responseObserver);
+        case METHODID_FULL_BIDI_CALL:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.fullBidiCall(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>) responseObserver);
+        case METHODID_HALF_BIDI_CALL:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.halfBidiCall(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>) responseObserver);
+        case METHODID_IMPORT:
+          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.import_(
+              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>) responseObserver);
+        default:
+          throw new AssertionError();
+      }
+    }
+  }
+
+  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+    io.grpc.ServiceDescriptor result = serviceDescriptor;
+    if (result == null) {
+      synchronized (TestServiceGrpc.class) {
+        result = serviceDescriptor;
+        if (result == null) {
+          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+              .addMethod(getUnaryCallMethod())
+              .addMethod(getStreamingOutputCallMethod())
+              .addMethod(getStreamingInputCallMethod())
+              .addMethod(getFullBidiCallMethod())
+              .addMethod(getHalfBidiCallMethod())
+              .addMethod(getImportMethod())
+              .build();
+        }
+      }
+    }
+    return result;
+  }
+}