Skip to content
Permalink
Browse files
Merge pull request #8 from CodingSinger/opensource
add pb、grpc、gson、pbstuff、arvo benchmark and upgrade version to 2.7.6
  • Loading branch information
CodingSinger committed Apr 17, 2020
2 parents 6c12d53 + 2a25884 commit 9e919c97f39ae361819925ed0f7772832534d42b
Showing 49 changed files with 7,424 additions and 61 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -0,0 +1,59 @@

package org.apache.dubbo.benchmark.bean;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;

@javax.annotation.Generated(
value = "by Dubbo generator",
comments = "Source: Page.proto")
public final class UserServiceDubbo {
private static final AtomicBoolean registered = new AtomicBoolean();

private static Class<?> init() {
Class<?> clazz = null;
try {
clazz = Class.forName(UserServiceDubbo.class.getName());
if (registered.compareAndSet(false, true)) {
org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
org.apache.dubbo.benchmark.bean.PagePB.Response.getDefaultInstance());
org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
org.apache.dubbo.benchmark.bean.PagePB.Request.getDefaultInstance());
}
} catch (ClassNotFoundException e) {
// ignore
}
return clazz;
}

private UserServiceDubbo() {}

public static final String SERVICE_NAME = "org.apache.dubbo.benchmark.bean.UserService";

/**
* Code generated for Dubbo
*/
public interface IUserService {

static Class<?> clazz = init();

org.apache.dubbo.benchmark.bean.PagePB.Response existUser(org.apache.dubbo.benchmark.bean.PagePB.Request request);

CompletableFuture<org.apache.dubbo.benchmark.bean.PagePB.Response> existUserAsync(org.apache.dubbo.benchmark.bean.PagePB.Request request);

org.apache.dubbo.benchmark.bean.PagePB.Response createUser(org.apache.dubbo.benchmark.bean.PagePB.Request request);

CompletableFuture<org.apache.dubbo.benchmark.bean.PagePB.Response> createUserAsync(org.apache.dubbo.benchmark.bean.PagePB.Request request);

org.apache.dubbo.benchmark.bean.PagePB.Response getUser(org.apache.dubbo.benchmark.bean.PagePB.Request request);

CompletableFuture<org.apache.dubbo.benchmark.bean.PagePB.Response> getUserAsync(org.apache.dubbo.benchmark.bean.PagePB.Request request);

org.apache.dubbo.benchmark.bean.PagePB.Response listUser(org.apache.dubbo.benchmark.bean.PagePB.Request request);

CompletableFuture<org.apache.dubbo.benchmark.bean.PagePB.Response> listUserAsync(org.apache.dubbo.benchmark.bean.PagePB.Request request);


}

}

Large diffs are not rendered by default.

@@ -11,5 +11,129 @@

<artifactId>benchmark-base</artifactId>

<properties>
<dubbo.compiler.version>0.0.1</dubbo.compiler.version>
<grpc.version>1.19.0</grpc.version>
</properties>

<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.7.1</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.7.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${grpc.version}</version>
</dependency>
<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>

<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>
<outputDirectory>build/generated/source/proto/main/java</outputDirectory>
<clearOutputDirectory>false</clearOutputDirectory>
<protocPlugins>
<protocPlugin>
<id>dubbo</id>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-compiler</artifactId>
<version>${dubbo.compiler.version}</version>
<mainClass>org.apache.dubbo.gen.dubbo.DubboGenerator</mainClass>
</protocPlugin>
</protocPlugins>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>

<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>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
<outputDirectory>build/generated/source/proto/main/java</outputDirectory>
<clearOutputDirectory>false</clearOutputDirectory>
<protocPlugins>
<protocPlugin>
<id>dubbo-grpc</id>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-compiler</artifactId>
<version>${dubbo.compiler.version}</version>
<mainClass>org.apache.dubbo.gen.grpc.DubboGrpcGenerator</mainClass>
</protocPlugin>
</protocPlugins>
</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>
</project>
@@ -6,6 +6,7 @@
import java.util.List;

public class User implements Serializable {

private static final long serialVersionUID = 2566816725396650300L;

private long id;
@@ -10,7 +10,7 @@

public class SerializationOptimizerImpl implements SerializationOptimizer {
@Override
public Collection<Class> getSerializableClasses() {
public Collection<Class<?>> getSerializableClasses() {
return Arrays.asList(User.class, Page.class, UserService.class);
}
}
@@ -0,0 +1,103 @@
package org.apache.dubbo.benchmark.service;

import com.google.protobuf.util.Timestamps;
import io.grpc.stub.StreamObserver;
import org.apache.dubbo.benchmark.bean.DubboUserServiceGrpc;
import org.apache.dubbo.benchmark.bean.PagePB;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* @author zhengzechao
* @date 2020-03-06
* Email ooczzoo@gmail.com
*/
public class GrpcUserServiceImpl extends DubboUserServiceGrpc.UserServiceImplBase {

@Override
public void existUser(PagePB.Request request, StreamObserver<PagePB.Response> responseObserver) {
String email = request.getEmail();
final PagePB.Response.Builder builder = PagePB.Response.newBuilder();
if (email == null || email.isEmpty()) {
builder.setState(true);
} else if (email.charAt(email.length() - 1) < '5') {
builder.setState(false);
}
builder.setState(true);
PagePB.Response response = builder.build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}

@Override
public void createUser(PagePB.Request request, StreamObserver<PagePB.Response> responseObserver) {
final PagePB.Response.Builder builder = PagePB.Response.newBuilder();
if (request.getUser() == null) {
builder.setState(false);
} else {
builder.setState(true);
}
PagePB.Response response = builder.build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}

@Override
public void getUser(PagePB.Request request, StreamObserver<PagePB.Response> responseObserver) {
final long id = request.getId();
final PagePB.User.Builder user = PagePB.User.newBuilder();
user.setId(id);
user.setName(new String("Doug Lea"));
user.setSex(1);
user.setBirthday(Timestamps.fromMillis(System.currentTimeMillis()));
user.setEmail(new String("dong.lea@gmail.com"));
user.setMobile(new String("18612345678"));
user.setAddress(new String("北京市 中关村 中关村大街1号 鼎好大厦 1605"));
user.setIcon(new String("https://www.baidu.com/img/bd_logo1.png"));
user.setStatus(1);
user.setCreateTime(Timestamps.fromMillis(System.currentTimeMillis()));
user.setUpdateTime(user.getCreateTime());
List<Integer> permissions = new ArrayList<Integer>(
Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92));
user.addAllPermissions(permissions);
PagePB.Response response = PagePB.Response.newBuilder().setUser(user.build()).build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}

@Override
public void listUser(PagePB.Request request, StreamObserver<PagePB.Response> responseObserver) {
final PagePB.Page.Builder page = PagePB.Page.newBuilder();
List<PagePB.User> userList = new ArrayList<>(15);

for (int i = 0; i < 15; i++) {
final PagePB.User.Builder user = PagePB.User.newBuilder();

user.setId(i);
user.setName(new String("Doug Lea"));
user.setSex(1);
user.setBirthday(Timestamps.fromMillis(System.currentTimeMillis()));
user.setEmail(new String("dong.lea@gmail.com"));
user.setMobile(new String("18612345678"));
user.setAddress(new String("北京市 中关村 中关村大街1号 鼎好大厦 1605"));
user.setIcon(new String("https://www.baidu.com/img/bd_logo1.png"));
user.setStatus(1);
user.setCreateTime(Timestamps.fromMillis(System.currentTimeMillis()));
user.setUpdateTime(user.getCreateTime());
List<Integer> permissions = new ArrayList<Integer>(
Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92));
user.addAllPermissions(permissions);
userList.add(user.build());
}

page.setPageNo(request.getPage());
page.setTotal(1000);
page.addAllUsers(userList);

PagePB.Response response = PagePB.Response.newBuilder().setPage(page.build()).build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
}

0 comments on commit 9e919c9

Please sign in to comment.