This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 981e76b85 Update async sample (#1045)
981e76b85 is described below
commit 981e76b8548a4fe5461e5dd3a0e81897bab98e32
Author: Ken Liu <[email protected]>
AuthorDate: Tue Mar 12 16:12:42 2024 +0800
Update async sample (#1045)
---
.../README.md | 0
.../samples/tri/unary/DubboGreeterTriple.java | 167 +++++++
.../apache/dubbo/samples/tri/unary/Greeter.java | 59 +++
.../dubbo/samples/tri/unary/GreeterOuterClass.java | 63 +++
.../dubbo/samples/tri/unary/GreeterReply.java | 507 +++++++++++++++++++++
.../samples/tri/unary/GreeterReplyOrBuilder.java | 21 +
.../dubbo/samples/tri/unary/GreeterRequest.java | 507 +++++++++++++++++++++
.../samples/tri/unary/GreeterRequestOrBuilder.java | 21 +
.../pom.xml | 63 ++-
.../dubbo/samples/tri/unary/GreeterImpl.java | 0
.../dubbo/samples/tri/unary/TriUnaryClient.java | 12 +-
.../dubbo/samples/tri/unary/TriUnaryServer.java | 13 +-
.../src/main/proto/greeter.proto | 0
.../src/main/resources/log4j2.xml | 0
1-basic/dubbo-samples-api/README.md | 2 +-
.../samples/tri/unary/util/EmbeddedZooKeeper.java | 309 -------------
.../samples/tri/unary/util/TriSampleConstants.java | 25 -
1-basic/pom.xml | 2 +-
.../org/apache/dubbo/async/boot/consumer/Task.java | 2 +-
.../src/main/resources/spring/async-consumer.xml | 2 +-
.../protocol/dubbo-samples-triple/README.MD | 2 +-
21 files changed, 1382 insertions(+), 395 deletions(-)
diff --git a/1-basic/dubbo-samples-idl/README.md
b/1-basic/dubbo-samples-api-idl/README.md
similarity index 100%
rename from 1-basic/dubbo-samples-idl/README.md
rename to 1-basic/dubbo-samples-api-idl/README.md
diff --git
a/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/DubboGreeterTriple.java
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/DubboGreeterTriple.java
new file mode 100644
index 000000000..8e90c7b15
--- /dev/null
+++
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/DubboGreeterTriple.java
@@ -0,0 +1,167 @@
+/*
+* 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.samples.tri.unary;
+
+import org.apache.dubbo.common.stream.StreamObserver;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.rpc.Invoker;
+import org.apache.dubbo.rpc.PathResolver;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.rpc.ServerService;
+import org.apache.dubbo.rpc.TriRpcStatus;
+import org.apache.dubbo.rpc.model.MethodDescriptor;
+import org.apache.dubbo.rpc.model.ServiceDescriptor;
+import org.apache.dubbo.rpc.model.StubMethodDescriptor;
+import org.apache.dubbo.rpc.model.StubServiceDescriptor;
+import org.apache.dubbo.rpc.stub.BiStreamMethodHandler;
+import org.apache.dubbo.rpc.stub.ServerStreamMethodHandler;
+import org.apache.dubbo.rpc.stub.StubInvocationUtil;
+import org.apache.dubbo.rpc.stub.StubInvoker;
+import org.apache.dubbo.rpc.stub.StubMethodHandler;
+import org.apache.dubbo.rpc.stub.StubSuppliers;
+import org.apache.dubbo.rpc.stub.UnaryStubMethodHandler;
+
+import com.google.protobuf.Message;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.concurrent.CompletableFuture;
+
+public final class DubboGreeterTriple {
+
+ public static final String SERVICE_NAME = Greeter.SERVICE_NAME;
+
+ private static final StubServiceDescriptor serviceDescriptor = new
StubServiceDescriptor(SERVICE_NAME,Greeter.class);
+
+ static {
+
org.apache.dubbo.rpc.protocol.tri.service.SchemaDescriptorRegistry.addSchemaDescriptor(SERVICE_NAME,GreeterOuterClass.getDescriptor());
+ StubSuppliers.addSupplier(SERVICE_NAME, DubboGreeterTriple::newStub);
+ StubSuppliers.addSupplier(Greeter.JAVA_SERVICE_NAME,
DubboGreeterTriple::newStub);
+ StubSuppliers.addDescriptor(SERVICE_NAME, serviceDescriptor);
+ StubSuppliers.addDescriptor(Greeter.JAVA_SERVICE_NAME,
serviceDescriptor);
+ }
+
+ @SuppressWarnings("all")
+ public static Greeter newStub(Invoker<?> invoker) {
+ return new GreeterStub((Invoker<Greeter>)invoker);
+ }
+
+ private static final StubMethodDescriptor greetMethod = new
StubMethodDescriptor("greet",
+ org.apache.dubbo.samples.tri.unary.GreeterRequest.class,
org.apache.dubbo.samples.tri.unary.GreeterReply.class, serviceDescriptor,
MethodDescriptor.RpcType.UNARY,
+ obj -> ((Message) obj).toByteArray(), obj -> ((Message)
obj).toByteArray(),
org.apache.dubbo.samples.tri.unary.GreeterRequest::parseFrom,
+ org.apache.dubbo.samples.tri.unary.GreeterReply::parseFrom);
+
+ private static final StubMethodDescriptor greetAsyncMethod = new
StubMethodDescriptor("greet",
+ org.apache.dubbo.samples.tri.unary.GreeterRequest.class,
java.util.concurrent.CompletableFuture.class, serviceDescriptor,
MethodDescriptor.RpcType.UNARY,
+ obj -> ((Message) obj).toByteArray(), obj -> ((Message)
obj).toByteArray(),
org.apache.dubbo.samples.tri.unary.GreeterRequest::parseFrom,
+ org.apache.dubbo.samples.tri.unary.GreeterReply::parseFrom);
+
+ private static final StubMethodDescriptor greetProxyAsyncMethod = new
StubMethodDescriptor("greetAsync",
+ org.apache.dubbo.samples.tri.unary.GreeterRequest.class,
org.apache.dubbo.samples.tri.unary.GreeterReply.class, serviceDescriptor,
MethodDescriptor.RpcType.UNARY,
+ obj -> ((Message) obj).toByteArray(), obj -> ((Message)
obj).toByteArray(),
org.apache.dubbo.samples.tri.unary.GreeterRequest::parseFrom,
+ org.apache.dubbo.samples.tri.unary.GreeterReply::parseFrom);
+
+
+
+
+
+ public static class GreeterStub implements Greeter{
+ private final Invoker<Greeter> invoker;
+
+ public GreeterStub(Invoker<Greeter> invoker) {
+ this.invoker = invoker;
+ }
+
+ @Override
+ public org.apache.dubbo.samples.tri.unary.GreeterReply
greet(org.apache.dubbo.samples.tri.unary.GreeterRequest request){
+ return StubInvocationUtil.unaryCall(invoker, greetMethod, request);
+ }
+
+ public
CompletableFuture<org.apache.dubbo.samples.tri.unary.GreeterReply>
greetAsync(org.apache.dubbo.samples.tri.unary.GreeterRequest request){
+ return StubInvocationUtil.unaryCall(invoker, greetAsyncMethod,
request);
+ }
+
+ @Override
+ public void greet(org.apache.dubbo.samples.tri.unary.GreeterRequest
request, StreamObserver<org.apache.dubbo.samples.tri.unary.GreeterReply>
responseObserver){
+ StubInvocationUtil.unaryCall(invoker, greetMethod , request,
responseObserver);
+ }
+
+
+
+ }
+
+ public static abstract class GreeterImplBase implements Greeter,
ServerService<Greeter> {
+
+ private <T, R> BiConsumer<T, StreamObserver<R>>
syncToAsync(java.util.function.Function<T, R> syncFun) {
+ return new BiConsumer<T, StreamObserver<R>>() {
+ @Override
+ public void accept(T t, StreamObserver<R> observer) {
+ try {
+ R ret = syncFun.apply(t);
+ observer.onNext(ret);
+ observer.onCompleted();
+ } catch (Throwable e) {
+ observer.onError(e);
+ }
+ }
+ };
+ }
+
+ @Override
+ public final Invoker<Greeter> getInvoker(URL url) {
+ PathResolver pathResolver = url.getOrDefaultFrameworkModel()
+ .getExtensionLoader(PathResolver.class)
+ .getDefaultExtension();
+ Map<String,StubMethodHandler<?, ?>> handlers = new HashMap<>();
+
+ pathResolver.addNativeStub( "/" + SERVICE_NAME + "/greet" );
+ pathResolver.addNativeStub( "/" + SERVICE_NAME + "/greetAsync" );
+
+ BiConsumer<org.apache.dubbo.samples.tri.unary.GreeterRequest,
StreamObserver<org.apache.dubbo.samples.tri.unary.GreeterReply>> greetFunc =
this::greet;
+ handlers.put(greetMethod.getMethodName(), new
UnaryStubMethodHandler<>(greetFunc));
+ BiConsumer<org.apache.dubbo.samples.tri.unary.GreeterRequest,
StreamObserver<org.apache.dubbo.samples.tri.unary.GreeterReply>> greetAsyncFunc
= syncToAsync(this::greet);
+ handlers.put(greetProxyAsyncMethod.getMethodName(), new
UnaryStubMethodHandler<>(greetAsyncFunc));
+
+
+
+
+ return new StubInvoker<>(this, url, Greeter.class, handlers);
+ }
+
+
+ @Override
+ public org.apache.dubbo.samples.tri.unary.GreeterReply
greet(org.apache.dubbo.samples.tri.unary.GreeterRequest request){
+ throw unimplementedMethodException(greetMethod);
+ }
+
+
+
+
+
+ @Override
+ public final ServiceDescriptor getServiceDescriptor() {
+ return serviceDescriptor;
+ }
+ private RpcException unimplementedMethodException(StubMethodDescriptor
methodDescriptor) {
+ return
TriRpcStatus.UNIMPLEMENTED.withDescription(String.format("Method %s is
unimplemented",
+ "/" + serviceDescriptor.getInterfaceName() + "/" +
methodDescriptor.getMethodName())).asException();
+ }
+ }
+
+}
diff --git
a/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/Greeter.java
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/Greeter.java
new file mode 100644
index 000000000..ff3efea87
--- /dev/null
+++
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/Greeter.java
@@ -0,0 +1,59 @@
+/*
+* 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.samples.tri.unary;
+
+import org.apache.dubbo.common.stream.StreamObserver;
+import com.google.protobuf.Message;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.concurrent.CompletableFuture;
+
+public interface Greeter extends org.apache.dubbo.rpc.model.DubboStub {
+
+ String JAVA_SERVICE_NAME = "org.apache.dubbo.samples.tri.unary.Greeter";
+ String SERVICE_NAME = "org.apache.dubbo.samples.tri.unary.Greeter";
+
+ org.apache.dubbo.samples.tri.unary.GreeterReply
greet(org.apache.dubbo.samples.tri.unary.GreeterRequest request);
+
+ default CompletableFuture<org.apache.dubbo.samples.tri.unary.GreeterReply>
greetAsync(org.apache.dubbo.samples.tri.unary.GreeterRequest request){
+ return CompletableFuture.completedFuture(greet(request));
+ }
+
+ /**
+ * This server stream type unary method is <b>only</b> used for generated
stub to support async unary method.
+ * It will not be called if you are NOT using Dubbo3 generated triple stub
and <b>DO NOT</b> implement this method.
+ */
+ default void greet(org.apache.dubbo.samples.tri.unary.GreeterRequest
request, StreamObserver<org.apache.dubbo.samples.tri.unary.GreeterReply>
responseObserver){
+ greetAsync(request).whenComplete((r, t) -> {
+ if (t != null) {
+ responseObserver.onError(t);
+ } else {
+ responseObserver.onNext(r);
+ responseObserver.onCompleted();
+ }
+ });
+ }
+
+
+
+
+
+
+}
diff --git
a/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterOuterClass.java
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterOuterClass.java
new file mode 100644
index 000000000..aafa3c1b6
--- /dev/null
+++
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterOuterClass.java
@@ -0,0 +1,63 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: greeter.proto
+
+package org.apache.dubbo.samples.tri.unary;
+
+public final class GreeterOuterClass {
+ private GreeterOuterClass() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistryLite registry) {
+ }
+
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ registerAllExtensions(
+ (com.google.protobuf.ExtensionRegistryLite) registry);
+ }
+ static final com.google.protobuf.Descriptors.Descriptor
+
internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_descriptor;
+ static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+
internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_fieldAccessorTable;
+ static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_descriptor;
+ static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+
internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n\rgreeter.proto\022\"org.apache.dubbo.sample" +
+ "s.tri.unary\"\036\n\016GreeterRequest\022\014\n\004name\030\001 " +
+ "\001(\t\"\037\n\014GreeterReply\022\017\n\007message\030\001
\001(\t2x\n\007" +
+ "Greeter\022m\n\005greet\0222.org.apache.dubbo.samp" +
+ "les.tri.unary.GreeterRequest\0320.org.apach" +
+ "e.dubbo.samples.tri.unary.GreeterReplyB\002" +
+ "P\001b\006proto3"
+ };
+ descriptor = com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ });
+
internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+
internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_fieldAccessorTable
= new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+
internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_descriptor,
+ new java.lang.String[] { "Name", });
+ internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_descriptor
=
+ getDescriptor().getMessageTypes().get(1);
+
internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_fieldAccessorTable
= new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+
internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_descriptor,
+ new java.lang.String[] { "Message", });
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git
a/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterReply.java
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterReply.java
new file mode 100644
index 000000000..58ac498d3
--- /dev/null
+++
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterReply.java
@@ -0,0 +1,507 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: greeter.proto
+
+package org.apache.dubbo.samples.tri.unary;
+
+/**
+ * Protobuf type {@code org.apache.dubbo.samples.tri.unary.GreeterReply}
+ */
+public final class GreeterReply extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ //
@@protoc_insertion_point(message_implements:org.apache.dubbo.samples.tri.unary.GreeterReply)
+ GreeterReplyOrBuilder {
+private static final long serialVersionUID = 0L;
+ // Use GreeterReply.newBuilder() to construct.
+ private GreeterReply(com.google.protobuf.GeneratedMessageV3.Builder<?>
builder) {
+ super(builder);
+ }
+ private GreeterReply() {
+ message_ = "";
+ }
+
+ @java.lang.Override
+ @SuppressWarnings({"unused"})
+ protected java.lang.Object newInstance(
+ UnusedPrivateParameter unused) {
+ return new GreeterReply();
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.dubbo.samples.tri.unary.GreeterReply.class,
org.apache.dubbo.samples.tri.unary.GreeterReply.Builder.class);
+ }
+
+ public static final int MESSAGE_FIELD_NUMBER = 1;
+ @SuppressWarnings("serial")
+ private volatile java.lang.Object message_ = "";
+ /**
+ * <code>string message = 1;</code>
+ * @return The message.
+ */
+ @java.lang.Override
+ public java.lang.String getMessage() {
+ java.lang.Object ref = message_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ message_ = s;
+ return s;
+ }
+ }
+ /**
+ * <code>string message = 1;</code>
+ * @return The bytes for message.
+ */
+ @java.lang.Override
+ public com.google.protobuf.ByteString
+ getMessageBytes() {
+ java.lang.Object ref = message_;
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ message_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private byte memoizedIsInitialized = -1;
+ @java.lang.Override
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ @java.lang.Override
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(message_)) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 1, message_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ @java.lang.Override
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(message_)) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1,
message_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof org.apache.dubbo.samples.tri.unary.GreeterReply)) {
+ return super.equals(obj);
+ }
+ org.apache.dubbo.samples.tri.unary.GreeterReply other =
(org.apache.dubbo.samples.tri.unary.GreeterReply) obj;
+
+ if (!getMessage()
+ .equals(other.getMessage())) return false;
+ if (!getUnknownFields().equals(other.getUnknownFields())) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (37 * hash) + MESSAGE_FIELD_NUMBER;
+ hash = (53 * hash) + getMessage().hashCode();
+ hash = (29 * hash) + getUnknownFields().hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply
parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply
parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply
parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply
parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ @java.lang.Override
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder
newBuilder(org.apache.dubbo.samples.tri.unary.GreeterReply prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ @java.lang.Override
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code org.apache.dubbo.samples.tri.unary.GreeterReply}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
+ //
@@protoc_insertion_point(builder_implements:org.apache.dubbo.samples.tri.unary.GreeterReply)
+ org.apache.dubbo.samples.tri.unary.GreeterReplyOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.dubbo.samples.tri.unary.GreeterReply.class,
org.apache.dubbo.samples.tri.unary.GreeterReply.Builder.class);
+ }
+
+ // Construct using
org.apache.dubbo.samples.tri.unary.GreeterReply.newBuilder()
+ private Builder() {
+
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ super(parent);
+
+ }
+ @java.lang.Override
+ public Builder clear() {
+ super.clear();
+ bitField0_ = 0;
+ message_ = "";
+ return this;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterReply_descriptor;
+ }
+
+ @java.lang.Override
+ public org.apache.dubbo.samples.tri.unary.GreeterReply
getDefaultInstanceForType() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterReply.getDefaultInstance();
+ }
+
+ @java.lang.Override
+ public org.apache.dubbo.samples.tri.unary.GreeterReply build() {
+ org.apache.dubbo.samples.tri.unary.GreeterReply result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ @java.lang.Override
+ public org.apache.dubbo.samples.tri.unary.GreeterReply buildPartial() {
+ org.apache.dubbo.samples.tri.unary.GreeterReply result = new
org.apache.dubbo.samples.tri.unary.GreeterReply(this);
+ if (bitField0_ != 0) { buildPartial0(result); }
+ onBuilt();
+ return result;
+ }
+
+ private void buildPartial0(org.apache.dubbo.samples.tri.unary.GreeterReply
result) {
+ int from_bitField0_ = bitField0_;
+ if (((from_bitField0_ & 0x00000001) != 0)) {
+ result.message_ = message_;
+ }
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.apache.dubbo.samples.tri.unary.GreeterReply) {
+ return
mergeFrom((org.apache.dubbo.samples.tri.unary.GreeterReply)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.apache.dubbo.samples.tri.unary.GreeterReply
other) {
+ if (other ==
org.apache.dubbo.samples.tri.unary.GreeterReply.getDefaultInstance()) return
this;
+ if (!other.getMessage().isEmpty()) {
+ message_ = other.message_;
+ bitField0_ |= 0x00000001;
+ onChanged();
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ onChanged();
+ return this;
+ }
+
+ @java.lang.Override
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ if (extensionRegistry == null) {
+ throw new java.lang.NullPointerException();
+ }
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ case 10: {
+ message_ = input.readStringRequireUtf8();
+ bitField0_ |= 0x00000001;
+ break;
+ } // case 10
+ default: {
+ if (!super.parseUnknownField(input, extensionRegistry, tag)) {
+ done = true; // was an endgroup tag
+ }
+ break;
+ } // default:
+ } // switch (tag)
+ } // while (!done)
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ } finally {
+ onChanged();
+ } // finally
+ return this;
+ }
+ private int bitField0_;
+
+ private java.lang.Object message_ = "";
+ /**
+ * <code>string message = 1;</code>
+ * @return The message.
+ */
+ public java.lang.String getMessage() {
+ java.lang.Object ref = message_;
+ if (!(ref instanceof java.lang.String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ message_ = s;
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>string message = 1;</code>
+ * @return The bytes for message.
+ */
+ public com.google.protobuf.ByteString
+ getMessageBytes() {
+ java.lang.Object ref = message_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ message_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>string message = 1;</code>
+ * @param value The message to set.
+ * @return This builder for chaining.
+ */
+ public Builder setMessage(
+ java.lang.String value) {
+ if (value == null) { throw new NullPointerException(); }
+ message_ = value;
+ bitField0_ |= 0x00000001;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>string message = 1;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearMessage() {
+ message_ = getDefaultInstance().getMessage();
+ bitField0_ = (bitField0_ & ~0x00000001);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>string message = 1;</code>
+ * @param value The bytes for message to set.
+ * @return This builder for chaining.
+ */
+ public Builder setMessageBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) { throw new NullPointerException(); }
+ checkByteStringIsUtf8(value);
+ message_ = value;
+ bitField0_ |= 0x00000001;
+ onChanged();
+ return this;
+ }
+ @java.lang.Override
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFields(unknownFields);
+ }
+
+ @java.lang.Override
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ //
@@protoc_insertion_point(builder_scope:org.apache.dubbo.samples.tri.unary.GreeterReply)
+ }
+
+ //
@@protoc_insertion_point(class_scope:org.apache.dubbo.samples.tri.unary.GreeterReply)
+ private static final org.apache.dubbo.samples.tri.unary.GreeterReply
DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new org.apache.dubbo.samples.tri.unary.GreeterReply();
+ }
+
+ public static org.apache.dubbo.samples.tri.unary.GreeterReply
getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser<GreeterReply>
+ PARSER = new com.google.protobuf.AbstractParser<GreeterReply>() {
+ @java.lang.Override
+ public GreeterReply parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ Builder builder = newBuilder();
+ try {
+ builder.mergeFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(builder.buildPartial());
+ } catch (com.google.protobuf.UninitializedMessageException e) {
+ throw
e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(e)
+ .setUnfinishedMessage(builder.buildPartial());
+ }
+ return builder.buildPartial();
+ }
+ };
+
+ public static com.google.protobuf.Parser<GreeterReply> parser() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Parser<GreeterReply> getParserForType() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public org.apache.dubbo.samples.tri.unary.GreeterReply
getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+}
+
diff --git
a/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterReplyOrBuilder.java
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterReplyOrBuilder.java
new file mode 100644
index 000000000..11b2b029a
--- /dev/null
+++
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterReplyOrBuilder.java
@@ -0,0 +1,21 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: greeter.proto
+
+package org.apache.dubbo.samples.tri.unary;
+
+public interface GreeterReplyOrBuilder extends
+ //
@@protoc_insertion_point(interface_extends:org.apache.dubbo.samples.tri.unary.GreeterReply)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * <code>string message = 1;</code>
+ * @return The message.
+ */
+ java.lang.String getMessage();
+ /**
+ * <code>string message = 1;</code>
+ * @return The bytes for message.
+ */
+ com.google.protobuf.ByteString
+ getMessageBytes();
+}
diff --git
a/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterRequest.java
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterRequest.java
new file mode 100644
index 000000000..712cd868f
--- /dev/null
+++
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterRequest.java
@@ -0,0 +1,507 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: greeter.proto
+
+package org.apache.dubbo.samples.tri.unary;
+
+/**
+ * Protobuf type {@code org.apache.dubbo.samples.tri.unary.GreeterRequest}
+ */
+public final class GreeterRequest extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ //
@@protoc_insertion_point(message_implements:org.apache.dubbo.samples.tri.unary.GreeterRequest)
+ GreeterRequestOrBuilder {
+private static final long serialVersionUID = 0L;
+ // Use GreeterRequest.newBuilder() to construct.
+ private GreeterRequest(com.google.protobuf.GeneratedMessageV3.Builder<?>
builder) {
+ super(builder);
+ }
+ private GreeterRequest() {
+ name_ = "";
+ }
+
+ @java.lang.Override
+ @SuppressWarnings({"unused"})
+ protected java.lang.Object newInstance(
+ UnusedPrivateParameter unused) {
+ return new GreeterRequest();
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.dubbo.samples.tri.unary.GreeterRequest.class,
org.apache.dubbo.samples.tri.unary.GreeterRequest.Builder.class);
+ }
+
+ public static final int NAME_FIELD_NUMBER = 1;
+ @SuppressWarnings("serial")
+ private volatile java.lang.Object name_ = "";
+ /**
+ * <code>string name = 1;</code>
+ * @return The name.
+ */
+ @java.lang.Override
+ public java.lang.String getName() {
+ java.lang.Object ref = name_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ name_ = s;
+ return s;
+ }
+ }
+ /**
+ * <code>string name = 1;</code>
+ * @return The bytes for name.
+ */
+ @java.lang.Override
+ public com.google.protobuf.ByteString
+ getNameBytes() {
+ java.lang.Object ref = name_;
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ name_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private byte memoizedIsInitialized = -1;
+ @java.lang.Override
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ @java.lang.Override
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ @java.lang.Override
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1,
name_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof org.apache.dubbo.samples.tri.unary.GreeterRequest)) {
+ return super.equals(obj);
+ }
+ org.apache.dubbo.samples.tri.unary.GreeterRequest other =
(org.apache.dubbo.samples.tri.unary.GreeterRequest) obj;
+
+ if (!getName()
+ .equals(other.getName())) return false;
+ if (!getUnknownFields().equals(other.getUnknownFields())) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (37 * hash) + NAME_FIELD_NUMBER;
+ hash = (53 * hash) + getName().hashCode();
+ hash = (29 * hash) + getUnknownFields().hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest
parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest
parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest
parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest
parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ @java.lang.Override
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder
newBuilder(org.apache.dubbo.samples.tri.unary.GreeterRequest prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ @java.lang.Override
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code org.apache.dubbo.samples.tri.unary.GreeterRequest}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
+ //
@@protoc_insertion_point(builder_implements:org.apache.dubbo.samples.tri.unary.GreeterRequest)
+ org.apache.dubbo.samples.tri.unary.GreeterRequestOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.dubbo.samples.tri.unary.GreeterRequest.class,
org.apache.dubbo.samples.tri.unary.GreeterRequest.Builder.class);
+ }
+
+ // Construct using
org.apache.dubbo.samples.tri.unary.GreeterRequest.newBuilder()
+ private Builder() {
+
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ super(parent);
+
+ }
+ @java.lang.Override
+ public Builder clear() {
+ super.clear();
+ bitField0_ = 0;
+ name_ = "";
+ return this;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterOuterClass.internal_static_org_apache_dubbo_samples_tri_unary_GreeterRequest_descriptor;
+ }
+
+ @java.lang.Override
+ public org.apache.dubbo.samples.tri.unary.GreeterRequest
getDefaultInstanceForType() {
+ return
org.apache.dubbo.samples.tri.unary.GreeterRequest.getDefaultInstance();
+ }
+
+ @java.lang.Override
+ public org.apache.dubbo.samples.tri.unary.GreeterRequest build() {
+ org.apache.dubbo.samples.tri.unary.GreeterRequest result =
buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ @java.lang.Override
+ public org.apache.dubbo.samples.tri.unary.GreeterRequest buildPartial() {
+ org.apache.dubbo.samples.tri.unary.GreeterRequest result = new
org.apache.dubbo.samples.tri.unary.GreeterRequest(this);
+ if (bitField0_ != 0) { buildPartial0(result); }
+ onBuilt();
+ return result;
+ }
+
+ private void
buildPartial0(org.apache.dubbo.samples.tri.unary.GreeterRequest result) {
+ int from_bitField0_ = bitField0_;
+ if (((from_bitField0_ & 0x00000001) != 0)) {
+ result.name_ = name_;
+ }
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.apache.dubbo.samples.tri.unary.GreeterRequest) {
+ return
mergeFrom((org.apache.dubbo.samples.tri.unary.GreeterRequest)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.apache.dubbo.samples.tri.unary.GreeterRequest
other) {
+ if (other ==
org.apache.dubbo.samples.tri.unary.GreeterRequest.getDefaultInstance()) return
this;
+ if (!other.getName().isEmpty()) {
+ name_ = other.name_;
+ bitField0_ |= 0x00000001;
+ onChanged();
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ onChanged();
+ return this;
+ }
+
+ @java.lang.Override
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ if (extensionRegistry == null) {
+ throw new java.lang.NullPointerException();
+ }
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ case 10: {
+ name_ = input.readStringRequireUtf8();
+ bitField0_ |= 0x00000001;
+ break;
+ } // case 10
+ default: {
+ if (!super.parseUnknownField(input, extensionRegistry, tag)) {
+ done = true; // was an endgroup tag
+ }
+ break;
+ } // default:
+ } // switch (tag)
+ } // while (!done)
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ } finally {
+ onChanged();
+ } // finally
+ return this;
+ }
+ private int bitField0_;
+
+ private java.lang.Object name_ = "";
+ /**
+ * <code>string name = 1;</code>
+ * @return The name.
+ */
+ public java.lang.String getName() {
+ java.lang.Object ref = name_;
+ if (!(ref instanceof java.lang.String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ name_ = s;
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>string name = 1;</code>
+ * @return The bytes for name.
+ */
+ public com.google.protobuf.ByteString
+ getNameBytes() {
+ java.lang.Object ref = name_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ name_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>string name = 1;</code>
+ * @param value The name to set.
+ * @return This builder for chaining.
+ */
+ public Builder setName(
+ java.lang.String value) {
+ if (value == null) { throw new NullPointerException(); }
+ name_ = value;
+ bitField0_ |= 0x00000001;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>string name = 1;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearName() {
+ name_ = getDefaultInstance().getName();
+ bitField0_ = (bitField0_ & ~0x00000001);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>string name = 1;</code>
+ * @param value The bytes for name to set.
+ * @return This builder for chaining.
+ */
+ public Builder setNameBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) { throw new NullPointerException(); }
+ checkByteStringIsUtf8(value);
+ name_ = value;
+ bitField0_ |= 0x00000001;
+ onChanged();
+ return this;
+ }
+ @java.lang.Override
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFields(unknownFields);
+ }
+
+ @java.lang.Override
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ //
@@protoc_insertion_point(builder_scope:org.apache.dubbo.samples.tri.unary.GreeterRequest)
+ }
+
+ //
@@protoc_insertion_point(class_scope:org.apache.dubbo.samples.tri.unary.GreeterRequest)
+ private static final org.apache.dubbo.samples.tri.unary.GreeterRequest
DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new org.apache.dubbo.samples.tri.unary.GreeterRequest();
+ }
+
+ public static org.apache.dubbo.samples.tri.unary.GreeterRequest
getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser<GreeterRequest>
+ PARSER = new com.google.protobuf.AbstractParser<GreeterRequest>() {
+ @java.lang.Override
+ public GreeterRequest parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ Builder builder = newBuilder();
+ try {
+ builder.mergeFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(builder.buildPartial());
+ } catch (com.google.protobuf.UninitializedMessageException e) {
+ throw
e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(e)
+ .setUnfinishedMessage(builder.buildPartial());
+ }
+ return builder.buildPartial();
+ }
+ };
+
+ public static com.google.protobuf.Parser<GreeterRequest> parser() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Parser<GreeterRequest> getParserForType() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public org.apache.dubbo.samples.tri.unary.GreeterRequest
getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+}
+
diff --git
a/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterRequestOrBuilder.java
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterRequestOrBuilder.java
new file mode 100644
index 000000000..e4c400efb
--- /dev/null
+++
b/1-basic/dubbo-samples-api-idl/build/generated/source/proto/main/java/org/apache/dubbo/samples/tri/unary/GreeterRequestOrBuilder.java
@@ -0,0 +1,21 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: greeter.proto
+
+package org.apache.dubbo.samples.tri.unary;
+
+public interface GreeterRequestOrBuilder extends
+ //
@@protoc_insertion_point(interface_extends:org.apache.dubbo.samples.tri.unary.GreeterRequest)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * <code>string name = 1;</code>
+ * @return The name.
+ */
+ java.lang.String getName();
+ /**
+ * <code>string name = 1;</code>
+ * @return The bytes for name.
+ */
+ com.google.protobuf.ByteString
+ getNameBytes();
+}
diff --git a/1-basic/dubbo-samples-idl/pom.xml
b/1-basic/dubbo-samples-api-idl/pom.xml
similarity index 73%
rename from 1-basic/dubbo-samples-idl/pom.xml
rename to 1-basic/dubbo-samples-api-idl/pom.xml
index b8a539092..a3d85900e 100644
--- a/1-basic/dubbo-samples-idl/pom.xml
+++ b/1-basic/dubbo-samples-api-idl/pom.xml
@@ -26,7 +26,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-samples-idl</artifactId>
+ <artifactId>dubbo-samples-api-idl</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
@@ -55,48 +55,12 @@
<artifactId>protobuf-java-util</artifactId>
<version>${protobuf-java.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-dependencies-zookeeper-curator5</artifactId>
- <version>${dubbo.version}</version>
- <type>pom</type>
- <exclusions>
- <exclusion>
- <artifactId>logback-classic</artifactId>
- <groupId>ch.qos.logback</groupId>
- </exclusion>
- <exclusion>
- <artifactId>logback-core</artifactId>
- <groupId>ch.qos.logback</groupId>
- </exclusion>
- <exclusion>
- <artifactId>log4j</artifactId>
- <groupId>log4j</groupId>
- </exclusion>
- <exclusion>
- <artifactId>slf4j-log4j12</artifactId>
- <groupId>org.slf4j</groupId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>
-
- <!-- Embedded Zookeeper Server Dependencies -->
- <dependency>
- <groupId>io.dropwizard.metrics</groupId>
- <artifactId>metrics-core</artifactId>
- <version>4.1.12.1</version>
- </dependency>
- <dependency>
- <groupId>org.xerial.snappy</groupId>
- <artifactId>snappy-java</artifactId>
- <version>1.1.10.5</version>
- </dependency>
</dependencies>
<build>
@@ -108,12 +72,18 @@
</extension>
</extensions>
<plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
+
<outputDirectory>build/generated/source/proto/main/java</outputDirectory>
<protocPlugins>
<protocPlugin>
<id>dubbo</id>
@@ -132,6 +102,25 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>3.3.0</version>
+ <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>
diff --git
a/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/GreeterImpl.java
b/1-basic/dubbo-samples-api-idl/src/main/java/org/apache/dubbo/samples/tri/unary/GreeterImpl.java
similarity index 100%
rename from
1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/GreeterImpl.java
rename to
1-basic/dubbo-samples-api-idl/src/main/java/org/apache/dubbo/samples/tri/unary/GreeterImpl.java
diff --git
a/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryClient.java
b/1-basic/dubbo-samples-api-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryClient.java
similarity index 82%
rename from
1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryClient.java
rename to
1-basic/dubbo-samples-api-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryClient.java
index d677bd200..3e9d23a9c 100644
---
a/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryClient.java
+++
b/1-basic/dubbo-samples-api-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryClient.java
@@ -20,9 +20,7 @@ package org.apache.dubbo.samples.tri.unary;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
-import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.samples.tri.unary.util.TriSampleConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,13 +34,9 @@ public class TriUnaryClient {
DubboBootstrap bootstrap = DubboBootstrap.getInstance();
ReferenceConfig<Greeter> ref = new ReferenceConfig<>();
ref.setInterface(Greeter.class);
- ref.setProtocol(CommonConstants.TRIPLE);
- ref.setProxy(CommonConstants.NATIVE_STUB);
- ref.setTimeout(3000);
+ ref.setUrl("tri://localhost:50052");
- ApplicationConfig applicationConfig = new
ApplicationConfig("tri-stub-consumer");
- applicationConfig.setQosEnable(false);
- bootstrap.application(applicationConfig).reference(ref).registry(new
RegistryConfig(TriSampleConstants.ZK_ADDRESS)).start();
+ bootstrap.reference(ref).start();
Greeter greeter = ref.get();
//sync
@@ -68,4 +62,4 @@ public class TriUnaryClient {
}
});
}
-}
\ No newline at end of file
+}
diff --git
a/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryServer.java
b/1-basic/dubbo-samples-api-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryServer.java
similarity index 68%
rename from
1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryServer.java
rename to
1-basic/dubbo-samples-api-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryServer.java
index ab6ac3e56..e1acccb4e 100644
---
a/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryServer.java
+++
b/1-basic/dubbo-samples-api-idl/src/main/java/org/apache/dubbo/samples/tri/unary/TriUnaryServer.java
@@ -23,26 +23,19 @@ import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.samples.tri.unary.util.EmbeddedZooKeeper;
-import org.apache.dubbo.samples.tri.unary.util.TriSampleConstants;
import java.io.IOException;
public class TriUnaryServer {
public static void main(String[] args) throws IOException {
- new EmbeddedZooKeeper(TriSampleConstants.ZK_PORT, false).start();
ServiceConfig<Greeter> service = new ServiceConfig<>();
service.setInterface(Greeter.class);
service.setRef(new GreeterImpl("tri-stub"));
- ApplicationConfig applicationConfig = new
ApplicationConfig("tri-stub-server");
- applicationConfig.setQosEnable(false);
+
DubboBootstrap bootstrap = DubboBootstrap.getInstance();
- bootstrap.application(applicationConfig)
- .registry(new RegistryConfig(TriSampleConstants.ZK_ADDRESS))
- .protocol(new ProtocolConfig(CommonConstants.TRIPLE,
TriSampleConstants.SERVER_PORT))
+ bootstrap.protocol(new ProtocolConfig(CommonConstants.TRIPLE, 50052))
.service(service)
- .start();
- System.out.println("Dubbo triple unary server started, port=" +
TriSampleConstants.SERVER_PORT);
+ .start().await();
}
}
diff --git a/1-basic/dubbo-samples-idl/src/main/proto/greeter.proto
b/1-basic/dubbo-samples-api-idl/src/main/proto/greeter.proto
similarity index 100%
rename from 1-basic/dubbo-samples-idl/src/main/proto/greeter.proto
rename to 1-basic/dubbo-samples-api-idl/src/main/proto/greeter.proto
diff --git a/1-basic/dubbo-samples-idl/src/main/resources/log4j2.xml
b/1-basic/dubbo-samples-api-idl/src/main/resources/log4j2.xml
similarity index 100%
rename from 1-basic/dubbo-samples-idl/src/main/resources/log4j2.xml
rename to 1-basic/dubbo-samples-api-idl/src/main/resources/log4j2.xml
diff --git a/1-basic/dubbo-samples-api/README.md
b/1-basic/dubbo-samples-api/README.md
index 7154bcca8..e12efe8eb 100644
--- a/1-basic/dubbo-samples-api/README.md
+++ b/1-basic/dubbo-samples-api/README.md
@@ -15,7 +15,7 @@ mvn
-Dexec.mainClass=org.apache.dubbo.samples.provider.Application exec:java
Now, you have a server running on port 50052 which accepts triple protocol
requests.
More usages of triple protocol can be found here:
-* [Triple with Protobuf (IDL mode)](../dubbo-samples-idl/)
+* [Triple with Protobuf (IDL mode)](../dubbo-samples-api-idl/)
* [Streaming RPCs](../../2-advanced/dubbo-samples-triple-streaming/)
* [Interoperability with standard gRPC clients and
servers](../../2-advanced/dubbo-samples-triple-grpc/)
* [Using triple with other languages and
browser](https://dubbo.apache.org/zh-cn/overview/mannual/)
diff --git
a/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/util/EmbeddedZooKeeper.java
b/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/util/EmbeddedZooKeeper.java
deleted file mode 100644
index 11f3bce57..000000000
---
a/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/util/EmbeddedZooKeeper.java
+++ /dev/null
@@ -1,309 +0,0 @@
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * 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.
- */
-
-package org.apache.dubbo.samples.tri.unary.util;
-
-import org.apache.zookeeper.server.ServerConfig;
-import org.apache.zookeeper.server.ZooKeeperServerMain;
-import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.SmartLifecycle;
-import org.springframework.util.ErrorHandler;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.ServerSocket;
-import java.util.List;
-import java.util.Properties;
-import java.util.Random;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-/**
- * from:
https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
- * <p>
- * Helper class to start an embedded instance of standalone (non clustered)
ZooKeeper.
- * <p>
- * NOTE: at least an external standalone server (if not an ensemble) are
recommended, even for
- * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication}
- *
- * @author Patrick Peralta
- * @author Mark Fisher
- * @author David Turanski
- */
-public class EmbeddedZooKeeper implements SmartLifecycle {
-
- private static final Random RANDOM = new Random();
-
- /**
- * Logger.
- */
- private static final Logger logger =
LoggerFactory.getLogger(EmbeddedZooKeeper.class);
-
- /**
- * ZooKeeper client port. This will be determined dynamically upon startup.
- */
- private final int clientPort;
-
- /**
- * Whether to auto-start. Default is true.
- */
- private boolean autoStartup = true;
-
- /**
- * Lifecycle phase. Default is 0.
- */
- private int phase = 0;
-
- /**
- * Thread for running the ZooKeeper server.
- */
- private volatile Thread zkServerThread;
-
- /**
- * ZooKeeper server.
- */
- private volatile ZooKeeperServerMain zkServer;
-
- /**
- * {@link ErrorHandler} to be invoked if an Exception is thrown from the
ZooKeeper server thread.
- */
- private ErrorHandler errorHandler;
-
- private boolean daemon = true;
-
- /**
- * Construct an EmbeddedZooKeeper with a random port.
- */
- public EmbeddedZooKeeper() {
- clientPort = findRandomPort(30000, 65535);
- }
-
- /**
- * Construct an EmbeddedZooKeeper with the provided port.
- *
- * @param clientPort port for ZooKeeper server to bind to
- */
- public EmbeddedZooKeeper(int clientPort, boolean daemon) {
- this.clientPort = clientPort;
- this.daemon = daemon;
- }
-
- /**
- * Returns the port that clients should use to connect to this embedded
server.
- *
- * @return dynamically determined client port
- */
- public int getClientPort() {
- return this.clientPort;
- }
-
- /**
- * Specify whether to start automatically. Default is true.
- *
- * @param autoStartup whether to start automatically
- */
- public void setAutoStartup(boolean autoStartup) {
- this.autoStartup = autoStartup;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAutoStartup() {
- return this.autoStartup;
- }
-
- /**
- * Specify the lifecycle phase for the embedded server.
- *
- * @param phase the lifecycle phase
- */
- public void setPhase(int phase) {
- this.phase = phase;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getPhase() {
- return this.phase;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isRunning() {
- return (zkServerThread != null);
- }
-
- /**
- * Start the ZooKeeper server in a background thread.
- * <p>
- * Register an error handler via {@link #setErrorHandler} in order to
handle
- * any exceptions thrown during startup or execution.
- */
- @Override
- public synchronized void start() {
- if (zkServerThread == null) {
- zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper
Server Starter");
- zkServerThread.setDaemon(daemon);
- zkServerThread.start();
- }
- }
-
- /**
- * Shutdown the ZooKeeper server.
- */
- @Override
- public synchronized void stop() {
- if (zkServerThread != null) {
- // The shutdown method is protected...thus this hack to invoke it.
- // This will log an exception on shutdown; see
- // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for
details.
- try {
- Method shutdown =
ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
- shutdown.setAccessible(true);
- shutdown.invoke(zkServer);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- // It is expected that the thread will exit after
- // the server is shutdown; this will block until
- // the shutdown is complete.
- try {
- zkServerThread.join(5000);
- zkServerThread = null;
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- logger.warn("Interrupted while waiting for embedded ZooKeeper
to exit");
- // abandoning zk thread
- zkServerThread = null;
- }
- }
- }
-
- /**
- * Stop the server if running and invoke the callback when complete.
- */
- @Override
- public void stop(Runnable callback) {
- stop();
- callback.run();
- }
-
- /**
- * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown
from the ZooKeeper server thread. If none
- * is provided, only error-level logging will occur.
- *
- * @param errorHandler the {@link ErrorHandler} to be invoked
- */
- public void setErrorHandler(ErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- /**
- * Runnable implementation that starts the ZooKeeper server.
- */
- private class ServerRunnable implements Runnable {
-
- @Override
- public void run() {
- try {
- Properties properties = new Properties();
- File file = new File(System.getProperty("java.io.tmpdir")
- + File.separator + UUID.randomUUID());
- file.deleteOnExit();
- properties.setProperty("dataDir", file.getAbsolutePath());
- properties.setProperty("clientPort",
String.valueOf(clientPort));
-
- QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
- quorumPeerConfig.parseProperties(properties);
-
- zkServer = new ZooKeeperServerMain();
- ServerConfig configuration = new ServerConfig();
- configuration.readFrom(quorumPeerConfig);
-
- System.setProperty("zookeeper.admin.enableServer", "false");
-
- zkServer.runFromConfig(configuration);
- } catch (Exception e) {
- if (errorHandler != null) {
- errorHandler.handleError(e);
- } else {
- logger.error("Exception running embedded ZooKeeper", e);
- }
- }
- }
- }
-
- /**
- * Workaround for SocketUtils.findRandomPort() deprecation.
- *
- * @param min min port
- * @param max max port
- * @return a random generated available port
- */
- private static int findRandomPort(int min, int max) {
- if (min < 1024) {
- throw new IllegalArgumentException("Max port shouldn't be less
than 1024.");
- }
-
- if (max > 65535) {
- throw new IllegalArgumentException("Max port shouldn't be greater
than 65535.");
- }
-
- if (min > max) {
- throw new IllegalArgumentException("Min port shouldn't be greater
than max port.");
- }
-
- int port = 0;
- int counter = 0;
-
- // Workaround for legacy JDK doesn't support Random.nextInt(min, max).
- List<Integer> randomInts = RANDOM.ints(min, max + 1)
- .limit(max - min)
- .mapToObj(Integer::valueOf)
- .collect(Collectors.toList());
-
- do {
- if (counter > max - min) {
- throw new IllegalStateException("Unable to find a port between
" + min + "-" + max);
- }
-
- port = randomInts.get(counter);
- counter++;
- } while (isPortInUse(port));
-
- return port;
- }
-
- private static boolean isPortInUse(int port) {
- try (ServerSocket ignored = new ServerSocket(port)) {
- return false;
- } catch (IOException e) {
- // continue
- }
- return true;
- }
-}
diff --git
a/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/util/TriSampleConstants.java
b/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/util/TriSampleConstants.java
deleted file mode 100644
index 0c02276be..000000000
---
a/1-basic/dubbo-samples-idl/src/main/java/org/apache/dubbo/samples/tri/unary/util/TriSampleConstants.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.samples.tri.unary.util;
-
-public class TriSampleConstants {
- public static final int SERVER_PORT =
Integer.parseInt(System.getProperty("provider.port", "50052"));
- public static final String ZK_HOST = System.getProperty("zookeeper.host",
"127.0.0.1");
- public static final int ZK_PORT =
Integer.parseInt(System.getProperty("zookeeper.port", "2181"));
- public static final String ZK_ADDRESS = "zookeeper://" + ZK_HOST + ":" +
ZK_PORT;
-}
diff --git a/1-basic/pom.xml b/1-basic/pom.xml
index c3aa12aae..bd1e8debd 100644
--- a/1-basic/pom.xml
+++ b/1-basic/pom.xml
@@ -28,7 +28,7 @@
<modules>
<module>dubbo-samples-api</module>
- <module>dubbo-samples-idl</module>
+ <module>dubbo-samples-api-idl</module>
<module>dubbo-samples-spring-boot</module>
<module>dubbo-samples-spring-boot-idl</module>
</modules>
diff --git
a/2-advanced/dubbo-samples-async/dubbo-samples-async-simple-boot/dubbo-samples-async-simple-boot-consumer/src/main/java/org/apache/dubbo/async/boot/consumer/Task.java
b/2-advanced/dubbo-samples-async/dubbo-samples-async-simple-boot/dubbo-samples-async-simple-boot-consumer/src/main/java/org/apache/dubbo/async/boot/consumer/Task.java
index 4efc96758..197a8a439 100644
---
a/2-advanced/dubbo-samples-async/dubbo-samples-async-simple-boot/dubbo-samples-async-simple-boot-consumer/src/main/java/org/apache/dubbo/async/boot/consumer/Task.java
+++
b/2-advanced/dubbo-samples-async/dubbo-samples-async-simple-boot/dubbo-samples-async-simple-boot-consumer/src/main/java/org/apache/dubbo/async/boot/consumer/Task.java
@@ -30,7 +30,7 @@ import java.util.concurrent.CompletableFuture;
*/
@Component
public class Task implements CommandLineRunner {
- @DubboReference
+ @DubboReference(async = true)
private HiService hiService;
@Override
diff --git
a/2-advanced/dubbo-samples-async/dubbo-samples-async-simple/src/main/resources/spring/async-consumer.xml
b/2-advanced/dubbo-samples-async/dubbo-samples-async-simple/src/main/resources/spring/async-consumer.xml
index 85517f238..50bb67803 100644
---
a/2-advanced/dubbo-samples-async/dubbo-samples-async-simple/src/main/resources/spring/async-consumer.xml
+++
b/2-advanced/dubbo-samples-async/dubbo-samples-async-simple/src/main/resources/spring/async-consumer.xml
@@ -29,6 +29,6 @@
<dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <dubbo:reference id="asyncService"
interface="org.apache.dubbo.samples.async.api.AsyncService" timeout="10000"/>
+ <dubbo:reference id="asyncService" async="true"
interface="org.apache.dubbo.samples.async.api.AsyncService" timeout="10000"/>
</beans>
diff --git a/3-extensions/protocol/dubbo-samples-triple/README.MD
b/3-extensions/protocol/dubbo-samples-triple/README.MD
index 4938325d0..f3ae3db9d 100644
--- a/3-extensions/protocol/dubbo-samples-triple/README.MD
+++ b/3-extensions/protocol/dubbo-samples-triple/README.MD
@@ -5,7 +5,7 @@ which supports interoperating with GRPC protocol naturally
using Protobuf serial
triple provides a compatible mode to upgrade without code modifications. So it
is smooth to migrate to triple.
This sample project contains most scenarios of Dubbo and non-Dubbo
interoperation. If you care about only one specific use-case of triple, we
recommend you check the following samples with each one focusing on only one
thing:
-* [Unary RPC](../../../1-basic/dubbo-samples-idl/)
+* [Unary RPC](../../../1-basic/dubbo-samples-api-idl/)
* [Streaming RPCs](../../../2-advanced/dubbo-samples-triple-streaming/)
* [Interoperability with standard gRPC clients and
servers](../../../2-advanced/dubbo-samples-triple-grpc/)
* [Triple without Protobuf (no IDL
mode)](../../../2-advanced/dubbo-samples-triple-no-idl/)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]