Skip to content

Commit

Permalink
Merge branch 'master-merged-performance-cloudnative'
Browse files Browse the repository at this point in the history
# 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
chickenlj committed Oct 28, 2019
2 parents 7e82c56 + 6d3bbb0 commit 39f84fe
Show file tree
Hide file tree
Showing 1,298 changed files with 52,595 additions and 29,324 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ target/
*.zip
*.tar
*.tar.gz
.flattened-pom.xml

# eclipse ignore
.settings/
Expand Down Expand Up @@ -35,3 +36,11 @@ Thumbs.db

# license check result
license-list

# grpc compiler
compiler/gradle.properties
compiler/build/*
compiler/.gradle/*

# protobuf
dubbo-serialization/dubbo-serialization-protobuf/build/*
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,6 @@ https://github.com/edazdarevic/CIDRUtils. The project is licensed under a MIT Li
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.

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/compiler'
10 changes: 10 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file added compiler/.gradle/4.3/fileChanges/last-build.bin
Binary file not shown.
Binary file not shown.
Binary file added compiler/.gradle/4.3/fileContent/fileContent.lock
Binary file not shown.
Binary file added compiler/.gradle/4.3/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added compiler/.gradle/4.3/fileHashes/fileHashes.lock
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added compiler/.gradle/4.3/taskHistory/taskHistory.bin
Binary file not shown.
Binary file added compiler/.gradle/4.3/taskHistory/taskHistory.lock
Binary file not shown.
Binary file added compiler/.gradle/4.9/fileChanges/last-build.bin
Binary file not shown.
Binary file not shown.
Binary file added compiler/.gradle/4.9/fileContent/fileContent.lock
Binary file not shown.
Binary file not shown.
Binary file added compiler/.gradle/4.9/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added compiler/.gradle/4.9/fileHashes/fileHashes.lock
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added compiler/.gradle/4.9/taskHistory/taskHistory.bin
Binary file not shown.
Binary file added compiler/.gradle/4.9/taskHistory/taskHistory.lock
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions compiler/.gradle/buildOutputCleanup/cache.properties
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.
12 changes: 12 additions & 0 deletions compiler/BUILD.bazel
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",
],
)
202 changes: 202 additions & 0 deletions compiler/README.md
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.
Loading

0 comments on commit 39f84fe

Please sign in to comment.