forked from apache/dubbo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master-merged-performance-cloudnative'
# Conflicts: # dubbo-bootstrap/dubbo-bootstrap-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java # dubbo-bootstrap/dubbo-bootstrap-spring/src/main/java/org/apache/dubbo/config/spring/util/ClassUtils.java # dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java # dubbo-common/pom.xml # dubbo-common/src/main/java/org/apache/dubbo/common/URL.java # dubbo-common/src/main/java/org/apache/dubbo/common/config/configcenter/Constants.java # dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java # dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java # dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java # dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java # dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java # dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java # dubbo-common/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java # dubbo-common/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java # dubbo-common/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java # dubbo-common/src/main/java/org/apache/dubbo/config/Constants.java # dubbo-common/src/main/java/org/apache/dubbo/rpc/support/ProtocolUtils.java # dubbo-compatible/src/main/java/com/alibaba/dubbo/common/Constants.java # dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java # dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java # dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java # dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractReferenceConfigTest.java # dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractServiceConfigTest.java # dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java # dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/builders/AbstractReferenceBuilderTest.java # dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/builders/AbstractServiceBuilderTest.java # dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/url/UrlTestBase.java # dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java # dubbo-configcenter/dubbo-configcenter-apollo/src/main/java/org/apache/dubbo/configcenter/support/apollo/ApolloDynamicConfiguration.java # dubbo-configcenter/dubbo-configcenter-consul/src/main/java/org/apache/dubbo/configcenter/consul/ConsulDynamicConfiguration.java # dubbo-configcenter/dubbo-configcenter-etcd/src/main/java/org/apache/dubbo/configcenter/support/etcd/EtcdDynamicConfiguration.java # dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java # dubbo-dependencies-bom/pom.xml # dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml # dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/integration/MetadataReportService.java # dubbo-metadata-report/dubbo-metadata-report-api/src/test/java/org/apache/dubbo/metadata/integration/MetadataReportServiceTest.java # dubbo-metadata-report/dubbo-metadata-report-etcd/src/test/java/org/apache/dubbo/metadata/store/etcd/EtcdMetadataReportTest.java # dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Constants.java # dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClientHandler.java # dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServerHandler.java # dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java # dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Constants.java # dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java # dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java # dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/interceptors/ConsumerContextClusterInterceptor.java # dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/service/GenericServiceTest.java # dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/validation/ValidationTest.java # dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RpcContextFilter.java # dubbo-rpc/dubbo-rpc-rest/src/test/java/org/apache/dubbo/rpc/protocol/rest/RestProtocolTest.java # pom.xml
- Loading branch information
Showing
1,298 changed files
with
52,595 additions
and
29,324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#Tue Oct 09 11:40:48 CST 2018 | ||
gradle.version=4.9 |
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
# Dubbo customized version | ||
|
||
## Get Started, how to use | ||
1. Add maven dependency | ||
```xml | ||
<build> | ||
<extensions> | ||
<extension> | ||
<groupId>kr.motd.maven</groupId> | ||
<artifactId>os-maven-plugin</artifactId> | ||
<version>1.6.1</version> | ||
</extension> | ||
</extensions> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.xolstice.maven.plugins</groupId> | ||
<artifactId>protobuf-maven-plugin</artifactId> | ||
<version>0.5.1</version> | ||
<configuration> | ||
<protocArtifact>com.google.protobuf:protoc:3.7.1:exe:${os.detected.classifier}</protocArtifact> | ||
<pluginId>grpc-java</pluginId> | ||
<pluginArtifact>org.apache.dubbo:protoc-gen-grpc-java:${proto_dubbo_plugin_version}:exe:${os.detected.classifier}</pluginArtifact> | ||
<outputDirectory>build/generated/source/proto/main/java</outputDirectory> | ||
<clearOutputDirectory>false</clearOutputDirectory> | ||
<!-- supports 'dubbo' and 'grpc' --> | ||
<pluginParameter>dubbo</pluginParameter> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>compile</goal> | ||
<goal>compile-custom</goal> | ||
<goal>test-compile</goal> | ||
<goal>test-compile-custom</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>build/generated/source/proto/main/java</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
``` | ||
|
||
2. Decide which protocol to use: Dubbo or gRPC | ||
* Dubbo, ` <pluginParameter>dubbo</pluginParameter>` | ||
* gRPC, ` <pluginParameter>grpc</pluginParameter>` | ||
|
||
3. Define service using IDL | ||
```text | ||
syntax = "proto3"; | ||
option java_multiple_files = true; | ||
option java_package = "org.apache.dubbo.demo"; | ||
option java_outer_classname = "DemoServiceProto"; | ||
option objc_class_prefix = "DEMOSRV"; | ||
package demoservice; | ||
// The demo service definition. | ||
service DemoService { | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
} | ||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} | ||
``` | ||
|
||
4. Build | ||
mvn clean compile | ||
|
||
## Customized | ||
|
||
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); | ||
} | ||
|
||
... | ||
} | ||
``` | ||
|
||
## Build locally | ||
|
||
To compile the plugin: | ||
``` | ||
$ ../gradlew java_pluginExecutable | ||
``` | ||
|
||
To publish to local repository | ||
``` | ||
$ ../gradlew publishToMavenLocal | ||
``` | ||
|
||
## Publish to maven repository | ||
|
||
Add gradle.properties | ||
```properties | ||
repositoryUser=user | ||
repositoryPasword=pwd | ||
``` | ||
|
||
Then, run | ||
``` | ||
$ ../gradlew publishMavenPublicationToDubboRepository | ||
``` | ||
Notice current groupId is `com.alibaba`. | ||
|
||
|
||
Check [here](https://github.com/grpc/grpc-java/blob/master/compiler/README.md) for basic requirements and usage of protoc plugin. |
Oops, something went wrong.