From ccb4c2d37fefcf41529b3d16e7f65250431c4e7c Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Sun, 21 Nov 2021 23:56:15 -0500 Subject: [PATCH 01/21] [Issue #417] gRPC design doc and protobuf models (#594) * [Issue #337] Fix HttpSubscriber startup issue * [Issue #337] test commit * [Issue #337] revert test commit * [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook * [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook * [Issue #337] Address code review comment for Subscriber Demo App * adding license headers * adding grpc build file * [Issue#417] update settings.gradle * [Issue#417] fix grpc generated code styles * [Issue#417] fix grpc generated code styles * [Issue#417] fix grpc generated code styles * [Issue#417] fix grpc generated code styles and license issue * [Issue#417] fix license issue * [Issue #417] ignore checkstyle for generated files * [Issue #417] adding allow licensed for grpc protobuf Co-authored-by: j00441484 --- build.gradle | 2 + .../eventmesh-runtime-protocol.md | 120 + .../eventmesh-runtime-protocol.md | 122 + .../eventmesh-protocol-grpc/build.gradle | 53 + .../src/main/proto/eventmesh-client.proto | 102 + eventmesh-sdk-java/build.gradle | 3 + .../grpc/protos/ConsumerServiceGrpc.java | 453 ++++ .../client/grpc/protos/EventmeshClient.java | 174 ++ .../client/grpc/protos/Heartbeat.java | 2117 ++++++++++++++++ .../grpc/protos/HeartbeatOrBuilder.java | 97 + .../grpc/protos/HeartbeatServiceGrpc.java | 302 +++ .../eventmesh/client/grpc/protos/Message.java | 1299 ++++++++++ .../client/grpc/protos/MessageOrBuilder.java | 92 + .../grpc/protos/PublisherServiceGrpc.java | 460 ++++ .../client/grpc/protos/RequestHeader.java | 1910 +++++++++++++++ .../grpc/protos/RequestHeaderOrBuilder.java | 137 ++ .../client/grpc/protos/Response.java | 972 ++++++++ .../client/grpc/protos/ResponseOrBuilder.java | 67 + .../client/grpc/protos/Subscription.java | 2138 +++++++++++++++++ .../grpc/protos/SubscriptionOrBuilder.java | 78 + settings.gradle | 1 + tool/license/allowed-licenses.txt | 0 22 files changed, 10699 insertions(+) create mode 100644 eventmesh-protocol-plugin/eventmesh-protocol-grpc/build.gradle create mode 100644 eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java create mode 100644 tool/license/allowed-licenses.txt diff --git a/build.gradle b/build.gradle index 4f7e7f6814..d9c7f771d9 100644 --- a/build.gradle +++ b/build.gradle @@ -75,6 +75,8 @@ allprojects { maxWarnings = 0 configFile = new File("${rootDir}/style/checkStyle.xml") } + + checkstyleMain.exclude '**/org/apache/eventmesh/client/grpc/protos**' } task tar(type: Tar) { diff --git a/docs/cn/instructions/eventmesh-runtime-protocol.md b/docs/cn/instructions/eventmesh-runtime-protocol.md index 01f369b96f..2921ee0112 100644 --- a/docs/cn/instructions/eventmesh-runtime-protocol.md +++ b/docs/cn/instructions/eventmesh-runtime-protocol.md @@ -258,3 +258,123 @@ public class LiteMessage { | 场景 | Server向Client发送消息请求码 | Client回复Server消息响应码 | 说明 | | ------------------ | ---------------------------- | -------------------------- | ---------------------- | | 客户端接收异步事件 | HTTP_PUSH_CLIENT_ASYNC(105) | retCode | retCode值为0时代表成功 | + + +## gRPC 协议文档 + +#### 1. protobuf + +在 `eventmesh-protocol-gprc` 模块有 Eventmesh gRPC 客户端的 protobuf 文件. the protobuf 文件路径是 `/src/main/proto/eventmesh-client.proto`. + +用gradle build 生成 gRPC 代码在 `/build/generated/source/proto/main`. 生成代码用于 `eventmesh-sdk-java` 模块. + +#### 2. gRPC 数据模型 + +- 消息 + +以下消息数据模型用于 `publish()`, `requestReply()` 和 `broadcast()` APIs. + +``` +message RequestHeader { + string env = 1; + string region = 2; + string idc = 3; + string ip = 4; + string pid = 5; + string sys = 6; + string username = 7; + string password = 8; + string version = 9; + string language = 10; + string seqNum = 11; +} + +message Message { + RequestHeader header = 1; + string productionGroup = 2; + string topic = 3; + string content = 4; + string ttl = 5; + string uniqueId = 6; +} + +message Response { + string respCode = 1; + string respMsg = 2; + string respTime = 3; + string seqNum = 4; +} +``` + +- 订阅 + +以下订阅数据模型用于 `subscribe()` 和 `unsubscribe()` APIs. + +``` +message Subscription { + RequestHeader header = 1; + string consumerGroup = 2; + + message SubscriptionItem { + string topic = 1; + string mode = 2; + string type = 3; + string url = 4; + } + + repeated SubscriptionItem subscriptionItems = 3; +} +``` + +- 心跳 + +以下心跳数据模型用于 `heartbeat()` API. + +``` +message Heartbeat { + RequestHeader header = 1; + string clientType = 2; + string producerGroup = 3; + string consumerGroup = 4; + + message HeartbeatItem { + string topic = 1; + string url = 2; + } + + repeated HeartbeatItem heartbeatItems = 5; +} +``` + +#### 3. gRPC 服务接口 + +- 事件生产端服务 APIs + +``` + # 异步事件生产 + rpc publish(Message) returns (Response); + + # 同步事件生产 + rpc requestReply(Message) returns (Response); + + # 事件广播 + rpc broadcast(Message) returns (Response); +``` + +- 事件消费端服务 APIs + +``` + # 所消费事件通过 HTTP Webhook推送事件 + rpc subscribe(Subscription) returns (Response); + + # 所消费事件通过 TCP stream推送事件 + rpc subscribeStream(Subscription) returns (stream Message); + + rpc unsubscribe(Subscription) returns (Response); +``` + +- 客户端心跳服务 API + +``` + rpc heartbeat(Heartbeat) returns (Response); +``` \ No newline at end of file diff --git a/docs/en/instructions/eventmesh-runtime-protocol.md b/docs/en/instructions/eventmesh-runtime-protocol.md index 9049bfff11..2bdadb2406 100644 --- a/docs/en/instructions/eventmesh-runtime-protocol.md +++ b/docs/en/instructions/eventmesh-runtime-protocol.md @@ -259,3 +259,125 @@ same with RequestHeader of Heartbeat Msg | Scene | Server Send | Client Reply | Remark | | ------------------ | ---------------------------- | -------------------------- | ---------------------- | | Push async msg to client | HTTP_PUSH_CLIENT_ASYNC(105) | retCode | retCode=0,send success | + +## gRPC Protocol Document In Eventmesh-Runtime + +#### 1. protobuf + +The `eventmesh-protocol-gprc` module contains the protobuf file of the evenmesh client. the protobuf file +is located as `/src/main/proto/eventmesh-client.proto`. + +Run the gradle build to generate the gRPC codes. The generated codes are located at `/build/generated/source/proto/main`. + +These generated grpc codes will be used in `eventmesh-sdk-java` module. + +#### 2. data models + +- message + +The following is the message data model, used by `publish()`, `requestReply()` and `broadcast()` APIs. + +``` +message RequestHeader { + string env = 1; + string region = 2; + string idc = 3; + string ip = 4; + string pid = 5; + string sys = 6; + string username = 7; + string password = 8; + string version = 9; + string language = 10; + string seqNum = 11; +} + +message Message { + RequestHeader header = 1; + string productionGroup = 2; + string topic = 3; + string content = 4; + string ttl = 5; + string uniqueId = 6; +} + +message Response { + string respCode = 1; + string respMsg = 2; + string respTime = 3; + string seqNum = 4; +} +``` + +- subscription + +The following data model is used by `subscribe()` and `unsubscribe()` APIs. + +``` +message Subscription { + RequestHeader header = 1; + string consumerGroup = 2; + + message SubscriptionItem { + string topic = 1; + string mode = 2; + string type = 3; + string url = 4; + } + + repeated SubscriptionItem subscriptionItems = 3; +} +``` + +- heartbeat + +The following data model is used by `heartbeat()` API. + +``` +message Heartbeat { + RequestHeader header = 1; + string clientType = 2; + string producerGroup = 3; + string consumerGroup = 4; + + message HeartbeatItem { + string topic = 1; + string url = 2; + } + + repeated HeartbeatItem heartbeatItems = 5; +} +``` + +#### 3. service operations + +- event publisher service APIs + +``` + # Async event publish + rpc publish(Message) returns (Response); + + # Sync event publish + rpc requestReply(Message) returns (Response); + + # event broadcast + rpc broadcast(Message) returns (Response); +``` + +- event consumer service APIs + +``` + # The subscribed event will be delivered by invoking the webhook url in the Subscription + rpc subscribe(Subscription) returns (Response); + + # The subscribed event will be delivered through stream of Message + rpc subscribeStream(Subscription) returns (stream Message); + + rpc unsubscribe(Subscription) returns (Response); +``` + +- client heartbeat service API + +``` + rpc heartbeat(Heartbeat) returns (Response); +``` \ No newline at end of file diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/build.gradle b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/build.gradle new file mode 100644 index 0000000000..1692e6bceb --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/build.gradle @@ -0,0 +1,53 @@ +/* + * 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. + */ + +plugins { + id 'java' + id 'com.google.protobuf' version '0.8.17' +} + +repositories { + mavenCentral() +} + +def grpcVersion = '1.15.0' // CURRENT_GRPC_VERSION +def protobufVersion = '3.5.1' +def protocVersion = protobufVersion + +dependencies { + implementation "io.grpc:grpc-protobuf:${grpcVersion}" + implementation "io.grpc:grpc-stub:${grpcVersion}" + implementation "com.google.protobuf:protobuf-java-util:${protobufVersion}" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' +} + +protobuf { + protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" } + plugins { + grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" } + } + generateProtoTasks { + all()*.plugins { + grpc {} + } + } +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto new file mode 100644 index 0000000000..1b2e3fa438 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto @@ -0,0 +1,102 @@ +/* + * 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. + */ + +syntax = "proto3"; + +package eventmesh.client; + +option java_multiple_files = true; +option java_package = "org.apache.eventmesh.client.grpc.protos"; +option java_outer_classname = "EventmeshClient"; + +message RequestHeader { + string env = 1; + string region = 2; + string idc = 3; + string ip = 4; + string pid = 5; + string sys = 6; + string username = 7; + string password = 8; + string version = 9; + string language = 10; + string seqNum = 11; +} + +message Message { + RequestHeader header = 1; + string productionGroup = 2; + string topic = 3; + string content = 4; + string ttl = 5; + string uniqueId = 6; +} + +message Response { + string respCode = 1; + string respMsg = 2; + string respTime = 3; + string seqNum = 4; +} + +message Subscription { + RequestHeader header = 1; + string consumerGroup = 2; + + message SubscriptionItem { + string topic = 1; + string mode = 2; + string type = 3; + string url = 4; + } + + repeated SubscriptionItem subscriptionItems = 3; +} + +message Heartbeat { + RequestHeader header = 1; + string clientType = 2; + string producerGroup = 3; + string consumerGroup = 4; + + message HeartbeatItem { + string topic = 1; + string url = 2; + } + + repeated HeartbeatItem heartbeatItems = 5; +} + +service PublisherService { + rpc publish(Message) returns (Response); + + rpc requestReply(Message) returns (Response); + + rpc broadcast(Message) returns (Response); +} + +service ConsumerService { + rpc subscribe(Subscription) returns (Response); + + rpc subscribeStream(Subscription) returns (stream Message); + + rpc unsubscribe(Subscription) returns (Response); +} + +service HeartbeatService { + rpc heartbeat(Heartbeat) returns (Response); +} \ No newline at end of file diff --git a/eventmesh-sdk-java/build.gradle b/eventmesh-sdk-java/build.gradle index 7b91767b06..7c213ab1d1 100644 --- a/eventmesh-sdk-java/build.gradle +++ b/eventmesh-sdk-java/build.gradle @@ -40,6 +40,9 @@ dependencies { testImplementation "io.netty:netty-all" testImplementation "org.apache.httpcomponents:httpclient" + implementation "io.grpc:grpc-protobuf:1.15.0" + implementation "io.grpc:grpc-stub:1.15.0" + implementation "com.google.protobuf:protobuf-java-util:3.5.1" compileOnly 'org.projectlombok:lombok:1.18.22' annotationProcessor 'org.projectlombok:lombok:1.18.22' diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java new file mode 100644 index 0000000000..aff9b4ce2c --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java @@ -0,0 +1,453 @@ +/* + * 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.eventmesh.client.grpc.protos; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.*; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.*; + +/** + * + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.15.0)", + comments = "Source: eventmesh-client.proto") +public final class ConsumerServiceGrpc { + + private ConsumerServiceGrpc() { + } + + public static final String SERVICE_NAME = "eventmesh.client.ConsumerService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getSubscribeMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "subscribe", + requestType = org.apache.eventmesh.client.grpc.protos.Subscription.class, + responseType = org.apache.eventmesh.client.grpc.protos.Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getSubscribeMethod() { + io.grpc.MethodDescriptor getSubscribeMethod; + if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { + synchronized (ConsumerServiceGrpc.class) { + if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { + ConsumerServiceGrpc.getSubscribeMethod = getSubscribeMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.client.ConsumerService", "subscribe")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Subscription.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) + .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribe")) + .build(); + } + } + } + return getSubscribeMethod; + } + + private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "subscribeStream", + requestType = org.apache.eventmesh.client.grpc.protos.Subscription.class, + responseType = org.apache.eventmesh.client.grpc.protos.Message.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor getSubscribeStreamMethod() { + io.grpc.MethodDescriptor getSubscribeStreamMethod; + if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { + synchronized (ConsumerServiceGrpc.class) { + if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { + ConsumerServiceGrpc.getSubscribeStreamMethod = getSubscribeStreamMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName( + "eventmesh.client.ConsumerService", "subscribeStream")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Subscription.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) + .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribeStream")) + .build(); + } + } + } + return getSubscribeStreamMethod; + } + + private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "unsubscribe", + requestType = org.apache.eventmesh.client.grpc.protos.Subscription.class, + responseType = org.apache.eventmesh.client.grpc.protos.Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getUnsubscribeMethod() { + io.grpc.MethodDescriptor getUnsubscribeMethod; + if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { + synchronized (ConsumerServiceGrpc.class) { + if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { + ConsumerServiceGrpc.getUnsubscribeMethod = getUnsubscribeMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.client.ConsumerService", "unsubscribe")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Subscription.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) + .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("unsubscribe")) + .build(); + } + } + } + return getUnsubscribeMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static ConsumerServiceStub newStub(io.grpc.Channel channel) { + return new ConsumerServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static ConsumerServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new ConsumerServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static ConsumerServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new ConsumerServiceFutureStub(channel); + } + + /** + * + */ + public static abstract class ConsumerServiceImplBase implements io.grpc.BindableService { + + /** + * + */ + public void subscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSubscribeMethod(), responseObserver); + } + + /** + * + */ + public void subscribeStream(org.apache.eventmesh.client.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSubscribeStreamMethod(), responseObserver); + } + + /** + * + */ + public void unsubscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUnsubscribeMethod(), responseObserver); + } + + @Override + public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getSubscribeMethod(), + asyncUnaryCall( + new MethodHandlers< + org.apache.eventmesh.client.grpc.protos.Subscription, + org.apache.eventmesh.client.grpc.protos.Response>( + this, METHODID_SUBSCRIBE))) + .addMethod( + getSubscribeStreamMethod(), + asyncServerStreamingCall( + new MethodHandlers< + org.apache.eventmesh.client.grpc.protos.Subscription, + org.apache.eventmesh.client.grpc.protos.Message>( + this, METHODID_SUBSCRIBE_STREAM))) + .addMethod( + getUnsubscribeMethod(), + asyncUnaryCall( + new MethodHandlers< + org.apache.eventmesh.client.grpc.protos.Subscription, + org.apache.eventmesh.client.grpc.protos.Response>( + this, METHODID_UNSUBSCRIBE))) + .build(); + } + } + + /** + * + */ + public static final class ConsumerServiceStub extends io.grpc.stub.AbstractStub { + private ConsumerServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private ConsumerServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected ConsumerServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ConsumerServiceStub(channel, callOptions); + } + + /** + * + */ + public void subscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getSubscribeMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + */ + public void subscribeStream(org.apache.eventmesh.client.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getSubscribeStreamMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + */ + public void unsubscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + * + */ + public static final class ConsumerServiceBlockingStub extends io.grpc.stub.AbstractStub { + private ConsumerServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private ConsumerServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected ConsumerServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ConsumerServiceBlockingStub(channel, callOptions); + } + + /** + * + */ + public org.apache.eventmesh.client.grpc.protos.Response subscribe(org.apache.eventmesh.client.grpc.protos.Subscription request) { + return blockingUnaryCall( + getChannel(), getSubscribeMethod(), getCallOptions(), request); + } + + /** + * + */ + public java.util.Iterator subscribeStream( + org.apache.eventmesh.client.grpc.protos.Subscription request) { + return blockingServerStreamingCall( + getChannel(), getSubscribeStreamMethod(), getCallOptions(), request); + } + + /** + * + */ + public org.apache.eventmesh.client.grpc.protos.Response unsubscribe(org.apache.eventmesh.client.grpc.protos.Subscription request) { + return blockingUnaryCall( + getChannel(), getUnsubscribeMethod(), getCallOptions(), request); + } + } + + /** + * + */ + public static final class ConsumerServiceFutureStub extends io.grpc.stub.AbstractStub { + private ConsumerServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private ConsumerServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected ConsumerServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ConsumerServiceFutureStub(channel, callOptions); + } + + /** + * + */ + public com.google.common.util.concurrent.ListenableFuture subscribe( + org.apache.eventmesh.client.grpc.protos.Subscription request) { + return futureUnaryCall( + getChannel().newCall(getSubscribeMethod(), getCallOptions()), request); + } + + /** + * + */ + public com.google.common.util.concurrent.ListenableFuture unsubscribe( + org.apache.eventmesh.client.grpc.protos.Subscription request) { + return futureUnaryCall( + getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_SUBSCRIBE = 0; + private static final int METHODID_SUBSCRIBE_STREAM = 1; + private static final int METHODID_UNSUBSCRIBE = 2; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final ConsumerServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(ConsumerServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_SUBSCRIBE: + serviceImpl.subscribe((org.apache.eventmesh.client.grpc.protos.Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SUBSCRIBE_STREAM: + serviceImpl.subscribeStream((org.apache.eventmesh.client.grpc.protos.Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UNSUBSCRIBE: + serviceImpl.unsubscribe((org.apache.eventmesh.client.grpc.protos.Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class ConsumerServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + ConsumerServiceBaseDescriptorSupplier() { + } + + @Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.apache.eventmesh.client.grpc.protos.EventmeshClient.getDescriptor(); + } + + @Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("ConsumerService"); + } + } + + private static final class ConsumerServiceFileDescriptorSupplier + extends ConsumerServiceBaseDescriptorSupplier { + ConsumerServiceFileDescriptorSupplier() { + } + } + + private static final class ConsumerServiceMethodDescriptorSupplier + extends ConsumerServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + ConsumerServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (ConsumerServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new ConsumerServiceFileDescriptorSupplier()) + .addMethod(getSubscribeMethod()) + .addMethod(getSubscribeStreamMethod()) + .addMethod(getUnsubscribeMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java new file mode 100644 index 0000000000..9bd4db761d --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java @@ -0,0 +1,174 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +public final class EventmeshClient { + private EventmeshClient() { + } + + 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_eventmesh_client_RequestHeader_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_client_RequestHeader_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_client_Message_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_client_Message_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_client_Response_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_client_Response_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_client_Subscription_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_client_Subscription_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_client_Heartbeat_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_client_Heartbeat_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + String[] descriptorData = { + "\n\026eventmesh-client.proto\022\020eventmesh.clie" + + "nt\"\266\001\n\rRequestHeader\022\013\n\003env\030\001 \001(\t\022\016\n\006reg" + + "ion\030\002 \001(\t\022\013\n\003idc\030\003 \001(\t\022\n\n\002ip\030\004 \001(\t\022\013\n\003pi" + + "d\030\005 \001(\t\022\013\n\003sys\030\006 \001(\t\022\020\n\010username\030\007 \001(\t\022\020" + + "\n\010password\030\010 \001(\t\022\017\n\007version\030\t \001(\t\022\020\n\010lan" + + "guage\030\n \001(\t\022\016\n\006seqNum\030\013 \001(\t\"\222\001\n\007Message\022" + + "/\n\006header\030\001 \001(\0132\037.eventmesh.client.Reque" + + "stHeader\022\027\n\017productionGroup\030\002 \001(\t\022\r\n\005top" + + "ic\030\003 \001(\t\022\017\n\007content\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020" + + "\n\010uniqueId\030\006 \001(\t\"O\n\010Response\022\020\n\010respCode" + + "\030\001 \001(\t\022\017\n\007respMsg\030\002 \001(\t\022\020\n\010respTime\030\003 \001(" + + "\t\022\016\n\006seqNum\030\004 \001(\t\"\356\001\n\014Subscription\022/\n\006he" + + "ader\030\001 \001(\0132\037.eventmesh.client.RequestHea" + + "der\022\025\n\rconsumerGroup\030\002 \001(\t\022J\n\021subscripti" + + "onItems\030\003 \003(\0132/.eventmesh.client.Subscri" + + "ption.SubscriptionItem\032J\n\020SubscriptionIt" + + "em\022\r\n\005topic\030\001 \001(\t\022\014\n\004mode\030\002 \001(\t\022\014\n\004type\030" + + "\003 \001(\t\022\013\n\003url\030\004 \001(\t\"\356\001\n\tHeartbeat\022/\n\006head" + + "er\030\001 \001(\0132\037.eventmesh.client.RequestHeade" + + "r\022\022\n\nclientType\030\002 \001(\t\022\025\n\rproducerGroup\030\003" + + " \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022A\n\016heartbeat" + + "Items\030\005 \003(\0132).eventmesh.client.Heartbeat" + + ".HeartbeatItem\032+\n\rHeartbeatItem\022\r\n\005topic" + + "\030\001 \001(\t\022\013\n\003url\030\002 \001(\t2\337\001\n\020PublisherService" + + "\022@\n\007publish\022\031.eventmesh.client.Message\032\032" + + ".eventmesh.client.Response\022E\n\014requestRep" + + "ly\022\031.eventmesh.client.Message\032\032.eventmes" + + "h.client.Response\022B\n\tbroadcast\022\031.eventme" + + "sh.client.Message\032\032.eventmesh.client.Res" + + "ponse2\365\001\n\017ConsumerService\022G\n\tsubscribe\022\036" + + ".eventmesh.client.Subscription\032\032.eventme" + + "sh.client.Response\022N\n\017subscribeStream\022\036." + + "eventmesh.client.Subscription\032\031.eventmes" + + "h.client.Message0\001\022I\n\013unsubscribe\022\036.even" + + "tmesh.client.Subscription\032\032.eventmesh.cl" + + "ient.Response2X\n\020HeartbeatService\022D\n\thea" + + "rtbeat\022\033.eventmesh.client.Heartbeat\032\032.ev" + + "entmesh.client.ResponseB<\n\'org.apache.ev" + + "entmesh.client.grpc.protosB\017EventmeshCli" + + "entP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + }, assigner); + internal_static_eventmesh_client_RequestHeader_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_eventmesh_client_RequestHeader_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_client_RequestHeader_descriptor, + new String[]{"Env", "Region", "Idc", "Ip", "Pid", "Sys", "Username", "Password", "Version", "Language", "SeqNum",}); + internal_static_eventmesh_client_Message_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_eventmesh_client_Message_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_client_Message_descriptor, + new String[]{"Header", "ProductionGroup", "Topic", "Content", "Ttl", "UniqueId",}); + internal_static_eventmesh_client_Response_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_eventmesh_client_Response_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_client_Response_descriptor, + new String[]{"RespCode", "RespMsg", "RespTime", "SeqNum",}); + internal_static_eventmesh_client_Subscription_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_eventmesh_client_Subscription_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_client_Subscription_descriptor, + new String[]{"Header", "ConsumerGroup", "SubscriptionItems",}); + internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor = + internal_static_eventmesh_client_Subscription_descriptor.getNestedTypes().get(0); + internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor, + new String[]{"Topic", "Mode", "Type", "Url",}); + internal_static_eventmesh_client_Heartbeat_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_eventmesh_client_Heartbeat_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_client_Heartbeat_descriptor, + new String[]{"Header", "ClientType", "ProducerGroup", "ConsumerGroup", "HeartbeatItems",}); + internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor = + internal_static_eventmesh_client_Heartbeat_descriptor.getNestedTypes().get(0); + internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor, + new String[]{"Topic", "Url",}); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java new file mode 100644 index 0000000000..f9927b7b81 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java @@ -0,0 +1,2117 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * Protobuf type {@code eventmesh.client.Heartbeat} + */ +public final class Heartbeat extends + com.google.protobuf.GeneratedMessageV3 implements + HeartbeatOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Heartbeat.newBuilder() to construct. + private Heartbeat(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Heartbeat() { + clientType_ = ""; + producerGroup_ = ""; + consumerGroup_ = ""; + heartbeatItems_ = java.util.Collections.emptyList(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + + private Heartbeat( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + clientType_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + producerGroup_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + consumerGroup_ = s; + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + heartbeatItems_.add( + input.readMessage(HeartbeatItem.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Heartbeat.class, Builder.class); + } + + public interface HeartbeatItemOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.client.Heartbeat.HeartbeatItem) + com.google.protobuf.MessageOrBuilder { + + /** + * string topic = 1; + */ + String getTopic(); + + /** + * string topic = 1; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * string url = 2; + */ + String getUrl(); + + /** + * string url = 2; + */ + com.google.protobuf.ByteString + getUrlBytes(); + } + + /** + * Protobuf type {@code eventmesh.client.Heartbeat.HeartbeatItem} + */ + public static final class HeartbeatItem extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.client.Heartbeat.HeartbeatItem) + HeartbeatItemOrBuilder { + private static final long serialVersionUID = 0L; + + // Use HeartbeatItem.newBuilder() to construct. + private HeartbeatItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private HeartbeatItem() { + topic_ = ""; + url_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + + private HeartbeatItem( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HeartbeatItem.class, Builder.class); + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile Object topic_; + + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int URL_FIELD_NUMBER = 2; + private volatile Object url_; + + /** + * string url = 2; + */ + public String getUrl() { + Object ref = url_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + + /** + * string url = 2; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); + } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, url_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); + } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, url_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof HeartbeatItem)) { + return super.equals(obj); + } + HeartbeatItem other = (HeartbeatItem) obj; + + boolean result = true; + result = result && getTopic() + .equals(other.getTopic()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static HeartbeatItem parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static HeartbeatItem parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static HeartbeatItem parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static HeartbeatItem parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static HeartbeatItem parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static HeartbeatItem parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static HeartbeatItem parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static HeartbeatItem 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 HeartbeatItem parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static HeartbeatItem 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 HeartbeatItem parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static HeartbeatItem parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(HeartbeatItem prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code eventmesh.client.Heartbeat.HeartbeatItem} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.client.Heartbeat.HeartbeatItem) + HeartbeatItemOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HeartbeatItem.class, Builder.class); + } + + // Construct using org.apache.eventmesh.client.grpc.protos.Heartbeat.HeartbeatItem.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + + public Builder clear() { + super.clear(); + topic_ = ""; + + url_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; + } + + public HeartbeatItem getDefaultInstanceForType() { + return HeartbeatItem.getDefaultInstance(); + } + + public HeartbeatItem build() { + HeartbeatItem result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public HeartbeatItem buildPartial() { + HeartbeatItem result = new HeartbeatItem(this); + result.topic_ = topic_; + result.url_ = url_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof HeartbeatItem) { + return mergeFrom((HeartbeatItem) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(HeartbeatItem other) { + if (other == HeartbeatItem.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + HeartbeatItem parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (HeartbeatItem) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object topic_ = ""; + + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string topic = 1; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + + /** + * string topic = 1; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + + /** + * string topic = 1; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private Object url_ = ""; + + /** + * string url = 2; + */ + public String getUrl() { + Object ref = url_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string url = 2; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string url = 2; + */ + public Builder setUrl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + + /** + * string url = 2; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + + /** + * string url = 2; + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } + + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.client.Heartbeat.HeartbeatItem) + } + + // @@protoc_insertion_point(class_scope:eventmesh.client.Heartbeat.HeartbeatItem) + private static final HeartbeatItem DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new HeartbeatItem(); + } + + public static HeartbeatItem getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HeartbeatItem parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HeartbeatItem(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public HeartbeatItem getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int CLIENTTYPE_FIELD_NUMBER = 2; + private volatile Object clientType_; + + /** + * string clientType = 2; + */ + public String getClientType() { + Object ref = clientType_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + clientType_ = s; + return s; + } + } + + /** + * string clientType = 2; + */ + public com.google.protobuf.ByteString + getClientTypeBytes() { + Object ref = clientType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + clientType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PRODUCERGROUP_FIELD_NUMBER = 3; + private volatile Object producerGroup_; + + /** + * string producerGroup = 3; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } + } + + /** + * string producerGroup = 3; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CONSUMERGROUP_FIELD_NUMBER = 4; + private volatile Object consumerGroup_; + + /** + * string consumerGroup = 4; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } + } + + /** + * string consumerGroup = 4; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int HEARTBEATITEMS_FIELD_NUMBER = 5; + private java.util.List heartbeatItems_; + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List getHeartbeatItemsList() { + return heartbeatItems_; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List + getHeartbeatItemsOrBuilderList() { + return heartbeatItems_; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public int getHeartbeatItemsCount() { + return heartbeatItems_.size(); + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem getHeartbeatItems(int index) { + return heartbeatItems_.get(index); + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( + int index) { + return heartbeatItems_.get(index); + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (!getClientTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, clientType_); + } + if (!getProducerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, producerGroup_); + } + if (!getConsumerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, consumerGroup_); + } + for (int i = 0; i < heartbeatItems_.size(); i++) { + output.writeMessage(5, heartbeatItems_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (!getClientTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, clientType_); + } + if (!getProducerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, producerGroup_); + } + if (!getConsumerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, consumerGroup_); + } + for (int i = 0; i < heartbeatItems_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, heartbeatItems_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Heartbeat)) { + return super.equals(obj); + } + Heartbeat other = (Heartbeat) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && getClientType() + .equals(other.getClientType()); + result = result && getProducerGroup() + .equals(other.getProducerGroup()); + result = result && getConsumerGroup() + .equals(other.getConsumerGroup()); + result = result && getHeartbeatItemsList() + .equals(other.getHeartbeatItemsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + CLIENTTYPE_FIELD_NUMBER; + hash = (53 * hash) + getClientType().hashCode(); + hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getProducerGroup().hashCode(); + hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getConsumerGroup().hashCode(); + if (getHeartbeatItemsCount() > 0) { + hash = (37 * hash) + HEARTBEATITEMS_FIELD_NUMBER; + hash = (53 * hash) + getHeartbeatItemsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Heartbeat parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Heartbeat parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Heartbeat parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Heartbeat parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Heartbeat parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Heartbeat parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Heartbeat parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static Heartbeat 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 Heartbeat parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static Heartbeat 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 Heartbeat parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static Heartbeat parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(Heartbeat prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code eventmesh.client.Heartbeat} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.client.Heartbeat) + HeartbeatOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Heartbeat.class, Builder.class); + } + + // Construct using org.apache.eventmesh.client.grpc.protos.Heartbeat.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getHeartbeatItemsFieldBuilder(); + } + } + + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + clientType_ = ""; + + producerGroup_ = ""; + + consumerGroup_ = ""; + + if (heartbeatItemsBuilder_ == null) { + heartbeatItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + heartbeatItemsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshClient.internal_static_eventmesh_client_Heartbeat_descriptor; + } + + public Heartbeat getDefaultInstanceForType() { + return Heartbeat.getDefaultInstance(); + } + + public Heartbeat build() { + Heartbeat result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Heartbeat buildPartial() { + Heartbeat result = new Heartbeat(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.clientType_ = clientType_; + result.producerGroup_ = producerGroup_; + result.consumerGroup_ = consumerGroup_; + if (heartbeatItemsBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.heartbeatItems_ = heartbeatItems_; + } else { + result.heartbeatItems_ = heartbeatItemsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Heartbeat) { + return mergeFrom((Heartbeat) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Heartbeat other) { + if (other == Heartbeat.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (!other.getClientType().isEmpty()) { + clientType_ = other.clientType_; + onChanged(); + } + if (!other.getProducerGroup().isEmpty()) { + producerGroup_ = other.producerGroup_; + onChanged(); + } + if (!other.getConsumerGroup().isEmpty()) { + consumerGroup_ = other.consumerGroup_; + onChanged(); + } + if (heartbeatItemsBuilder_ == null) { + if (!other.heartbeatItems_.isEmpty()) { + if (heartbeatItems_.isEmpty()) { + heartbeatItems_ = other.heartbeatItems_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.addAll(other.heartbeatItems_); + } + onChanged(); + } + } else { + if (!other.heartbeatItems_.isEmpty()) { + if (heartbeatItemsBuilder_.isEmpty()) { + heartbeatItemsBuilder_.dispose(); + heartbeatItemsBuilder_ = null; + heartbeatItems_ = other.heartbeatItems_; + bitField0_ = (bitField0_ & ~0x00000010); + heartbeatItemsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getHeartbeatItemsFieldBuilder() : null; + } else { + heartbeatItemsBuilder_.addAllMessages(other.heartbeatItems_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Heartbeat parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Heartbeat) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private Object clientType_ = ""; + + /** + * string clientType = 2; + */ + public String getClientType() { + Object ref = clientType_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + clientType_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string clientType = 2; + */ + public com.google.protobuf.ByteString + getClientTypeBytes() { + Object ref = clientType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + clientType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string clientType = 2; + */ + public Builder setClientType( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + clientType_ = value; + onChanged(); + return this; + } + + /** + * string clientType = 2; + */ + public Builder clearClientType() { + + clientType_ = getDefaultInstance().getClientType(); + onChanged(); + return this; + } + + /** + * string clientType = 2; + */ + public Builder setClientTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + clientType_ = value; + onChanged(); + return this; + } + + private Object producerGroup_ = ""; + + /** + * string producerGroup = 3; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string producerGroup = 3; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string producerGroup = 3; + */ + public Builder setProducerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + producerGroup_ = value; + onChanged(); + return this; + } + + /** + * string producerGroup = 3; + */ + public Builder clearProducerGroup() { + + producerGroup_ = getDefaultInstance().getProducerGroup(); + onChanged(); + return this; + } + + /** + * string producerGroup = 3; + */ + public Builder setProducerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + producerGroup_ = value; + onChanged(); + return this; + } + + private Object consumerGroup_ = ""; + + /** + * string consumerGroup = 4; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string consumerGroup = 4; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string consumerGroup = 4; + */ + public Builder setConsumerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + consumerGroup_ = value; + onChanged(); + return this; + } + + /** + * string consumerGroup = 4; + */ + public Builder clearConsumerGroup() { + + consumerGroup_ = getDefaultInstance().getConsumerGroup(); + onChanged(); + return this; + } + + /** + * string consumerGroup = 4; + */ + public Builder setConsumerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + consumerGroup_ = value; + onChanged(); + return this; + } + + private java.util.List heartbeatItems_ = + java.util.Collections.emptyList(); + + private void ensureHeartbeatItemsIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = new java.util.ArrayList(heartbeatItems_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> heartbeatItemsBuilder_; + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List getHeartbeatItemsList() { + if (heartbeatItemsBuilder_ == null) { + return java.util.Collections.unmodifiableList(heartbeatItems_); + } else { + return heartbeatItemsBuilder_.getMessageList(); + } + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public int getHeartbeatItemsCount() { + if (heartbeatItemsBuilder_ == null) { + return heartbeatItems_.size(); + } else { + return heartbeatItemsBuilder_.getCount(); + } + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem getHeartbeatItems(int index) { + if (heartbeatItemsBuilder_ == null) { + return heartbeatItems_.get(index); + } else { + return heartbeatItemsBuilder_.getMessage(index); + } + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder setHeartbeatItems( + int index, HeartbeatItem value) { + if (heartbeatItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.set(index, value); + onChanged(); + } else { + heartbeatItemsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder setHeartbeatItems( + int index, HeartbeatItem.Builder builderForValue) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.set(index, builderForValue.build()); + onChanged(); + } else { + heartbeatItemsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems(HeartbeatItem value) { + if (heartbeatItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(value); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems( + int index, HeartbeatItem value) { + if (heartbeatItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(index, value); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems( + HeartbeatItem.Builder builderForValue) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(builderForValue.build()); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems( + int index, HeartbeatItem.Builder builderForValue) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(index, builderForValue.build()); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addAllHeartbeatItems( + Iterable values) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, heartbeatItems_); + onChanged(); + } else { + heartbeatItemsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder clearHeartbeatItems() { + if (heartbeatItemsBuilder_ == null) { + heartbeatItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + heartbeatItemsBuilder_.clear(); + } + return this; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder removeHeartbeatItems(int index) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.remove(index); + onChanged(); + } else { + heartbeatItemsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem.Builder getHeartbeatItemsBuilder( + int index) { + return getHeartbeatItemsFieldBuilder().getBuilder(index); + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( + int index) { + if (heartbeatItemsBuilder_ == null) { + return heartbeatItems_.get(index); + } else { + return heartbeatItemsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List + getHeartbeatItemsOrBuilderList() { + if (heartbeatItemsBuilder_ != null) { + return heartbeatItemsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(heartbeatItems_); + } + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem.Builder addHeartbeatItemsBuilder() { + return getHeartbeatItemsFieldBuilder().addBuilder( + HeartbeatItem.getDefaultInstance()); + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem.Builder addHeartbeatItemsBuilder( + int index) { + return getHeartbeatItemsFieldBuilder().addBuilder( + index, HeartbeatItem.getDefaultInstance()); + } + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List + getHeartbeatItemsBuilderList() { + return getHeartbeatItemsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> + getHeartbeatItemsFieldBuilder() { + if (heartbeatItemsBuilder_ == null) { + heartbeatItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder>( + heartbeatItems_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + heartbeatItems_ = null; + } + return heartbeatItemsBuilder_; + } + + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.client.Heartbeat) + } + + // @@protoc_insertion_point(class_scope:eventmesh.client.Heartbeat) + private static final Heartbeat DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new Heartbeat(); + } + + public static Heartbeat getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Heartbeat parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Heartbeat(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Heartbeat getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java new file mode 100644 index 0000000000..ec67c09c33 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java @@ -0,0 +1,97 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * HeartbeatOrBuilder interface. + */ +public interface HeartbeatOrBuilder extends com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.client.RequestHeader header = 1. + */ + boolean hasHeader(); + + /** + * .eventmesh.client.RequestHeader header = 1. + */ + RequestHeader getHeader(); + + /** + * .eventmesh.client.RequestHeader header = 1. + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * string clientType = 2. + */ + String getClientType(); + + /** + * string clientType = 2. + */ + com.google.protobuf.ByteString getClientTypeBytes(); + + /** + * string producerGroup = 3. + */ + String getProducerGroup(); + + /** + * string producerGroup = 3. + */ + com.google.protobuf.ByteString getProducerGroupBytes(); + + /** + * string consumerGroup = 4. + */ + String getConsumerGroup(); + + /** + * string consumerGroup = 4. + */ + com.google.protobuf.ByteString getConsumerGroupBytes(); + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. + */ + java.util.List getHeartbeatItemsList(); + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. + */ + Heartbeat.HeartbeatItem getHeartbeatItems(int index); + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. + */ + int getHeartbeatItemsCount(); + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. + */ + java.util.List getHeartbeatItemsOrBuilderList(); + + /** + * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. + */ + Heartbeat.HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder(int index); +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java new file mode 100644 index 0000000000..40df4200ab --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java @@ -0,0 +1,302 @@ +/* + * 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.eventmesh.client.grpc.protos; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + * + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.15.0)", + comments = "Source: eventmesh-client.proto") +public final class HeartbeatServiceGrpc { + + private HeartbeatServiceGrpc() { + } + + public static final String SERVICE_NAME = "eventmesh.client.HeartbeatService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getHeartbeatMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "heartbeat", + requestType = org.apache.eventmesh.client.grpc.protos.Heartbeat.class, + responseType = org.apache.eventmesh.client.grpc.protos.Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getHeartbeatMethod() { + io.grpc.MethodDescriptor getHeartbeatMethod; + if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { + synchronized (HeartbeatServiceGrpc.class) { + if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { + HeartbeatServiceGrpc.getHeartbeatMethod = getHeartbeatMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.client.HeartbeatService", "heartbeat")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Heartbeat.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) + .setSchemaDescriptor(new HeartbeatServiceMethodDescriptorSupplier("heartbeat")) + .build(); + } + } + } + return getHeartbeatMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static HeartbeatServiceStub newStub(io.grpc.Channel channel) { + return new HeartbeatServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static HeartbeatServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new HeartbeatServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static HeartbeatServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new HeartbeatServiceFutureStub(channel); + } + + /** + * + */ + public static abstract class HeartbeatServiceImplBase implements io.grpc.BindableService { + + /** + * + */ + public void heartbeat(org.apache.eventmesh.client.grpc.protos.Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getHeartbeatMethod(), responseObserver); + } + + @Override + public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getHeartbeatMethod(), + asyncUnaryCall( + new MethodHandlers< + org.apache.eventmesh.client.grpc.protos.Heartbeat, + org.apache.eventmesh.client.grpc.protos.Response>( + this, METHODID_HEARTBEAT))) + .build(); + } + } + + /** + * + */ + public static final class HeartbeatServiceStub extends io.grpc.stub.AbstractStub { + private HeartbeatServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private HeartbeatServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected HeartbeatServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new HeartbeatServiceStub(channel, callOptions); + } + + /** + * + */ + public void heartbeat(org.apache.eventmesh.client.grpc.protos.Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + * + */ + public static final class HeartbeatServiceBlockingStub extends io.grpc.stub.AbstractStub { + private HeartbeatServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private HeartbeatServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected HeartbeatServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new HeartbeatServiceBlockingStub(channel, callOptions); + } + + /** + * + */ + public org.apache.eventmesh.client.grpc.protos.Response heartbeat(org.apache.eventmesh.client.grpc.protos.Heartbeat request) { + return blockingUnaryCall( + getChannel(), getHeartbeatMethod(), getCallOptions(), request); + } + } + + /** + * + */ + public static final class HeartbeatServiceFutureStub extends io.grpc.stub.AbstractStub { + private HeartbeatServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private HeartbeatServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected HeartbeatServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new HeartbeatServiceFutureStub(channel, callOptions); + } + + /** + * + */ + public com.google.common.util.concurrent.ListenableFuture heartbeat( + org.apache.eventmesh.client.grpc.protos.Heartbeat request) { + return futureUnaryCall( + getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_HEARTBEAT = 0; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final HeartbeatServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(HeartbeatServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_HEARTBEAT: + serviceImpl.heartbeat((org.apache.eventmesh.client.grpc.protos.Heartbeat) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class HeartbeatServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + HeartbeatServiceBaseDescriptorSupplier() { + } + + @Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.apache.eventmesh.client.grpc.protos.EventmeshClient.getDescriptor(); + } + + @Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("HeartbeatService"); + } + } + + private static final class HeartbeatServiceFileDescriptorSupplier + extends HeartbeatServiceBaseDescriptorSupplier { + HeartbeatServiceFileDescriptorSupplier() { + } + } + + private static final class HeartbeatServiceMethodDescriptorSupplier + extends HeartbeatServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + HeartbeatServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (HeartbeatServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new HeartbeatServiceFileDescriptorSupplier()) + .addMethod(getHeartbeatMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java new file mode 100644 index 0000000000..ecef2824ff --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java @@ -0,0 +1,1299 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * Protobuf type {@code eventmesh.client.Message} + */ +public final class Message extends + com.google.protobuf.GeneratedMessageV3 implements MessageOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Message.newBuilder() to construct. + private Message(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Message() { + productionGroup_ = ""; + topic_ = ""; + content_ = ""; + ttl_ = ""; + uniqueId_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + + private Message( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + productionGroup_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + content_ = s; + break; + } + case 42: { + String s = input.readStringRequireUtf8(); + + ttl_ = s; + break; + } + case 50: { + String s = input.readStringRequireUtf8(); + + uniqueId_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Message_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Message_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Message.class, Builder.class); + } + + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int PRODUCTIONGROUP_FIELD_NUMBER = 2; + private volatile Object productionGroup_; + + /** + * string productionGroup = 2; + */ + public String getProductionGroup() { + Object ref = productionGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + productionGroup_ = s; + return s; + } + } + + /** + * string productionGroup = 2; + */ + public com.google.protobuf.ByteString + getProductionGroupBytes() { + Object ref = productionGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + productionGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TOPIC_FIELD_NUMBER = 3; + private volatile Object topic_; + + /** + * string topic = 3; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + + /** + * string topic = 3; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CONTENT_FIELD_NUMBER = 4; + private volatile Object content_; + + /** + * string content = 4; + */ + public String getContent() { + Object ref = content_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } + } + + /** + * string content = 4; + */ + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TTL_FIELD_NUMBER = 5; + private volatile Object ttl_; + + /** + * string ttl = 5; + */ + public String getTtl() { + Object ref = ttl_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ttl_ = s; + return s; + } + } + + /** + * string ttl = 5; + */ + public com.google.protobuf.ByteString + getTtlBytes() { + Object ref = ttl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ttl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int UNIQUEID_FIELD_NUMBER = 6; + private volatile Object uniqueId_; + + /** + * string uniqueId = 6; + */ + public String getUniqueId() { + Object ref = uniqueId_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + uniqueId_ = s; + return s; + } + } + + /** + * string uniqueId = 6; + */ + public com.google.protobuf.ByteString + getUniqueIdBytes() { + Object ref = uniqueId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + uniqueId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (!getProductionGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, productionGroup_); + } + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, topic_); + } + if (!getContentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, content_); + } + if (!getTtlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, ttl_); + } + if (!getUniqueIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, uniqueId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (!getProductionGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, productionGroup_); + } + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, topic_); + } + if (!getContentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, content_); + } + if (!getTtlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, ttl_); + } + if (!getUniqueIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, uniqueId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Message)) { + return super.equals(obj); + } + Message other = (Message) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && getProductionGroup() + .equals(other.getProductionGroup()); + result = result && getTopic() + .equals(other.getTopic()); + result = result && getContent() + .equals(other.getContent()); + result = result && getTtl() + .equals(other.getTtl()); + result = result && getUniqueId() + .equals(other.getUniqueId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + PRODUCTIONGROUP_FIELD_NUMBER; + hash = (53 * hash) + getProductionGroup().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + CONTENT_FIELD_NUMBER; + hash = (53 * hash) + getContent().hashCode(); + hash = (37 * hash) + TTL_FIELD_NUMBER; + hash = (53 * hash) + getTtl().hashCode(); + hash = (37 * hash) + UNIQUEID_FIELD_NUMBER; + hash = (53 * hash) + getUniqueId().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Message parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Message parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Message parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Message parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Message parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Message parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Message parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static Message 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 Message parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static Message 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 Message parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static Message parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(Message prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code eventmesh.client.Message} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.client.Message) + MessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Message_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Message_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Message.class, Builder.class); + } + + // Construct using org.apache.eventmesh.client.grpc.protos.Message.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + productionGroup_ = ""; + + topic_ = ""; + + content_ = ""; + + ttl_ = ""; + + uniqueId_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshClient.internal_static_eventmesh_client_Message_descriptor; + } + + public Message getDefaultInstanceForType() { + return Message.getDefaultInstance(); + } + + public Message build() { + Message result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Message buildPartial() { + Message result = new Message(this); + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.productionGroup_ = productionGroup_; + result.topic_ = topic_; + result.content_ = content_; + result.ttl_ = ttl_; + result.uniqueId_ = uniqueId_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Message) { + return mergeFrom((Message) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Message other) { + if (other == Message.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (!other.getProductionGroup().isEmpty()) { + productionGroup_ = other.productionGroup_; + onChanged(); + } + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (!other.getContent().isEmpty()) { + content_ = other.content_; + onChanged(); + } + if (!other.getTtl().isEmpty()) { + ttl_ = other.ttl_; + onChanged(); + } + if (!other.getUniqueId().isEmpty()) { + uniqueId_ = other.uniqueId_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Message parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Message) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private Object productionGroup_ = ""; + + /** + * string productionGroup = 2; + */ + public String getProductionGroup() { + Object ref = productionGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + productionGroup_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string productionGroup = 2; + */ + public com.google.protobuf.ByteString + getProductionGroupBytes() { + Object ref = productionGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + productionGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string productionGroup = 2; + */ + public Builder setProductionGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + productionGroup_ = value; + onChanged(); + return this; + } + + /** + * string productionGroup = 2; + */ + public Builder clearProductionGroup() { + + productionGroup_ = getDefaultInstance().getProductionGroup(); + onChanged(); + return this; + } + + /** + * string productionGroup = 2; + */ + public Builder setProductionGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + productionGroup_ = value; + onChanged(); + return this; + } + + private Object topic_ = ""; + + /** + * string topic = 3; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string topic = 3; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string topic = 3; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + + /** + * string topic = 3; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + + /** + * string topic = 3; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private Object content_ = ""; + + /** + * string content = 4; + */ + public String getContent() { + Object ref = content_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string content = 4; + */ + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string content = 4; + */ + public Builder setContent( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + content_ = value; + onChanged(); + return this; + } + + /** + * string content = 4; + */ + public Builder clearContent() { + + content_ = getDefaultInstance().getContent(); + onChanged(); + return this; + } + + /** + * string content = 4; + */ + public Builder setContentBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + content_ = value; + onChanged(); + return this; + } + + private Object ttl_ = ""; + + /** + * string ttl = 5; + */ + public String getTtl() { + Object ref = ttl_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ttl_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string ttl = 5; + */ + public com.google.protobuf.ByteString + getTtlBytes() { + Object ref = ttl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ttl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string ttl = 5; + */ + public Builder setTtl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + ttl_ = value; + onChanged(); + return this; + } + + /** + * string ttl = 5; + */ + public Builder clearTtl() { + + ttl_ = getDefaultInstance().getTtl(); + onChanged(); + return this; + } + + /** + * string ttl = 5; + */ + public Builder setTtlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + ttl_ = value; + onChanged(); + return this; + } + + private Object uniqueId_ = ""; + + /** + * string uniqueId = 6; + */ + public String getUniqueId() { + Object ref = uniqueId_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + uniqueId_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string uniqueId = 6; + */ + public com.google.protobuf.ByteString + getUniqueIdBytes() { + Object ref = uniqueId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + uniqueId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string uniqueId = 6; + */ + public Builder setUniqueId( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + uniqueId_ = value; + onChanged(); + return this; + } + + /** + * string uniqueId = 6; + */ + public Builder clearUniqueId() { + + uniqueId_ = getDefaultInstance().getUniqueId(); + onChanged(); + return this; + } + + /** + * string uniqueId = 6; + */ + public Builder setUniqueIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + uniqueId_ = value; + onChanged(); + return this; + } + + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.client.Message) + } + + // @@protoc_insertion_point(class_scope:eventmesh.client.Message) + private static final Message DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new Message(); + } + + public static Message getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Message parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Message(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Message getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java new file mode 100644 index 0000000000..05dfb84241 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java @@ -0,0 +1,92 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * MessageOrBuilder interface. + */ +public interface MessageOrBuilder extends com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.client.RequestHeader header = 1. + */ + boolean hasHeader(); + + /** + * .eventmesh.client.RequestHeader header = 1. + */ + RequestHeader getHeader(); + + /** + * .eventmesh.client.RequestHeader header = 1. + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * string productionGroup = 2. + */ + String getProductionGroup(); + + /** + * string productionGroup = 2. + */ + com.google.protobuf.ByteString getProductionGroupBytes(); + + /** + * string topic = 3. + */ + String getTopic(); + + /** + * string topic = 3. + */ + com.google.protobuf.ByteString getTopicBytes(); + + /** + * string content = 4. + */ + String getContent(); + + /** + * string content = 4. + */ + com.google.protobuf.ByteString getContentBytes(); + + /** + * string ttl = 5. + */ + String getTtl(); + + /** + * string ttl = 5. + */ + com.google.protobuf.ByteString getTtlBytes(); + + /** + * string uniqueId = 6. + */ + String getUniqueId(); + + /** + * string uniqueId = 6. + */ + com.google.protobuf.ByteString getUniqueIdBytes(); +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java new file mode 100644 index 0000000000..d075d8fe4b --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java @@ -0,0 +1,460 @@ +/* + * 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.eventmesh.client.grpc.protos; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + * + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.15.0)", + comments = "Source: eventmesh-client.proto") +public final class PublisherServiceGrpc { + + private PublisherServiceGrpc() { + } + + public static final String SERVICE_NAME = "eventmesh.client.PublisherService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getPublishMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "publish", + requestType = org.apache.eventmesh.client.grpc.protos.Message.class, + responseType = org.apache.eventmesh.client.grpc.protos.Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getPublishMethod() { + io.grpc.MethodDescriptor getPublishMethod; + if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { + PublisherServiceGrpc.getPublishMethod = getPublishMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.client.PublisherService", "publish")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("publish")) + .build(); + } + } + } + return getPublishMethod; + } + + private static volatile io.grpc.MethodDescriptor getRequestReplyMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "requestReply", + requestType = org.apache.eventmesh.client.grpc.protos.Message.class, + responseType = org.apache.eventmesh.client.grpc.protos.Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getRequestReplyMethod() { + io.grpc.MethodDescriptor getRequestReplyMethod; + if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { + PublisherServiceGrpc.getRequestReplyMethod = getRequestReplyMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.client.PublisherService", "requestReply")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("requestReply")) + .build(); + } + } + } + return getRequestReplyMethod; + } + + private static volatile io.grpc.MethodDescriptor getBroadcastMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "broadcast", + requestType = org.apache.eventmesh.client.grpc.protos.Message.class, + responseType = org.apache.eventmesh.client.grpc.protos.Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getBroadcastMethod() { + io.grpc.MethodDescriptor getBroadcastMethod; + if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { + PublisherServiceGrpc.getBroadcastMethod = getBroadcastMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.client.PublisherService", "broadcast")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("broadcast")) + .build(); + } + } + } + return getBroadcastMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static PublisherServiceStub newStub(io.grpc.Channel channel) { + return new PublisherServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static PublisherServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new PublisherServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static PublisherServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new PublisherServiceFutureStub(channel); + } + + /** + * + */ + public static abstract class PublisherServiceImplBase implements io.grpc.BindableService { + + /** + * + */ + public void publish(org.apache.eventmesh.client.grpc.protos.Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getPublishMethod(), responseObserver); + } + + /** + * + */ + public void requestReply(org.apache.eventmesh.client.grpc.protos.Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getRequestReplyMethod(), responseObserver); + } + + /** + * + */ + public void broadcast(org.apache.eventmesh.client.grpc.protos.Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getBroadcastMethod(), responseObserver); + } + + @Override + public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getPublishMethod(), + asyncUnaryCall( + new MethodHandlers< + org.apache.eventmesh.client.grpc.protos.Message, + org.apache.eventmesh.client.grpc.protos.Response>( + this, METHODID_PUBLISH))) + .addMethod( + getRequestReplyMethod(), + asyncUnaryCall( + new MethodHandlers< + org.apache.eventmesh.client.grpc.protos.Message, + org.apache.eventmesh.client.grpc.protos.Response>( + this, METHODID_REQUEST_REPLY))) + .addMethod( + getBroadcastMethod(), + asyncUnaryCall( + new MethodHandlers< + org.apache.eventmesh.client.grpc.protos.Message, + org.apache.eventmesh.client.grpc.protos.Response>( + this, METHODID_BROADCAST))) + .build(); + } + } + + /** + * + */ + public static final class PublisherServiceStub extends io.grpc.stub.AbstractStub { + private PublisherServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected PublisherServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherServiceStub(channel, callOptions); + } + + /** + * + */ + public void publish(org.apache.eventmesh.client.grpc.protos.Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getPublishMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + */ + public void requestReply(org.apache.eventmesh.client.grpc.protos.Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + */ + public void broadcast(org.apache.eventmesh.client.grpc.protos.Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getBroadcastMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + * + */ + public static final class PublisherServiceBlockingStub extends io.grpc.stub.AbstractStub { + private PublisherServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected PublisherServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherServiceBlockingStub(channel, callOptions); + } + + /** + * + */ + public org.apache.eventmesh.client.grpc.protos.Response publish(org.apache.eventmesh.client.grpc.protos.Message request) { + return blockingUnaryCall( + getChannel(), getPublishMethod(), getCallOptions(), request); + } + + /** + * + */ + public org.apache.eventmesh.client.grpc.protos.Response requestReply(org.apache.eventmesh.client.grpc.protos.Message request) { + return blockingUnaryCall( + getChannel(), getRequestReplyMethod(), getCallOptions(), request); + } + + /** + * + */ + public org.apache.eventmesh.client.grpc.protos.Response broadcast(org.apache.eventmesh.client.grpc.protos.Message request) { + return blockingUnaryCall( + getChannel(), getBroadcastMethod(), getCallOptions(), request); + } + } + + /** + * + */ + public static final class PublisherServiceFutureStub extends io.grpc.stub.AbstractStub { + private PublisherServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected PublisherServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherServiceFutureStub(channel, callOptions); + } + + /** + * + */ + public com.google.common.util.concurrent.ListenableFuture publish( + org.apache.eventmesh.client.grpc.protos.Message request) { + return futureUnaryCall( + getChannel().newCall(getPublishMethod(), getCallOptions()), request); + } + + /** + * + */ + public com.google.common.util.concurrent.ListenableFuture requestReply( + org.apache.eventmesh.client.grpc.protos.Message request) { + return futureUnaryCall( + getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request); + } + + /** + * + */ + public com.google.common.util.concurrent.ListenableFuture broadcast( + org.apache.eventmesh.client.grpc.protos.Message request) { + return futureUnaryCall( + getChannel().newCall(getBroadcastMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_PUBLISH = 0; + private static final int METHODID_REQUEST_REPLY = 1; + private static final int METHODID_BROADCAST = 2; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final PublisherServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(PublisherServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_PUBLISH: + serviceImpl.publish((org.apache.eventmesh.client.grpc.protos.Message) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_REQUEST_REPLY: + serviceImpl.requestReply((org.apache.eventmesh.client.grpc.protos.Message) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_BROADCAST: + serviceImpl.broadcast((org.apache.eventmesh.client.grpc.protos.Message) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class PublisherServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + PublisherServiceBaseDescriptorSupplier() { + } + + @Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.apache.eventmesh.client.grpc.protos.EventmeshClient.getDescriptor(); + } + + @Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("PublisherService"); + } + } + + private static final class PublisherServiceFileDescriptorSupplier + extends PublisherServiceBaseDescriptorSupplier { + PublisherServiceFileDescriptorSupplier() { + } + } + + private static final class PublisherServiceMethodDescriptorSupplier + extends PublisherServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + PublisherServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (PublisherServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new PublisherServiceFileDescriptorSupplier()) + .addMethod(getPublishMethod()) + .addMethod(getRequestReplyMethod()) + .addMethod(getBroadcastMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java new file mode 100644 index 0000000000..ed21ed8d35 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java @@ -0,0 +1,1910 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * Protobuf type {@code eventmesh.client.RequestHeader} + */ +public final class RequestHeader extends + com.google.protobuf.GeneratedMessageV3 implements RequestHeaderOrBuilder { + private static final long serialVersionUID = 0L; + + // Use RequestHeader.newBuilder() to construct. + private RequestHeader(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RequestHeader() { + env_ = ""; + region_ = ""; + idc_ = ""; + ip_ = ""; + pid_ = ""; + sys_ = ""; + username_ = ""; + password_ = ""; + version_ = ""; + language_ = ""; + seqNum_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + + private RequestHeader( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + env_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + region_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + idc_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + ip_ = s; + break; + } + case 42: { + String s = input.readStringRequireUtf8(); + + pid_ = s; + break; + } + case 50: { + String s = input.readStringRequireUtf8(); + + sys_ = s; + break; + } + case 58: { + String s = input.readStringRequireUtf8(); + + username_ = s; + break; + } + case 66: { + String s = input.readStringRequireUtf8(); + + password_ = s; + break; + } + case 74: { + String s = input.readStringRequireUtf8(); + + version_ = s; + break; + } + case 82: { + String s = input.readStringRequireUtf8(); + + language_ = s; + break; + } + case 90: { + String s = input.readStringRequireUtf8(); + + seqNum_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_RequestHeader_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_RequestHeader_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RequestHeader.class, Builder.class); + } + + public static final int ENV_FIELD_NUMBER = 1; + private volatile Object env_; + + /** + * string env = 1; + */ + public String getEnv() { + Object ref = env_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + env_ = s; + return s; + } + } + + /** + * string env = 1; + */ + public com.google.protobuf.ByteString + getEnvBytes() { + Object ref = env_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + env_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REGION_FIELD_NUMBER = 2; + private volatile Object region_; + + /** + * string region = 2; + */ + public String getRegion() { + Object ref = region_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + region_ = s; + return s; + } + } + + /** + * string region = 2; + */ + public com.google.protobuf.ByteString + getRegionBytes() { + Object ref = region_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + region_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int IDC_FIELD_NUMBER = 3; + private volatile Object idc_; + + /** + * string idc = 3; + */ + public String getIdc() { + Object ref = idc_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + idc_ = s; + return s; + } + } + + /** + * string idc = 3; + */ + public com.google.protobuf.ByteString + getIdcBytes() { + Object ref = idc_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + idc_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int IP_FIELD_NUMBER = 4; + private volatile Object ip_; + + /** + * string ip = 4; + */ + public String getIp() { + Object ref = ip_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ip_ = s; + return s; + } + } + + /** + * string ip = 4; + */ + public com.google.protobuf.ByteString + getIpBytes() { + Object ref = ip_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ip_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PID_FIELD_NUMBER = 5; + private volatile Object pid_; + + /** + * string pid = 5; + */ + public String getPid() { + Object ref = pid_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + pid_ = s; + return s; + } + } + + /** + * string pid = 5; + */ + public com.google.protobuf.ByteString + getPidBytes() { + Object ref = pid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + pid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SYS_FIELD_NUMBER = 6; + private volatile Object sys_; + + /** + * string sys = 6; + */ + public String getSys() { + Object ref = sys_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + sys_ = s; + return s; + } + } + + /** + * string sys = 6; + */ + public com.google.protobuf.ByteString + getSysBytes() { + Object ref = sys_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + sys_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int USERNAME_FIELD_NUMBER = 7; + private volatile Object username_; + + /** + * string username = 7; + */ + public String getUsername() { + Object ref = username_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + username_ = s; + return s; + } + } + + /** + * string username = 7; + */ + public com.google.protobuf.ByteString + getUsernameBytes() { + Object ref = username_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PASSWORD_FIELD_NUMBER = 8; + private volatile Object password_; + + /** + * string password = 8; + */ + public String getPassword() { + Object ref = password_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + password_ = s; + return s; + } + } + + /** + * string password = 8; + */ + public com.google.protobuf.ByteString + getPasswordBytes() { + Object ref = password_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VERSION_FIELD_NUMBER = 9; + private volatile Object version_; + + /** + * string version = 9; + */ + public String getVersion() { + Object ref = version_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + version_ = s; + return s; + } + } + + /** + * string version = 9; + */ + public com.google.protobuf.ByteString + getVersionBytes() { + Object ref = version_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + version_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LANGUAGE_FIELD_NUMBER = 10; + private volatile Object language_; + + /** + * string language = 10; + */ + public String getLanguage() { + Object ref = language_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + language_ = s; + return s; + } + } + + /** + * string language = 10; + */ + public com.google.protobuf.ByteString + getLanguageBytes() { + Object ref = language_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SEQNUM_FIELD_NUMBER = 11; + private volatile Object seqNum_; + + /** + * string seqNum = 11; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } + } + + /** + * string seqNum = 11; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getEnvBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, env_); + } + if (!getRegionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, region_); + } + if (!getIdcBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, idc_); + } + if (!getIpBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, ip_); + } + if (!getPidBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, pid_); + } + if (!getSysBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, sys_); + } + if (!getUsernameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, username_); + } + if (!getPasswordBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, password_); + } + if (!getVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, version_); + } + if (!getLanguageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, language_); + } + if (!getSeqNumBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 11, seqNum_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getEnvBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, env_); + } + if (!getRegionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, region_); + } + if (!getIdcBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, idc_); + } + if (!getIpBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, ip_); + } + if (!getPidBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, pid_); + } + if (!getSysBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, sys_); + } + if (!getUsernameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, username_); + } + if (!getPasswordBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, password_); + } + if (!getVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, version_); + } + if (!getLanguageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, language_); + } + if (!getSeqNumBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, seqNum_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof RequestHeader)) { + return super.equals(obj); + } + RequestHeader other = (RequestHeader) obj; + + boolean result = true; + result = result && getEnv() + .equals(other.getEnv()); + result = result && getRegion() + .equals(other.getRegion()); + result = result && getIdc() + .equals(other.getIdc()); + result = result && getIp() + .equals(other.getIp()); + result = result && getPid() + .equals(other.getPid()); + result = result && getSys() + .equals(other.getSys()); + result = result && getUsername() + .equals(other.getUsername()); + result = result && getPassword() + .equals(other.getPassword()); + result = result && getVersion() + .equals(other.getVersion()); + result = result && getLanguage() + .equals(other.getLanguage()); + result = result && getSeqNum() + .equals(other.getSeqNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENV_FIELD_NUMBER; + hash = (53 * hash) + getEnv().hashCode(); + hash = (37 * hash) + REGION_FIELD_NUMBER; + hash = (53 * hash) + getRegion().hashCode(); + hash = (37 * hash) + IDC_FIELD_NUMBER; + hash = (53 * hash) + getIdc().hashCode(); + hash = (37 * hash) + IP_FIELD_NUMBER; + hash = (53 * hash) + getIp().hashCode(); + hash = (37 * hash) + PID_FIELD_NUMBER; + hash = (53 * hash) + getPid().hashCode(); + hash = (37 * hash) + SYS_FIELD_NUMBER; + hash = (53 * hash) + getSys().hashCode(); + hash = (37 * hash) + USERNAME_FIELD_NUMBER; + hash = (53 * hash) + getUsername().hashCode(); + hash = (37 * hash) + PASSWORD_FIELD_NUMBER; + hash = (53 * hash) + getPassword().hashCode(); + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + getVersion().hashCode(); + hash = (37 * hash) + LANGUAGE_FIELD_NUMBER; + hash = (53 * hash) + getLanguage().hashCode(); + hash = (37 * hash) + SEQNUM_FIELD_NUMBER; + hash = (53 * hash) + getSeqNum().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static RequestHeader parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static RequestHeader parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static RequestHeader parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static RequestHeader parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static RequestHeader parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static RequestHeader parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static RequestHeader parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static RequestHeader 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 RequestHeader parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static RequestHeader 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 RequestHeader parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static RequestHeader parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(RequestHeader prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code eventmesh.client.RequestHeader} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.client.RequestHeader) + RequestHeaderOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_RequestHeader_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_RequestHeader_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RequestHeader.class, Builder.class); + } + + // Construct using org.apache.eventmesh.client.grpc.protos.RequestHeader.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + + public Builder clear() { + super.clear(); + env_ = ""; + + region_ = ""; + + idc_ = ""; + + ip_ = ""; + + pid_ = ""; + + sys_ = ""; + + username_ = ""; + + password_ = ""; + + version_ = ""; + + language_ = ""; + + seqNum_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshClient.internal_static_eventmesh_client_RequestHeader_descriptor; + } + + public RequestHeader getDefaultInstanceForType() { + return RequestHeader.getDefaultInstance(); + } + + public RequestHeader build() { + RequestHeader result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public RequestHeader buildPartial() { + RequestHeader result = new RequestHeader(this); + result.env_ = env_; + result.region_ = region_; + result.idc_ = idc_; + result.ip_ = ip_; + result.pid_ = pid_; + result.sys_ = sys_; + result.username_ = username_; + result.password_ = password_; + result.version_ = version_; + result.language_ = language_; + result.seqNum_ = seqNum_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof RequestHeader) { + return mergeFrom((RequestHeader) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(RequestHeader other) { + if (other == RequestHeader.getDefaultInstance()) return this; + if (!other.getEnv().isEmpty()) { + env_ = other.env_; + onChanged(); + } + if (!other.getRegion().isEmpty()) { + region_ = other.region_; + onChanged(); + } + if (!other.getIdc().isEmpty()) { + idc_ = other.idc_; + onChanged(); + } + if (!other.getIp().isEmpty()) { + ip_ = other.ip_; + onChanged(); + } + if (!other.getPid().isEmpty()) { + pid_ = other.pid_; + onChanged(); + } + if (!other.getSys().isEmpty()) { + sys_ = other.sys_; + onChanged(); + } + if (!other.getUsername().isEmpty()) { + username_ = other.username_; + onChanged(); + } + if (!other.getPassword().isEmpty()) { + password_ = other.password_; + onChanged(); + } + if (!other.getVersion().isEmpty()) { + version_ = other.version_; + onChanged(); + } + if (!other.getLanguage().isEmpty()) { + language_ = other.language_; + onChanged(); + } + if (!other.getSeqNum().isEmpty()) { + seqNum_ = other.seqNum_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + RequestHeader parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (RequestHeader) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object env_ = ""; + + /** + * string env = 1; + */ + public String getEnv() { + Object ref = env_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + env_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string env = 1; + */ + public com.google.protobuf.ByteString + getEnvBytes() { + Object ref = env_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + env_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string env = 1; + */ + public Builder setEnv( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + env_ = value; + onChanged(); + return this; + } + + /** + * string env = 1; + */ + public Builder clearEnv() { + + env_ = getDefaultInstance().getEnv(); + onChanged(); + return this; + } + + /** + * string env = 1; + */ + public Builder setEnvBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + env_ = value; + onChanged(); + return this; + } + + private Object region_ = ""; + + /** + * string region = 2; + */ + public String getRegion() { + Object ref = region_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + region_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string region = 2; + */ + public com.google.protobuf.ByteString + getRegionBytes() { + Object ref = region_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + region_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string region = 2; + */ + public Builder setRegion( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + region_ = value; + onChanged(); + return this; + } + + /** + * string region = 2; + */ + public Builder clearRegion() { + + region_ = getDefaultInstance().getRegion(); + onChanged(); + return this; + } + + /** + * string region = 2; + */ + public Builder setRegionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + region_ = value; + onChanged(); + return this; + } + + private Object idc_ = ""; + + /** + * string idc = 3; + */ + public String getIdc() { + Object ref = idc_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + idc_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string idc = 3; + */ + public com.google.protobuf.ByteString + getIdcBytes() { + Object ref = idc_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + idc_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string idc = 3; + */ + public Builder setIdc( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + idc_ = value; + onChanged(); + return this; + } + + /** + * string idc = 3; + */ + public Builder clearIdc() { + + idc_ = getDefaultInstance().getIdc(); + onChanged(); + return this; + } + + /** + * string idc = 3; + */ + public Builder setIdcBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + idc_ = value; + onChanged(); + return this; + } + + private Object ip_ = ""; + + /** + * string ip = 4; + */ + public String getIp() { + Object ref = ip_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ip_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string ip = 4; + */ + public com.google.protobuf.ByteString + getIpBytes() { + Object ref = ip_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ip_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string ip = 4; + */ + public Builder setIp( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + ip_ = value; + onChanged(); + return this; + } + + /** + * string ip = 4; + */ + public Builder clearIp() { + + ip_ = getDefaultInstance().getIp(); + onChanged(); + return this; + } + + /** + * string ip = 4; + */ + public Builder setIpBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + ip_ = value; + onChanged(); + return this; + } + + private Object pid_ = ""; + + /** + * string pid = 5; + */ + public String getPid() { + Object ref = pid_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + pid_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string pid = 5; + */ + public com.google.protobuf.ByteString + getPidBytes() { + Object ref = pid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + pid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string pid = 5; + */ + public Builder setPid( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + pid_ = value; + onChanged(); + return this; + } + + /** + * string pid = 5; + */ + public Builder clearPid() { + + pid_ = getDefaultInstance().getPid(); + onChanged(); + return this; + } + + /** + * string pid = 5; + */ + public Builder setPidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pid_ = value; + onChanged(); + return this; + } + + private Object sys_ = ""; + + /** + * string sys = 6; + */ + public String getSys() { + Object ref = sys_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + sys_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string sys = 6; + */ + public com.google.protobuf.ByteString + getSysBytes() { + Object ref = sys_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + sys_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string sys = 6; + */ + public Builder setSys( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + sys_ = value; + onChanged(); + return this; + } + + /** + * string sys = 6; + */ + public Builder clearSys() { + + sys_ = getDefaultInstance().getSys(); + onChanged(); + return this; + } + + /** + * string sys = 6; + */ + public Builder setSysBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + sys_ = value; + onChanged(); + return this; + } + + private Object username_ = ""; + + /** + * string username = 7; + */ + public String getUsername() { + Object ref = username_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + username_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string username = 7; + */ + public com.google.protobuf.ByteString + getUsernameBytes() { + Object ref = username_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string username = 7; + */ + public Builder setUsername( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + username_ = value; + onChanged(); + return this; + } + + /** + * string username = 7; + */ + public Builder clearUsername() { + + username_ = getDefaultInstance().getUsername(); + onChanged(); + return this; + } + + /** + * string username = 7; + */ + public Builder setUsernameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + username_ = value; + onChanged(); + return this; + } + + private Object password_ = ""; + + /** + * string password = 8; + */ + public String getPassword() { + Object ref = password_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + password_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string password = 8; + */ + public com.google.protobuf.ByteString + getPasswordBytes() { + Object ref = password_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string password = 8; + */ + public Builder setPassword( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + password_ = value; + onChanged(); + return this; + } + + /** + * string password = 8; + */ + public Builder clearPassword() { + + password_ = getDefaultInstance().getPassword(); + onChanged(); + return this; + } + + /** + * string password = 8; + */ + public Builder setPasswordBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + password_ = value; + onChanged(); + return this; + } + + private Object version_ = ""; + + /** + * string version = 9; + */ + public String getVersion() { + Object ref = version_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + version_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string version = 9; + */ + public com.google.protobuf.ByteString + getVersionBytes() { + Object ref = version_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + version_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string version = 9; + */ + public Builder setVersion( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + version_ = value; + onChanged(); + return this; + } + + /** + * string version = 9; + */ + public Builder clearVersion() { + + version_ = getDefaultInstance().getVersion(); + onChanged(); + return this; + } + + /** + * string version = 9; + */ + public Builder setVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + version_ = value; + onChanged(); + return this; + } + + private Object language_ = ""; + + /** + * string language = 10; + */ + public String getLanguage() { + Object ref = language_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + language_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string language = 10; + */ + public com.google.protobuf.ByteString + getLanguageBytes() { + Object ref = language_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string language = 10; + */ + public Builder setLanguage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + language_ = value; + onChanged(); + return this; + } + + /** + * string language = 10; + */ + public Builder clearLanguage() { + + language_ = getDefaultInstance().getLanguage(); + onChanged(); + return this; + } + + /** + * string language = 10; + */ + public Builder setLanguageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + language_ = value; + onChanged(); + return this; + } + + private Object seqNum_ = ""; + + /** + * string seqNum = 11; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string seqNum = 11; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string seqNum = 11; + */ + public Builder setSeqNum( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + seqNum_ = value; + onChanged(); + return this; + } + + /** + * string seqNum = 11; + */ + public Builder clearSeqNum() { + + seqNum_ = getDefaultInstance().getSeqNum(); + onChanged(); + return this; + } + + /** + * string seqNum = 11; + */ + public Builder setSeqNumBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + seqNum_ = value; + onChanged(); + return this; + } + + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.client.RequestHeader) + } + + // @@protoc_insertion_point(class_scope:eventmesh.client.RequestHeader) + private static final RequestHeader DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new RequestHeader(); + } + + public static RequestHeader getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public RequestHeader parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RequestHeader(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public RequestHeader getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java new file mode 100644 index 0000000000..a112bfa22a --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java @@ -0,0 +1,137 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * RequestHeaderOrBuilder interface. + */ +public interface RequestHeaderOrBuilder extends com.google.protobuf.MessageOrBuilder { + + /** + * string env = 1. + */ + String getEnv(); + + /** + * string env = 1. + */ + com.google.protobuf.ByteString getEnvBytes(); + + /** + * string region = 2. + */ + String getRegion(); + + /** + * string region = 2. + */ + com.google.protobuf.ByteString getRegionBytes(); + + /** + * string idc = 3. + */ + String getIdc(); + + /** + * string idc = 3. + */ + com.google.protobuf.ByteString getIdcBytes(); + + /** + * string ip = 4. + */ + String getIp(); + + /** + * string ip = 4. + */ + com.google.protobuf.ByteString getIpBytes(); + + /** + * string pid = 5. + */ + String getPid(); + + /** + * string pid = 5. + */ + com.google.protobuf.ByteString getPidBytes(); + + /** + * string sys = 6. + */ + String getSys(); + + /** + * string sys = 6. + */ + com.google.protobuf.ByteString getSysBytes(); + + /** + * string username = 7. + */ + String getUsername(); + + /** + * string username = 7. + */ + com.google.protobuf.ByteString getUsernameBytes(); + + /** + * string password = 8. + */ + String getPassword(); + + /** + * string password = 8. + */ + com.google.protobuf.ByteString getPasswordBytes(); + + /** + * string version = 9. + */ + String getVersion(); + + /** + * string version = 9. + */ + com.google.protobuf.ByteString getVersionBytes(); + + /** + * string language = 10. + */ + String getLanguage(); + + /** + * string language = 10. + */ + com.google.protobuf.ByteString getLanguageBytes(); + + /** + * string seqNum = 11. + */ + String getSeqNum(); + + /** + * string seqNum = 11. + */ + com.google.protobuf.ByteString getSeqNumBytes(); +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java new file mode 100644 index 0000000000..b54fc330c8 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java @@ -0,0 +1,972 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * Protobuf type {@code eventmesh.client.Response} + */ +public final class Response extends + com.google.protobuf.GeneratedMessageV3 implements ResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Response.newBuilder() to construct. + private Response(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Response() { + respCode_ = ""; + respMsg_ = ""; + respTime_ = ""; + seqNum_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + + private Response( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + respCode_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + respMsg_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + respTime_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + seqNum_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Response_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Response_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Response.class, Builder.class); + } + + public static final int RESPCODE_FIELD_NUMBER = 1; + private volatile Object respCode_; + + /** + * string respCode = 1; + */ + public String getRespCode() { + Object ref = respCode_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respCode_ = s; + return s; + } + } + + /** + * string respCode = 1; + */ + public com.google.protobuf.ByteString + getRespCodeBytes() { + Object ref = respCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESPMSG_FIELD_NUMBER = 2; + private volatile Object respMsg_; + + /** + * string respMsg = 2; + */ + public String getRespMsg() { + Object ref = respMsg_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respMsg_ = s; + return s; + } + } + + /** + * string respMsg = 2; + */ + public com.google.protobuf.ByteString + getRespMsgBytes() { + Object ref = respMsg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respMsg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESPTIME_FIELD_NUMBER = 3; + private volatile Object respTime_; + + /** + * string respTime = 3; + */ + public String getRespTime() { + Object ref = respTime_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respTime_ = s; + return s; + } + } + + /** + * string respTime = 3; + */ + public com.google.protobuf.ByteString + getRespTimeBytes() { + Object ref = respTime_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respTime_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SEQNUM_FIELD_NUMBER = 4; + private volatile Object seqNum_; + + /** + * string seqNum = 4; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } + } + + /** + * string seqNum = 4; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRespCodeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, respCode_); + } + if (!getRespMsgBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, respMsg_); + } + if (!getRespTimeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, respTime_); + } + if (!getSeqNumBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, seqNum_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRespCodeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, respCode_); + } + if (!getRespMsgBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, respMsg_); + } + if (!getRespTimeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, respTime_); + } + if (!getSeqNumBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, seqNum_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Response)) { + return super.equals(obj); + } + Response other = (Response) obj; + + boolean result = true; + result = result && getRespCode() + .equals(other.getRespCode()); + result = result && getRespMsg() + .equals(other.getRespMsg()); + result = result && getRespTime() + .equals(other.getRespTime()); + result = result && getSeqNum() + .equals(other.getSeqNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESPCODE_FIELD_NUMBER; + hash = (53 * hash) + getRespCode().hashCode(); + hash = (37 * hash) + RESPMSG_FIELD_NUMBER; + hash = (53 * hash) + getRespMsg().hashCode(); + hash = (37 * hash) + RESPTIME_FIELD_NUMBER; + hash = (53 * hash) + getRespTime().hashCode(); + hash = (37 * hash) + SEQNUM_FIELD_NUMBER; + hash = (53 * hash) + getSeqNum().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Response parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Response parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Response parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Response parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Response parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Response parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Response parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static Response 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 Response parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static Response 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 Response parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static Response parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(Response prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code eventmesh.client.Response} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.client.Response) + ResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Response_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Response_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Response.class, Builder.class); + } + + // Construct using org.apache.eventmesh.client.grpc.protos.Response.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + + public Builder clear() { + super.clear(); + respCode_ = ""; + + respMsg_ = ""; + + respTime_ = ""; + + seqNum_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshClient.internal_static_eventmesh_client_Response_descriptor; + } + + public Response getDefaultInstanceForType() { + return Response.getDefaultInstance(); + } + + public Response build() { + Response result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Response buildPartial() { + Response result = new Response(this); + result.respCode_ = respCode_; + result.respMsg_ = respMsg_; + result.respTime_ = respTime_; + result.seqNum_ = seqNum_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Response) { + return mergeFrom((Response) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Response other) { + if (other == Response.getDefaultInstance()) return this; + if (!other.getRespCode().isEmpty()) { + respCode_ = other.respCode_; + onChanged(); + } + if (!other.getRespMsg().isEmpty()) { + respMsg_ = other.respMsg_; + onChanged(); + } + if (!other.getRespTime().isEmpty()) { + respTime_ = other.respTime_; + onChanged(); + } + if (!other.getSeqNum().isEmpty()) { + seqNum_ = other.seqNum_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Response parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Response) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object respCode_ = ""; + + /** + * string respCode = 1; + */ + public String getRespCode() { + Object ref = respCode_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respCode_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string respCode = 1; + */ + public com.google.protobuf.ByteString + getRespCodeBytes() { + Object ref = respCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string respCode = 1; + */ + public Builder setRespCode( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + respCode_ = value; + onChanged(); + return this; + } + + /** + * string respCode = 1; + */ + public Builder clearRespCode() { + + respCode_ = getDefaultInstance().getRespCode(); + onChanged(); + return this; + } + + /** + * string respCode = 1; + */ + public Builder setRespCodeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + respCode_ = value; + onChanged(); + return this; + } + + private Object respMsg_ = ""; + + /** + * string respMsg = 2; + */ + public String getRespMsg() { + Object ref = respMsg_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respMsg_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string respMsg = 2; + */ + public com.google.protobuf.ByteString + getRespMsgBytes() { + Object ref = respMsg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respMsg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string respMsg = 2; + */ + public Builder setRespMsg( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + respMsg_ = value; + onChanged(); + return this; + } + + /** + * string respMsg = 2; + */ + public Builder clearRespMsg() { + + respMsg_ = getDefaultInstance().getRespMsg(); + onChanged(); + return this; + } + + /** + * string respMsg = 2; + */ + public Builder setRespMsgBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + respMsg_ = value; + onChanged(); + return this; + } + + private Object respTime_ = ""; + + /** + * string respTime = 3; + */ + public String getRespTime() { + Object ref = respTime_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respTime_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string respTime = 3; + */ + public com.google.protobuf.ByteString + getRespTimeBytes() { + Object ref = respTime_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respTime_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string respTime = 3; + */ + public Builder setRespTime( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + respTime_ = value; + onChanged(); + return this; + } + + /** + * string respTime = 3; + */ + public Builder clearRespTime() { + + respTime_ = getDefaultInstance().getRespTime(); + onChanged(); + return this; + } + + /** + * string respTime = 3; + */ + public Builder setRespTimeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + respTime_ = value; + onChanged(); + return this; + } + + private Object seqNum_ = ""; + + /** + * string seqNum = 4; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string seqNum = 4; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string seqNum = 4; + */ + public Builder setSeqNum( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + seqNum_ = value; + onChanged(); + return this; + } + + /** + * string seqNum = 4; + */ + public Builder clearSeqNum() { + + seqNum_ = getDefaultInstance().getSeqNum(); + onChanged(); + return this; + } + + /** + * string seqNum = 4; + */ + public Builder setSeqNumBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + seqNum_ = value; + onChanged(); + return this; + } + + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.client.Response) + } + + // @@protoc_insertion_point(class_scope:eventmesh.client.Response) + private static final Response DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new Response(); + } + + public static Response getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Response parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Response(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Response getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java new file mode 100644 index 0000000000..0b4acd2fe4 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java @@ -0,0 +1,67 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * ResponseOrBuilder interface. + */ +public interface ResponseOrBuilder extends com.google.protobuf.MessageOrBuilder { + + /** + * string respCode = 1. + */ + String getRespCode(); + + /** + * string respCode = 1. + */ + com.google.protobuf.ByteString getRespCodeBytes(); + + /** + * string respMsg = 2. + */ + String getRespMsg(); + + /** + * string respMsg = 2. + */ + com.google.protobuf.ByteString getRespMsgBytes(); + + /** + * string respTime = 3. + */ + String getRespTime(); + + /** + * string respTime = 3. + */ + com.google.protobuf.ByteString getRespTimeBytes(); + + /** + * string seqNum = 4. + */ + String getSeqNum(); + + /** + * string seqNum = 4. + */ + com.google.protobuf.ByteString getSeqNumBytes(); +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java new file mode 100644 index 0000000000..803e1daf5c --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java @@ -0,0 +1,2138 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * Protobuf type {@code eventmesh.client.Subscription} + */ +public final class Subscription extends + com.google.protobuf.GeneratedMessageV3 implements SubscriptionOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Subscription.newBuilder() to construct. + private Subscription(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Subscription() { + consumerGroup_ = ""; + subscriptionItems_ = java.util.Collections.emptyList(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + + private Subscription( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + consumerGroup_ = s; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + subscriptionItems_.add( + input.readMessage(SubscriptionItem.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Subscription.class, Builder.class); + } + + public interface SubscriptionItemOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.client.Subscription.SubscriptionItem) + com.google.protobuf.MessageOrBuilder { + + /** + * string topic = 1; + */ + String getTopic(); + + /** + * string topic = 1; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * string mode = 2; + */ + String getMode(); + + /** + * string mode = 2; + */ + com.google.protobuf.ByteString + getModeBytes(); + + /** + * string type = 3; + */ + String getType(); + + /** + * string type = 3; + */ + com.google.protobuf.ByteString + getTypeBytes(); + + /** + * string url = 4; + */ + String getUrl(); + + /** + * string url = 4; + */ + com.google.protobuf.ByteString + getUrlBytes(); + } + + /** + * Protobuf type {@code eventmesh.client.Subscription.SubscriptionItem} + */ + public static final class SubscriptionItem extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.client.Subscription.SubscriptionItem) + SubscriptionItemOrBuilder { + private static final long serialVersionUID = 0L; + + // Use SubscriptionItem.newBuilder() to construct. + private SubscriptionItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private SubscriptionItem() { + topic_ = ""; + mode_ = ""; + type_ = ""; + url_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + + private SubscriptionItem( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + mode_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + type_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SubscriptionItem.class, Builder.class); + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile Object topic_; + + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MODE_FIELD_NUMBER = 2; + private volatile Object mode_; + + /** + * string mode = 2; + */ + public String getMode() { + Object ref = mode_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + mode_ = s; + return s; + } + } + + /** + * string mode = 2; + */ + public com.google.protobuf.ByteString + getModeBytes() { + Object ref = mode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + mode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 3; + private volatile Object type_; + + /** + * string type = 3; + */ + public String getType() { + Object ref = type_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + type_ = s; + return s; + } + } + + /** + * string type = 3; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int URL_FIELD_NUMBER = 4; + private volatile Object url_; + + /** + * string url = 4; + */ + public String getUrl() { + Object ref = url_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); + } + if (!getModeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, mode_); + } + if (!getTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_); + } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, url_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); + } + if (!getModeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, mode_); + } + if (!getTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_); + } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, url_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SubscriptionItem)) { + return super.equals(obj); + } + SubscriptionItem other = (SubscriptionItem) obj; + + boolean result = true; + result = result && getTopic() + .equals(other.getTopic()); + result = result && getMode() + .equals(other.getMode()); + result = result && getType() + .equals(other.getType()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + MODE_FIELD_NUMBER; + hash = (53 * hash) + getMode().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SubscriptionItem parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static SubscriptionItem parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static SubscriptionItem parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static SubscriptionItem parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static SubscriptionItem parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static SubscriptionItem parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static SubscriptionItem parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static SubscriptionItem 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 SubscriptionItem parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static SubscriptionItem 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 SubscriptionItem parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static SubscriptionItem parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(SubscriptionItem prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code eventmesh.client.Subscription.SubscriptionItem} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.client.Subscription.SubscriptionItem) + SubscriptionItemOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SubscriptionItem.class, Builder.class); + } + + // Construct using org.apache.eventmesh.client.grpc.protos.Subscription.SubscriptionItem.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + + public Builder clear() { + super.clear(); + topic_ = ""; + + mode_ = ""; + + type_ = ""; + + url_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; + } + + public SubscriptionItem getDefaultInstanceForType() { + return SubscriptionItem.getDefaultInstance(); + } + + public SubscriptionItem build() { + SubscriptionItem result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public SubscriptionItem buildPartial() { + SubscriptionItem result = new SubscriptionItem(this); + result.topic_ = topic_; + result.mode_ = mode_; + result.type_ = type_; + result.url_ = url_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SubscriptionItem) { + return mergeFrom((SubscriptionItem) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SubscriptionItem other) { + if (other == SubscriptionItem.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (!other.getMode().isEmpty()) { + mode_ = other.mode_; + onChanged(); + } + if (!other.getType().isEmpty()) { + type_ = other.type_; + onChanged(); + } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + SubscriptionItem parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (SubscriptionItem) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object topic_ = ""; + + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string topic = 1; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + + /** + * string topic = 1; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + + /** + * string topic = 1; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private Object mode_ = ""; + + /** + * string mode = 2; + */ + public String getMode() { + Object ref = mode_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + mode_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string mode = 2; + */ + public com.google.protobuf.ByteString + getModeBytes() { + Object ref = mode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + mode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string mode = 2; + */ + public Builder setMode( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + mode_ = value; + onChanged(); + return this; + } + + /** + * string mode = 2; + */ + public Builder clearMode() { + + mode_ = getDefaultInstance().getMode(); + onChanged(); + return this; + } + + /** + * string mode = 2; + */ + public Builder setModeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + mode_ = value; + onChanged(); + return this; + } + + private Object type_ = ""; + + /** + * string type = 3; + */ + public String getType() { + Object ref = type_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + type_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string type = 3; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string type = 3; + */ + public Builder setType( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value; + onChanged(); + return this; + } + + /** + * string type = 3; + */ + public Builder clearType() { + + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + + /** + * string type = 3; + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + type_ = value; + onChanged(); + return this; + } + + private Object url_ = ""; + + /** + * string url = 4; + */ + public String getUrl() { + Object ref = url_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string url = 4; + */ + public Builder setUrl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + + /** + * string url = 4; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + + /** + * string url = 4; + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } + + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.client.Subscription.SubscriptionItem) + } + + // @@protoc_insertion_point(class_scope:eventmesh.client.Subscription.SubscriptionItem) + private static final SubscriptionItem DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new SubscriptionItem(); + } + + public static SubscriptionItem getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public SubscriptionItem parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SubscriptionItem(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public SubscriptionItem getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int CONSUMERGROUP_FIELD_NUMBER = 2; + private volatile Object consumerGroup_; + + /** + * string consumerGroup = 2; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } + } + + /** + * string consumerGroup = 2; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SUBSCRIPTIONITEMS_FIELD_NUMBER = 3; + private java.util.List subscriptionItems_; + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List getSubscriptionItemsList() { + return subscriptionItems_; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List + getSubscriptionItemsOrBuilderList() { + return subscriptionItems_; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public int getSubscriptionItemsCount() { + return subscriptionItems_.size(); + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem getSubscriptionItems(int index) { + return subscriptionItems_.get(index); + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( + int index) { + return subscriptionItems_.get(index); + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (!getConsumerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, consumerGroup_); + } + for (int i = 0; i < subscriptionItems_.size(); i++) { + output.writeMessage(3, subscriptionItems_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (!getConsumerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, consumerGroup_); + } + for (int i = 0; i < subscriptionItems_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, subscriptionItems_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Subscription)) { + return super.equals(obj); + } + Subscription other = (Subscription) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && getConsumerGroup() + .equals(other.getConsumerGroup()); + result = result && getSubscriptionItemsList() + .equals(other.getSubscriptionItemsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getConsumerGroup().hashCode(); + if (getSubscriptionItemsCount() > 0) { + hash = (37 * hash) + SUBSCRIPTIONITEMS_FIELD_NUMBER; + hash = (53 * hash) + getSubscriptionItemsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Subscription parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Subscription parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Subscription parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Subscription parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Subscription parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static Subscription parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static Subscription parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static Subscription 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 Subscription parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static Subscription 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 Subscription parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static Subscription parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(Subscription prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code eventmesh.client.Subscription} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.client.Subscription) + SubscriptionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Subscription.class, Builder.class); + } + + // Construct using org.apache.eventmesh.client.grpc.protos.Subscription.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getSubscriptionItemsFieldBuilder(); + } + } + + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + consumerGroup_ = ""; + + if (subscriptionItemsBuilder_ == null) { + subscriptionItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + subscriptionItemsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshClient.internal_static_eventmesh_client_Subscription_descriptor; + } + + public Subscription getDefaultInstanceForType() { + return Subscription.getDefaultInstance(); + } + + public Subscription build() { + Subscription result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Subscription buildPartial() { + Subscription result = new Subscription(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.consumerGroup_ = consumerGroup_; + if (subscriptionItemsBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.subscriptionItems_ = subscriptionItems_; + } else { + result.subscriptionItems_ = subscriptionItemsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Subscription) { + return mergeFrom((Subscription) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Subscription other) { + if (other == Subscription.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (!other.getConsumerGroup().isEmpty()) { + consumerGroup_ = other.consumerGroup_; + onChanged(); + } + if (subscriptionItemsBuilder_ == null) { + if (!other.subscriptionItems_.isEmpty()) { + if (subscriptionItems_.isEmpty()) { + subscriptionItems_ = other.subscriptionItems_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.addAll(other.subscriptionItems_); + } + onChanged(); + } + } else { + if (!other.subscriptionItems_.isEmpty()) { + if (subscriptionItemsBuilder_.isEmpty()) { + subscriptionItemsBuilder_.dispose(); + subscriptionItemsBuilder_ = null; + subscriptionItems_ = other.subscriptionItems_; + bitField0_ = (bitField0_ & ~0x00000004); + subscriptionItemsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSubscriptionItemsFieldBuilder() : null; + } else { + subscriptionItemsBuilder_.addAllMessages(other.subscriptionItems_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Subscription parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Subscription) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + + /** + * .eventmesh.client.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private Object consumerGroup_ = ""; + + /** + * string consumerGroup = 2; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + + /** + * string consumerGroup = 2; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string consumerGroup = 2; + */ + public Builder setConsumerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + consumerGroup_ = value; + onChanged(); + return this; + } + + /** + * string consumerGroup = 2; + */ + public Builder clearConsumerGroup() { + + consumerGroup_ = getDefaultInstance().getConsumerGroup(); + onChanged(); + return this; + } + + /** + * string consumerGroup = 2; + */ + public Builder setConsumerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + consumerGroup_ = value; + onChanged(); + return this; + } + + private java.util.List subscriptionItems_ = + java.util.Collections.emptyList(); + + private void ensureSubscriptionItemsIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = new java.util.ArrayList(subscriptionItems_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> subscriptionItemsBuilder_; + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List getSubscriptionItemsList() { + if (subscriptionItemsBuilder_ == null) { + return java.util.Collections.unmodifiableList(subscriptionItems_); + } else { + return subscriptionItemsBuilder_.getMessageList(); + } + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public int getSubscriptionItemsCount() { + if (subscriptionItemsBuilder_ == null) { + return subscriptionItems_.size(); + } else { + return subscriptionItemsBuilder_.getCount(); + } + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem getSubscriptionItems(int index) { + if (subscriptionItemsBuilder_ == null) { + return subscriptionItems_.get(index); + } else { + return subscriptionItemsBuilder_.getMessage(index); + } + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder setSubscriptionItems( + int index, SubscriptionItem value) { + if (subscriptionItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.set(index, value); + onChanged(); + } else { + subscriptionItemsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder setSubscriptionItems( + int index, SubscriptionItem.Builder builderForValue) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.set(index, builderForValue.build()); + onChanged(); + } else { + subscriptionItemsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems(SubscriptionItem value) { + if (subscriptionItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(value); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems( + int index, SubscriptionItem value) { + if (subscriptionItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(index, value); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems( + SubscriptionItem.Builder builderForValue) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(builderForValue.build()); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems( + int index, SubscriptionItem.Builder builderForValue) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(index, builderForValue.build()); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addAllSubscriptionItems( + Iterable values) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, subscriptionItems_); + onChanged(); + } else { + subscriptionItemsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder clearSubscriptionItems() { + if (subscriptionItemsBuilder_ == null) { + subscriptionItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + subscriptionItemsBuilder_.clear(); + } + return this; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder removeSubscriptionItems(int index) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.remove(index); + onChanged(); + } else { + subscriptionItemsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem.Builder getSubscriptionItemsBuilder( + int index) { + return getSubscriptionItemsFieldBuilder().getBuilder(index); + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( + int index) { + if (subscriptionItemsBuilder_ == null) { + return subscriptionItems_.get(index); + } else { + return subscriptionItemsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List + getSubscriptionItemsOrBuilderList() { + if (subscriptionItemsBuilder_ != null) { + return subscriptionItemsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(subscriptionItems_); + } + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem.Builder addSubscriptionItemsBuilder() { + return getSubscriptionItemsFieldBuilder().addBuilder( + SubscriptionItem.getDefaultInstance()); + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem.Builder addSubscriptionItemsBuilder( + int index) { + return getSubscriptionItemsFieldBuilder().addBuilder( + index, SubscriptionItem.getDefaultInstance()); + } + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List + getSubscriptionItemsBuilderList() { + return getSubscriptionItemsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> + getSubscriptionItemsFieldBuilder() { + if (subscriptionItemsBuilder_ == null) { + subscriptionItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder>( + subscriptionItems_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + subscriptionItems_ = null; + } + return subscriptionItemsBuilder_; + } + + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.client.Subscription) + } + + // @@protoc_insertion_point(class_scope:eventmesh.client.Subscription) + private static final Subscription DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new Subscription(); + } + + public static Subscription getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Subscription parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Subscription(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Subscription getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java new file mode 100644 index 0000000000..b47e54826d --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java @@ -0,0 +1,78 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.client.grpc.protos; + +/** + * SubscriptionOrBuilder interface. + */ +public interface SubscriptionOrBuilder extends com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.client.RequestHeader header = 1. + */ + boolean hasHeader(); + + /** + * .eventmesh.client.RequestHeader header = 1. + */ + RequestHeader getHeader(); + + /** + * .eventmesh.client.RequestHeader header = 1. + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * string consumerGroup = 2. + */ + String getConsumerGroup(); + + /** + * string consumerGroup = 2. + */ + com.google.protobuf.ByteString getConsumerGroupBytes(); + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. + */ + java.util.List getSubscriptionItemsList(); + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. + */ + Subscription.SubscriptionItem getSubscriptionItems(int index); + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. + */ + int getSubscriptionItemsCount(); + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. + */ + java.util.List + getSubscriptionItemsOrBuilderList(); + + /** + * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. + */ + Subscription.SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder(int index); +} diff --git a/settings.gradle b/settings.gradle index 1d94585bd6..946abdf6ae 100644 --- a/settings.gradle +++ b/settings.gradle @@ -36,4 +36,5 @@ include 'eventmesh-protocol-plugin:eventmesh-protocol-openmessage' include 'eventmesh-protocol-plugin:eventmesh-protocol-cloudevents' include 'eventmesh-protocol-plugin:eventmesh-protocol-meshmessage' include 'eventmesh-admin:eventmesh-admin-rocketmq' +include 'eventmesh-protocol-plugin:eventmesh-protocol-grpc' diff --git a/tool/license/allowed-licenses.txt b/tool/license/allowed-licenses.txt new file mode 100644 index 0000000000..e69de29bb2 From 8667dae4839eed38f0f541335e7da3c580f41375 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Fri, 10 Dec 2021 17:15:18 -0500 Subject: [PATCH 02/21] GRPC producer publish API --- build.gradle | 5 + eventmesh-common/build.gradle | 3 + .../grpc/protos/ConsumerServiceGrpc.java | 440 ++++ .../protocol/grpc/protos/EventmeshGrpc.java | 183 ++ .../protocol/grpc/protos/Heartbeat.java | 1978 +++++++++++++++ .../grpc/protos/HeartbeatOrBuilder.java | 93 + .../grpc/protos/HeartbeatServiceGrpc.java | 297 +++ .../common/protocol/grpc/protos/Message.java | 1222 ++++++++++ .../grpc/protos/MessageOrBuilder.java | 89 + .../grpc/protos/PublisherServiceGrpc.java | 447 ++++ .../protocol/grpc/protos/RequestHeader.java | 1803 ++++++++++++++ .../grpc/protos/RequestHeaderOrBuilder.java | 136 ++ .../common/protocol/grpc/protos/Response.java | 914 +++++++ .../grpc/protos/ResponseOrBuilder.java | 66 + .../protocol/grpc/protos/Subscription.java | 1998 +++++++++++++++ .../grpc/protos/SubscriptionOrBuilder.java | 73 + .../src/main/proto/eventmesh-client.proto | 8 +- eventmesh-runtime/build.gradle | 7 + eventmesh-runtime/conf/eventmesh.properties | 1 + .../runtime/boot/EventMeshGrpcServer.java | 83 + .../runtime/boot/EventMeshServer.java | 26 +- .../runtime/boot/EventMeshStartup.java | 5 +- .../EventMeshGrpcConfiguration.java | 228 ++ .../grpc/interceptor/MetricsInterceptor.java | 20 + .../processor/SendAsyncMessageProcessor.java | 79 + .../grpc/producer/EventMeshProducer.java | 118 + .../grpc/producer/ProducerManager.java | 91 + .../grpc/producer/SendMessageContext.java | 152 ++ .../protocol/grpc/retry/DelayRetryable.java | 24 + .../core/protocol/grpc/retry/GrpcRetryer.java | 122 + .../protocol/grpc/retry/RetryContext.java | 50 + .../grpc/service/ProducerService.java | 44 + .../protocol/grpc/service/ServiceUtils.java | 48 + .../runtime/client/common/Server.java | 2 +- eventmesh-sdk-java/build.gradle | 7 + .../eventmesh/client/grpc/Producer.java | 42 + .../client/grpc/config/ClientConfig.java | 172 ++ .../grpc/protos/ConsumerServiceGrpc.java | 453 ---- .../client/grpc/protos/EventmeshClient.java | 174 -- .../client/grpc/protos/Heartbeat.java | 2117 ---------------- .../grpc/protos/HeartbeatOrBuilder.java | 97 - .../grpc/protos/HeartbeatServiceGrpc.java | 302 --- .../eventmesh/client/grpc/protos/Message.java | 1299 ---------- .../client/grpc/protos/MessageOrBuilder.java | 92 - .../grpc/protos/PublisherServiceGrpc.java | 460 ---- .../client/grpc/protos/RequestHeader.java | 1910 --------------- .../grpc/protos/RequestHeaderOrBuilder.java | 137 -- .../client/grpc/protos/Response.java | 972 -------- .../client/grpc/protos/ResponseOrBuilder.java | 67 - .../client/grpc/protos/Subscription.java | 2138 ----------------- .../grpc/protos/SubscriptionOrBuilder.java | 78 - 51 files changed, 11069 insertions(+), 10303 deletions(-) create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Message.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/MessageOrBuilder.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/ProducerManager.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/SendMessageContext.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/DelayRetryable.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/RetryContext.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/Producer.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/ClientConfig.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java diff --git a/build.gradle b/build.gradle index d9c7f771d9..4b5569bb0e 100644 --- a/build.gradle +++ b/build.gradle @@ -456,6 +456,11 @@ subprojects { dependency "io.cloudevents:cloudevents-core:2.2.0" dependency "io.cloudevents:cloudevents-json-jackson:2.2.0" + + dependency "io.grpc:grpc-protobuf:1.15.0" + dependency "io.grpc:grpc-stub:1.15.0" + dependency "io.grpc:grpc-netty:1.15.0" + dependency "io.grpc:grpc-netty-shaded:1.15.0" } } } \ No newline at end of file diff --git a/eventmesh-common/build.gradle b/eventmesh-common/build.gradle index 715ae91462..d373fe1e71 100644 --- a/eventmesh-common/build.gradle +++ b/eventmesh-common/build.gradle @@ -38,6 +38,9 @@ dependencies { implementation "io.netty:netty-all" + implementation "io.grpc:grpc-protobuf:1.15.0" + implementation "io.grpc:grpc-stub:1.15.0" + implementation "com.github.stefanbirkner:system-rules" compileOnly 'org.projectlombok:lombok:1.18.22' diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java new file mode 100644 index 0000000000..c9791a88a5 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java @@ -0,0 +1,440 @@ +/* + * 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.eventmesh.common.protocol.grpc.protos; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.15.0)", + comments = "Source: eventmesh-client.proto") +public final class ConsumerServiceGrpc { + + private ConsumerServiceGrpc() {} + + public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.ConsumerService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getSubscribeMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "subscribe", + requestType = Subscription.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getSubscribeMethod() { + io.grpc.MethodDescriptor getSubscribeMethod; + if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { + synchronized (ConsumerServiceGrpc.class) { + if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { + ConsumerServiceGrpc.getSubscribeMethod = getSubscribeMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.ConsumerService", "subscribe")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Subscription.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribe")) + .build(); + } + } + } + return getSubscribeMethod; + } + + private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "subscribeStream", + requestType = Subscription.class, + responseType = Message.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor getSubscribeStreamMethod() { + io.grpc.MethodDescriptor getSubscribeStreamMethod; + if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { + synchronized (ConsumerServiceGrpc.class) { + if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { + ConsumerServiceGrpc.getSubscribeStreamMethod = getSubscribeStreamMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.ConsumerService", "subscribeStream")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Subscription.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Message.getDefaultInstance())) + .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribeStream")) + .build(); + } + } + } + return getSubscribeStreamMethod; + } + + private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "unsubscribe", + requestType = Subscription.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getUnsubscribeMethod() { + io.grpc.MethodDescriptor getUnsubscribeMethod; + if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { + synchronized (ConsumerServiceGrpc.class) { + if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { + ConsumerServiceGrpc.getUnsubscribeMethod = getUnsubscribeMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.ConsumerService", "unsubscribe")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Subscription.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("unsubscribe")) + .build(); + } + } + } + return getUnsubscribeMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static ConsumerServiceStub newStub(io.grpc.Channel channel) { + return new ConsumerServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static ConsumerServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new ConsumerServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static ConsumerServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new ConsumerServiceFutureStub(channel); + } + + /** + */ + public static abstract class ConsumerServiceImplBase implements io.grpc.BindableService { + + /** + */ + public void subscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSubscribeMethod(), responseObserver); + } + + /** + */ + public void subscribeStream(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSubscribeStreamMethod(), responseObserver); + } + + /** + */ + public void unsubscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUnsubscribeMethod(), responseObserver); + } + + @Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getSubscribeMethod(), + asyncUnaryCall( + new MethodHandlers< + Subscription, + Response>( + this, METHODID_SUBSCRIBE))) + .addMethod( + getSubscribeStreamMethod(), + asyncServerStreamingCall( + new MethodHandlers< + Subscription, + Message>( + this, METHODID_SUBSCRIBE_STREAM))) + .addMethod( + getUnsubscribeMethod(), + asyncUnaryCall( + new MethodHandlers< + Subscription, + Response>( + this, METHODID_UNSUBSCRIBE))) + .build(); + } + } + + /** + */ + public static final class ConsumerServiceStub extends io.grpc.stub.AbstractStub { + private ConsumerServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private ConsumerServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected ConsumerServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ConsumerServiceStub(channel, callOptions); + } + + /** + */ + public void subscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getSubscribeMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void subscribeStream(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(getSubscribeStreamMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void unsubscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class ConsumerServiceBlockingStub extends io.grpc.stub.AbstractStub { + private ConsumerServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private ConsumerServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected ConsumerServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ConsumerServiceBlockingStub(channel, callOptions); + } + + /** + */ + public Response subscribe(Subscription request) { + return blockingUnaryCall( + getChannel(), getSubscribeMethod(), getCallOptions(), request); + } + + /** + */ + public java.util.Iterator subscribeStream( + Subscription request) { + return blockingServerStreamingCall( + getChannel(), getSubscribeStreamMethod(), getCallOptions(), request); + } + + /** + */ + public Response unsubscribe(Subscription request) { + return blockingUnaryCall( + getChannel(), getUnsubscribeMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class ConsumerServiceFutureStub extends io.grpc.stub.AbstractStub { + private ConsumerServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private ConsumerServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected ConsumerServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ConsumerServiceFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture subscribe( + Subscription request) { + return futureUnaryCall( + getChannel().newCall(getSubscribeMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture unsubscribe( + Subscription request) { + return futureUnaryCall( + getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_SUBSCRIBE = 0; + private static final int METHODID_SUBSCRIBE_STREAM = 1; + private static final int METHODID_UNSUBSCRIBE = 2; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final ConsumerServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(ConsumerServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_SUBSCRIBE: + serviceImpl.subscribe((Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SUBSCRIBE_STREAM: + serviceImpl.subscribeStream((Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UNSUBSCRIBE: + serviceImpl.unsubscribe((Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class ConsumerServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + ConsumerServiceBaseDescriptorSupplier() {} + + @Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.apache.eventmesh.common.protocol.grpc.protos.EventmeshGrpc.getDescriptor(); + } + + @Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("ConsumerService"); + } + } + + private static final class ConsumerServiceFileDescriptorSupplier + extends ConsumerServiceBaseDescriptorSupplier { + ConsumerServiceFileDescriptorSupplier() {} + } + + private static final class ConsumerServiceMethodDescriptorSupplier + extends ConsumerServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + ConsumerServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (ConsumerServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new ConsumerServiceFileDescriptorSupplier()) + .addMethod(getSubscribeMethod()) + .addMethod(getSubscribeStreamMethod()) + .addMethod(getUnsubscribeMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java new file mode 100644 index 0000000000..2e815e41b4 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -0,0 +1,183 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public final class EventmeshGrpc { + private EventmeshGrpc() {} + 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_eventmesh_common_protocol_grpc_RequestHeader_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Message_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Message_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Response_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + String[] descriptorData = { + "\n\026eventmesh-client.proto\022\036eventmesh.comm" + + "on.protocol.grpc\"\266\001\n\rRequestHeader\022\013\n\003en" + + "v\030\001 \001(\t\022\016\n\006region\030\002 \001(\t\022\013\n\003idc\030\003 \001(\t\022\n\n\002" + + "ip\030\004 \001(\t\022\013\n\003pid\030\005 \001(\t\022\013\n\003sys\030\006 \001(\t\022\020\n\010us" + + "ername\030\007 \001(\t\022\020\n\010password\030\010 \001(\t\022\017\n\007versio" + + "n\030\t \001(\t\022\020\n\010language\030\n \001(\t\022\016\n\006seqNum\030\013 \001(" + + "\t\"\236\001\n\007Message\022=\n\006header\030\001 \001(\0132-.eventmes" + + "h.common.protocol.grpc.RequestHeader\022\025\n\r" + + "producerGroup\030\002 \001(\t\022\r\n\005topic\030\003 \001(\t\022\017\n\007co" + + "ntent\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020\n\010uniqueId\030\006 \001" + + "(\t\"O\n\010Response\022\020\n\010respCode\030\001 \001(\t\022\017\n\007resp" + + "Msg\030\002 \001(\t\022\020\n\010respTime\030\003 \001(\t\022\016\n\006seqNum\030\004 " + + "\001(\t\"\212\002\n\014Subscription\022=\n\006header\030\001 \001(\0132-.e" + + "ventmesh.common.protocol.grpc.RequestHea" + + "der\022\025\n\rconsumerGroup\030\002 \001(\t\022X\n\021subscripti" + + "onItems\030\003 \003(\0132=.eventmesh.common.protoco" + + "l.grpc.Subscription.SubscriptionItem\032J\n\020" + + "SubscriptionItem\022\r\n\005topic\030\001 \001(\t\022\014\n\004mode\030" + + "\002 \001(\t\022\014\n\004type\030\003 \001(\t\022\013\n\003url\030\004 \001(\t\"\212\002\n\tHea" + + "rtbeat\022=\n\006header\030\001 \001(\0132-.eventmesh.commo" + + "n.protocol.grpc.RequestHeader\022\022\n\nclientT" + + "ype\030\002 \001(\t\022\025\n\rproducerGroup\030\003 \001(\t\022\025\n\rcons" + + "umerGroup\030\004 \001(\t\022O\n\016heartbeatItems\030\005 \003(\0132" + + "7.eventmesh.common.protocol.grpc.Heartbe" + + "at.HeartbeatItem\032+\n\rHeartbeatItem\022\r\n\005top" + + "ic\030\001 \001(\t\022\013\n\003url\030\002 \001(\t2\263\002\n\020PublisherServi" + + "ce\022\\\n\007publish\022\'.eventmesh.common.protoco" + + "l.grpc.Message\032(.eventmesh.common.protoc" + + "ol.grpc.Response\022a\n\014requestReply\022\'.event" + + "mesh.common.protocol.grpc.Message\032(.even" + + "tmesh.common.protocol.grpc.Response\022^\n\tb" + + "roadcast\022\'.eventmesh.common.protocol.grp" + + "c.Message\032(.eventmesh.common.protocol.gr" + + "pc.Response2\311\002\n\017ConsumerService\022c\n\tsubsc" + + "ribe\022,.eventmesh.common.protocol.grpc.Su" + + "bscription\032(.eventmesh.common.protocol.g" + + "rpc.Response\022j\n\017subscribeStream\022,.eventm" + + "esh.common.protocol.grpc.Subscription\032\'." + + "eventmesh.common.protocol.grpc.Message0\001" + + "\022e\n\013unsubscribe\022,.eventmesh.common.proto" + + "col.grpc.Subscription\032(.eventmesh.common" + + ".protocol.grpc.Response2t\n\020HeartbeatServ" + + "ice\022`\n\theartbeat\022).eventmesh.common.prot" + + "ocol.grpc.Heartbeat\032(.eventmesh.common.p" + + "rotocol.grpc.ResponseBC\n0org.apache.even" + + "tmesh.common.protocol.grpc.protosB\rEvent" + + "meshGrpcP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor, + new String[] { "Env", "Region", "Idc", "Ip", "Pid", "Sys", "Username", "Password", "Version", "Language", "SeqNum", }); + internal_static_eventmesh_common_protocol_grpc_Message_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_eventmesh_common_protocol_grpc_Message_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Message_descriptor, + new String[] { "Header", "ProducerGroup", "Topic", "Content", "Ttl", "UniqueId", }); + internal_static_eventmesh_common_protocol_grpc_Response_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Response_descriptor, + new String[] { "RespCode", "RespMsg", "RespTime", "SeqNum", }); + internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor, + new String[] { "Header", "ConsumerGroup", "SubscriptionItems", }); + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor = + internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor.getNestedTypes().get(0); + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor, + new String[] { "Topic", "Mode", "Type", "Url", }); + internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor, + new String[] { "Header", "ClientType", "ProducerGroup", "ConsumerGroup", "HeartbeatItems", }); + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor = + internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor.getNestedTypes().get(0); + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor, + new String[] { "Topic", "Url", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java new file mode 100644 index 0000000000..f616a65790 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java @@ -0,0 +1,1978 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat} + */ +public final class Heartbeat extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Heartbeat) + HeartbeatOrBuilder { +private static final long serialVersionUID = 0L; + // Use Heartbeat.newBuilder() to construct. + private Heartbeat(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Heartbeat() { + clientType_ = ""; + producerGroup_ = ""; + consumerGroup_ = ""; + heartbeatItems_ = java.util.Collections.emptyList(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Heartbeat( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + clientType_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + producerGroup_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + consumerGroup_ = s; + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + heartbeatItems_.add( + input.readMessage(HeartbeatItem.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Heartbeat.class, Builder.class); + } + + public interface HeartbeatItemOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + com.google.protobuf.MessageOrBuilder { + + /** + * string topic = 1; + */ + String getTopic(); + /** + * string topic = 1; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * string url = 2; + */ + String getUrl(); + /** + * string url = 2; + */ + com.google.protobuf.ByteString + getUrlBytes(); + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem} + */ + public static final class HeartbeatItem extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + HeartbeatItemOrBuilder { + private static final long serialVersionUID = 0L; + // Use HeartbeatItem.newBuilder() to construct. + private HeartbeatItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private HeartbeatItem() { + topic_ = ""; + url_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private HeartbeatItem( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HeartbeatItem.class, Builder.class); + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile Object topic_; + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int URL_FIELD_NUMBER = 2; + private volatile Object url_; + /** + * string url = 2; + */ + public String getUrl() { + Object ref = url_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + /** + * string url = 2; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); + } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, url_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); + } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, url_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof HeartbeatItem)) { + return super.equals(obj); + } + HeartbeatItem other = (HeartbeatItem) obj; + + boolean result = true; + result = result && getTopic() + .equals(other.getTopic()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static HeartbeatItem parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HeartbeatItem parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HeartbeatItem parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HeartbeatItem parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HeartbeatItem parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HeartbeatItem parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HeartbeatItem parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static HeartbeatItem 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 HeartbeatItem parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static HeartbeatItem 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 HeartbeatItem parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static HeartbeatItem parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(HeartbeatItem prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + HeartbeatItemOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HeartbeatItem.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.HeartbeatItem.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + topic_ = ""; + + url_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor; + } + + public HeartbeatItem getDefaultInstanceForType() { + return HeartbeatItem.getDefaultInstance(); + } + + public HeartbeatItem build() { + HeartbeatItem result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public HeartbeatItem buildPartial() { + HeartbeatItem result = new HeartbeatItem(this); + result.topic_ = topic_; + result.url_ = url_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof HeartbeatItem) { + return mergeFrom((HeartbeatItem)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(HeartbeatItem other) { + if (other == HeartbeatItem.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + HeartbeatItem parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (HeartbeatItem) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object topic_ = ""; + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string topic = 1; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private Object url_ = ""; + /** + * string url = 2; + */ + public String getUrl() { + Object ref = url_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string url = 2; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string url = 2; + */ + public Builder setUrl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * string url = 2; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + /** + * string url = 2; + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) + private static final HeartbeatItem DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new HeartbeatItem(); + } + + public static HeartbeatItem getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HeartbeatItem parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HeartbeatItem(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public HeartbeatItem getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int CLIENTTYPE_FIELD_NUMBER = 2; + private volatile Object clientType_; + /** + * string clientType = 2; + */ + public String getClientType() { + Object ref = clientType_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + clientType_ = s; + return s; + } + } + /** + * string clientType = 2; + */ + public com.google.protobuf.ByteString + getClientTypeBytes() { + Object ref = clientType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + clientType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PRODUCERGROUP_FIELD_NUMBER = 3; + private volatile Object producerGroup_; + /** + * string producerGroup = 3; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } + } + /** + * string producerGroup = 3; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CONSUMERGROUP_FIELD_NUMBER = 4; + private volatile Object consumerGroup_; + /** + * string consumerGroup = 4; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } + } + /** + * string consumerGroup = 4; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int HEARTBEATITEMS_FIELD_NUMBER = 5; + private java.util.List heartbeatItems_; + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List getHeartbeatItemsList() { + return heartbeatItems_; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List + getHeartbeatItemsOrBuilderList() { + return heartbeatItems_; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public int getHeartbeatItemsCount() { + return heartbeatItems_.size(); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem getHeartbeatItems(int index) { + return heartbeatItems_.get(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( + int index) { + return heartbeatItems_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (!getClientTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, clientType_); + } + if (!getProducerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, producerGroup_); + } + if (!getConsumerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, consumerGroup_); + } + for (int i = 0; i < heartbeatItems_.size(); i++) { + output.writeMessage(5, heartbeatItems_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (!getClientTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, clientType_); + } + if (!getProducerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, producerGroup_); + } + if (!getConsumerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, consumerGroup_); + } + for (int i = 0; i < heartbeatItems_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, heartbeatItems_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Heartbeat)) { + return super.equals(obj); + } + Heartbeat other = (Heartbeat) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && getClientType() + .equals(other.getClientType()); + result = result && getProducerGroup() + .equals(other.getProducerGroup()); + result = result && getConsumerGroup() + .equals(other.getConsumerGroup()); + result = result && getHeartbeatItemsList() + .equals(other.getHeartbeatItemsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + CLIENTTYPE_FIELD_NUMBER; + hash = (53 * hash) + getClientType().hashCode(); + hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getProducerGroup().hashCode(); + hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getConsumerGroup().hashCode(); + if (getHeartbeatItemsCount() > 0) { + hash = (37 * hash) + HEARTBEATITEMS_FIELD_NUMBER; + hash = (53 * hash) + getHeartbeatItemsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Heartbeat parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Heartbeat parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Heartbeat parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Heartbeat parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Heartbeat parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Heartbeat parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Heartbeat parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Heartbeat 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 Heartbeat parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static Heartbeat 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 Heartbeat parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Heartbeat parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Heartbeat prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Heartbeat) + HeartbeatOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Heartbeat.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getHeartbeatItemsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + clientType_ = ""; + + producerGroup_ = ""; + + consumerGroup_ = ""; + + if (heartbeatItemsBuilder_ == null) { + heartbeatItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + heartbeatItemsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor; + } + + public Heartbeat getDefaultInstanceForType() { + return Heartbeat.getDefaultInstance(); + } + + public Heartbeat build() { + Heartbeat result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Heartbeat buildPartial() { + Heartbeat result = new Heartbeat(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.clientType_ = clientType_; + result.producerGroup_ = producerGroup_; + result.consumerGroup_ = consumerGroup_; + if (heartbeatItemsBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.heartbeatItems_ = heartbeatItems_; + } else { + result.heartbeatItems_ = heartbeatItemsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Heartbeat) { + return mergeFrom((Heartbeat)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Heartbeat other) { + if (other == Heartbeat.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (!other.getClientType().isEmpty()) { + clientType_ = other.clientType_; + onChanged(); + } + if (!other.getProducerGroup().isEmpty()) { + producerGroup_ = other.producerGroup_; + onChanged(); + } + if (!other.getConsumerGroup().isEmpty()) { + consumerGroup_ = other.consumerGroup_; + onChanged(); + } + if (heartbeatItemsBuilder_ == null) { + if (!other.heartbeatItems_.isEmpty()) { + if (heartbeatItems_.isEmpty()) { + heartbeatItems_ = other.heartbeatItems_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.addAll(other.heartbeatItems_); + } + onChanged(); + } + } else { + if (!other.heartbeatItems_.isEmpty()) { + if (heartbeatItemsBuilder_.isEmpty()) { + heartbeatItemsBuilder_.dispose(); + heartbeatItemsBuilder_ = null; + heartbeatItems_ = other.heartbeatItems_; + bitField0_ = (bitField0_ & ~0x00000010); + heartbeatItemsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getHeartbeatItemsFieldBuilder() : null; + } else { + heartbeatItemsBuilder_.addAllMessages(other.heartbeatItems_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Heartbeat parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Heartbeat) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private Object clientType_ = ""; + /** + * string clientType = 2; + */ + public String getClientType() { + Object ref = clientType_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + clientType_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string clientType = 2; + */ + public com.google.protobuf.ByteString + getClientTypeBytes() { + Object ref = clientType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + clientType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string clientType = 2; + */ + public Builder setClientType( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + clientType_ = value; + onChanged(); + return this; + } + /** + * string clientType = 2; + */ + public Builder clearClientType() { + + clientType_ = getDefaultInstance().getClientType(); + onChanged(); + return this; + } + /** + * string clientType = 2; + */ + public Builder setClientTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + clientType_ = value; + onChanged(); + return this; + } + + private Object producerGroup_ = ""; + /** + * string producerGroup = 3; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string producerGroup = 3; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string producerGroup = 3; + */ + public Builder setProducerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + producerGroup_ = value; + onChanged(); + return this; + } + /** + * string producerGroup = 3; + */ + public Builder clearProducerGroup() { + + producerGroup_ = getDefaultInstance().getProducerGroup(); + onChanged(); + return this; + } + /** + * string producerGroup = 3; + */ + public Builder setProducerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + producerGroup_ = value; + onChanged(); + return this; + } + + private Object consumerGroup_ = ""; + /** + * string consumerGroup = 4; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string consumerGroup = 4; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string consumerGroup = 4; + */ + public Builder setConsumerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + consumerGroup_ = value; + onChanged(); + return this; + } + /** + * string consumerGroup = 4; + */ + public Builder clearConsumerGroup() { + + consumerGroup_ = getDefaultInstance().getConsumerGroup(); + onChanged(); + return this; + } + /** + * string consumerGroup = 4; + */ + public Builder setConsumerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + consumerGroup_ = value; + onChanged(); + return this; + } + + private java.util.List heartbeatItems_ = + java.util.Collections.emptyList(); + private void ensureHeartbeatItemsIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + heartbeatItems_ = new java.util.ArrayList(heartbeatItems_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> heartbeatItemsBuilder_; + + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List getHeartbeatItemsList() { + if (heartbeatItemsBuilder_ == null) { + return java.util.Collections.unmodifiableList(heartbeatItems_); + } else { + return heartbeatItemsBuilder_.getMessageList(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public int getHeartbeatItemsCount() { + if (heartbeatItemsBuilder_ == null) { + return heartbeatItems_.size(); + } else { + return heartbeatItemsBuilder_.getCount(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem getHeartbeatItems(int index) { + if (heartbeatItemsBuilder_ == null) { + return heartbeatItems_.get(index); + } else { + return heartbeatItemsBuilder_.getMessage(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder setHeartbeatItems( + int index, HeartbeatItem value) { + if (heartbeatItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.set(index, value); + onChanged(); + } else { + heartbeatItemsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder setHeartbeatItems( + int index, HeartbeatItem.Builder builderForValue) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.set(index, builderForValue.build()); + onChanged(); + } else { + heartbeatItemsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems(HeartbeatItem value) { + if (heartbeatItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(value); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems( + int index, HeartbeatItem value) { + if (heartbeatItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(index, value); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems( + HeartbeatItem.Builder builderForValue) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(builderForValue.build()); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addHeartbeatItems( + int index, HeartbeatItem.Builder builderForValue) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.add(index, builderForValue.build()); + onChanged(); + } else { + heartbeatItemsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder addAllHeartbeatItems( + Iterable values) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, heartbeatItems_); + onChanged(); + } else { + heartbeatItemsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder clearHeartbeatItems() { + if (heartbeatItemsBuilder_ == null) { + heartbeatItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + heartbeatItemsBuilder_.clear(); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public Builder removeHeartbeatItems(int index) { + if (heartbeatItemsBuilder_ == null) { + ensureHeartbeatItemsIsMutable(); + heartbeatItems_.remove(index); + onChanged(); + } else { + heartbeatItemsBuilder_.remove(index); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem.Builder getHeartbeatItemsBuilder( + int index) { + return getHeartbeatItemsFieldBuilder().getBuilder(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( + int index) { + if (heartbeatItemsBuilder_ == null) { + return heartbeatItems_.get(index); } else { + return heartbeatItemsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List + getHeartbeatItemsOrBuilderList() { + if (heartbeatItemsBuilder_ != null) { + return heartbeatItemsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(heartbeatItems_); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem.Builder addHeartbeatItemsBuilder() { + return getHeartbeatItemsFieldBuilder().addBuilder( + HeartbeatItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public HeartbeatItem.Builder addHeartbeatItemsBuilder( + int index) { + return getHeartbeatItemsFieldBuilder().addBuilder( + index, HeartbeatItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + public java.util.List + getHeartbeatItemsBuilderList() { + return getHeartbeatItemsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> + getHeartbeatItemsFieldBuilder() { + if (heartbeatItemsBuilder_ == null) { + heartbeatItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder>( + heartbeatItems_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + heartbeatItems_ = null; + } + return heartbeatItemsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Heartbeat) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Heartbeat) + private static final Heartbeat DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Heartbeat(); + } + + public static Heartbeat getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Heartbeat parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Heartbeat(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Heartbeat getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java new file mode 100644 index 0000000000..7bbe0aba1c --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java @@ -0,0 +1,93 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface HeartbeatOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Heartbeat) + com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + boolean hasHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeader getHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * string clientType = 2; + */ + String getClientType(); + /** + * string clientType = 2; + */ + com.google.protobuf.ByteString + getClientTypeBytes(); + + /** + * string producerGroup = 3; + */ + String getProducerGroup(); + /** + * string producerGroup = 3; + */ + com.google.protobuf.ByteString + getProducerGroupBytes(); + + /** + * string consumerGroup = 4; + */ + String getConsumerGroup(); + /** + * string consumerGroup = 4; + */ + com.google.protobuf.ByteString + getConsumerGroupBytes(); + + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + java.util.List + getHeartbeatItemsList(); + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + Heartbeat.HeartbeatItem getHeartbeatItems(int index); + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + int getHeartbeatItemsCount(); + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + java.util.List + getHeartbeatItemsOrBuilderList(); + /** + * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5; + */ + Heartbeat.HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( + int index); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java new file mode 100644 index 0000000000..8f8f500cc0 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java @@ -0,0 +1,297 @@ +/* + * 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.eventmesh.common.protocol.grpc.protos; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.15.0)", + comments = "Source: eventmesh-client.proto") +public final class HeartbeatServiceGrpc { + + private HeartbeatServiceGrpc() {} + + public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.HeartbeatService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getHeartbeatMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "heartbeat", + requestType = Heartbeat.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getHeartbeatMethod() { + io.grpc.MethodDescriptor getHeartbeatMethod; + if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { + synchronized (HeartbeatServiceGrpc.class) { + if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { + HeartbeatServiceGrpc.getHeartbeatMethod = getHeartbeatMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.HeartbeatService", "heartbeat")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Heartbeat.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new HeartbeatServiceMethodDescriptorSupplier("heartbeat")) + .build(); + } + } + } + return getHeartbeatMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static HeartbeatServiceStub newStub(io.grpc.Channel channel) { + return new HeartbeatServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static HeartbeatServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new HeartbeatServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static HeartbeatServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new HeartbeatServiceFutureStub(channel); + } + + /** + */ + public static abstract class HeartbeatServiceImplBase implements io.grpc.BindableService { + + /** + */ + public void heartbeat(Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getHeartbeatMethod(), responseObserver); + } + + @Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getHeartbeatMethod(), + asyncUnaryCall( + new MethodHandlers< + Heartbeat, + Response>( + this, METHODID_HEARTBEAT))) + .build(); + } + } + + /** + */ + public static final class HeartbeatServiceStub extends io.grpc.stub.AbstractStub { + private HeartbeatServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private HeartbeatServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected HeartbeatServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new HeartbeatServiceStub(channel, callOptions); + } + + /** + */ + public void heartbeat(Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class HeartbeatServiceBlockingStub extends io.grpc.stub.AbstractStub { + private HeartbeatServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private HeartbeatServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected HeartbeatServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new HeartbeatServiceBlockingStub(channel, callOptions); + } + + /** + */ + public Response heartbeat(Heartbeat request) { + return blockingUnaryCall( + getChannel(), getHeartbeatMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class HeartbeatServiceFutureStub extends io.grpc.stub.AbstractStub { + private HeartbeatServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private HeartbeatServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected HeartbeatServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new HeartbeatServiceFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture heartbeat( + Heartbeat request) { + return futureUnaryCall( + getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_HEARTBEAT = 0; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final HeartbeatServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(HeartbeatServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_HEARTBEAT: + serviceImpl.heartbeat((Heartbeat) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class HeartbeatServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + HeartbeatServiceBaseDescriptorSupplier() {} + + @Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.apache.eventmesh.common.protocol.grpc.protos.EventmeshGrpc.getDescriptor(); + } + + @Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("HeartbeatService"); + } + } + + private static final class HeartbeatServiceFileDescriptorSupplier + extends HeartbeatServiceBaseDescriptorSupplier { + HeartbeatServiceFileDescriptorSupplier() {} + } + + private static final class HeartbeatServiceMethodDescriptorSupplier + extends HeartbeatServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + HeartbeatServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (HeartbeatServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new HeartbeatServiceFileDescriptorSupplier()) + .addMethod(getHeartbeatMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Message.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Message.java new file mode 100644 index 0000000000..afa82dd075 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Message.java @@ -0,0 +1,1222 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.Message} + */ +public final class Message extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Message) + MessageOrBuilder { +private static final long serialVersionUID = 0L; + // Use Message.newBuilder() to construct. + private Message(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Message() { + producerGroup_ = ""; + topic_ = ""; + content_ = ""; + ttl_ = ""; + uniqueId_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Message( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + producerGroup_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + content_ = s; + break; + } + case 42: { + String s = input.readStringRequireUtf8(); + + ttl_ = s; + break; + } + case 50: { + String s = input.readStringRequireUtf8(); + + uniqueId_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Message.class, Builder.class); + } + + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int PRODUCERGROUP_FIELD_NUMBER = 2; + private volatile Object producerGroup_; + /** + * string producerGroup = 2; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } + } + /** + * string producerGroup = 2; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TOPIC_FIELD_NUMBER = 3; + private volatile Object topic_; + /** + * string topic = 3; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * string topic = 3; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CONTENT_FIELD_NUMBER = 4; + private volatile Object content_; + /** + * string content = 4; + */ + public String getContent() { + Object ref = content_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } + } + /** + * string content = 4; + */ + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TTL_FIELD_NUMBER = 5; + private volatile Object ttl_; + /** + * string ttl = 5; + */ + public String getTtl() { + Object ref = ttl_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ttl_ = s; + return s; + } + } + /** + * string ttl = 5; + */ + public com.google.protobuf.ByteString + getTtlBytes() { + Object ref = ttl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ttl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int UNIQUEID_FIELD_NUMBER = 6; + private volatile Object uniqueId_; + /** + * string uniqueId = 6; + */ + public String getUniqueId() { + Object ref = uniqueId_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + uniqueId_ = s; + return s; + } + } + /** + * string uniqueId = 6; + */ + public com.google.protobuf.ByteString + getUniqueIdBytes() { + Object ref = uniqueId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + uniqueId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (!getProducerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, producerGroup_); + } + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, topic_); + } + if (!getContentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, content_); + } + if (!getTtlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, ttl_); + } + if (!getUniqueIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, uniqueId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (!getProducerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, producerGroup_); + } + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, topic_); + } + if (!getContentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, content_); + } + if (!getTtlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, ttl_); + } + if (!getUniqueIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, uniqueId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Message)) { + return super.equals(obj); + } + Message other = (Message) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && getProducerGroup() + .equals(other.getProducerGroup()); + result = result && getTopic() + .equals(other.getTopic()); + result = result && getContent() + .equals(other.getContent()); + result = result && getTtl() + .equals(other.getTtl()); + result = result && getUniqueId() + .equals(other.getUniqueId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getProducerGroup().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + CONTENT_FIELD_NUMBER; + hash = (53 * hash) + getContent().hashCode(); + hash = (37 * hash) + TTL_FIELD_NUMBER; + hash = (53 * hash) + getTtl().hashCode(); + hash = (37 * hash) + UNIQUEID_FIELD_NUMBER; + hash = (53 * hash) + getUniqueId().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Message parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Message parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Message parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Message parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Message parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Message parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Message parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Message 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 Message parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static Message 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 Message parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Message parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Message prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Message} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Message) + MessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Message.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Message.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + producerGroup_ = ""; + + topic_ = ""; + + content_ = ""; + + ttl_ = ""; + + uniqueId_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_descriptor; + } + + public Message getDefaultInstanceForType() { + return Message.getDefaultInstance(); + } + + public Message build() { + Message result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Message buildPartial() { + Message result = new Message(this); + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.producerGroup_ = producerGroup_; + result.topic_ = topic_; + result.content_ = content_; + result.ttl_ = ttl_; + result.uniqueId_ = uniqueId_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Message) { + return mergeFrom((Message)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Message other) { + if (other == Message.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (!other.getProducerGroup().isEmpty()) { + producerGroup_ = other.producerGroup_; + onChanged(); + } + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (!other.getContent().isEmpty()) { + content_ = other.content_; + onChanged(); + } + if (!other.getTtl().isEmpty()) { + ttl_ = other.ttl_; + onChanged(); + } + if (!other.getUniqueId().isEmpty()) { + uniqueId_ = other.uniqueId_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Message parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Message) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private Object producerGroup_ = ""; + /** + * string producerGroup = 2; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string producerGroup = 2; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string producerGroup = 2; + */ + public Builder setProducerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + producerGroup_ = value; + onChanged(); + return this; + } + /** + * string producerGroup = 2; + */ + public Builder clearProducerGroup() { + + producerGroup_ = getDefaultInstance().getProducerGroup(); + onChanged(); + return this; + } + /** + * string producerGroup = 2; + */ + public Builder setProducerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + producerGroup_ = value; + onChanged(); + return this; + } + + private Object topic_ = ""; + /** + * string topic = 3; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string topic = 3; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string topic = 3; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * string topic = 3; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * string topic = 3; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private Object content_ = ""; + /** + * string content = 4; + */ + public String getContent() { + Object ref = content_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string content = 4; + */ + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string content = 4; + */ + public Builder setContent( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + content_ = value; + onChanged(); + return this; + } + /** + * string content = 4; + */ + public Builder clearContent() { + + content_ = getDefaultInstance().getContent(); + onChanged(); + return this; + } + /** + * string content = 4; + */ + public Builder setContentBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + content_ = value; + onChanged(); + return this; + } + + private Object ttl_ = ""; + /** + * string ttl = 5; + */ + public String getTtl() { + Object ref = ttl_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ttl_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string ttl = 5; + */ + public com.google.protobuf.ByteString + getTtlBytes() { + Object ref = ttl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ttl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string ttl = 5; + */ + public Builder setTtl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + ttl_ = value; + onChanged(); + return this; + } + /** + * string ttl = 5; + */ + public Builder clearTtl() { + + ttl_ = getDefaultInstance().getTtl(); + onChanged(); + return this; + } + /** + * string ttl = 5; + */ + public Builder setTtlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + ttl_ = value; + onChanged(); + return this; + } + + private Object uniqueId_ = ""; + /** + * string uniqueId = 6; + */ + public String getUniqueId() { + Object ref = uniqueId_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + uniqueId_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string uniqueId = 6; + */ + public com.google.protobuf.ByteString + getUniqueIdBytes() { + Object ref = uniqueId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + uniqueId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string uniqueId = 6; + */ + public Builder setUniqueId( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + uniqueId_ = value; + onChanged(); + return this; + } + /** + * string uniqueId = 6; + */ + public Builder clearUniqueId() { + + uniqueId_ = getDefaultInstance().getUniqueId(); + onChanged(); + return this; + } + /** + * string uniqueId = 6; + */ + public Builder setUniqueIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + uniqueId_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Message) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Message) + private static final Message DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Message(); + } + + public static Message getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Message parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Message(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Message getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/MessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/MessageOrBuilder.java new file mode 100644 index 0000000000..698f020916 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/MessageOrBuilder.java @@ -0,0 +1,89 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface MessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Message) + com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + boolean hasHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeader getHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * string producerGroup = 2; + */ + String getProducerGroup(); + /** + * string producerGroup = 2; + */ + com.google.protobuf.ByteString + getProducerGroupBytes(); + + /** + * string topic = 3; + */ + String getTopic(); + /** + * string topic = 3; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * string content = 4; + */ + String getContent(); + /** + * string content = 4; + */ + com.google.protobuf.ByteString + getContentBytes(); + + /** + * string ttl = 5; + */ + String getTtl(); + /** + * string ttl = 5; + */ + com.google.protobuf.ByteString + getTtlBytes(); + + /** + * string uniqueId = 6; + */ + String getUniqueId(); + /** + * string uniqueId = 6; + */ + com.google.protobuf.ByteString + getUniqueIdBytes(); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java new file mode 100644 index 0000000000..64c5fea15f --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java @@ -0,0 +1,447 @@ +/* + * 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.eventmesh.common.protocol.grpc.protos; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.15.0)", + comments = "Source: eventmesh-client.proto") +public final class PublisherServiceGrpc { + + private PublisherServiceGrpc() {} + + public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.PublisherService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getPublishMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "publish", + requestType = Message.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getPublishMethod() { + io.grpc.MethodDescriptor getPublishMethod; + if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { + PublisherServiceGrpc.getPublishMethod = getPublishMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.PublisherService", "publish")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Message.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("publish")) + .build(); + } + } + } + return getPublishMethod; + } + + private static volatile io.grpc.MethodDescriptor getRequestReplyMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "requestReply", + requestType = Message.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getRequestReplyMethod() { + io.grpc.MethodDescriptor getRequestReplyMethod; + if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { + PublisherServiceGrpc.getRequestReplyMethod = getRequestReplyMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.PublisherService", "requestReply")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Message.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("requestReply")) + .build(); + } + } + } + return getRequestReplyMethod; + } + + private static volatile io.grpc.MethodDescriptor getBroadcastMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "broadcast", + requestType = Message.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getBroadcastMethod() { + io.grpc.MethodDescriptor getBroadcastMethod; + if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { + PublisherServiceGrpc.getBroadcastMethod = getBroadcastMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.PublisherService", "broadcast")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Message.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("broadcast")) + .build(); + } + } + } + return getBroadcastMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static PublisherServiceStub newStub(io.grpc.Channel channel) { + return new PublisherServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static PublisherServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new PublisherServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static PublisherServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new PublisherServiceFutureStub(channel); + } + + /** + */ + public static abstract class PublisherServiceImplBase implements io.grpc.BindableService { + + /** + */ + public void publish(Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getPublishMethod(), responseObserver); + } + + /** + */ + public void requestReply(Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getRequestReplyMethod(), responseObserver); + } + + /** + */ + public void broadcast(Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getBroadcastMethod(), responseObserver); + } + + @Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getPublishMethod(), + asyncUnaryCall( + new MethodHandlers< + Message, + Response>( + this, METHODID_PUBLISH))) + .addMethod( + getRequestReplyMethod(), + asyncUnaryCall( + new MethodHandlers< + Message, + Response>( + this, METHODID_REQUEST_REPLY))) + .addMethod( + getBroadcastMethod(), + asyncUnaryCall( + new MethodHandlers< + Message, + Response>( + this, METHODID_BROADCAST))) + .build(); + } + } + + /** + */ + public static final class PublisherServiceStub extends io.grpc.stub.AbstractStub { + private PublisherServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected PublisherServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherServiceStub(channel, callOptions); + } + + /** + */ + public void publish(Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getPublishMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void requestReply(Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void broadcast(Message request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getBroadcastMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class PublisherServiceBlockingStub extends io.grpc.stub.AbstractStub { + private PublisherServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected PublisherServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherServiceBlockingStub(channel, callOptions); + } + + /** + */ + public Response publish(Message request) { + return blockingUnaryCall( + getChannel(), getPublishMethod(), getCallOptions(), request); + } + + /** + */ + public Response requestReply(Message request) { + return blockingUnaryCall( + getChannel(), getRequestReplyMethod(), getCallOptions(), request); + } + + /** + */ + public Response broadcast(Message request) { + return blockingUnaryCall( + getChannel(), getBroadcastMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class PublisherServiceFutureStub extends io.grpc.stub.AbstractStub { + private PublisherServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected PublisherServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherServiceFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture publish( + Message request) { + return futureUnaryCall( + getChannel().newCall(getPublishMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture requestReply( + Message request) { + return futureUnaryCall( + getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture broadcast( + Message request) { + return futureUnaryCall( + getChannel().newCall(getBroadcastMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_PUBLISH = 0; + private static final int METHODID_REQUEST_REPLY = 1; + private static final int METHODID_BROADCAST = 2; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final PublisherServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(PublisherServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_PUBLISH: + serviceImpl.publish((Message) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_REQUEST_REPLY: + serviceImpl.requestReply((Message) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_BROADCAST: + serviceImpl.broadcast((Message) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class PublisherServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + PublisherServiceBaseDescriptorSupplier() {} + + @Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.apache.eventmesh.common.protocol.grpc.protos.EventmeshGrpc.getDescriptor(); + } + + @Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("PublisherService"); + } + } + + private static final class PublisherServiceFileDescriptorSupplier + extends PublisherServiceBaseDescriptorSupplier { + PublisherServiceFileDescriptorSupplier() {} + } + + private static final class PublisherServiceMethodDescriptorSupplier + extends PublisherServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + PublisherServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (PublisherServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new PublisherServiceFileDescriptorSupplier()) + .addMethod(getPublishMethod()) + .addMethod(getRequestReplyMethod()) + .addMethod(getBroadcastMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java new file mode 100644 index 0000000000..6a0c2ed007 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java @@ -0,0 +1,1803 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.RequestHeader} + */ +public final class RequestHeader extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.RequestHeader) + RequestHeaderOrBuilder { +private static final long serialVersionUID = 0L; + // Use RequestHeader.newBuilder() to construct. + private RequestHeader(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private RequestHeader() { + env_ = ""; + region_ = ""; + idc_ = ""; + ip_ = ""; + pid_ = ""; + sys_ = ""; + username_ = ""; + password_ = ""; + version_ = ""; + language_ = ""; + seqNum_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private RequestHeader( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + env_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + region_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + idc_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + ip_ = s; + break; + } + case 42: { + String s = input.readStringRequireUtf8(); + + pid_ = s; + break; + } + case 50: { + String s = input.readStringRequireUtf8(); + + sys_ = s; + break; + } + case 58: { + String s = input.readStringRequireUtf8(); + + username_ = s; + break; + } + case 66: { + String s = input.readStringRequireUtf8(); + + password_ = s; + break; + } + case 74: { + String s = input.readStringRequireUtf8(); + + version_ = s; + break; + } + case 82: { + String s = input.readStringRequireUtf8(); + + language_ = s; + break; + } + case 90: { + String s = input.readStringRequireUtf8(); + + seqNum_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RequestHeader.class, Builder.class); + } + + public static final int ENV_FIELD_NUMBER = 1; + private volatile Object env_; + /** + * string env = 1; + */ + public String getEnv() { + Object ref = env_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + env_ = s; + return s; + } + } + /** + * string env = 1; + */ + public com.google.protobuf.ByteString + getEnvBytes() { + Object ref = env_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + env_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REGION_FIELD_NUMBER = 2; + private volatile Object region_; + /** + * string region = 2; + */ + public String getRegion() { + Object ref = region_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + region_ = s; + return s; + } + } + /** + * string region = 2; + */ + public com.google.protobuf.ByteString + getRegionBytes() { + Object ref = region_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + region_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int IDC_FIELD_NUMBER = 3; + private volatile Object idc_; + /** + * string idc = 3; + */ + public String getIdc() { + Object ref = idc_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + idc_ = s; + return s; + } + } + /** + * string idc = 3; + */ + public com.google.protobuf.ByteString + getIdcBytes() { + Object ref = idc_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + idc_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int IP_FIELD_NUMBER = 4; + private volatile Object ip_; + /** + * string ip = 4; + */ + public String getIp() { + Object ref = ip_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ip_ = s; + return s; + } + } + /** + * string ip = 4; + */ + public com.google.protobuf.ByteString + getIpBytes() { + Object ref = ip_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ip_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PID_FIELD_NUMBER = 5; + private volatile Object pid_; + /** + * string pid = 5; + */ + public String getPid() { + Object ref = pid_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + pid_ = s; + return s; + } + } + /** + * string pid = 5; + */ + public com.google.protobuf.ByteString + getPidBytes() { + Object ref = pid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + pid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SYS_FIELD_NUMBER = 6; + private volatile Object sys_; + /** + * string sys = 6; + */ + public String getSys() { + Object ref = sys_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + sys_ = s; + return s; + } + } + /** + * string sys = 6; + */ + public com.google.protobuf.ByteString + getSysBytes() { + Object ref = sys_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + sys_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int USERNAME_FIELD_NUMBER = 7; + private volatile Object username_; + /** + * string username = 7; + */ + public String getUsername() { + Object ref = username_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + username_ = s; + return s; + } + } + /** + * string username = 7; + */ + public com.google.protobuf.ByteString + getUsernameBytes() { + Object ref = username_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PASSWORD_FIELD_NUMBER = 8; + private volatile Object password_; + /** + * string password = 8; + */ + public String getPassword() { + Object ref = password_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + password_ = s; + return s; + } + } + /** + * string password = 8; + */ + public com.google.protobuf.ByteString + getPasswordBytes() { + Object ref = password_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VERSION_FIELD_NUMBER = 9; + private volatile Object version_; + /** + * string version = 9; + */ + public String getVersion() { + Object ref = version_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + version_ = s; + return s; + } + } + /** + * string version = 9; + */ + public com.google.protobuf.ByteString + getVersionBytes() { + Object ref = version_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + version_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LANGUAGE_FIELD_NUMBER = 10; + private volatile Object language_; + /** + * string language = 10; + */ + public String getLanguage() { + Object ref = language_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + language_ = s; + return s; + } + } + /** + * string language = 10; + */ + public com.google.protobuf.ByteString + getLanguageBytes() { + Object ref = language_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SEQNUM_FIELD_NUMBER = 11; + private volatile Object seqNum_; + /** + * string seqNum = 11; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } + } + /** + * string seqNum = 11; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getEnvBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, env_); + } + if (!getRegionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, region_); + } + if (!getIdcBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, idc_); + } + if (!getIpBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, ip_); + } + if (!getPidBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, pid_); + } + if (!getSysBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, sys_); + } + if (!getUsernameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, username_); + } + if (!getPasswordBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, password_); + } + if (!getVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, version_); + } + if (!getLanguageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, language_); + } + if (!getSeqNumBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 11, seqNum_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getEnvBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, env_); + } + if (!getRegionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, region_); + } + if (!getIdcBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, idc_); + } + if (!getIpBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, ip_); + } + if (!getPidBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, pid_); + } + if (!getSysBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, sys_); + } + if (!getUsernameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, username_); + } + if (!getPasswordBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, password_); + } + if (!getVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, version_); + } + if (!getLanguageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, language_); + } + if (!getSeqNumBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, seqNum_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof RequestHeader)) { + return super.equals(obj); + } + RequestHeader other = (RequestHeader) obj; + + boolean result = true; + result = result && getEnv() + .equals(other.getEnv()); + result = result && getRegion() + .equals(other.getRegion()); + result = result && getIdc() + .equals(other.getIdc()); + result = result && getIp() + .equals(other.getIp()); + result = result && getPid() + .equals(other.getPid()); + result = result && getSys() + .equals(other.getSys()); + result = result && getUsername() + .equals(other.getUsername()); + result = result && getPassword() + .equals(other.getPassword()); + result = result && getVersion() + .equals(other.getVersion()); + result = result && getLanguage() + .equals(other.getLanguage()); + result = result && getSeqNum() + .equals(other.getSeqNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENV_FIELD_NUMBER; + hash = (53 * hash) + getEnv().hashCode(); + hash = (37 * hash) + REGION_FIELD_NUMBER; + hash = (53 * hash) + getRegion().hashCode(); + hash = (37 * hash) + IDC_FIELD_NUMBER; + hash = (53 * hash) + getIdc().hashCode(); + hash = (37 * hash) + IP_FIELD_NUMBER; + hash = (53 * hash) + getIp().hashCode(); + hash = (37 * hash) + PID_FIELD_NUMBER; + hash = (53 * hash) + getPid().hashCode(); + hash = (37 * hash) + SYS_FIELD_NUMBER; + hash = (53 * hash) + getSys().hashCode(); + hash = (37 * hash) + USERNAME_FIELD_NUMBER; + hash = (53 * hash) + getUsername().hashCode(); + hash = (37 * hash) + PASSWORD_FIELD_NUMBER; + hash = (53 * hash) + getPassword().hashCode(); + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + getVersion().hashCode(); + hash = (37 * hash) + LANGUAGE_FIELD_NUMBER; + hash = (53 * hash) + getLanguage().hashCode(); + hash = (37 * hash) + SEQNUM_FIELD_NUMBER; + hash = (53 * hash) + getSeqNum().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static RequestHeader parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RequestHeader parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RequestHeader parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RequestHeader parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RequestHeader parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RequestHeader parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RequestHeader parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static RequestHeader 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 RequestHeader parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static RequestHeader 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 RequestHeader parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static RequestHeader parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(RequestHeader prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.RequestHeader} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.RequestHeader) + RequestHeaderOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RequestHeader.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + env_ = ""; + + region_ = ""; + + idc_ = ""; + + ip_ = ""; + + pid_ = ""; + + sys_ = ""; + + username_ = ""; + + password_ = ""; + + version_ = ""; + + language_ = ""; + + seqNum_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor; + } + + public RequestHeader getDefaultInstanceForType() { + return RequestHeader.getDefaultInstance(); + } + + public RequestHeader build() { + RequestHeader result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public RequestHeader buildPartial() { + RequestHeader result = new RequestHeader(this); + result.env_ = env_; + result.region_ = region_; + result.idc_ = idc_; + result.ip_ = ip_; + result.pid_ = pid_; + result.sys_ = sys_; + result.username_ = username_; + result.password_ = password_; + result.version_ = version_; + result.language_ = language_; + result.seqNum_ = seqNum_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof RequestHeader) { + return mergeFrom((RequestHeader)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(RequestHeader other) { + if (other == RequestHeader.getDefaultInstance()) return this; + if (!other.getEnv().isEmpty()) { + env_ = other.env_; + onChanged(); + } + if (!other.getRegion().isEmpty()) { + region_ = other.region_; + onChanged(); + } + if (!other.getIdc().isEmpty()) { + idc_ = other.idc_; + onChanged(); + } + if (!other.getIp().isEmpty()) { + ip_ = other.ip_; + onChanged(); + } + if (!other.getPid().isEmpty()) { + pid_ = other.pid_; + onChanged(); + } + if (!other.getSys().isEmpty()) { + sys_ = other.sys_; + onChanged(); + } + if (!other.getUsername().isEmpty()) { + username_ = other.username_; + onChanged(); + } + if (!other.getPassword().isEmpty()) { + password_ = other.password_; + onChanged(); + } + if (!other.getVersion().isEmpty()) { + version_ = other.version_; + onChanged(); + } + if (!other.getLanguage().isEmpty()) { + language_ = other.language_; + onChanged(); + } + if (!other.getSeqNum().isEmpty()) { + seqNum_ = other.seqNum_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + RequestHeader parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (RequestHeader) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object env_ = ""; + /** + * string env = 1; + */ + public String getEnv() { + Object ref = env_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + env_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string env = 1; + */ + public com.google.protobuf.ByteString + getEnvBytes() { + Object ref = env_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + env_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string env = 1; + */ + public Builder setEnv( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + env_ = value; + onChanged(); + return this; + } + /** + * string env = 1; + */ + public Builder clearEnv() { + + env_ = getDefaultInstance().getEnv(); + onChanged(); + return this; + } + /** + * string env = 1; + */ + public Builder setEnvBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + env_ = value; + onChanged(); + return this; + } + + private Object region_ = ""; + /** + * string region = 2; + */ + public String getRegion() { + Object ref = region_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + region_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string region = 2; + */ + public com.google.protobuf.ByteString + getRegionBytes() { + Object ref = region_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + region_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string region = 2; + */ + public Builder setRegion( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + region_ = value; + onChanged(); + return this; + } + /** + * string region = 2; + */ + public Builder clearRegion() { + + region_ = getDefaultInstance().getRegion(); + onChanged(); + return this; + } + /** + * string region = 2; + */ + public Builder setRegionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + region_ = value; + onChanged(); + return this; + } + + private Object idc_ = ""; + /** + * string idc = 3; + */ + public String getIdc() { + Object ref = idc_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + idc_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string idc = 3; + */ + public com.google.protobuf.ByteString + getIdcBytes() { + Object ref = idc_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + idc_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string idc = 3; + */ + public Builder setIdc( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + idc_ = value; + onChanged(); + return this; + } + /** + * string idc = 3; + */ + public Builder clearIdc() { + + idc_ = getDefaultInstance().getIdc(); + onChanged(); + return this; + } + /** + * string idc = 3; + */ + public Builder setIdcBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + idc_ = value; + onChanged(); + return this; + } + + private Object ip_ = ""; + /** + * string ip = 4; + */ + public String getIp() { + Object ref = ip_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ip_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string ip = 4; + */ + public com.google.protobuf.ByteString + getIpBytes() { + Object ref = ip_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ip_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string ip = 4; + */ + public Builder setIp( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + ip_ = value; + onChanged(); + return this; + } + /** + * string ip = 4; + */ + public Builder clearIp() { + + ip_ = getDefaultInstance().getIp(); + onChanged(); + return this; + } + /** + * string ip = 4; + */ + public Builder setIpBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + ip_ = value; + onChanged(); + return this; + } + + private Object pid_ = ""; + /** + * string pid = 5; + */ + public String getPid() { + Object ref = pid_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + pid_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string pid = 5; + */ + public com.google.protobuf.ByteString + getPidBytes() { + Object ref = pid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + pid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string pid = 5; + */ + public Builder setPid( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + pid_ = value; + onChanged(); + return this; + } + /** + * string pid = 5; + */ + public Builder clearPid() { + + pid_ = getDefaultInstance().getPid(); + onChanged(); + return this; + } + /** + * string pid = 5; + */ + public Builder setPidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pid_ = value; + onChanged(); + return this; + } + + private Object sys_ = ""; + /** + * string sys = 6; + */ + public String getSys() { + Object ref = sys_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + sys_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string sys = 6; + */ + public com.google.protobuf.ByteString + getSysBytes() { + Object ref = sys_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + sys_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string sys = 6; + */ + public Builder setSys( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + sys_ = value; + onChanged(); + return this; + } + /** + * string sys = 6; + */ + public Builder clearSys() { + + sys_ = getDefaultInstance().getSys(); + onChanged(); + return this; + } + /** + * string sys = 6; + */ + public Builder setSysBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + sys_ = value; + onChanged(); + return this; + } + + private Object username_ = ""; + /** + * string username = 7; + */ + public String getUsername() { + Object ref = username_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + username_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string username = 7; + */ + public com.google.protobuf.ByteString + getUsernameBytes() { + Object ref = username_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string username = 7; + */ + public Builder setUsername( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + username_ = value; + onChanged(); + return this; + } + /** + * string username = 7; + */ + public Builder clearUsername() { + + username_ = getDefaultInstance().getUsername(); + onChanged(); + return this; + } + /** + * string username = 7; + */ + public Builder setUsernameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + username_ = value; + onChanged(); + return this; + } + + private Object password_ = ""; + /** + * string password = 8; + */ + public String getPassword() { + Object ref = password_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + password_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string password = 8; + */ + public com.google.protobuf.ByteString + getPasswordBytes() { + Object ref = password_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string password = 8; + */ + public Builder setPassword( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + password_ = value; + onChanged(); + return this; + } + /** + * string password = 8; + */ + public Builder clearPassword() { + + password_ = getDefaultInstance().getPassword(); + onChanged(); + return this; + } + /** + * string password = 8; + */ + public Builder setPasswordBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + password_ = value; + onChanged(); + return this; + } + + private Object version_ = ""; + /** + * string version = 9; + */ + public String getVersion() { + Object ref = version_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + version_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string version = 9; + */ + public com.google.protobuf.ByteString + getVersionBytes() { + Object ref = version_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + version_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string version = 9; + */ + public Builder setVersion( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + version_ = value; + onChanged(); + return this; + } + /** + * string version = 9; + */ + public Builder clearVersion() { + + version_ = getDefaultInstance().getVersion(); + onChanged(); + return this; + } + /** + * string version = 9; + */ + public Builder setVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + version_ = value; + onChanged(); + return this; + } + + private Object language_ = ""; + /** + * string language = 10; + */ + public String getLanguage() { + Object ref = language_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + language_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string language = 10; + */ + public com.google.protobuf.ByteString + getLanguageBytes() { + Object ref = language_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string language = 10; + */ + public Builder setLanguage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + language_ = value; + onChanged(); + return this; + } + /** + * string language = 10; + */ + public Builder clearLanguage() { + + language_ = getDefaultInstance().getLanguage(); + onChanged(); + return this; + } + /** + * string language = 10; + */ + public Builder setLanguageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + language_ = value; + onChanged(); + return this; + } + + private Object seqNum_ = ""; + /** + * string seqNum = 11; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string seqNum = 11; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string seqNum = 11; + */ + public Builder setSeqNum( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + seqNum_ = value; + onChanged(); + return this; + } + /** + * string seqNum = 11; + */ + public Builder clearSeqNum() { + + seqNum_ = getDefaultInstance().getSeqNum(); + onChanged(); + return this; + } + /** + * string seqNum = 11; + */ + public Builder setSeqNumBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + seqNum_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.RequestHeader) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.RequestHeader) + private static final RequestHeader DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new RequestHeader(); + } + + public static RequestHeader getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public RequestHeader parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new RequestHeader(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public RequestHeader getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java new file mode 100644 index 0000000000..3f8d4eabbd --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java @@ -0,0 +1,136 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface RequestHeaderOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.RequestHeader) + com.google.protobuf.MessageOrBuilder { + + /** + * string env = 1; + */ + String getEnv(); + /** + * string env = 1; + */ + com.google.protobuf.ByteString + getEnvBytes(); + + /** + * string region = 2; + */ + String getRegion(); + /** + * string region = 2; + */ + com.google.protobuf.ByteString + getRegionBytes(); + + /** + * string idc = 3; + */ + String getIdc(); + /** + * string idc = 3; + */ + com.google.protobuf.ByteString + getIdcBytes(); + + /** + * string ip = 4; + */ + String getIp(); + /** + * string ip = 4; + */ + com.google.protobuf.ByteString + getIpBytes(); + + /** + * string pid = 5; + */ + String getPid(); + /** + * string pid = 5; + */ + com.google.protobuf.ByteString + getPidBytes(); + + /** + * string sys = 6; + */ + String getSys(); + /** + * string sys = 6; + */ + com.google.protobuf.ByteString + getSysBytes(); + + /** + * string username = 7; + */ + String getUsername(); + /** + * string username = 7; + */ + com.google.protobuf.ByteString + getUsernameBytes(); + + /** + * string password = 8; + */ + String getPassword(); + /** + * string password = 8; + */ + com.google.protobuf.ByteString + getPasswordBytes(); + + /** + * string version = 9; + */ + String getVersion(); + /** + * string version = 9; + */ + com.google.protobuf.ByteString + getVersionBytes(); + + /** + * string language = 10; + */ + String getLanguage(); + /** + * string language = 10; + */ + com.google.protobuf.ByteString + getLanguageBytes(); + + /** + * string seqNum = 11; + */ + String getSeqNum(); + /** + * string seqNum = 11; + */ + com.google.protobuf.ByteString + getSeqNumBytes(); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java new file mode 100644 index 0000000000..9c087d2a12 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java @@ -0,0 +1,914 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.Response} + */ +public final class Response extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Response) + ResponseOrBuilder { +private static final long serialVersionUID = 0L; + // Use Response.newBuilder() to construct. + private Response(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Response() { + respCode_ = ""; + respMsg_ = ""; + respTime_ = ""; + seqNum_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Response( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + respCode_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + respMsg_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + respTime_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + seqNum_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Response.class, Builder.class); + } + + public static final int RESPCODE_FIELD_NUMBER = 1; + private volatile Object respCode_; + /** + * string respCode = 1; + */ + public String getRespCode() { + Object ref = respCode_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respCode_ = s; + return s; + } + } + /** + * string respCode = 1; + */ + public com.google.protobuf.ByteString + getRespCodeBytes() { + Object ref = respCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESPMSG_FIELD_NUMBER = 2; + private volatile Object respMsg_; + /** + * string respMsg = 2; + */ + public String getRespMsg() { + Object ref = respMsg_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respMsg_ = s; + return s; + } + } + /** + * string respMsg = 2; + */ + public com.google.protobuf.ByteString + getRespMsgBytes() { + Object ref = respMsg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respMsg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESPTIME_FIELD_NUMBER = 3; + private volatile Object respTime_; + /** + * string respTime = 3; + */ + public String getRespTime() { + Object ref = respTime_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respTime_ = s; + return s; + } + } + /** + * string respTime = 3; + */ + public com.google.protobuf.ByteString + getRespTimeBytes() { + Object ref = respTime_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respTime_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SEQNUM_FIELD_NUMBER = 4; + private volatile Object seqNum_; + /** + * string seqNum = 4; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } + } + /** + * string seqNum = 4; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRespCodeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, respCode_); + } + if (!getRespMsgBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, respMsg_); + } + if (!getRespTimeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, respTime_); + } + if (!getSeqNumBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, seqNum_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRespCodeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, respCode_); + } + if (!getRespMsgBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, respMsg_); + } + if (!getRespTimeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, respTime_); + } + if (!getSeqNumBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, seqNum_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Response)) { + return super.equals(obj); + } + Response other = (Response) obj; + + boolean result = true; + result = result && getRespCode() + .equals(other.getRespCode()); + result = result && getRespMsg() + .equals(other.getRespMsg()); + result = result && getRespTime() + .equals(other.getRespTime()); + result = result && getSeqNum() + .equals(other.getSeqNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESPCODE_FIELD_NUMBER; + hash = (53 * hash) + getRespCode().hashCode(); + hash = (37 * hash) + RESPMSG_FIELD_NUMBER; + hash = (53 * hash) + getRespMsg().hashCode(); + hash = (37 * hash) + RESPTIME_FIELD_NUMBER; + hash = (53 * hash) + getRespTime().hashCode(); + hash = (37 * hash) + SEQNUM_FIELD_NUMBER; + hash = (53 * hash) + getSeqNum().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Response parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Response parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Response parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Response parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Response parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Response parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Response parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Response 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 Response parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static Response 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 Response parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Response parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Response prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Response} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Response) + ResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Response.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Response.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + respCode_ = ""; + + respMsg_ = ""; + + respTime_ = ""; + + seqNum_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_descriptor; + } + + public Response getDefaultInstanceForType() { + return Response.getDefaultInstance(); + } + + public Response build() { + Response result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Response buildPartial() { + Response result = new Response(this); + result.respCode_ = respCode_; + result.respMsg_ = respMsg_; + result.respTime_ = respTime_; + result.seqNum_ = seqNum_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Response) { + return mergeFrom((Response)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Response other) { + if (other == Response.getDefaultInstance()) return this; + if (!other.getRespCode().isEmpty()) { + respCode_ = other.respCode_; + onChanged(); + } + if (!other.getRespMsg().isEmpty()) { + respMsg_ = other.respMsg_; + onChanged(); + } + if (!other.getRespTime().isEmpty()) { + respTime_ = other.respTime_; + onChanged(); + } + if (!other.getSeqNum().isEmpty()) { + seqNum_ = other.seqNum_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Response parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Response) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object respCode_ = ""; + /** + * string respCode = 1; + */ + public String getRespCode() { + Object ref = respCode_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respCode_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string respCode = 1; + */ + public com.google.protobuf.ByteString + getRespCodeBytes() { + Object ref = respCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string respCode = 1; + */ + public Builder setRespCode( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + respCode_ = value; + onChanged(); + return this; + } + /** + * string respCode = 1; + */ + public Builder clearRespCode() { + + respCode_ = getDefaultInstance().getRespCode(); + onChanged(); + return this; + } + /** + * string respCode = 1; + */ + public Builder setRespCodeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + respCode_ = value; + onChanged(); + return this; + } + + private Object respMsg_ = ""; + /** + * string respMsg = 2; + */ + public String getRespMsg() { + Object ref = respMsg_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respMsg_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string respMsg = 2; + */ + public com.google.protobuf.ByteString + getRespMsgBytes() { + Object ref = respMsg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respMsg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string respMsg = 2; + */ + public Builder setRespMsg( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + respMsg_ = value; + onChanged(); + return this; + } + /** + * string respMsg = 2; + */ + public Builder clearRespMsg() { + + respMsg_ = getDefaultInstance().getRespMsg(); + onChanged(); + return this; + } + /** + * string respMsg = 2; + */ + public Builder setRespMsgBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + respMsg_ = value; + onChanged(); + return this; + } + + private Object respTime_ = ""; + /** + * string respTime = 3; + */ + public String getRespTime() { + Object ref = respTime_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + respTime_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string respTime = 3; + */ + public com.google.protobuf.ByteString + getRespTimeBytes() { + Object ref = respTime_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + respTime_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string respTime = 3; + */ + public Builder setRespTime( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + respTime_ = value; + onChanged(); + return this; + } + /** + * string respTime = 3; + */ + public Builder clearRespTime() { + + respTime_ = getDefaultInstance().getRespTime(); + onChanged(); + return this; + } + /** + * string respTime = 3; + */ + public Builder setRespTimeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + respTime_ = value; + onChanged(); + return this; + } + + private Object seqNum_ = ""; + /** + * string seqNum = 4; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string seqNum = 4; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string seqNum = 4; + */ + public Builder setSeqNum( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + seqNum_ = value; + onChanged(); + return this; + } + /** + * string seqNum = 4; + */ + public Builder clearSeqNum() { + + seqNum_ = getDefaultInstance().getSeqNum(); + onChanged(); + return this; + } + /** + * string seqNum = 4; + */ + public Builder setSeqNumBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + seqNum_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Response) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Response) + private static final Response DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Response(); + } + + public static Response getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Response parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Response(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Response getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java new file mode 100644 index 0000000000..4c3abd6326 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface ResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Response) + com.google.protobuf.MessageOrBuilder { + + /** + * string respCode = 1; + */ + String getRespCode(); + /** + * string respCode = 1; + */ + com.google.protobuf.ByteString + getRespCodeBytes(); + + /** + * string respMsg = 2; + */ + String getRespMsg(); + /** + * string respMsg = 2; + */ + com.google.protobuf.ByteString + getRespMsgBytes(); + + /** + * string respTime = 3; + */ + String getRespTime(); + /** + * string respTime = 3; + */ + com.google.protobuf.ByteString + getRespTimeBytes(); + + /** + * string seqNum = 4; + */ + String getSeqNum(); + /** + * string seqNum = 4; + */ + com.google.protobuf.ByteString + getSeqNumBytes(); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java new file mode 100644 index 0000000000..cd2f799e22 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java @@ -0,0 +1,1998 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription} + */ +public final class Subscription extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Subscription) + SubscriptionOrBuilder { +private static final long serialVersionUID = 0L; + // Use Subscription.newBuilder() to construct. + private Subscription(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Subscription() { + consumerGroup_ = ""; + subscriptionItems_ = java.util.Collections.emptyList(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Subscription( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + consumerGroup_ = s; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + subscriptionItems_.add( + input.readMessage(SubscriptionItem.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Subscription.class, Builder.class); + } + + public interface SubscriptionItemOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + com.google.protobuf.MessageOrBuilder { + + /** + * string topic = 1; + */ + String getTopic(); + /** + * string topic = 1; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * string mode = 2; + */ + String getMode(); + /** + * string mode = 2; + */ + com.google.protobuf.ByteString + getModeBytes(); + + /** + * string type = 3; + */ + String getType(); + /** + * string type = 3; + */ + com.google.protobuf.ByteString + getTypeBytes(); + + /** + * string url = 4; + */ + String getUrl(); + /** + * string url = 4; + */ + com.google.protobuf.ByteString + getUrlBytes(); + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem} + */ + public static final class SubscriptionItem extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + SubscriptionItemOrBuilder { + private static final long serialVersionUID = 0L; + // Use SubscriptionItem.newBuilder() to construct. + private SubscriptionItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SubscriptionItem() { + topic_ = ""; + mode_ = ""; + type_ = ""; + url_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SubscriptionItem( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + mode_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + type_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SubscriptionItem.class, Builder.class); + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile Object topic_; + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MODE_FIELD_NUMBER = 2; + private volatile Object mode_; + /** + * string mode = 2; + */ + public String getMode() { + Object ref = mode_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + mode_ = s; + return s; + } + } + /** + * string mode = 2; + */ + public com.google.protobuf.ByteString + getModeBytes() { + Object ref = mode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + mode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 3; + private volatile Object type_; + /** + * string type = 3; + */ + public String getType() { + Object ref = type_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + type_ = s; + return s; + } + } + /** + * string type = 3; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int URL_FIELD_NUMBER = 4; + private volatile Object url_; + /** + * string url = 4; + */ + public String getUrl() { + Object ref = url_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); + } + if (!getModeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, mode_); + } + if (!getTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_); + } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, url_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); + } + if (!getModeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, mode_); + } + if (!getTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_); + } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, url_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SubscriptionItem)) { + return super.equals(obj); + } + SubscriptionItem other = (SubscriptionItem) obj; + + boolean result = true; + result = result && getTopic() + .equals(other.getTopic()); + result = result && getMode() + .equals(other.getMode()); + result = result && getType() + .equals(other.getType()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + MODE_FIELD_NUMBER; + hash = (53 * hash) + getMode().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static SubscriptionItem parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SubscriptionItem parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SubscriptionItem parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SubscriptionItem parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SubscriptionItem parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static SubscriptionItem parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static SubscriptionItem parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SubscriptionItem 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 SubscriptionItem parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static SubscriptionItem 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 SubscriptionItem parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static SubscriptionItem parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(SubscriptionItem prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + SubscriptionItemOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + SubscriptionItem.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + topic_ = ""; + + mode_ = ""; + + type_ = ""; + + url_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor; + } + + public SubscriptionItem getDefaultInstanceForType() { + return SubscriptionItem.getDefaultInstance(); + } + + public SubscriptionItem build() { + SubscriptionItem result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public SubscriptionItem buildPartial() { + SubscriptionItem result = new SubscriptionItem(this); + result.topic_ = topic_; + result.mode_ = mode_; + result.type_ = type_; + result.url_ = url_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof SubscriptionItem) { + return mergeFrom((SubscriptionItem)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(SubscriptionItem other) { + if (other == SubscriptionItem.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (!other.getMode().isEmpty()) { + mode_ = other.mode_; + onChanged(); + } + if (!other.getType().isEmpty()) { + type_ = other.type_; + onChanged(); + } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + SubscriptionItem parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (SubscriptionItem) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object topic_ = ""; + /** + * string topic = 1; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string topic = 1; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private Object mode_ = ""; + /** + * string mode = 2; + */ + public String getMode() { + Object ref = mode_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + mode_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string mode = 2; + */ + public com.google.protobuf.ByteString + getModeBytes() { + Object ref = mode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + mode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string mode = 2; + */ + public Builder setMode( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + mode_ = value; + onChanged(); + return this; + } + /** + * string mode = 2; + */ + public Builder clearMode() { + + mode_ = getDefaultInstance().getMode(); + onChanged(); + return this; + } + /** + * string mode = 2; + */ + public Builder setModeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + mode_ = value; + onChanged(); + return this; + } + + private Object type_ = ""; + /** + * string type = 3; + */ + public String getType() { + Object ref = type_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + type_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string type = 3; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string type = 3; + */ + public Builder setType( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value; + onChanged(); + return this; + } + /** + * string type = 3; + */ + public Builder clearType() { + + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + * string type = 3; + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + type_ = value; + onChanged(); + return this; + } + + private Object url_ = ""; + /** + * string url = 4; + */ + public String getUrl() { + Object ref = url_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string url = 4; + */ + public Builder setUrl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * string url = 4; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + /** + * string url = 4; + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem) + private static final SubscriptionItem DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new SubscriptionItem(); + } + + public static SubscriptionItem getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public SubscriptionItem parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SubscriptionItem(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public SubscriptionItem getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int CONSUMERGROUP_FIELD_NUMBER = 2; + private volatile Object consumerGroup_; + /** + * string consumerGroup = 2; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } + } + /** + * string consumerGroup = 2; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SUBSCRIPTIONITEMS_FIELD_NUMBER = 3; + private java.util.List subscriptionItems_; + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List getSubscriptionItemsList() { + return subscriptionItems_; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List + getSubscriptionItemsOrBuilderList() { + return subscriptionItems_; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public int getSubscriptionItemsCount() { + return subscriptionItems_.size(); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem getSubscriptionItems(int index) { + return subscriptionItems_.get(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( + int index) { + return subscriptionItems_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (!getConsumerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, consumerGroup_); + } + for (int i = 0; i < subscriptionItems_.size(); i++) { + output.writeMessage(3, subscriptionItems_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (!getConsumerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, consumerGroup_); + } + for (int i = 0; i < subscriptionItems_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, subscriptionItems_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Subscription)) { + return super.equals(obj); + } + Subscription other = (Subscription) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && getConsumerGroup() + .equals(other.getConsumerGroup()); + result = result && getSubscriptionItemsList() + .equals(other.getSubscriptionItemsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getConsumerGroup().hashCode(); + if (getSubscriptionItemsCount() > 0) { + hash = (37 * hash) + SUBSCRIPTIONITEMS_FIELD_NUMBER; + hash = (53 * hash) + getSubscriptionItemsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Subscription parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Subscription parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Subscription parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Subscription parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Subscription parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Subscription parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Subscription parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Subscription 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 Subscription parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static Subscription 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 Subscription parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Subscription parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Subscription prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Subscription) + SubscriptionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Subscription.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Subscription.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getSubscriptionItemsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + consumerGroup_ = ""; + + if (subscriptionItemsBuilder_ == null) { + subscriptionItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + subscriptionItemsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor; + } + + public Subscription getDefaultInstanceForType() { + return Subscription.getDefaultInstance(); + } + + public Subscription build() { + Subscription result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Subscription buildPartial() { + Subscription result = new Subscription(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.consumerGroup_ = consumerGroup_; + if (subscriptionItemsBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.subscriptionItems_ = subscriptionItems_; + } else { + result.subscriptionItems_ = subscriptionItemsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Subscription) { + return mergeFrom((Subscription)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Subscription other) { + if (other == Subscription.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (!other.getConsumerGroup().isEmpty()) { + consumerGroup_ = other.consumerGroup_; + onChanged(); + } + if (subscriptionItemsBuilder_ == null) { + if (!other.subscriptionItems_.isEmpty()) { + if (subscriptionItems_.isEmpty()) { + subscriptionItems_ = other.subscriptionItems_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.addAll(other.subscriptionItems_); + } + onChanged(); + } + } else { + if (!other.subscriptionItems_.isEmpty()) { + if (subscriptionItemsBuilder_.isEmpty()) { + subscriptionItemsBuilder_.dispose(); + subscriptionItemsBuilder_ = null; + subscriptionItems_ = other.subscriptionItems_; + bitField0_ = (bitField0_ & ~0x00000004); + subscriptionItemsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSubscriptionItemsFieldBuilder() : null; + } else { + subscriptionItemsBuilder_.addAllMessages(other.subscriptionItems_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Subscription parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Subscription) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private Object consumerGroup_ = ""; + /** + * string consumerGroup = 2; + */ + public String getConsumerGroup() { + Object ref = consumerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + consumerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string consumerGroup = 2; + */ + public com.google.protobuf.ByteString + getConsumerGroupBytes() { + Object ref = consumerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + consumerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string consumerGroup = 2; + */ + public Builder setConsumerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + consumerGroup_ = value; + onChanged(); + return this; + } + /** + * string consumerGroup = 2; + */ + public Builder clearConsumerGroup() { + + consumerGroup_ = getDefaultInstance().getConsumerGroup(); + onChanged(); + return this; + } + /** + * string consumerGroup = 2; + */ + public Builder setConsumerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + consumerGroup_ = value; + onChanged(); + return this; + } + + private java.util.List subscriptionItems_ = + java.util.Collections.emptyList(); + private void ensureSubscriptionItemsIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + subscriptionItems_ = new java.util.ArrayList(subscriptionItems_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> subscriptionItemsBuilder_; + + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List getSubscriptionItemsList() { + if (subscriptionItemsBuilder_ == null) { + return java.util.Collections.unmodifiableList(subscriptionItems_); + } else { + return subscriptionItemsBuilder_.getMessageList(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public int getSubscriptionItemsCount() { + if (subscriptionItemsBuilder_ == null) { + return subscriptionItems_.size(); + } else { + return subscriptionItemsBuilder_.getCount(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem getSubscriptionItems(int index) { + if (subscriptionItemsBuilder_ == null) { + return subscriptionItems_.get(index); + } else { + return subscriptionItemsBuilder_.getMessage(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder setSubscriptionItems( + int index, SubscriptionItem value) { + if (subscriptionItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.set(index, value); + onChanged(); + } else { + subscriptionItemsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder setSubscriptionItems( + int index, SubscriptionItem.Builder builderForValue) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.set(index, builderForValue.build()); + onChanged(); + } else { + subscriptionItemsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems(SubscriptionItem value) { + if (subscriptionItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(value); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems( + int index, SubscriptionItem value) { + if (subscriptionItemsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(index, value); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems( + SubscriptionItem.Builder builderForValue) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(builderForValue.build()); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addSubscriptionItems( + int index, SubscriptionItem.Builder builderForValue) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.add(index, builderForValue.build()); + onChanged(); + } else { + subscriptionItemsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder addAllSubscriptionItems( + Iterable values) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, subscriptionItems_); + onChanged(); + } else { + subscriptionItemsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder clearSubscriptionItems() { + if (subscriptionItemsBuilder_ == null) { + subscriptionItems_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + subscriptionItemsBuilder_.clear(); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public Builder removeSubscriptionItems(int index) { + if (subscriptionItemsBuilder_ == null) { + ensureSubscriptionItemsIsMutable(); + subscriptionItems_.remove(index); + onChanged(); + } else { + subscriptionItemsBuilder_.remove(index); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem.Builder getSubscriptionItemsBuilder( + int index) { + return getSubscriptionItemsFieldBuilder().getBuilder(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( + int index) { + if (subscriptionItemsBuilder_ == null) { + return subscriptionItems_.get(index); } else { + return subscriptionItemsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List + getSubscriptionItemsOrBuilderList() { + if (subscriptionItemsBuilder_ != null) { + return subscriptionItemsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(subscriptionItems_); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem.Builder addSubscriptionItemsBuilder() { + return getSubscriptionItemsFieldBuilder().addBuilder( + SubscriptionItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public SubscriptionItem.Builder addSubscriptionItemsBuilder( + int index) { + return getSubscriptionItemsFieldBuilder().addBuilder( + index, SubscriptionItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + public java.util.List + getSubscriptionItemsBuilderList() { + return getSubscriptionItemsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> + getSubscriptionItemsFieldBuilder() { + if (subscriptionItemsBuilder_ == null) { + subscriptionItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder>( + subscriptionItems_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + subscriptionItems_ = null; + } + return subscriptionItemsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Subscription) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Subscription) + private static final Subscription DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Subscription(); + } + + public static Subscription getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Subscription parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Subscription(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Subscription getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java new file mode 100644 index 0000000000..713ae21717 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java @@ -0,0 +1,73 @@ +/* + * 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface SubscriptionOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Subscription) + com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + boolean hasHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeader getHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * string consumerGroup = 2; + */ + String getConsumerGroup(); + /** + * string consumerGroup = 2; + */ + com.google.protobuf.ByteString + getConsumerGroupBytes(); + + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + java.util.List + getSubscriptionItemsList(); + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + Subscription.SubscriptionItem getSubscriptionItems(int index); + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + int getSubscriptionItemsCount(); + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + java.util.List + getSubscriptionItemsOrBuilderList(); + /** + * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3; + */ + Subscription.SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( + int index); +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto index 1b2e3fa438..9ecaaa661b 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto @@ -17,11 +17,11 @@ syntax = "proto3"; -package eventmesh.client; +package eventmesh.common.protocol.grpc; option java_multiple_files = true; -option java_package = "org.apache.eventmesh.client.grpc.protos"; -option java_outer_classname = "EventmeshClient"; +option java_package = "org.apache.eventmesh.common.protocol.grpc.protos"; +option java_outer_classname = "EventmeshGrpc"; message RequestHeader { string env = 1; @@ -39,7 +39,7 @@ message RequestHeader { message Message { RequestHeader header = 1; - string productionGroup = 2; + string producerGroup = 2; string topic = 3; string content = 4; string ttl = 5; diff --git a/eventmesh-runtime/build.gradle b/eventmesh-runtime/build.gradle index 6c34c51405..e0ede31026 100644 --- a/eventmesh-runtime/build.gradle +++ b/eventmesh-runtime/build.gradle @@ -15,6 +15,8 @@ * limitations under the License. */ +def grpcVersion = '1.15.0' + dependencies { implementation 'io.opentelemetry:opentelemetry-api' implementation 'io.opentelemetry:opentelemetry-sdk' @@ -41,6 +43,11 @@ dependencies { implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") + implementation "io.grpc:grpc-protobuf:${grpcVersion}" + implementation "io.grpc:grpc-stub:${grpcVersion}" + implementation "io.grpc:grpc-netty:${grpcVersion}" + implementation "io.grpc:grpc-netty-shaded:${grpcVersion}" + // for debug only, can be removed implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-cloudevents") implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-meshmessage") diff --git a/eventmesh-runtime/conf/eventmesh.properties b/eventmesh-runtime/conf/eventmesh.properties index 755eeb3fc2..61fcb3b388 100644 --- a/eventmesh-runtime/conf/eventmesh.properties +++ b/eventmesh-runtime/conf/eventmesh.properties @@ -21,6 +21,7 @@ eventMesh.server.cluster=COMMON eventMesh.server.name=EVENTMESH-runtime eventMesh.sysid=0000 eventMesh.server.http.port=10105 +eventMesh.server.grpc.port=10205 ########################## eventMesh tcp configuration ############################ eventMesh.server.tcp.enabled=true eventMesh.server.tcp.port=10000 diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java new file mode 100644 index 0000000000..ff034ffe42 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java @@ -0,0 +1,83 @@ +package org.apache.eventmesh.runtime.boot; + +import io.grpc.Server; +import io.grpc.ServerBuilder; +import org.apache.eventmesh.common.ThreadPoolFactory; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.core.protocol.grpc.interceptor.MetricsInterceptor; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ProducerService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; + +public class EventMeshGrpcServer { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + + private Server server; + + private ProducerManager producerManager; + + private ThreadPoolExecutor sendMsgExecutor; + + public EventMeshGrpcServer(EventMeshGrpcConfiguration eventMeshGrpcConfiguration) { + this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; + } + + public void init() throws Exception { + logger.info("==================EventMeshGRPCServer Initializing=================="); + + initThreadPool(); + + producerManager = new ProducerManager(this); + producerManager.init(); + + server = ServerBuilder.forPort(5005) + .intercept(new MetricsInterceptor()) + .addService(new ProducerService(this, sendMsgExecutor)) + .build(); + + logger.info("GRPCServer[port=5005] started"); + logger.info("-----------------EventMeshGRPCServer initialized"); + } + + public void start() throws Exception { + logger.info("---------------EventMeshGRPCServer starting-------------------"); + + producerManager.start(); + server.start(); + + logger.info("---------------EventMeshGRPCServer running-------------------"); + } + + public void shutdown() throws Exception { + logger.info("---------------EventMeshGRPCServer stopping-------------------"); + + producerManager.shutdown(); + server.shutdown(); + + logger.info("---------------EventMeshGRPCServer stopped-------------------"); + } + + public EventMeshGrpcConfiguration getEventMeshGrpcConfiguration() { + return this.eventMeshGrpcConfiguration; + } + + public ProducerManager getProducerManager() { + return producerManager; + } + + private void initThreadPool() { + BlockingQueue sendMsgThreadPoolQueue = + new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSendMsgBlockQSize); + + sendMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, + eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, "eventMesh-grpc-sendMsg-", true); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java index 8dde5d75f8..ed15d54ba8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java @@ -19,6 +19,7 @@ import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; import org.apache.eventmesh.runtime.configuration.EventMeshTCPConfiguration; import org.apache.eventmesh.runtime.connector.ConnectorResource; @@ -36,6 +37,10 @@ public class EventMeshServer { private EventMeshTCPServer eventMeshTCPServer; + private EventMeshGrpcServer eventMeshGrpcServer; + + private EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + private EventMeshHTTPConfiguration eventMeshHttpConfiguration; private EventMeshTCPConfiguration eventMeshTCPConfiguration; @@ -49,9 +54,11 @@ public class EventMeshServer { private ServiceState serviceState; public EventMeshServer(EventMeshHTTPConfiguration eventMeshHttpConfiguration, - EventMeshTCPConfiguration eventMeshTCPConfiguration) { + EventMeshTCPConfiguration eventMeshTCPConfiguration, + EventMeshGrpcConfiguration eventMeshGrpcConfiguration) { this.eventMeshHttpConfiguration = eventMeshHttpConfiguration; this.eventMeshTCPConfiguration = eventMeshTCPConfiguration; + this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; this.acl = new Acl(); this.registry = new Registry(); this.connectorResource = new ConnectorResource(); @@ -70,6 +77,11 @@ public void init() throws Exception { connectorResource.init(eventMeshHttpConfiguration.eventMeshConnectorPluginType); + if (eventMeshGrpcConfiguration != null) { + eventMeshGrpcServer = new EventMeshGrpcServer(eventMeshGrpcConfiguration); + eventMeshGrpcServer.init(); + } + eventMeshHTTPServer = new EventMeshHTTPServer(this, eventMeshHttpConfiguration); eventMeshHTTPServer.init(); eventMeshTCPServer = new EventMeshTCPServer(this, eventMeshTCPConfiguration, registry); @@ -96,6 +108,10 @@ public void start() throws Exception { registry.start(); } + if (eventMeshGrpcConfiguration != null) { + eventMeshGrpcServer.start(); + } + eventMeshHTTPServer.start(); if (eventMeshTCPConfiguration != null && eventMeshTCPConfiguration.eventMeshTcpServerEnabled) { eventMeshTCPServer.start(); @@ -117,6 +133,10 @@ public void shutdown() throws Exception { connectorResource.release(); + if (eventMeshGrpcConfiguration != null) { + eventMeshGrpcServer.shutdown(); + } + if (eventMeshHttpConfiguration != null && eventMeshHttpConfiguration.eventMeshServerSecurityEnable) { acl.shutdown(); } @@ -124,6 +144,10 @@ public void shutdown() throws Exception { logger.info("server state:{}", serviceState); } + public EventMeshGrpcServer getEventMeshGrpcServer() { + return eventMeshGrpcServer; + } + public EventMeshHTTPServer getEventMeshHTTPServer() { return eventMeshHTTPServer; } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java index ef6b129e27..48d4be7d73 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshStartup.java @@ -18,6 +18,7 @@ package org.apache.eventmesh.runtime.boot; import org.apache.eventmesh.common.config.ConfigurationWrapper; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; import org.apache.eventmesh.runtime.configuration.EventMeshTCPConfiguration; import org.apache.eventmesh.runtime.constants.EventMeshConstants; @@ -41,7 +42,9 @@ public static void main(String[] args) throws Exception { eventMeshHttpConfiguration.init(); EventMeshTCPConfiguration eventMeshTCPConfiguration = new EventMeshTCPConfiguration(configurationWrapper); eventMeshTCPConfiguration.init(); - EventMeshServer server = new EventMeshServer(eventMeshHttpConfiguration, eventMeshTCPConfiguration); + EventMeshGrpcConfiguration eventMeshGrpcConfiguration = new EventMeshGrpcConfiguration(configurationWrapper); + eventMeshGrpcConfiguration.init(); + EventMeshServer server = new EventMeshServer(eventMeshHttpConfiguration, eventMeshTCPConfiguration, eventMeshGrpcConfiguration); server.init(); server.start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java new file mode 100644 index 0000000000..aa450dda82 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java @@ -0,0 +1,228 @@ +/* + * 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.eventmesh.runtime.configuration; + +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.config.CommonConfiguration; +import org.apache.eventmesh.common.config.ConfigurationWrapper; + +public class EventMeshGrpcConfiguration extends CommonConfiguration { + + public int grpcServerPort = 10205; + + public boolean eventMeshServerBatchMsgBatchEnabled = Boolean.TRUE; + + public int eventMeshServerBatchMsgThreadNum = 10; + + public int eventMeshServerSendMsgThreadNum = 8; + + public int eventMeshServerPushMsgThreadNum = 8; + + public int eventMeshServerReplyMsgThreadNum = 8; + + public int eventMeshServerClientManageThreadNum = 4; + + public int eventMeshServerRegistryThreadNum = 10; + + public int eventMeshServerAdminThreadNum = 2; + + public int eventMeshServerRetryThreadNum = 2; + + public int eventMeshServerPullRegistryInterval = 30000; + + public int eventMeshServerAsyncAccumulationThreshold = 1000; + + public int eventMeshServerRetryBlockQSize = 10000; + + public int eventMeshServerBatchBlockQSize = 1000; + + public int eventMeshServerSendMsgBlockQSize = 1000; + + public int eventMeshServerPushMsgBlockQSize = 1000; + + public int eventMeshServerClientManageBlockQSize = 1000; + + public int eventMeshServerBusyCheckInterval = 1000; + + public boolean eventMeshServerConsumerEnabled = false; + + public boolean eventMeshServerUseTls = false; + + public int eventMeshBatchMsgRequestNumPerSecond = 20000; + + public EventMeshGrpcConfiguration(ConfigurationWrapper configurationWrapper) { + super(configurationWrapper); + } + + @Override + public void init() { + super.init(); + + if (configurationWrapper != null) { + String httpServerPortStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_GRPC_PORT); + Preconditions.checkState(StringUtils.isNotEmpty(httpServerPortStr) && StringUtils.isNumeric(httpServerPortStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_GRPC_PORT)); + grpcServerPort = Integer.valueOf(StringUtils.deleteWhitespace(httpServerPortStr)); + + String eventMeshServerBatchMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerBatchMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerBatchMsgThreadNumStr)) { + eventMeshServerBatchMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchMsgThreadNumStr)); + } + + String eventMeshServerBatchMsgReqNumPerSecondStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_REQ_NUM_PER_SECOND); + if (StringUtils.isNotEmpty(eventMeshServerBatchMsgReqNumPerSecondStr) && StringUtils.isNumeric(eventMeshServerBatchMsgReqNumPerSecondStr)) { + eventMeshBatchMsgRequestNumPerSecond = Integer.valueOf(eventMeshServerBatchMsgReqNumPerSecondStr); + } + + String eventMeshServerBatchMsgBatchEnableStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_BATCH_ENABLED); + if (StringUtils.isNotBlank(eventMeshServerBatchMsgBatchEnableStr)) { + eventMeshServerBatchMsgBatchEnabled = Boolean.valueOf(eventMeshServerBatchMsgBatchEnableStr); + } + + String eventMeshServerAsyncAccumulationThresholdStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ASYNC_ACCUMULATION_THRESHOLD); + if (StringUtils.isNotEmpty(eventMeshServerAsyncAccumulationThresholdStr) && StringUtils.isNumeric(eventMeshServerAsyncAccumulationThresholdStr)) { + eventMeshServerAsyncAccumulationThreshold = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAsyncAccumulationThresholdStr)); + } + + String eventMeshServerSendMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SENDMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerSendMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerSendMsgThreadNumStr)) { + eventMeshServerSendMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgThreadNumStr)); + } + + String eventMeshServerReplyMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REPLYMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerReplyMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerReplyMsgThreadNumStr)) { + eventMeshServerReplyMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerReplyMsgThreadNumStr)); + } + + String eventMeshServerPushMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_PUSHMSG_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerPushMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerPushMsgThreadNumStr)) { + eventMeshServerPushMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgThreadNumStr)); + } + + String eventMeshServerRegistryThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REGISTRY_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerRegistryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRegistryThreadNumStr)) { + eventMeshServerRegistryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRegistryThreadNumStr)); + } + + String eventMeshServerClientManageThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_CLIENTMANAGE_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerClientManageThreadNumStr) && StringUtils.isNumeric(eventMeshServerClientManageThreadNumStr)) { + eventMeshServerClientManageThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageThreadNumStr)); + } + + String eventMeshServerPullRegistryIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_PULL_REGISTRY_INTERVAL); + if (StringUtils.isNotEmpty(eventMeshServerPullRegistryIntervalStr) && StringUtils.isNumeric(eventMeshServerPullRegistryIntervalStr)) { + eventMeshServerPullRegistryInterval = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPullRegistryIntervalStr)); + } + + String eventMeshServerAdminThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ADMIN_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerAdminThreadNumStr) && StringUtils.isNumeric(eventMeshServerAdminThreadNumStr)) { + eventMeshServerAdminThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAdminThreadNumStr)); + } + + String eventMeshServerRetryBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerRetryBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerRetryBlockQSizeStr)) { + eventMeshServerRetryBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryBlockQSizeStr)); + } + + String eventMeshServerBatchBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_BATCHMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerBatchBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerBatchBlockQSizeStr)) { + eventMeshServerBatchBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchBlockQSizeStr)); + } + + String eventMeshServerSendMsgBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_SENDMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerSendMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerSendMsgBlockQSizeStr)) { + eventMeshServerSendMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgBlockQSizeStr)); + } + + String eventMeshServerPushMsgBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_PUSHMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerPushMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerPushMsgBlockQSizeStr)) { + eventMeshServerPushMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgBlockQSizeStr)); + } + + String eventMeshServerClientManageBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_CLIENTM_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerClientManageBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerClientManageBlockQSizeStr)) { + eventMeshServerClientManageBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageBlockQSizeStr)); + } + + String eventMeshServerBusyCheckIntervalStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_BUSY_CHECK_INTERVAL); + if (StringUtils.isNotEmpty(eventMeshServerBusyCheckIntervalStr) && StringUtils.isNumeric(eventMeshServerBusyCheckIntervalStr)) { + eventMeshServerBusyCheckInterval = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBusyCheckIntervalStr)); + } + + String eventMeshServerConsumerEnabledStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_CONSUMER_ENABLED); + if (StringUtils.isNotEmpty(eventMeshServerConsumerEnabledStr)) { + eventMeshServerConsumerEnabled = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerConsumerEnabledStr)); + } + + String eventMeshServerRetryThreadNumStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_THREAD_NUM); + if (StringUtils.isNotEmpty(eventMeshServerRetryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRetryThreadNumStr)) { + eventMeshServerRetryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryThreadNumStr)); + } + + String eventMeshServerUseTlsStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_TLS_ENABLED); + if (StringUtils.isNotEmpty(eventMeshServerUseTlsStr)) { + eventMeshServerUseTls = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerUseTlsStr)); + } + } + } + + static class ConfKeys { + + public static String KEYS_EVENTMESH_SERVER_GRPC_PORT = "eventMesh.server.grpc.port"; + + public static String KEYS_EVENTMESH_BATCHMSG_THREAD_NUM = "eventMesh.server.batchmsg.threads.num"; + + public static String KEYS_EVENTMESH_BATCHMSG_REQ_NUM_PER_SECOND = "eventMesh.server.batchmsg.reqNumPerSecond"; + + public static String KEYS_EVENTMESH_BATCHMSG_BATCH_ENABLED = "eventMesh.server.batchmsg.batch.enabled"; + + public static String KEYS_EVENTMESH_ASYNC_ACCUMULATION_THRESHOLD = "eventMesh.server.async.accumulation.threshold"; + + public static String KEY_EVENTMESH_BUSY_CHECK_INTERVAL = "eventMesh.server.busy.check.interval"; + + public static String KEYS_EVENTMESH_SENDMSG_THREAD_NUM = "eventMesh.server.sendmsg.threads.num"; + + public static String KEYS_EVENTMESH_REPLYMSG_THREAD_NUM = "eventMesh.server.replymsg.threads.num"; + + public static String KEYS_EVENTMESH_PUSHMSG_THREAD_NUM = "eventMesh.server.pushmsg.threads.num"; + + public static String KEYS_EVENTMESH_REGISTRY_THREAD_NUM = "eventMesh.server.registry.threads.num"; + + public static String KEYS_EVENTMESH_CLIENTMANAGE_THREAD_NUM = "eventMesh.server.clientmanage.threads.num"; + + public static String KEYS_EVENTMESH_ADMIN_THREAD_NUM = "eventMesh.server.admin.threads.num"; + + public static String KEY_EVENTMESH_RETRY_THREAD_NUM = "eventMesh.server.retry.threads.num"; + + public static String KEYS_EVENTMESH_PULL_REGISTRY_INTERVAL = "eventMesh.server.pull.registry.interval"; + + public static String KEY_EVENTMESH_RETRY_BLOCKQ_SIZE = "eventMesh.server.retry.blockQ.size"; + + public static String KEY_EVENTMESH_BATCHMSG_BLOCKQ_SIZE = "eventMesh.server.batchmsg.blockQ.size"; + + public static String KEY_EVENTMESH_SENDMSG_BLOCKQ_SIZE = "eventMesh.server.sendmsg.blockQ.size"; + + public static String KEY_EVENTMESH_PUSHMSG_BLOCKQ_SIZE = "eventMesh.server.pushmsg.blockQ.size"; + + public static String KEY_EVENTMESH_CLIENTM_BLOCKQ_SIZE = "eventMesh.server.clientM.blockQ.size"; + + public static String KEY_EVENTMESH_CONSUMER_ENABLED = "eventMesh.server.consumer.enabled"; + + public static String KEY_EVENTMESH_TLS_ENABLED = "eventMesh.server.useTls.enabled"; + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java new file mode 100644 index 0000000000..7e22377d77 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java @@ -0,0 +1,20 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.interceptor; + +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.ServerCallHandler; +import io.grpc.ServerInterceptor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MetricsInterceptor implements ServerInterceptor { + + private Logger logger = LoggerFactory.getLogger("grpc-services"); + + @Override + public ServerCall.Listener interceptCall( + ServerCall call, Metadata headers, ServerCallHandler next) { + logger.info("Call: {}", call.getMethodDescriptor().getFullMethodName()); + return next.startCall(call, headers); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java new file mode 100644 index 0000000000..077275a25b --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java @@ -0,0 +1,79 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.processor; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.protocol.grpc.protos.Message; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.apache.eventmesh.runtime.util.EventMeshUtil; + +public class SendAsyncMessageProcessor { + + private EventMeshGrpcServer eventMeshGrpcServer; + + public SendAsyncMessageProcessor(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void process(Object request, StreamObserver responseObserver) throws Exception { + Message message = (Message) request; + RequestHeader requestHeader = message.getHeader(); + + if (!ServiceUtils.validateHeader(requestHeader)) { + ServiceUtils.sendResp(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + return; + } + + if (!ServiceUtils.validateMessage(message)) { + ServiceUtils.sendResp(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + return; + } + + String producerGroup = message.getProducerGroup(); + + ProducerManager producerManager = eventMeshGrpcServer.getProducerManager(); + EventMeshProducer eventMeshProducer = producerManager.getEventMeshProducer(producerGroup); + + SendMessageContext sendMessageContext = new SendMessageContext(requestHeader.getSeqNum(), null, + eventMeshProducer, eventMeshGrpcServer); + + eventMeshProducer.send(sendMessageContext, new SendCallback() { + @Override + public void onSuccess(SendResult sendResult) { + ServiceUtils.sendResp(EventMeshRetCode.SUCCESS, sendResult.toString(), responseObserver); + } + + @Override + public void onException(OnExceptionContext context) { + ServiceUtils.sendResp(EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR, + EventMeshUtil.stackTrace(context.getException(), 2), responseObserver); + } + }); + + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java new file mode 100644 index 0000000000..c31a242e82 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java @@ -0,0 +1,118 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.producer; + +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.core.consumergroup.ProducerGroupConf; +import org.apache.eventmesh.runtime.core.plugin.MQProducerWrapper; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Properties; + +public class EventMeshProducer { + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + private ProducerGroupConf producerGroupConfig; + + private EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + + private MQProducerWrapper mqProducerWrapper; + + private ServiceState serviceState; + + public void send(SendMessageContext sendMsgContext, SendCallback sendCallback) + throws Exception { + mqProducerWrapper.send(sendMsgContext.getEvent(), sendCallback); + } + + public void request(SendMessageContext sendMsgContext, RequestReplyCallback rrCallback, long timeout) + throws Exception { + mqProducerWrapper.request(sendMsgContext.getEvent(), rrCallback, timeout); + } + + public boolean reply(SendMessageContext sendMsgContext, SendCallback sendCallback) + throws Exception { + mqProducerWrapper.reply(sendMsgContext.getEvent(), sendCallback); + return true; + } + + public MQProducerWrapper getMqProducerWrapper() { + return mqProducerWrapper; + } + + public synchronized void init(EventMeshGrpcConfiguration eventMeshGrpcConfiguration, + ProducerGroupConf producerGroupConfig) throws Exception { + this.producerGroupConfig = producerGroupConfig; + this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; + + Properties keyValue = new Properties(); + keyValue.put("producerGroup", producerGroupConfig.getGroupName()); + keyValue.put("instanceName", EventMeshUtil.buildMeshClientID( + producerGroupConfig.getGroupName(), eventMeshGrpcConfiguration.eventMeshCluster)); + + //TODO for defibus + keyValue.put("eventMeshIDC", eventMeshGrpcConfiguration.eventMeshIDC); + mqProducerWrapper = new MQProducerWrapper( + eventMeshGrpcConfiguration.eventMeshConnectorPluginType); + mqProducerWrapper.init(keyValue); + serviceState = ServiceState.INITED; + logger.info("EventMeshProducer [{}] inited...........", producerGroupConfig.getGroupName()); + } + + public synchronized void start() throws Exception { + if (serviceState == null || ServiceState.RUNNING.equals(serviceState)) { + return; + } + + mqProducerWrapper.start(); + serviceState = ServiceState.RUNNING; + logger.info("EventMeshProducer [{}] started..........", producerGroupConfig.getGroupName()); + } + + public synchronized void shutdown() throws Exception { + if (serviceState == null || ServiceState.INITED.equals(serviceState)) { + return; + } + + mqProducerWrapper.shutdown(); + serviceState = ServiceState.STOPED; + logger.info("EventMeshProducer [{}] shutdown.........", producerGroupConfig.getGroupName()); + } + + public ProducerGroupConf getProducerGroupConfig() { + return this.producerGroupConfig; + } + + public ServiceState getStatus() { + return this.serviceState; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("eventMeshProducer={").append("status=").append(serviceState.name()).append(",").append("producerGroupConfig=") + .append(producerGroupConfig).append("}"); + return sb.toString(); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/ProducerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/ProducerManager.java new file mode 100644 index 0000000000..60aade4bc9 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/ProducerManager.java @@ -0,0 +1,91 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.producer; + +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.core.consumergroup.ProducerGroupConf; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.ConcurrentHashMap; + +public class ProducerManager { + + public Logger logger = LoggerFactory.getLogger(this.getClass()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + private ConcurrentHashMap producerTable = new ConcurrentHashMap<>(); + + public ProducerManager(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void init() throws Exception { + logger.info("Grpc ProducerManager inited......"); + } + + public void start() throws Exception { + logger.info("Grpc ProducerManager started......"); + } + + public EventMeshProducer getEventMeshProducer(String producerGroup) throws Exception { + EventMeshProducer eventMeshProducer = null; + if (!producerTable.containsKey(producerGroup)) { + synchronized (producerTable) { + if (!producerTable.containsKey(producerGroup)) { + ProducerGroupConf producerGroupConfig = new ProducerGroupConf(producerGroup); + eventMeshProducer = createEventMeshProducer(producerGroupConfig); + eventMeshProducer.start(); + } + } + } + + eventMeshProducer = producerTable.get(producerGroup); + + if (!ServiceState.RUNNING.equals(eventMeshProducer.getStatus())) { + eventMeshProducer.start(); + } + + return eventMeshProducer; + } + + private synchronized EventMeshProducer createEventMeshProducer( + ProducerGroupConf producerGroupConfig) throws Exception { + if (producerTable.containsKey(producerGroupConfig.getGroupName())) { + return producerTable.get(producerGroupConfig.getGroupName()); + } + EventMeshProducer eventMeshProducer = new EventMeshProducer(); + eventMeshProducer.init(eventMeshGrpcServer.getEventMeshGrpcConfiguration(), + producerGroupConfig); + producerTable.put(producerGroupConfig.getGroupName(), eventMeshProducer); + return eventMeshProducer; + } + + public void shutdown() { + for (EventMeshProducer eventMeshProducer : producerTable.values()) { + try { + eventMeshProducer.shutdown(); + } catch (Exception ex) { + logger.error("shutdown eventMeshProducer[{}] err", eventMeshProducer, ex); + } + } + logger.info("producerManager shutdown......"); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/SendMessageContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/SendMessageContext.java new file mode 100644 index 0000000000..e0c28c5115 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/SendMessageContext.java @@ -0,0 +1,152 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.producer; + +import io.cloudevents.CloudEvent; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.retry.RetryContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SendMessageContext extends RetryContext { + + public static Logger logger = LoggerFactory.getLogger("retry"); + + private CloudEvent event; + + private String bizSeqNo; + + private EventMeshProducer eventMeshProducer; + + private long createTime = System.currentTimeMillis(); + + private Map props; + + public EventMeshGrpcServer eventMeshGrpcServer; + + private List eventList; + + public SendMessageContext(String bizSeqNo, CloudEvent event, EventMeshProducer eventMeshProducer, + EventMeshGrpcServer eventMeshGrpcServer) { + this.bizSeqNo = bizSeqNo; + this.event = event; + this.eventMeshProducer = eventMeshProducer; + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void addProp(String key, String val) { + if (props == null) { + props = new HashMap<>(); + } + props.put(key, val); + } + + public String getProp(String key) { + return props.get(key); + } + + public String getBizSeqNo() { + return bizSeqNo; + } + + public void setBizSeqNo(String bizSeqNo) { + this.bizSeqNo = bizSeqNo; + } + + public CloudEvent getEvent() { + return event; + } + + public void setEvent(CloudEvent event) { + this.event = event; + } + + public EventMeshProducer getEventMeshProducer() { + return eventMeshProducer; + } + + public void setEventMeshProducer(EventMeshProducer eventMeshProducer) { + this.eventMeshProducer = eventMeshProducer; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public List getEventList() { + return eventList; + } + + public void setEventList(List eventList) { + this.eventList = eventList; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("sendMessageContext={") + .append("bizSeqNo=").append(bizSeqNo) + .append(",retryTimes=").append(retryTimes) + .append(",producer=") + .append(eventMeshProducer != null ? eventMeshProducer : null) + .append(",executeTime=") + .append(DateFormatUtils.format(executeTime, Constants.DATE_FORMAT)) + .append(",createTime=") + .append(DateFormatUtils.format(createTime, Constants.DATE_FORMAT)).append("}"); + return sb.toString(); + } + + @Override + public boolean retry() throws Exception { + if (eventMeshProducer == null) { + return false; + } + + if (retryTimes > 0) { //retry once + return false; + } + + retryTimes++; + eventMeshProducer.send(this, new SendCallback() { + + @Override + public void onSuccess(SendResult sendResult) { + } + + @Override + public void onException(OnExceptionContext context) { + logger.warn("", context.getException()); + //eventMeshHTTPServer.metrics.summaryMetrics.recordSendBatchMsgFailed(1); + } + }); + return true; + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/DelayRetryable.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/DelayRetryable.java new file mode 100644 index 0000000000..bba736d1de --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/DelayRetryable.java @@ -0,0 +1,24 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.retry; + +import java.util.concurrent.Delayed; + +public interface DelayRetryable extends Delayed { + boolean retry() throws Exception; +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java new file mode 100644 index 0000000000..be9001da21 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java @@ -0,0 +1,122 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.retry; + +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.DelayQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +public class GrpcRetryer { + + private Logger retryLogger = LoggerFactory.getLogger("retry"); + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + private EventMeshGrpcConfiguration grpcConfiguration; + + public GrpcRetryer(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.grpcConfiguration = eventMeshGrpcServer.getEventMeshGrpcConfiguration(); + } + + private DelayQueue failed = new DelayQueue(); + + private ThreadPoolExecutor pool; + + private Thread dispatcher; + + public void pushRetry(DelayRetryable delayRetryable) { + if (failed.size() >= eventMeshGrpcServer.getEventMeshGrpcConfiguration() + .eventMeshServerRetryBlockQSize) { + retryLogger.error("[RETRY-QUEUE] is full!"); + return; + } + failed.offer(delayRetryable); + } + + public void init() { + pool = new ThreadPoolExecutor(grpcConfiguration.eventMeshServerRetryThreadNum, + grpcConfiguration.eventMeshServerRetryThreadNum, + 60000, + TimeUnit.MILLISECONDS, + new ArrayBlockingQueue(grpcConfiguration.eventMeshServerRetryBlockQSize), + new ThreadFactory() { + private AtomicInteger count = new AtomicInteger(); + + @Override + public Thread newThread(Runnable r) { + Thread thread = new Thread(r, "grpc-retry-" + count.incrementAndGet()); + thread.setPriority(Thread.NORM_PRIORITY); + thread.setDaemon(true); + return thread; + } + }, new ThreadPoolExecutor.AbortPolicy()); + + dispatcher = new Thread(new Runnable() { + @Override + public void run() { + try { + DelayRetryable retryObj = null; + while (!Thread.currentThread().isInterrupted() + && (retryObj = failed.take()) != null) { + final DelayRetryable delayRetryable = retryObj; + pool.execute(() -> { + try { + delayRetryable.retry(); + if (retryLogger.isDebugEnabled()) { + retryLogger.debug("retryObj : {}", delayRetryable); + } + } catch (Exception e) { + retryLogger.error("grpc-retry-dispatcher error!", e); + } + }); + } + } catch (Exception e) { + retryLogger.error("grpc-retry-dispatcher error!", e); + } + } + }, "grpc-retry-dispatcher"); + dispatcher.setDaemon(true); + logger.info("GrpcRetryer inited......"); + } + + public int size() { + return failed.size(); + } + + public void shutdown() { + dispatcher.interrupt(); + pool.shutdown(); + logger.info("GrpcRetryer shutdown......"); + } + + public void start() throws Exception { + dispatcher.start(); + logger.info("GrpcRetryer started......"); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/RetryContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/RetryContext.java new file mode 100644 index 0000000000..c09f3b9f54 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/RetryContext.java @@ -0,0 +1,50 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.retry; + +import java.util.concurrent.Delayed; +import java.util.concurrent.TimeUnit; + +public abstract class RetryContext implements DelayRetryable { + + public int retryTimes = 0; + + public long executeTime = System.currentTimeMillis(); + + public RetryContext delay(long delay) { + this.executeTime = System.currentTimeMillis() + delay; + return this; + } + + @Override + public int compareTo(Delayed delayed) { + RetryContext obj = (RetryContext) delayed; + if (this.executeTime > obj.executeTime) { + return 1; + } else if (this.executeTime == obj.executeTime) { + return 0; + } else { + return -1; + } + } + + @Override + public long getDelay(TimeUnit unit) { + return unit.convert(this.executeTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java new file mode 100644 index 0000000000..88bbe680cb --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java @@ -0,0 +1,44 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.service; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.protos.Message; +import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SendAsyncMessageProcessor; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.ThreadPoolExecutor; + +public class ProducerService extends PublisherServiceGrpc.PublisherServiceImplBase { + + private Logger logger = LoggerFactory.getLogger(ProducerService.class); + + private EventMeshGrpcServer eventMeshGrpcServer; + + private ThreadPoolExecutor threadPoolExecutor; + + public ProducerService(EventMeshGrpcServer eventMeshGrpcServer, + ThreadPoolExecutor threadPoolExecutor) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.threadPoolExecutor = threadPoolExecutor; + } + + public void publish(Message request, StreamObserver responseObserver) { + threadPoolExecutor.submit(() -> { + SendAsyncMessageProcessor sendAsyncMessageProcessor = new SendAsyncMessageProcessor(eventMeshGrpcServer); + try { + sendAsyncMessageProcessor.process(request, responseObserver); + } catch (Exception e) { + logger.error("Error code {}, error message {}", EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getRetCode(), + EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getErrMsg(), e); + ServiceUtils.sendResp(EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR, e.getMessage(), responseObserver); + } + }); + } + +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java new file mode 100644 index 0000000000..c560034903 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -0,0 +1,48 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.service; + +import io.grpc.stub.StreamObserver; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.grpc.protos.Message; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; + +public class ServiceUtils { + + static public boolean validateHeader(RequestHeader header) { + if (StringUtils.isBlank(header.getIdc()) + || StringUtils.isBlank(header.getPid()) + || !StringUtils.isNumeric(header.getPid()) + || StringUtils.isBlank(header.getSys())) { + return false; + } + return true; + } + + static public boolean validateMessage(Message message) { + if (StringUtils.isBlank(message.getUniqueId()) + || StringUtils.isBlank(message.getProducerGroup()) + || StringUtils.isBlank(message.getTopic()) + || StringUtils.isBlank(message.getContent()) + || (StringUtils.isBlank(message.getTtl()))) { + return false; + } + return true; + } + + static public void sendResp(EventMeshRetCode code, StreamObserver responseObserver) { + Response response = Response.newBuilder() + .setRespCode(code.getRetCode().toString()) + .setRespMsg(code.getErrMsg()).build(); + responseObserver.onNext(response); + responseObserver.onCompleted(); + } + + static public void sendResp(EventMeshRetCode code, String message, StreamObserver responseObserver) { + Response response = Response.newBuilder() + .setRespCode(code.getRetCode().toString()) + .setRespMsg(code.getErrMsg() + " " + message).build(); + responseObserver.onNext(response); + responseObserver.onCompleted(); + } +} diff --git a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/Server.java b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/Server.java index 4a43511fbe..d52eecc830 100644 --- a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/Server.java +++ b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/Server.java @@ -34,7 +34,7 @@ public class Server { public void startAccessServer() throws Exception { EventMeshHTTPConfiguration eventMeshHttpConfiguration = new EventMeshHTTPConfiguration(null); eventMeshHttpConfiguration.init(); - server = new EventMeshServer(eventMeshHttpConfiguration, null); + server = new EventMeshServer(eventMeshHttpConfiguration, null, null); server.init(); server.start(); } diff --git a/eventmesh-sdk-java/build.gradle b/eventmesh-sdk-java/build.gradle index 7c213ab1d1..13389091b3 100644 --- a/eventmesh-sdk-java/build.gradle +++ b/eventmesh-sdk-java/build.gradle @@ -15,6 +15,8 @@ * limitations under the License. */ +def grpcVersion = '1.15.0' + dependencies { implementation project(":eventmesh-common") @@ -26,6 +28,11 @@ dependencies { implementation "io.netty:netty-all" implementation "org.apache.httpcomponents:httpclient" + implementation "io.grpc:grpc-protobuf:${grpcVersion}" + implementation "io.grpc:grpc-stub:${grpcVersion}" + implementation "io.grpc:grpc-netty:${grpcVersion}" + implementation "io.grpc:grpc-netty-shaded:${grpcVersion}" + // protocol implementation "io.cloudevents:cloudevents-core" implementation "io.cloudevents:cloudevents-json-jackson" diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/Producer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/Producer.java new file mode 100644 index 0000000000..a15801528e --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/Producer.java @@ -0,0 +1,42 @@ +package org.apache.eventmesh.client.grpc; + +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import org.apache.eventmesh.client.grpc.config.ClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.Message; +import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Producer { + + private static Logger logger = LoggerFactory.getLogger(Producer.class); + + private ClientConfig clientConfig; + + private ManagedChannel channel; + + public Producer(ClientConfig clientConfig) { + this.clientConfig = clientConfig; + } + + public void start() { + channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) + .usePlaintext().build(); + } + + public boolean publish(String content) { + PublisherServiceGrpc.PublisherServiceBlockingStub publisherClient = PublisherServiceGrpc.newBlockingStub(channel); + + Message message = Message.newBuilder().setContent(content).build(); + + Response response = publisherClient.publish(message); + logger.info("===========" + response.getRespCode() + " " + response.getRespMsg()); + return true; + } + + public void stop() { + channel.shutdown(); + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/ClientConfig.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/ClientConfig.java new file mode 100644 index 0000000000..4703630d69 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/ClientConfig.java @@ -0,0 +1,172 @@ +/* + * 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.eventmesh.client.grpc.config; + +public class ClientConfig { + + private String serverAddr = ""; + + private int serverPort = 0; + + private String env; + + private String consumerGroup = "DefaultConsumerGroup"; + + private String producerGroup = "DefaultProducerGroup"; + + private String idc; + + private String ip = "127.0.0.1"; + + private String pid; + + private String sys; + + private String userName; + + private String password; + + private boolean useTls = false; + + public ClientConfig setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } + + public String getServerAddr() { + return this.serverAddr; + } + + public ClientConfig setServerPort(int serverPort) { + this.serverPort = serverPort; + return this; + } + + public int getServerPort() { + return this.serverPort; + } + + public String getEnv() { + return env; + } + + public ClientConfig setEnv(String env) { + this.env = env; + return this; + } + + public String getIdc() { + return idc; + } + + public ClientConfig setIdc(String idc) { + this.idc = idc; + return this; + } + + public String getIp() { + return ip; + } + + public ClientConfig setIp(String ip) { + this.ip = ip; + return this; + } + + public String getPid() { + return pid; + } + + public ClientConfig setPid(String pid) { + this.pid = pid; + return this; + } + + public String getSys() { + return sys; + } + + public ClientConfig setSys(String sys) { + this.sys = sys; + return this; + } + + public String getUserName() { + return userName; + } + + public ClientConfig setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getPassword() { + return password; + } + + public ClientConfig setPassword(String password) { + this.password = password; + return this; + } + + public boolean isUseTls() { + return useTls; + } + + public ClientConfig setUseTls(boolean useTls) { + this.useTls = useTls; + return this; + } + + public String getConsumerGroup() { + return consumerGroup; + } + + public ClientConfig setConsumerGroup(String consumerGroup) { + this.consumerGroup = consumerGroup; + return this; + } + + public String getProducerGroup() { + return producerGroup; + } + + public ClientConfig setProducerGroup(String producerGroup) { + this.producerGroup = producerGroup; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("ClientConfig={") + .append("ServerAddr=").append(serverAddr).append(",") + .append("ServerPort=").append(serverPort).append(",") + .append("env=").append(env).append(",") + .append("idc=").append(idc).append(",") + .append("producerGroup=").append(producerGroup).append(",") + .append("consumerGroup=").append(consumerGroup).append(",") + .append("ip=").append(ip).append(",") + .append("pid=").append(pid).append(",") + .append("sys=").append(sys).append(",") + .append("userName=").append(userName).append(",") + .append("password=").append("***").append(",") + .append("useTls=").append(useTls).append("}"); + return sb.toString(); + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java deleted file mode 100644 index aff9b4ce2c..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ConsumerServiceGrpc.java +++ /dev/null @@ -1,453 +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.eventmesh.client.grpc.protos; - -import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.*; -import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.*; - -/** - * - */ -@javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.15.0)", - comments = "Source: eventmesh-client.proto") -public final class ConsumerServiceGrpc { - - private ConsumerServiceGrpc() { - } - - public static final String SERVICE_NAME = "eventmesh.client.ConsumerService"; - - // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getSubscribeMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "subscribe", - requestType = org.apache.eventmesh.client.grpc.protos.Subscription.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getSubscribeMethod() { - io.grpc.MethodDescriptor getSubscribeMethod; - if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { - synchronized (ConsumerServiceGrpc.class) { - if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { - ConsumerServiceGrpc.getSubscribeMethod = getSubscribeMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.ConsumerService", "subscribe")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Subscription.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribe")) - .build(); - } - } - } - return getSubscribeMethod; - } - - private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "subscribeStream", - requestType = org.apache.eventmesh.client.grpc.protos.Subscription.class, - responseType = org.apache.eventmesh.client.grpc.protos.Message.class, - methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - public static io.grpc.MethodDescriptor getSubscribeStreamMethod() { - io.grpc.MethodDescriptor getSubscribeStreamMethod; - if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { - synchronized (ConsumerServiceGrpc.class) { - if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { - ConsumerServiceGrpc.getSubscribeStreamMethod = getSubscribeStreamMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.ConsumerService", "subscribeStream")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Subscription.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) - .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribeStream")) - .build(); - } - } - } - return getSubscribeStreamMethod; - } - - private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "unsubscribe", - requestType = org.apache.eventmesh.client.grpc.protos.Subscription.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getUnsubscribeMethod() { - io.grpc.MethodDescriptor getUnsubscribeMethod; - if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { - synchronized (ConsumerServiceGrpc.class) { - if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { - ConsumerServiceGrpc.getUnsubscribeMethod = getUnsubscribeMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.ConsumerService", "unsubscribe")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Subscription.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("unsubscribe")) - .build(); - } - } - } - return getUnsubscribeMethod; - } - - /** - * Creates a new async stub that supports all call types for the service - */ - public static ConsumerServiceStub newStub(io.grpc.Channel channel) { - return new ConsumerServiceStub(channel); - } - - /** - * Creates a new blocking-style stub that supports unary and streaming output calls on the service - */ - public static ConsumerServiceBlockingStub newBlockingStub( - io.grpc.Channel channel) { - return new ConsumerServiceBlockingStub(channel); - } - - /** - * Creates a new ListenableFuture-style stub that supports unary calls on the service - */ - public static ConsumerServiceFutureStub newFutureStub( - io.grpc.Channel channel) { - return new ConsumerServiceFutureStub(channel); - } - - /** - * - */ - public static abstract class ConsumerServiceImplBase implements io.grpc.BindableService { - - /** - * - */ - public void subscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getSubscribeMethod(), responseObserver); - } - - /** - * - */ - public void subscribeStream(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getSubscribeStreamMethod(), responseObserver); - } - - /** - * - */ - public void unsubscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getUnsubscribeMethod(), responseObserver); - } - - @Override - public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getSubscribeMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Subscription, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_SUBSCRIBE))) - .addMethod( - getSubscribeStreamMethod(), - asyncServerStreamingCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Subscription, - org.apache.eventmesh.client.grpc.protos.Message>( - this, METHODID_SUBSCRIBE_STREAM))) - .addMethod( - getUnsubscribeMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Subscription, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_UNSUBSCRIBE))) - .build(); - } - } - - /** - * - */ - public static final class ConsumerServiceStub extends io.grpc.stub.AbstractStub { - private ConsumerServiceStub(io.grpc.Channel channel) { - super(channel); - } - - private ConsumerServiceStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected ConsumerServiceStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new ConsumerServiceStub(channel, callOptions); - } - - /** - * - */ - public void subscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getSubscribeMethod(), getCallOptions()), request, responseObserver); - } - - /** - * - */ - public void subscribeStream(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncServerStreamingCall( - getChannel().newCall(getSubscribeStreamMethod(), getCallOptions()), request, responseObserver); - } - - /** - * - */ - public void unsubscribe(org.apache.eventmesh.client.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request, responseObserver); - } - } - - /** - * - */ - public static final class ConsumerServiceBlockingStub extends io.grpc.stub.AbstractStub { - private ConsumerServiceBlockingStub(io.grpc.Channel channel) { - super(channel); - } - - private ConsumerServiceBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected ConsumerServiceBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new ConsumerServiceBlockingStub(channel, callOptions); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response subscribe(org.apache.eventmesh.client.grpc.protos.Subscription request) { - return blockingUnaryCall( - getChannel(), getSubscribeMethod(), getCallOptions(), request); - } - - /** - * - */ - public java.util.Iterator subscribeStream( - org.apache.eventmesh.client.grpc.protos.Subscription request) { - return blockingServerStreamingCall( - getChannel(), getSubscribeStreamMethod(), getCallOptions(), request); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response unsubscribe(org.apache.eventmesh.client.grpc.protos.Subscription request) { - return blockingUnaryCall( - getChannel(), getUnsubscribeMethod(), getCallOptions(), request); - } - } - - /** - * - */ - public static final class ConsumerServiceFutureStub extends io.grpc.stub.AbstractStub { - private ConsumerServiceFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private ConsumerServiceFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected ConsumerServiceFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new ConsumerServiceFutureStub(channel, callOptions); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture subscribe( - org.apache.eventmesh.client.grpc.protos.Subscription request) { - return futureUnaryCall( - getChannel().newCall(getSubscribeMethod(), getCallOptions()), request); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture unsubscribe( - org.apache.eventmesh.client.grpc.protos.Subscription request) { - return futureUnaryCall( - getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request); - } - } - - private static final int METHODID_SUBSCRIBE = 0; - private static final int METHODID_SUBSCRIBE_STREAM = 1; - private static final int METHODID_UNSUBSCRIBE = 2; - - private static final class MethodHandlers implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final ConsumerServiceImplBase serviceImpl; - private final int methodId; - - MethodHandlers(ConsumerServiceImplBase serviceImpl, int methodId) { - this.serviceImpl = serviceImpl; - this.methodId = methodId; - } - - @Override - @SuppressWarnings("unchecked") - public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_SUBSCRIBE: - serviceImpl.subscribe((org.apache.eventmesh.client.grpc.protos.Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_SUBSCRIBE_STREAM: - serviceImpl.subscribeStream((org.apache.eventmesh.client.grpc.protos.Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_UNSUBSCRIBE: - serviceImpl.unsubscribe((org.apache.eventmesh.client.grpc.protos.Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - default: - throw new AssertionError(); - } - } - - @Override - @SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } - } - - private static abstract class ConsumerServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { - ConsumerServiceBaseDescriptorSupplier() { - } - - @Override - public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return org.apache.eventmesh.client.grpc.protos.EventmeshClient.getDescriptor(); - } - - @Override - public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { - return getFileDescriptor().findServiceByName("ConsumerService"); - } - } - - private static final class ConsumerServiceFileDescriptorSupplier - extends ConsumerServiceBaseDescriptorSupplier { - ConsumerServiceFileDescriptorSupplier() { - } - } - - private static final class ConsumerServiceMethodDescriptorSupplier - extends ConsumerServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; - - ConsumerServiceMethodDescriptorSupplier(String methodName) { - this.methodName = methodName; - } - - @Override - public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { - return getServiceDescriptor().findMethodByName(methodName); - } - } - - private static volatile io.grpc.ServiceDescriptor serviceDescriptor; - - public static io.grpc.ServiceDescriptor getServiceDescriptor() { - io.grpc.ServiceDescriptor result = serviceDescriptor; - if (result == null) { - synchronized (ConsumerServiceGrpc.class) { - result = serviceDescriptor; - if (result == null) { - serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) - .setSchemaDescriptor(new ConsumerServiceFileDescriptorSupplier()) - .addMethod(getSubscribeMethod()) - .addMethod(getSubscribeStreamMethod()) - .addMethod(getUnsubscribeMethod()) - .build(); - } - } - } - return result; - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java deleted file mode 100644 index 9bd4db761d..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/EventmeshClient.java +++ /dev/null @@ -1,174 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -public final class EventmeshClient { - private EventmeshClient() { - } - - 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_eventmesh_client_RequestHeader_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_RequestHeader_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Message_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Message_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Response_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Response_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Subscription_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Subscription_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Heartbeat_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Heartbeat_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - - static { - String[] descriptorData = { - "\n\026eventmesh-client.proto\022\020eventmesh.clie" + - "nt\"\266\001\n\rRequestHeader\022\013\n\003env\030\001 \001(\t\022\016\n\006reg" + - "ion\030\002 \001(\t\022\013\n\003idc\030\003 \001(\t\022\n\n\002ip\030\004 \001(\t\022\013\n\003pi" + - "d\030\005 \001(\t\022\013\n\003sys\030\006 \001(\t\022\020\n\010username\030\007 \001(\t\022\020" + - "\n\010password\030\010 \001(\t\022\017\n\007version\030\t \001(\t\022\020\n\010lan" + - "guage\030\n \001(\t\022\016\n\006seqNum\030\013 \001(\t\"\222\001\n\007Message\022" + - "/\n\006header\030\001 \001(\0132\037.eventmesh.client.Reque" + - "stHeader\022\027\n\017productionGroup\030\002 \001(\t\022\r\n\005top" + - "ic\030\003 \001(\t\022\017\n\007content\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020" + - "\n\010uniqueId\030\006 \001(\t\"O\n\010Response\022\020\n\010respCode" + - "\030\001 \001(\t\022\017\n\007respMsg\030\002 \001(\t\022\020\n\010respTime\030\003 \001(" + - "\t\022\016\n\006seqNum\030\004 \001(\t\"\356\001\n\014Subscription\022/\n\006he" + - "ader\030\001 \001(\0132\037.eventmesh.client.RequestHea" + - "der\022\025\n\rconsumerGroup\030\002 \001(\t\022J\n\021subscripti" + - "onItems\030\003 \003(\0132/.eventmesh.client.Subscri" + - "ption.SubscriptionItem\032J\n\020SubscriptionIt" + - "em\022\r\n\005topic\030\001 \001(\t\022\014\n\004mode\030\002 \001(\t\022\014\n\004type\030" + - "\003 \001(\t\022\013\n\003url\030\004 \001(\t\"\356\001\n\tHeartbeat\022/\n\006head" + - "er\030\001 \001(\0132\037.eventmesh.client.RequestHeade" + - "r\022\022\n\nclientType\030\002 \001(\t\022\025\n\rproducerGroup\030\003" + - " \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022A\n\016heartbeat" + - "Items\030\005 \003(\0132).eventmesh.client.Heartbeat" + - ".HeartbeatItem\032+\n\rHeartbeatItem\022\r\n\005topic" + - "\030\001 \001(\t\022\013\n\003url\030\002 \001(\t2\337\001\n\020PublisherService" + - "\022@\n\007publish\022\031.eventmesh.client.Message\032\032" + - ".eventmesh.client.Response\022E\n\014requestRep" + - "ly\022\031.eventmesh.client.Message\032\032.eventmes" + - "h.client.Response\022B\n\tbroadcast\022\031.eventme" + - "sh.client.Message\032\032.eventmesh.client.Res" + - "ponse2\365\001\n\017ConsumerService\022G\n\tsubscribe\022\036" + - ".eventmesh.client.Subscription\032\032.eventme" + - "sh.client.Response\022N\n\017subscribeStream\022\036." + - "eventmesh.client.Subscription\032\031.eventmes" + - "h.client.Message0\001\022I\n\013unsubscribe\022\036.even" + - "tmesh.client.Subscription\032\032.eventmesh.cl" + - "ient.Response2X\n\020HeartbeatService\022D\n\thea" + - "rtbeat\022\033.eventmesh.client.Heartbeat\032\032.ev" + - "entmesh.client.ResponseB<\n\'org.apache.ev" + - "entmesh.client.grpc.protosB\017EventmeshCli" + - "entP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[]{ - }, assigner); - internal_static_eventmesh_client_RequestHeader_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_eventmesh_client_RequestHeader_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_RequestHeader_descriptor, - new String[]{"Env", "Region", "Idc", "Ip", "Pid", "Sys", "Username", "Password", "Version", "Language", "SeqNum",}); - internal_static_eventmesh_client_Message_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_eventmesh_client_Message_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Message_descriptor, - new String[]{"Header", "ProductionGroup", "Topic", "Content", "Ttl", "UniqueId",}); - internal_static_eventmesh_client_Response_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_eventmesh_client_Response_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Response_descriptor, - new String[]{"RespCode", "RespMsg", "RespTime", "SeqNum",}); - internal_static_eventmesh_client_Subscription_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_eventmesh_client_Subscription_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Subscription_descriptor, - new String[]{"Header", "ConsumerGroup", "SubscriptionItems",}); - internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor = - internal_static_eventmesh_client_Subscription_descriptor.getNestedTypes().get(0); - internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor, - new String[]{"Topic", "Mode", "Type", "Url",}); - internal_static_eventmesh_client_Heartbeat_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_eventmesh_client_Heartbeat_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Heartbeat_descriptor, - new String[]{"Header", "ClientType", "ProducerGroup", "ConsumerGroup", "HeartbeatItems",}); - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor = - internal_static_eventmesh_client_Heartbeat_descriptor.getNestedTypes().get(0); - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor, - new String[]{"Topic", "Url",}); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java deleted file mode 100644 index f9927b7b81..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Heartbeat.java +++ /dev/null @@ -1,2117 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.Heartbeat} - */ -public final class Heartbeat extends - com.google.protobuf.GeneratedMessageV3 implements - HeartbeatOrBuilder { - private static final long serialVersionUID = 0L; - - // Use Heartbeat.newBuilder() to construct. - private Heartbeat(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Heartbeat() { - clientType_ = ""; - producerGroup_ = ""; - consumerGroup_ = ""; - heartbeatItems_ = java.util.Collections.emptyList(); - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private Heartbeat( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - RequestHeader.Builder subBuilder = null; - if (header_ != null) { - subBuilder = header_.toBuilder(); - } - header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(header_); - header_ = subBuilder.buildPartial(); - } - - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - clientType_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - producerGroup_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - consumerGroup_ = s; - break; - } - case 42: { - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - heartbeatItems_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - heartbeatItems_.add( - input.readMessage(HeartbeatItem.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Heartbeat.class, Builder.class); - } - - public interface HeartbeatItemOrBuilder extends - // @@protoc_insertion_point(interface_extends:eventmesh.client.Heartbeat.HeartbeatItem) - com.google.protobuf.MessageOrBuilder { - - /** - * string topic = 1; - */ - String getTopic(); - - /** - * string topic = 1; - */ - com.google.protobuf.ByteString - getTopicBytes(); - - /** - * string url = 2; - */ - String getUrl(); - - /** - * string url = 2; - */ - com.google.protobuf.ByteString - getUrlBytes(); - } - - /** - * Protobuf type {@code eventmesh.client.Heartbeat.HeartbeatItem} - */ - public static final class HeartbeatItem extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:eventmesh.client.Heartbeat.HeartbeatItem) - HeartbeatItemOrBuilder { - private static final long serialVersionUID = 0L; - - // Use HeartbeatItem.newBuilder() to construct. - private HeartbeatItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private HeartbeatItem() { - topic_ = ""; - url_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private HeartbeatItem( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - url_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - HeartbeatItem.class, Builder.class); - } - - public static final int TOPIC_FIELD_NUMBER = 1; - private volatile Object topic_; - - /** - * string topic = 1; - */ - public String getTopic() { - Object ref = topic_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - - /** - * string topic = 1; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int URL_FIELD_NUMBER = 2; - private volatile Object url_; - - /** - * string url = 2; - */ - public String getUrl() { - Object ref = url_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } - } - - /** - * string url = 2; - */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); - } - if (!getUrlBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, url_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); - } - if (!getUrlBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, url_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof HeartbeatItem)) { - return super.equals(obj); - } - HeartbeatItem other = (HeartbeatItem) obj; - - boolean result = true; - result = result && getTopic() - .equals(other.getTopic()); - result = result && getUrl() - .equals(other.getUrl()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + TOPIC_FIELD_NUMBER; - hash = (53 * hash) + getTopic().hashCode(); - hash = (37 * hash) + URL_FIELD_NUMBER; - hash = (53 * hash) + getUrl().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static HeartbeatItem parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static HeartbeatItem parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static HeartbeatItem parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static HeartbeatItem parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static HeartbeatItem parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static HeartbeatItem parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static HeartbeatItem parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static HeartbeatItem 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 HeartbeatItem parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static HeartbeatItem 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 HeartbeatItem parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static HeartbeatItem parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(HeartbeatItem prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Heartbeat.HeartbeatItem} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Heartbeat.HeartbeatItem) - HeartbeatItemOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - HeartbeatItem.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Heartbeat.HeartbeatItem.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - topic_ = ""; - - url_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_HeartbeatItem_descriptor; - } - - public HeartbeatItem getDefaultInstanceForType() { - return HeartbeatItem.getDefaultInstance(); - } - - public HeartbeatItem build() { - HeartbeatItem result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public HeartbeatItem buildPartial() { - HeartbeatItem result = new HeartbeatItem(this); - result.topic_ = topic_; - result.url_ = url_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof HeartbeatItem) { - return mergeFrom((HeartbeatItem) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(HeartbeatItem other) { - if (other == HeartbeatItem.getDefaultInstance()) return this; - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - if (!other.getUrl().isEmpty()) { - url_ = other.url_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - HeartbeatItem parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (HeartbeatItem) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object topic_ = ""; - - /** - * string topic = 1; - */ - public String getTopic() { - Object ref = topic_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string topic = 1; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string topic = 1; - */ - public Builder setTopic( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - - /** - * string topic = 1; - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - - /** - * string topic = 1; - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - - private Object url_ = ""; - - /** - * string url = 2; - */ - public String getUrl() { - Object ref = url_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string url = 2; - */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string url = 2; - */ - public Builder setUrl( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - url_ = value; - onChanged(); - return this; - } - - /** - * string url = 2; - */ - public Builder clearUrl() { - - url_ = getDefaultInstance().getUrl(); - onChanged(); - return this; - } - - /** - * string url = 2; - */ - public Builder setUrlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - url_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Heartbeat.HeartbeatItem) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Heartbeat.HeartbeatItem) - private static final HeartbeatItem DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new HeartbeatItem(); - } - - public static HeartbeatItem getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public HeartbeatItem parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new HeartbeatItem(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public HeartbeatItem getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private int bitField0_; - public static final int HEADER_FIELD_NUMBER = 1; - private RequestHeader header_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - return getHeader(); - } - - public static final int CLIENTTYPE_FIELD_NUMBER = 2; - private volatile Object clientType_; - - /** - * string clientType = 2; - */ - public String getClientType() { - Object ref = clientType_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - clientType_ = s; - return s; - } - } - - /** - * string clientType = 2; - */ - public com.google.protobuf.ByteString - getClientTypeBytes() { - Object ref = clientType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - clientType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PRODUCERGROUP_FIELD_NUMBER = 3; - private volatile Object producerGroup_; - - /** - * string producerGroup = 3; - */ - public String getProducerGroup() { - Object ref = producerGroup_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - producerGroup_ = s; - return s; - } - } - - /** - * string producerGroup = 3; - */ - public com.google.protobuf.ByteString - getProducerGroupBytes() { - Object ref = producerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - producerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CONSUMERGROUP_FIELD_NUMBER = 4; - private volatile Object consumerGroup_; - - /** - * string consumerGroup = 4; - */ - public String getConsumerGroup() { - Object ref = consumerGroup_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - consumerGroup_ = s; - return s; - } - } - - /** - * string consumerGroup = 4; - */ - public com.google.protobuf.ByteString - getConsumerGroupBytes() { - Object ref = consumerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - consumerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int HEARTBEATITEMS_FIELD_NUMBER = 5; - private java.util.List heartbeatItems_; - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List getHeartbeatItemsList() { - return heartbeatItems_; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List - getHeartbeatItemsOrBuilderList() { - return heartbeatItems_; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public int getHeartbeatItemsCount() { - return heartbeatItems_.size(); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem getHeartbeatItems(int index) { - return heartbeatItems_.get(index); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( - int index) { - return heartbeatItems_.get(index); - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (header_ != null) { - output.writeMessage(1, getHeader()); - } - if (!getClientTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, clientType_); - } - if (!getProducerGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, producerGroup_); - } - if (!getConsumerGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, consumerGroup_); - } - for (int i = 0; i < heartbeatItems_.size(); i++) { - output.writeMessage(5, heartbeatItems_.get(i)); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (header_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getHeader()); - } - if (!getClientTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, clientType_); - } - if (!getProducerGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, producerGroup_); - } - if (!getConsumerGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, consumerGroup_); - } - for (int i = 0; i < heartbeatItems_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, heartbeatItems_.get(i)); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Heartbeat)) { - return super.equals(obj); - } - Heartbeat other = (Heartbeat) obj; - - boolean result = true; - result = result && (hasHeader() == other.hasHeader()); - if (hasHeader()) { - result = result && getHeader() - .equals(other.getHeader()); - } - result = result && getClientType() - .equals(other.getClientType()); - result = result && getProducerGroup() - .equals(other.getProducerGroup()); - result = result && getConsumerGroup() - .equals(other.getConsumerGroup()); - result = result && getHeartbeatItemsList() - .equals(other.getHeartbeatItemsList()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasHeader()) { - hash = (37 * hash) + HEADER_FIELD_NUMBER; - hash = (53 * hash) + getHeader().hashCode(); - } - hash = (37 * hash) + CLIENTTYPE_FIELD_NUMBER; - hash = (53 * hash) + getClientType().hashCode(); - hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER; - hash = (53 * hash) + getProducerGroup().hashCode(); - hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; - hash = (53 * hash) + getConsumerGroup().hashCode(); - if (getHeartbeatItemsCount() > 0) { - hash = (37 * hash) + HEARTBEATITEMS_FIELD_NUMBER; - hash = (53 * hash) + getHeartbeatItemsList().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static Heartbeat parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Heartbeat parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Heartbeat parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Heartbeat parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Heartbeat parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Heartbeat parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Heartbeat parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Heartbeat 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 Heartbeat parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static Heartbeat 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 Heartbeat parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Heartbeat parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Heartbeat prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Heartbeat} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Heartbeat) - HeartbeatOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Heartbeat.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Heartbeat.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getHeartbeatItemsFieldBuilder(); - } - } - - public Builder clear() { - super.clear(); - if (headerBuilder_ == null) { - header_ = null; - } else { - header_ = null; - headerBuilder_ = null; - } - clientType_ = ""; - - producerGroup_ = ""; - - consumerGroup_ = ""; - - if (heartbeatItemsBuilder_ == null) { - heartbeatItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - } else { - heartbeatItemsBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Heartbeat_descriptor; - } - - public Heartbeat getDefaultInstanceForType() { - return Heartbeat.getDefaultInstance(); - } - - public Heartbeat build() { - Heartbeat result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Heartbeat buildPartial() { - Heartbeat result = new Heartbeat(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (headerBuilder_ == null) { - result.header_ = header_; - } else { - result.header_ = headerBuilder_.build(); - } - result.clientType_ = clientType_; - result.producerGroup_ = producerGroup_; - result.consumerGroup_ = consumerGroup_; - if (heartbeatItemsBuilder_ == null) { - if (((bitField0_ & 0x00000010) == 0x00000010)) { - heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_); - bitField0_ = (bitField0_ & ~0x00000010); - } - result.heartbeatItems_ = heartbeatItems_; - } else { - result.heartbeatItems_ = heartbeatItemsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Heartbeat) { - return mergeFrom((Heartbeat) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Heartbeat other) { - if (other == Heartbeat.getDefaultInstance()) return this; - if (other.hasHeader()) { - mergeHeader(other.getHeader()); - } - if (!other.getClientType().isEmpty()) { - clientType_ = other.clientType_; - onChanged(); - } - if (!other.getProducerGroup().isEmpty()) { - producerGroup_ = other.producerGroup_; - onChanged(); - } - if (!other.getConsumerGroup().isEmpty()) { - consumerGroup_ = other.consumerGroup_; - onChanged(); - } - if (heartbeatItemsBuilder_ == null) { - if (!other.heartbeatItems_.isEmpty()) { - if (heartbeatItems_.isEmpty()) { - heartbeatItems_ = other.heartbeatItems_; - bitField0_ = (bitField0_ & ~0x00000010); - } else { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.addAll(other.heartbeatItems_); - } - onChanged(); - } - } else { - if (!other.heartbeatItems_.isEmpty()) { - if (heartbeatItemsBuilder_.isEmpty()) { - heartbeatItemsBuilder_.dispose(); - heartbeatItemsBuilder_ = null; - heartbeatItems_ = other.heartbeatItems_; - bitField0_ = (bitField0_ & ~0x00000010); - heartbeatItemsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getHeartbeatItemsFieldBuilder() : null; - } else { - heartbeatItemsBuilder_.addAllMessages(other.heartbeatItems_); - } - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Heartbeat parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Heartbeat) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int bitField0_; - - private RequestHeader header_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return headerBuilder_ != null || header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - if (headerBuilder_ == null) { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } else { - return headerBuilder_.getMessage(); - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - header_ = value; - onChanged(); - } else { - headerBuilder_.setMessage(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader( - RequestHeader.Builder builderForValue) { - if (headerBuilder_ == null) { - header_ = builderForValue.build(); - onChanged(); - } else { - headerBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder mergeHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (header_ != null) { - header_ = - RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); - } else { - header_ = value; - } - onChanged(); - } else { - headerBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder clearHeader() { - if (headerBuilder_ == null) { - header_ = null; - onChanged(); - } else { - header_ = null; - headerBuilder_ = null; - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader.Builder getHeaderBuilder() { - - onChanged(); - return getHeaderFieldBuilder().getBuilder(); - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - if (headerBuilder_ != null) { - return headerBuilder_.getMessageOrBuilder(); - } else { - return header_ == null ? - RequestHeader.getDefaultInstance() : header_; - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> - getHeaderFieldBuilder() { - if (headerBuilder_ == null) { - headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( - getHeader(), - getParentForChildren(), - isClean()); - header_ = null; - } - return headerBuilder_; - } - - private Object clientType_ = ""; - - /** - * string clientType = 2; - */ - public String getClientType() { - Object ref = clientType_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - clientType_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string clientType = 2; - */ - public com.google.protobuf.ByteString - getClientTypeBytes() { - Object ref = clientType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - clientType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string clientType = 2; - */ - public Builder setClientType( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - clientType_ = value; - onChanged(); - return this; - } - - /** - * string clientType = 2; - */ - public Builder clearClientType() { - - clientType_ = getDefaultInstance().getClientType(); - onChanged(); - return this; - } - - /** - * string clientType = 2; - */ - public Builder setClientTypeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - clientType_ = value; - onChanged(); - return this; - } - - private Object producerGroup_ = ""; - - /** - * string producerGroup = 3; - */ - public String getProducerGroup() { - Object ref = producerGroup_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - producerGroup_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string producerGroup = 3; - */ - public com.google.protobuf.ByteString - getProducerGroupBytes() { - Object ref = producerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - producerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string producerGroup = 3; - */ - public Builder setProducerGroup( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - producerGroup_ = value; - onChanged(); - return this; - } - - /** - * string producerGroup = 3; - */ - public Builder clearProducerGroup() { - - producerGroup_ = getDefaultInstance().getProducerGroup(); - onChanged(); - return this; - } - - /** - * string producerGroup = 3; - */ - public Builder setProducerGroupBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - producerGroup_ = value; - onChanged(); - return this; - } - - private Object consumerGroup_ = ""; - - /** - * string consumerGroup = 4; - */ - public String getConsumerGroup() { - Object ref = consumerGroup_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - consumerGroup_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string consumerGroup = 4; - */ - public com.google.protobuf.ByteString - getConsumerGroupBytes() { - Object ref = consumerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - consumerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string consumerGroup = 4; - */ - public Builder setConsumerGroup( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - consumerGroup_ = value; - onChanged(); - return this; - } - - /** - * string consumerGroup = 4; - */ - public Builder clearConsumerGroup() { - - consumerGroup_ = getDefaultInstance().getConsumerGroup(); - onChanged(); - return this; - } - - /** - * string consumerGroup = 4; - */ - public Builder setConsumerGroupBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - consumerGroup_ = value; - onChanged(); - return this; - } - - private java.util.List heartbeatItems_ = - java.util.Collections.emptyList(); - - private void ensureHeartbeatItemsIsMutable() { - if (!((bitField0_ & 0x00000010) == 0x00000010)) { - heartbeatItems_ = new java.util.ArrayList(heartbeatItems_); - bitField0_ |= 0x00000010; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> heartbeatItemsBuilder_; - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List getHeartbeatItemsList() { - if (heartbeatItemsBuilder_ == null) { - return java.util.Collections.unmodifiableList(heartbeatItems_); - } else { - return heartbeatItemsBuilder_.getMessageList(); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public int getHeartbeatItemsCount() { - if (heartbeatItemsBuilder_ == null) { - return heartbeatItems_.size(); - } else { - return heartbeatItemsBuilder_.getCount(); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem getHeartbeatItems(int index) { - if (heartbeatItemsBuilder_ == null) { - return heartbeatItems_.get(index); - } else { - return heartbeatItemsBuilder_.getMessage(index); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder setHeartbeatItems( - int index, HeartbeatItem value) { - if (heartbeatItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.set(index, value); - onChanged(); - } else { - heartbeatItemsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder setHeartbeatItems( - int index, HeartbeatItem.Builder builderForValue) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.set(index, builderForValue.build()); - onChanged(); - } else { - heartbeatItemsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addHeartbeatItems(HeartbeatItem value) { - if (heartbeatItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.add(value); - onChanged(); - } else { - heartbeatItemsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addHeartbeatItems( - int index, HeartbeatItem value) { - if (heartbeatItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.add(index, value); - onChanged(); - } else { - heartbeatItemsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addHeartbeatItems( - HeartbeatItem.Builder builderForValue) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.add(builderForValue.build()); - onChanged(); - } else { - heartbeatItemsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addHeartbeatItems( - int index, HeartbeatItem.Builder builderForValue) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.add(index, builderForValue.build()); - onChanged(); - } else { - heartbeatItemsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder addAllHeartbeatItems( - Iterable values) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, heartbeatItems_); - onChanged(); - } else { - heartbeatItemsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder clearHeartbeatItems() { - if (heartbeatItemsBuilder_ == null) { - heartbeatItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - onChanged(); - } else { - heartbeatItemsBuilder_.clear(); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public Builder removeHeartbeatItems(int index) { - if (heartbeatItemsBuilder_ == null) { - ensureHeartbeatItemsIsMutable(); - heartbeatItems_.remove(index); - onChanged(); - } else { - heartbeatItemsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem.Builder getHeartbeatItemsBuilder( - int index) { - return getHeartbeatItemsFieldBuilder().getBuilder(index); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder( - int index) { - if (heartbeatItemsBuilder_ == null) { - return heartbeatItems_.get(index); - } else { - return heartbeatItemsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List - getHeartbeatItemsOrBuilderList() { - if (heartbeatItemsBuilder_ != null) { - return heartbeatItemsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(heartbeatItems_); - } - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem.Builder addHeartbeatItemsBuilder() { - return getHeartbeatItemsFieldBuilder().addBuilder( - HeartbeatItem.getDefaultInstance()); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public HeartbeatItem.Builder addHeartbeatItemsBuilder( - int index) { - return getHeartbeatItemsFieldBuilder().addBuilder( - index, HeartbeatItem.getDefaultInstance()); - } - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5; - */ - public java.util.List - getHeartbeatItemsBuilderList() { - return getHeartbeatItemsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> - getHeartbeatItemsFieldBuilder() { - if (heartbeatItemsBuilder_ == null) { - heartbeatItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder>( - heartbeatItems_, - ((bitField0_ & 0x00000010) == 0x00000010), - getParentForChildren(), - isClean()); - heartbeatItems_ = null; - } - return heartbeatItemsBuilder_; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Heartbeat) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Heartbeat) - private static final Heartbeat DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new Heartbeat(); - } - - public static Heartbeat getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Heartbeat parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Heartbeat(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Heartbeat getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java deleted file mode 100644 index ec67c09c33..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatOrBuilder.java +++ /dev/null @@ -1,97 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * HeartbeatOrBuilder interface. - */ -public interface HeartbeatOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - boolean hasHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeader getHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeaderOrBuilder getHeaderOrBuilder(); - - /** - * string clientType = 2. - */ - String getClientType(); - - /** - * string clientType = 2. - */ - com.google.protobuf.ByteString getClientTypeBytes(); - - /** - * string producerGroup = 3. - */ - String getProducerGroup(); - - /** - * string producerGroup = 3. - */ - com.google.protobuf.ByteString getProducerGroupBytes(); - - /** - * string consumerGroup = 4. - */ - String getConsumerGroup(); - - /** - * string consumerGroup = 4. - */ - com.google.protobuf.ByteString getConsumerGroupBytes(); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - java.util.List getHeartbeatItemsList(); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - Heartbeat.HeartbeatItem getHeartbeatItems(int index); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - int getHeartbeatItemsCount(); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - java.util.List getHeartbeatItemsOrBuilderList(); - - /** - * repeated .eventmesh.client.Heartbeat.HeartbeatItem heartbeatItems = 5. - */ - Heartbeat.HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder(int index); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java deleted file mode 100644 index 40df4200ab..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/HeartbeatServiceGrpc.java +++ /dev/null @@ -1,302 +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.eventmesh.client.grpc.protos; - -import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; - -/** - * - */ -@javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.15.0)", - comments = "Source: eventmesh-client.proto") -public final class HeartbeatServiceGrpc { - - private HeartbeatServiceGrpc() { - } - - public static final String SERVICE_NAME = "eventmesh.client.HeartbeatService"; - - // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getHeartbeatMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "heartbeat", - requestType = org.apache.eventmesh.client.grpc.protos.Heartbeat.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getHeartbeatMethod() { - io.grpc.MethodDescriptor getHeartbeatMethod; - if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { - synchronized (HeartbeatServiceGrpc.class) { - if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { - HeartbeatServiceGrpc.getHeartbeatMethod = getHeartbeatMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.HeartbeatService", "heartbeat")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Heartbeat.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new HeartbeatServiceMethodDescriptorSupplier("heartbeat")) - .build(); - } - } - } - return getHeartbeatMethod; - } - - /** - * Creates a new async stub that supports all call types for the service - */ - public static HeartbeatServiceStub newStub(io.grpc.Channel channel) { - return new HeartbeatServiceStub(channel); - } - - /** - * Creates a new blocking-style stub that supports unary and streaming output calls on the service - */ - public static HeartbeatServiceBlockingStub newBlockingStub( - io.grpc.Channel channel) { - return new HeartbeatServiceBlockingStub(channel); - } - - /** - * Creates a new ListenableFuture-style stub that supports unary calls on the service - */ - public static HeartbeatServiceFutureStub newFutureStub( - io.grpc.Channel channel) { - return new HeartbeatServiceFutureStub(channel); - } - - /** - * - */ - public static abstract class HeartbeatServiceImplBase implements io.grpc.BindableService { - - /** - * - */ - public void heartbeat(org.apache.eventmesh.client.grpc.protos.Heartbeat request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getHeartbeatMethod(), responseObserver); - } - - @Override - public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getHeartbeatMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Heartbeat, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_HEARTBEAT))) - .build(); - } - } - - /** - * - */ - public static final class HeartbeatServiceStub extends io.grpc.stub.AbstractStub { - private HeartbeatServiceStub(io.grpc.Channel channel) { - super(channel); - } - - private HeartbeatServiceStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected HeartbeatServiceStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new HeartbeatServiceStub(channel, callOptions); - } - - /** - * - */ - public void heartbeat(org.apache.eventmesh.client.grpc.protos.Heartbeat request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request, responseObserver); - } - } - - /** - * - */ - public static final class HeartbeatServiceBlockingStub extends io.grpc.stub.AbstractStub { - private HeartbeatServiceBlockingStub(io.grpc.Channel channel) { - super(channel); - } - - private HeartbeatServiceBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected HeartbeatServiceBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new HeartbeatServiceBlockingStub(channel, callOptions); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response heartbeat(org.apache.eventmesh.client.grpc.protos.Heartbeat request) { - return blockingUnaryCall( - getChannel(), getHeartbeatMethod(), getCallOptions(), request); - } - } - - /** - * - */ - public static final class HeartbeatServiceFutureStub extends io.grpc.stub.AbstractStub { - private HeartbeatServiceFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private HeartbeatServiceFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected HeartbeatServiceFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new HeartbeatServiceFutureStub(channel, callOptions); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture heartbeat( - org.apache.eventmesh.client.grpc.protos.Heartbeat request) { - return futureUnaryCall( - getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request); - } - } - - private static final int METHODID_HEARTBEAT = 0; - - private static final class MethodHandlers implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final HeartbeatServiceImplBase serviceImpl; - private final int methodId; - - MethodHandlers(HeartbeatServiceImplBase serviceImpl, int methodId) { - this.serviceImpl = serviceImpl; - this.methodId = methodId; - } - - @Override - @SuppressWarnings("unchecked") - public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_HEARTBEAT: - serviceImpl.heartbeat((org.apache.eventmesh.client.grpc.protos.Heartbeat) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - default: - throw new AssertionError(); - } - } - - @Override - @SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } - } - - private static abstract class HeartbeatServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { - HeartbeatServiceBaseDescriptorSupplier() { - } - - @Override - public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return org.apache.eventmesh.client.grpc.protos.EventmeshClient.getDescriptor(); - } - - @Override - public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { - return getFileDescriptor().findServiceByName("HeartbeatService"); - } - } - - private static final class HeartbeatServiceFileDescriptorSupplier - extends HeartbeatServiceBaseDescriptorSupplier { - HeartbeatServiceFileDescriptorSupplier() { - } - } - - private static final class HeartbeatServiceMethodDescriptorSupplier - extends HeartbeatServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; - - HeartbeatServiceMethodDescriptorSupplier(String methodName) { - this.methodName = methodName; - } - - @Override - public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { - return getServiceDescriptor().findMethodByName(methodName); - } - } - - private static volatile io.grpc.ServiceDescriptor serviceDescriptor; - - public static io.grpc.ServiceDescriptor getServiceDescriptor() { - io.grpc.ServiceDescriptor result = serviceDescriptor; - if (result == null) { - synchronized (HeartbeatServiceGrpc.class) { - result = serviceDescriptor; - if (result == null) { - serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) - .setSchemaDescriptor(new HeartbeatServiceFileDescriptorSupplier()) - .addMethod(getHeartbeatMethod()) - .build(); - } - } - } - return result; - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java deleted file mode 100644 index ecef2824ff..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Message.java +++ /dev/null @@ -1,1299 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.Message} - */ -public final class Message extends - com.google.protobuf.GeneratedMessageV3 implements MessageOrBuilder { - private static final long serialVersionUID = 0L; - - // Use Message.newBuilder() to construct. - private Message(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Message() { - productionGroup_ = ""; - topic_ = ""; - content_ = ""; - ttl_ = ""; - uniqueId_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private Message( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - RequestHeader.Builder subBuilder = null; - if (header_ != null) { - subBuilder = header_.toBuilder(); - } - header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(header_); - header_ = subBuilder.buildPartial(); - } - - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - productionGroup_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - content_ = s; - break; - } - case 42: { - String s = input.readStringRequireUtf8(); - - ttl_ = s; - break; - } - case 50: { - String s = input.readStringRequireUtf8(); - - uniqueId_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Message_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Message_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Message.class, Builder.class); - } - - public static final int HEADER_FIELD_NUMBER = 1; - private RequestHeader header_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - return getHeader(); - } - - public static final int PRODUCTIONGROUP_FIELD_NUMBER = 2; - private volatile Object productionGroup_; - - /** - * string productionGroup = 2; - */ - public String getProductionGroup() { - Object ref = productionGroup_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - productionGroup_ = s; - return s; - } - } - - /** - * string productionGroup = 2; - */ - public com.google.protobuf.ByteString - getProductionGroupBytes() { - Object ref = productionGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - productionGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TOPIC_FIELD_NUMBER = 3; - private volatile Object topic_; - - /** - * string topic = 3; - */ - public String getTopic() { - Object ref = topic_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - - /** - * string topic = 3; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CONTENT_FIELD_NUMBER = 4; - private volatile Object content_; - - /** - * string content = 4; - */ - public String getContent() { - Object ref = content_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - content_ = s; - return s; - } - } - - /** - * string content = 4; - */ - public com.google.protobuf.ByteString - getContentBytes() { - Object ref = content_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - content_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TTL_FIELD_NUMBER = 5; - private volatile Object ttl_; - - /** - * string ttl = 5; - */ - public String getTtl() { - Object ref = ttl_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - ttl_ = s; - return s; - } - } - - /** - * string ttl = 5; - */ - public com.google.protobuf.ByteString - getTtlBytes() { - Object ref = ttl_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - ttl_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int UNIQUEID_FIELD_NUMBER = 6; - private volatile Object uniqueId_; - - /** - * string uniqueId = 6; - */ - public String getUniqueId() { - Object ref = uniqueId_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - uniqueId_ = s; - return s; - } - } - - /** - * string uniqueId = 6; - */ - public com.google.protobuf.ByteString - getUniqueIdBytes() { - Object ref = uniqueId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - uniqueId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (header_ != null) { - output.writeMessage(1, getHeader()); - } - if (!getProductionGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, productionGroup_); - } - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, topic_); - } - if (!getContentBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, content_); - } - if (!getTtlBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, ttl_); - } - if (!getUniqueIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, uniqueId_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (header_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getHeader()); - } - if (!getProductionGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, productionGroup_); - } - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, topic_); - } - if (!getContentBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, content_); - } - if (!getTtlBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, ttl_); - } - if (!getUniqueIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, uniqueId_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Message)) { - return super.equals(obj); - } - Message other = (Message) obj; - - boolean result = true; - result = result && (hasHeader() == other.hasHeader()); - if (hasHeader()) { - result = result && getHeader() - .equals(other.getHeader()); - } - result = result && getProductionGroup() - .equals(other.getProductionGroup()); - result = result && getTopic() - .equals(other.getTopic()); - result = result && getContent() - .equals(other.getContent()); - result = result && getTtl() - .equals(other.getTtl()); - result = result && getUniqueId() - .equals(other.getUniqueId()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasHeader()) { - hash = (37 * hash) + HEADER_FIELD_NUMBER; - hash = (53 * hash) + getHeader().hashCode(); - } - hash = (37 * hash) + PRODUCTIONGROUP_FIELD_NUMBER; - hash = (53 * hash) + getProductionGroup().hashCode(); - hash = (37 * hash) + TOPIC_FIELD_NUMBER; - hash = (53 * hash) + getTopic().hashCode(); - hash = (37 * hash) + CONTENT_FIELD_NUMBER; - hash = (53 * hash) + getContent().hashCode(); - hash = (37 * hash) + TTL_FIELD_NUMBER; - hash = (53 * hash) + getTtl().hashCode(); - hash = (37 * hash) + UNIQUEID_FIELD_NUMBER; - hash = (53 * hash) + getUniqueId().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static Message parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Message parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Message parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Message parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Message parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Message parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Message parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Message 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 Message parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static Message 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 Message parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Message parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Message prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Message} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Message) - MessageOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Message_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Message_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Message.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Message.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - if (headerBuilder_ == null) { - header_ = null; - } else { - header_ = null; - headerBuilder_ = null; - } - productionGroup_ = ""; - - topic_ = ""; - - content_ = ""; - - ttl_ = ""; - - uniqueId_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Message_descriptor; - } - - public Message getDefaultInstanceForType() { - return Message.getDefaultInstance(); - } - - public Message build() { - Message result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Message buildPartial() { - Message result = new Message(this); - if (headerBuilder_ == null) { - result.header_ = header_; - } else { - result.header_ = headerBuilder_.build(); - } - result.productionGroup_ = productionGroup_; - result.topic_ = topic_; - result.content_ = content_; - result.ttl_ = ttl_; - result.uniqueId_ = uniqueId_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Message) { - return mergeFrom((Message) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Message other) { - if (other == Message.getDefaultInstance()) return this; - if (other.hasHeader()) { - mergeHeader(other.getHeader()); - } - if (!other.getProductionGroup().isEmpty()) { - productionGroup_ = other.productionGroup_; - onChanged(); - } - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - if (!other.getContent().isEmpty()) { - content_ = other.content_; - onChanged(); - } - if (!other.getTtl().isEmpty()) { - ttl_ = other.ttl_; - onChanged(); - } - if (!other.getUniqueId().isEmpty()) { - uniqueId_ = other.uniqueId_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Message parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Message) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private RequestHeader header_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return headerBuilder_ != null || header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - if (headerBuilder_ == null) { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } else { - return headerBuilder_.getMessage(); - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - header_ = value; - onChanged(); - } else { - headerBuilder_.setMessage(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader( - RequestHeader.Builder builderForValue) { - if (headerBuilder_ == null) { - header_ = builderForValue.build(); - onChanged(); - } else { - headerBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder mergeHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (header_ != null) { - header_ = - RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); - } else { - header_ = value; - } - onChanged(); - } else { - headerBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder clearHeader() { - if (headerBuilder_ == null) { - header_ = null; - onChanged(); - } else { - header_ = null; - headerBuilder_ = null; - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader.Builder getHeaderBuilder() { - - onChanged(); - return getHeaderFieldBuilder().getBuilder(); - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - if (headerBuilder_ != null) { - return headerBuilder_.getMessageOrBuilder(); - } else { - return header_ == null ? - RequestHeader.getDefaultInstance() : header_; - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> - getHeaderFieldBuilder() { - if (headerBuilder_ == null) { - headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( - getHeader(), - getParentForChildren(), - isClean()); - header_ = null; - } - return headerBuilder_; - } - - private Object productionGroup_ = ""; - - /** - * string productionGroup = 2; - */ - public String getProductionGroup() { - Object ref = productionGroup_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - productionGroup_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string productionGroup = 2; - */ - public com.google.protobuf.ByteString - getProductionGroupBytes() { - Object ref = productionGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - productionGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string productionGroup = 2; - */ - public Builder setProductionGroup( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - productionGroup_ = value; - onChanged(); - return this; - } - - /** - * string productionGroup = 2; - */ - public Builder clearProductionGroup() { - - productionGroup_ = getDefaultInstance().getProductionGroup(); - onChanged(); - return this; - } - - /** - * string productionGroup = 2; - */ - public Builder setProductionGroupBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - productionGroup_ = value; - onChanged(); - return this; - } - - private Object topic_ = ""; - - /** - * string topic = 3; - */ - public String getTopic() { - Object ref = topic_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string topic = 3; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string topic = 3; - */ - public Builder setTopic( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - - /** - * string topic = 3; - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - - /** - * string topic = 3; - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - - private Object content_ = ""; - - /** - * string content = 4; - */ - public String getContent() { - Object ref = content_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - content_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string content = 4; - */ - public com.google.protobuf.ByteString - getContentBytes() { - Object ref = content_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - content_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string content = 4; - */ - public Builder setContent( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - content_ = value; - onChanged(); - return this; - } - - /** - * string content = 4; - */ - public Builder clearContent() { - - content_ = getDefaultInstance().getContent(); - onChanged(); - return this; - } - - /** - * string content = 4; - */ - public Builder setContentBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - content_ = value; - onChanged(); - return this; - } - - private Object ttl_ = ""; - - /** - * string ttl = 5; - */ - public String getTtl() { - Object ref = ttl_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - ttl_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string ttl = 5; - */ - public com.google.protobuf.ByteString - getTtlBytes() { - Object ref = ttl_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - ttl_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string ttl = 5; - */ - public Builder setTtl( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - ttl_ = value; - onChanged(); - return this; - } - - /** - * string ttl = 5; - */ - public Builder clearTtl() { - - ttl_ = getDefaultInstance().getTtl(); - onChanged(); - return this; - } - - /** - * string ttl = 5; - */ - public Builder setTtlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - ttl_ = value; - onChanged(); - return this; - } - - private Object uniqueId_ = ""; - - /** - * string uniqueId = 6; - */ - public String getUniqueId() { - Object ref = uniqueId_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - uniqueId_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string uniqueId = 6; - */ - public com.google.protobuf.ByteString - getUniqueIdBytes() { - Object ref = uniqueId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - uniqueId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string uniqueId = 6; - */ - public Builder setUniqueId( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - uniqueId_ = value; - onChanged(); - return this; - } - - /** - * string uniqueId = 6; - */ - public Builder clearUniqueId() { - - uniqueId_ = getDefaultInstance().getUniqueId(); - onChanged(); - return this; - } - - /** - * string uniqueId = 6; - */ - public Builder setUniqueIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - uniqueId_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Message) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Message) - private static final Message DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new Message(); - } - - public static Message getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Message parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Message(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Message getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java deleted file mode 100644 index 05dfb84241..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/MessageOrBuilder.java +++ /dev/null @@ -1,92 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * MessageOrBuilder interface. - */ -public interface MessageOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - boolean hasHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeader getHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeaderOrBuilder getHeaderOrBuilder(); - - /** - * string productionGroup = 2. - */ - String getProductionGroup(); - - /** - * string productionGroup = 2. - */ - com.google.protobuf.ByteString getProductionGroupBytes(); - - /** - * string topic = 3. - */ - String getTopic(); - - /** - * string topic = 3. - */ - com.google.protobuf.ByteString getTopicBytes(); - - /** - * string content = 4. - */ - String getContent(); - - /** - * string content = 4. - */ - com.google.protobuf.ByteString getContentBytes(); - - /** - * string ttl = 5. - */ - String getTtl(); - - /** - * string ttl = 5. - */ - com.google.protobuf.ByteString getTtlBytes(); - - /** - * string uniqueId = 6. - */ - String getUniqueId(); - - /** - * string uniqueId = 6. - */ - com.google.protobuf.ByteString getUniqueIdBytes(); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java deleted file mode 100644 index d075d8fe4b..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/PublisherServiceGrpc.java +++ /dev/null @@ -1,460 +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.eventmesh.client.grpc.protos; - -import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; - -/** - * - */ -@javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.15.0)", - comments = "Source: eventmesh-client.proto") -public final class PublisherServiceGrpc { - - private PublisherServiceGrpc() { - } - - public static final String SERVICE_NAME = "eventmesh.client.PublisherService"; - - // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getPublishMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "publish", - requestType = org.apache.eventmesh.client.grpc.protos.Message.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getPublishMethod() { - io.grpc.MethodDescriptor getPublishMethod; - if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { - synchronized (PublisherServiceGrpc.class) { - if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { - PublisherServiceGrpc.getPublishMethod = getPublishMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.PublisherService", "publish")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("publish")) - .build(); - } - } - } - return getPublishMethod; - } - - private static volatile io.grpc.MethodDescriptor getRequestReplyMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "requestReply", - requestType = org.apache.eventmesh.client.grpc.protos.Message.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getRequestReplyMethod() { - io.grpc.MethodDescriptor getRequestReplyMethod; - if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { - synchronized (PublisherServiceGrpc.class) { - if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { - PublisherServiceGrpc.getRequestReplyMethod = getRequestReplyMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.PublisherService", "requestReply")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("requestReply")) - .build(); - } - } - } - return getRequestReplyMethod; - } - - private static volatile io.grpc.MethodDescriptor getBroadcastMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "broadcast", - requestType = org.apache.eventmesh.client.grpc.protos.Message.class, - responseType = org.apache.eventmesh.client.grpc.protos.Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getBroadcastMethod() { - io.grpc.MethodDescriptor getBroadcastMethod; - if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { - synchronized (PublisherServiceGrpc.class) { - if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { - PublisherServiceGrpc.getBroadcastMethod = getBroadcastMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.client.PublisherService", "broadcast")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Message.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.client.grpc.protos.Response.getDefaultInstance())) - .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("broadcast")) - .build(); - } - } - } - return getBroadcastMethod; - } - - /** - * Creates a new async stub that supports all call types for the service - */ - public static PublisherServiceStub newStub(io.grpc.Channel channel) { - return new PublisherServiceStub(channel); - } - - /** - * Creates a new blocking-style stub that supports unary and streaming output calls on the service - */ - public static PublisherServiceBlockingStub newBlockingStub( - io.grpc.Channel channel) { - return new PublisherServiceBlockingStub(channel); - } - - /** - * Creates a new ListenableFuture-style stub that supports unary calls on the service - */ - public static PublisherServiceFutureStub newFutureStub( - io.grpc.Channel channel) { - return new PublisherServiceFutureStub(channel); - } - - /** - * - */ - public static abstract class PublisherServiceImplBase implements io.grpc.BindableService { - - /** - * - */ - public void publish(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getPublishMethod(), responseObserver); - } - - /** - * - */ - public void requestReply(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getRequestReplyMethod(), responseObserver); - } - - /** - * - */ - public void broadcast(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getBroadcastMethod(), responseObserver); - } - - @Override - public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getPublishMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Message, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_PUBLISH))) - .addMethod( - getRequestReplyMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Message, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_REQUEST_REPLY))) - .addMethod( - getBroadcastMethod(), - asyncUnaryCall( - new MethodHandlers< - org.apache.eventmesh.client.grpc.protos.Message, - org.apache.eventmesh.client.grpc.protos.Response>( - this, METHODID_BROADCAST))) - .build(); - } - } - - /** - * - */ - public static final class PublisherServiceStub extends io.grpc.stub.AbstractStub { - private PublisherServiceStub(io.grpc.Channel channel) { - super(channel); - } - - private PublisherServiceStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected PublisherServiceStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new PublisherServiceStub(channel, callOptions); - } - - /** - * - */ - public void publish(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getPublishMethod(), getCallOptions()), request, responseObserver); - } - - /** - * - */ - public void requestReply(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request, responseObserver); - } - - /** - * - */ - public void broadcast(org.apache.eventmesh.client.grpc.protos.Message request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getBroadcastMethod(), getCallOptions()), request, responseObserver); - } - } - - /** - * - */ - public static final class PublisherServiceBlockingStub extends io.grpc.stub.AbstractStub { - private PublisherServiceBlockingStub(io.grpc.Channel channel) { - super(channel); - } - - private PublisherServiceBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected PublisherServiceBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new PublisherServiceBlockingStub(channel, callOptions); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response publish(org.apache.eventmesh.client.grpc.protos.Message request) { - return blockingUnaryCall( - getChannel(), getPublishMethod(), getCallOptions(), request); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response requestReply(org.apache.eventmesh.client.grpc.protos.Message request) { - return blockingUnaryCall( - getChannel(), getRequestReplyMethod(), getCallOptions(), request); - } - - /** - * - */ - public org.apache.eventmesh.client.grpc.protos.Response broadcast(org.apache.eventmesh.client.grpc.protos.Message request) { - return blockingUnaryCall( - getChannel(), getBroadcastMethod(), getCallOptions(), request); - } - } - - /** - * - */ - public static final class PublisherServiceFutureStub extends io.grpc.stub.AbstractStub { - private PublisherServiceFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private PublisherServiceFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @Override - protected PublisherServiceFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new PublisherServiceFutureStub(channel, callOptions); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture publish( - org.apache.eventmesh.client.grpc.protos.Message request) { - return futureUnaryCall( - getChannel().newCall(getPublishMethod(), getCallOptions()), request); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture requestReply( - org.apache.eventmesh.client.grpc.protos.Message request) { - return futureUnaryCall( - getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request); - } - - /** - * - */ - public com.google.common.util.concurrent.ListenableFuture broadcast( - org.apache.eventmesh.client.grpc.protos.Message request) { - return futureUnaryCall( - getChannel().newCall(getBroadcastMethod(), getCallOptions()), request); - } - } - - private static final int METHODID_PUBLISH = 0; - private static final int METHODID_REQUEST_REPLY = 1; - private static final int METHODID_BROADCAST = 2; - - private static final class MethodHandlers implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final PublisherServiceImplBase serviceImpl; - private final int methodId; - - MethodHandlers(PublisherServiceImplBase serviceImpl, int methodId) { - this.serviceImpl = serviceImpl; - this.methodId = methodId; - } - - @Override - @SuppressWarnings("unchecked") - public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_PUBLISH: - serviceImpl.publish((org.apache.eventmesh.client.grpc.protos.Message) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_REQUEST_REPLY: - serviceImpl.requestReply((org.apache.eventmesh.client.grpc.protos.Message) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_BROADCAST: - serviceImpl.broadcast((org.apache.eventmesh.client.grpc.protos.Message) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - default: - throw new AssertionError(); - } - } - - @Override - @SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } - } - - private static abstract class PublisherServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { - PublisherServiceBaseDescriptorSupplier() { - } - - @Override - public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return org.apache.eventmesh.client.grpc.protos.EventmeshClient.getDescriptor(); - } - - @Override - public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { - return getFileDescriptor().findServiceByName("PublisherService"); - } - } - - private static final class PublisherServiceFileDescriptorSupplier - extends PublisherServiceBaseDescriptorSupplier { - PublisherServiceFileDescriptorSupplier() { - } - } - - private static final class PublisherServiceMethodDescriptorSupplier - extends PublisherServiceBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; - - PublisherServiceMethodDescriptorSupplier(String methodName) { - this.methodName = methodName; - } - - @Override - public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { - return getServiceDescriptor().findMethodByName(methodName); - } - } - - private static volatile io.grpc.ServiceDescriptor serviceDescriptor; - - public static io.grpc.ServiceDescriptor getServiceDescriptor() { - io.grpc.ServiceDescriptor result = serviceDescriptor; - if (result == null) { - synchronized (PublisherServiceGrpc.class) { - result = serviceDescriptor; - if (result == null) { - serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) - .setSchemaDescriptor(new PublisherServiceFileDescriptorSupplier()) - .addMethod(getPublishMethod()) - .addMethod(getRequestReplyMethod()) - .addMethod(getBroadcastMethod()) - .build(); - } - } - } - return result; - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java deleted file mode 100644 index ed21ed8d35..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeader.java +++ /dev/null @@ -1,1910 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.RequestHeader} - */ -public final class RequestHeader extends - com.google.protobuf.GeneratedMessageV3 implements RequestHeaderOrBuilder { - private static final long serialVersionUID = 0L; - - // Use RequestHeader.newBuilder() to construct. - private RequestHeader(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private RequestHeader() { - env_ = ""; - region_ = ""; - idc_ = ""; - ip_ = ""; - pid_ = ""; - sys_ = ""; - username_ = ""; - password_ = ""; - version_ = ""; - language_ = ""; - seqNum_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private RequestHeader( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - env_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - region_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - idc_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - ip_ = s; - break; - } - case 42: { - String s = input.readStringRequireUtf8(); - - pid_ = s; - break; - } - case 50: { - String s = input.readStringRequireUtf8(); - - sys_ = s; - break; - } - case 58: { - String s = input.readStringRequireUtf8(); - - username_ = s; - break; - } - case 66: { - String s = input.readStringRequireUtf8(); - - password_ = s; - break; - } - case 74: { - String s = input.readStringRequireUtf8(); - - version_ = s; - break; - } - case 82: { - String s = input.readStringRequireUtf8(); - - language_ = s; - break; - } - case 90: { - String s = input.readStringRequireUtf8(); - - seqNum_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_fieldAccessorTable - .ensureFieldAccessorsInitialized( - RequestHeader.class, Builder.class); - } - - public static final int ENV_FIELD_NUMBER = 1; - private volatile Object env_; - - /** - * string env = 1; - */ - public String getEnv() { - Object ref = env_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - env_ = s; - return s; - } - } - - /** - * string env = 1; - */ - public com.google.protobuf.ByteString - getEnvBytes() { - Object ref = env_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - env_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int REGION_FIELD_NUMBER = 2; - private volatile Object region_; - - /** - * string region = 2; - */ - public String getRegion() { - Object ref = region_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - region_ = s; - return s; - } - } - - /** - * string region = 2; - */ - public com.google.protobuf.ByteString - getRegionBytes() { - Object ref = region_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - region_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int IDC_FIELD_NUMBER = 3; - private volatile Object idc_; - - /** - * string idc = 3; - */ - public String getIdc() { - Object ref = idc_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - idc_ = s; - return s; - } - } - - /** - * string idc = 3; - */ - public com.google.protobuf.ByteString - getIdcBytes() { - Object ref = idc_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - idc_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int IP_FIELD_NUMBER = 4; - private volatile Object ip_; - - /** - * string ip = 4; - */ - public String getIp() { - Object ref = ip_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - ip_ = s; - return s; - } - } - - /** - * string ip = 4; - */ - public com.google.protobuf.ByteString - getIpBytes() { - Object ref = ip_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - ip_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PID_FIELD_NUMBER = 5; - private volatile Object pid_; - - /** - * string pid = 5; - */ - public String getPid() { - Object ref = pid_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - pid_ = s; - return s; - } - } - - /** - * string pid = 5; - */ - public com.google.protobuf.ByteString - getPidBytes() { - Object ref = pid_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - pid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SYS_FIELD_NUMBER = 6; - private volatile Object sys_; - - /** - * string sys = 6; - */ - public String getSys() { - Object ref = sys_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - sys_ = s; - return s; - } - } - - /** - * string sys = 6; - */ - public com.google.protobuf.ByteString - getSysBytes() { - Object ref = sys_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - sys_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int USERNAME_FIELD_NUMBER = 7; - private volatile Object username_; - - /** - * string username = 7; - */ - public String getUsername() { - Object ref = username_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - username_ = s; - return s; - } - } - - /** - * string username = 7; - */ - public com.google.protobuf.ByteString - getUsernameBytes() { - Object ref = username_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - username_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PASSWORD_FIELD_NUMBER = 8; - private volatile Object password_; - - /** - * string password = 8; - */ - public String getPassword() { - Object ref = password_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - password_ = s; - return s; - } - } - - /** - * string password = 8; - */ - public com.google.protobuf.ByteString - getPasswordBytes() { - Object ref = password_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - password_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int VERSION_FIELD_NUMBER = 9; - private volatile Object version_; - - /** - * string version = 9; - */ - public String getVersion() { - Object ref = version_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - version_ = s; - return s; - } - } - - /** - * string version = 9; - */ - public com.google.protobuf.ByteString - getVersionBytes() { - Object ref = version_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - version_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int LANGUAGE_FIELD_NUMBER = 10; - private volatile Object language_; - - /** - * string language = 10; - */ - public String getLanguage() { - Object ref = language_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - language_ = s; - return s; - } - } - - /** - * string language = 10; - */ - public com.google.protobuf.ByteString - getLanguageBytes() { - Object ref = language_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - language_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SEQNUM_FIELD_NUMBER = 11; - private volatile Object seqNum_; - - /** - * string seqNum = 11; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } - } - - /** - * string seqNum = 11; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getEnvBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, env_); - } - if (!getRegionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, region_); - } - if (!getIdcBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, idc_); - } - if (!getIpBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, ip_); - } - if (!getPidBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, pid_); - } - if (!getSysBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, sys_); - } - if (!getUsernameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 7, username_); - } - if (!getPasswordBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 8, password_); - } - if (!getVersionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 9, version_); - } - if (!getLanguageBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 10, language_); - } - if (!getSeqNumBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 11, seqNum_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getEnvBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, env_); - } - if (!getRegionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, region_); - } - if (!getIdcBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, idc_); - } - if (!getIpBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, ip_); - } - if (!getPidBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, pid_); - } - if (!getSysBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, sys_); - } - if (!getUsernameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, username_); - } - if (!getPasswordBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, password_); - } - if (!getVersionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, version_); - } - if (!getLanguageBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, language_); - } - if (!getSeqNumBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, seqNum_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof RequestHeader)) { - return super.equals(obj); - } - RequestHeader other = (RequestHeader) obj; - - boolean result = true; - result = result && getEnv() - .equals(other.getEnv()); - result = result && getRegion() - .equals(other.getRegion()); - result = result && getIdc() - .equals(other.getIdc()); - result = result && getIp() - .equals(other.getIp()); - result = result && getPid() - .equals(other.getPid()); - result = result && getSys() - .equals(other.getSys()); - result = result && getUsername() - .equals(other.getUsername()); - result = result && getPassword() - .equals(other.getPassword()); - result = result && getVersion() - .equals(other.getVersion()); - result = result && getLanguage() - .equals(other.getLanguage()); - result = result && getSeqNum() - .equals(other.getSeqNum()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ENV_FIELD_NUMBER; - hash = (53 * hash) + getEnv().hashCode(); - hash = (37 * hash) + REGION_FIELD_NUMBER; - hash = (53 * hash) + getRegion().hashCode(); - hash = (37 * hash) + IDC_FIELD_NUMBER; - hash = (53 * hash) + getIdc().hashCode(); - hash = (37 * hash) + IP_FIELD_NUMBER; - hash = (53 * hash) + getIp().hashCode(); - hash = (37 * hash) + PID_FIELD_NUMBER; - hash = (53 * hash) + getPid().hashCode(); - hash = (37 * hash) + SYS_FIELD_NUMBER; - hash = (53 * hash) + getSys().hashCode(); - hash = (37 * hash) + USERNAME_FIELD_NUMBER; - hash = (53 * hash) + getUsername().hashCode(); - hash = (37 * hash) + PASSWORD_FIELD_NUMBER; - hash = (53 * hash) + getPassword().hashCode(); - hash = (37 * hash) + VERSION_FIELD_NUMBER; - hash = (53 * hash) + getVersion().hashCode(); - hash = (37 * hash) + LANGUAGE_FIELD_NUMBER; - hash = (53 * hash) + getLanguage().hashCode(); - hash = (37 * hash) + SEQNUM_FIELD_NUMBER; - hash = (53 * hash) + getSeqNum().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static RequestHeader parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static RequestHeader parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static RequestHeader parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static RequestHeader parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static RequestHeader parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static RequestHeader parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static RequestHeader parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static RequestHeader 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 RequestHeader parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static RequestHeader 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 RequestHeader parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static RequestHeader parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(RequestHeader prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.RequestHeader} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.RequestHeader) - RequestHeaderOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_fieldAccessorTable - .ensureFieldAccessorsInitialized( - RequestHeader.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.RequestHeader.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - env_ = ""; - - region_ = ""; - - idc_ = ""; - - ip_ = ""; - - pid_ = ""; - - sys_ = ""; - - username_ = ""; - - password_ = ""; - - version_ = ""; - - language_ = ""; - - seqNum_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_RequestHeader_descriptor; - } - - public RequestHeader getDefaultInstanceForType() { - return RequestHeader.getDefaultInstance(); - } - - public RequestHeader build() { - RequestHeader result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public RequestHeader buildPartial() { - RequestHeader result = new RequestHeader(this); - result.env_ = env_; - result.region_ = region_; - result.idc_ = idc_; - result.ip_ = ip_; - result.pid_ = pid_; - result.sys_ = sys_; - result.username_ = username_; - result.password_ = password_; - result.version_ = version_; - result.language_ = language_; - result.seqNum_ = seqNum_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof RequestHeader) { - return mergeFrom((RequestHeader) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(RequestHeader other) { - if (other == RequestHeader.getDefaultInstance()) return this; - if (!other.getEnv().isEmpty()) { - env_ = other.env_; - onChanged(); - } - if (!other.getRegion().isEmpty()) { - region_ = other.region_; - onChanged(); - } - if (!other.getIdc().isEmpty()) { - idc_ = other.idc_; - onChanged(); - } - if (!other.getIp().isEmpty()) { - ip_ = other.ip_; - onChanged(); - } - if (!other.getPid().isEmpty()) { - pid_ = other.pid_; - onChanged(); - } - if (!other.getSys().isEmpty()) { - sys_ = other.sys_; - onChanged(); - } - if (!other.getUsername().isEmpty()) { - username_ = other.username_; - onChanged(); - } - if (!other.getPassword().isEmpty()) { - password_ = other.password_; - onChanged(); - } - if (!other.getVersion().isEmpty()) { - version_ = other.version_; - onChanged(); - } - if (!other.getLanguage().isEmpty()) { - language_ = other.language_; - onChanged(); - } - if (!other.getSeqNum().isEmpty()) { - seqNum_ = other.seqNum_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - RequestHeader parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (RequestHeader) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object env_ = ""; - - /** - * string env = 1; - */ - public String getEnv() { - Object ref = env_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - env_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string env = 1; - */ - public com.google.protobuf.ByteString - getEnvBytes() { - Object ref = env_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - env_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string env = 1; - */ - public Builder setEnv( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - env_ = value; - onChanged(); - return this; - } - - /** - * string env = 1; - */ - public Builder clearEnv() { - - env_ = getDefaultInstance().getEnv(); - onChanged(); - return this; - } - - /** - * string env = 1; - */ - public Builder setEnvBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - env_ = value; - onChanged(); - return this; - } - - private Object region_ = ""; - - /** - * string region = 2; - */ - public String getRegion() { - Object ref = region_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - region_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string region = 2; - */ - public com.google.protobuf.ByteString - getRegionBytes() { - Object ref = region_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - region_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string region = 2; - */ - public Builder setRegion( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - region_ = value; - onChanged(); - return this; - } - - /** - * string region = 2; - */ - public Builder clearRegion() { - - region_ = getDefaultInstance().getRegion(); - onChanged(); - return this; - } - - /** - * string region = 2; - */ - public Builder setRegionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - region_ = value; - onChanged(); - return this; - } - - private Object idc_ = ""; - - /** - * string idc = 3; - */ - public String getIdc() { - Object ref = idc_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - idc_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string idc = 3; - */ - public com.google.protobuf.ByteString - getIdcBytes() { - Object ref = idc_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - idc_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string idc = 3; - */ - public Builder setIdc( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - idc_ = value; - onChanged(); - return this; - } - - /** - * string idc = 3; - */ - public Builder clearIdc() { - - idc_ = getDefaultInstance().getIdc(); - onChanged(); - return this; - } - - /** - * string idc = 3; - */ - public Builder setIdcBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - idc_ = value; - onChanged(); - return this; - } - - private Object ip_ = ""; - - /** - * string ip = 4; - */ - public String getIp() { - Object ref = ip_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - ip_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string ip = 4; - */ - public com.google.protobuf.ByteString - getIpBytes() { - Object ref = ip_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - ip_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string ip = 4; - */ - public Builder setIp( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - ip_ = value; - onChanged(); - return this; - } - - /** - * string ip = 4; - */ - public Builder clearIp() { - - ip_ = getDefaultInstance().getIp(); - onChanged(); - return this; - } - - /** - * string ip = 4; - */ - public Builder setIpBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - ip_ = value; - onChanged(); - return this; - } - - private Object pid_ = ""; - - /** - * string pid = 5; - */ - public String getPid() { - Object ref = pid_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - pid_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string pid = 5; - */ - public com.google.protobuf.ByteString - getPidBytes() { - Object ref = pid_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - pid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string pid = 5; - */ - public Builder setPid( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - pid_ = value; - onChanged(); - return this; - } - - /** - * string pid = 5; - */ - public Builder clearPid() { - - pid_ = getDefaultInstance().getPid(); - onChanged(); - return this; - } - - /** - * string pid = 5; - */ - public Builder setPidBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pid_ = value; - onChanged(); - return this; - } - - private Object sys_ = ""; - - /** - * string sys = 6; - */ - public String getSys() { - Object ref = sys_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - sys_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string sys = 6; - */ - public com.google.protobuf.ByteString - getSysBytes() { - Object ref = sys_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - sys_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string sys = 6; - */ - public Builder setSys( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - sys_ = value; - onChanged(); - return this; - } - - /** - * string sys = 6; - */ - public Builder clearSys() { - - sys_ = getDefaultInstance().getSys(); - onChanged(); - return this; - } - - /** - * string sys = 6; - */ - public Builder setSysBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - sys_ = value; - onChanged(); - return this; - } - - private Object username_ = ""; - - /** - * string username = 7; - */ - public String getUsername() { - Object ref = username_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - username_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string username = 7; - */ - public com.google.protobuf.ByteString - getUsernameBytes() { - Object ref = username_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - username_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string username = 7; - */ - public Builder setUsername( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - username_ = value; - onChanged(); - return this; - } - - /** - * string username = 7; - */ - public Builder clearUsername() { - - username_ = getDefaultInstance().getUsername(); - onChanged(); - return this; - } - - /** - * string username = 7; - */ - public Builder setUsernameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - username_ = value; - onChanged(); - return this; - } - - private Object password_ = ""; - - /** - * string password = 8; - */ - public String getPassword() { - Object ref = password_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - password_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string password = 8; - */ - public com.google.protobuf.ByteString - getPasswordBytes() { - Object ref = password_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - password_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string password = 8; - */ - public Builder setPassword( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - password_ = value; - onChanged(); - return this; - } - - /** - * string password = 8; - */ - public Builder clearPassword() { - - password_ = getDefaultInstance().getPassword(); - onChanged(); - return this; - } - - /** - * string password = 8; - */ - public Builder setPasswordBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - password_ = value; - onChanged(); - return this; - } - - private Object version_ = ""; - - /** - * string version = 9; - */ - public String getVersion() { - Object ref = version_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - version_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string version = 9; - */ - public com.google.protobuf.ByteString - getVersionBytes() { - Object ref = version_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - version_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string version = 9; - */ - public Builder setVersion( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - version_ = value; - onChanged(); - return this; - } - - /** - * string version = 9; - */ - public Builder clearVersion() { - - version_ = getDefaultInstance().getVersion(); - onChanged(); - return this; - } - - /** - * string version = 9; - */ - public Builder setVersionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - version_ = value; - onChanged(); - return this; - } - - private Object language_ = ""; - - /** - * string language = 10; - */ - public String getLanguage() { - Object ref = language_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - language_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string language = 10; - */ - public com.google.protobuf.ByteString - getLanguageBytes() { - Object ref = language_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - language_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string language = 10; - */ - public Builder setLanguage( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - language_ = value; - onChanged(); - return this; - } - - /** - * string language = 10; - */ - public Builder clearLanguage() { - - language_ = getDefaultInstance().getLanguage(); - onChanged(); - return this; - } - - /** - * string language = 10; - */ - public Builder setLanguageBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - language_ = value; - onChanged(); - return this; - } - - private Object seqNum_ = ""; - - /** - * string seqNum = 11; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string seqNum = 11; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string seqNum = 11; - */ - public Builder setSeqNum( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - seqNum_ = value; - onChanged(); - return this; - } - - /** - * string seqNum = 11; - */ - public Builder clearSeqNum() { - - seqNum_ = getDefaultInstance().getSeqNum(); - onChanged(); - return this; - } - - /** - * string seqNum = 11; - */ - public Builder setSeqNumBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - seqNum_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.RequestHeader) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.RequestHeader) - private static final RequestHeader DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new RequestHeader(); - } - - public static RequestHeader getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public RequestHeader parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new RequestHeader(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public RequestHeader getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java deleted file mode 100644 index a112bfa22a..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/RequestHeaderOrBuilder.java +++ /dev/null @@ -1,137 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * RequestHeaderOrBuilder interface. - */ -public interface RequestHeaderOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * string env = 1. - */ - String getEnv(); - - /** - * string env = 1. - */ - com.google.protobuf.ByteString getEnvBytes(); - - /** - * string region = 2. - */ - String getRegion(); - - /** - * string region = 2. - */ - com.google.protobuf.ByteString getRegionBytes(); - - /** - * string idc = 3. - */ - String getIdc(); - - /** - * string idc = 3. - */ - com.google.protobuf.ByteString getIdcBytes(); - - /** - * string ip = 4. - */ - String getIp(); - - /** - * string ip = 4. - */ - com.google.protobuf.ByteString getIpBytes(); - - /** - * string pid = 5. - */ - String getPid(); - - /** - * string pid = 5. - */ - com.google.protobuf.ByteString getPidBytes(); - - /** - * string sys = 6. - */ - String getSys(); - - /** - * string sys = 6. - */ - com.google.protobuf.ByteString getSysBytes(); - - /** - * string username = 7. - */ - String getUsername(); - - /** - * string username = 7. - */ - com.google.protobuf.ByteString getUsernameBytes(); - - /** - * string password = 8. - */ - String getPassword(); - - /** - * string password = 8. - */ - com.google.protobuf.ByteString getPasswordBytes(); - - /** - * string version = 9. - */ - String getVersion(); - - /** - * string version = 9. - */ - com.google.protobuf.ByteString getVersionBytes(); - - /** - * string language = 10. - */ - String getLanguage(); - - /** - * string language = 10. - */ - com.google.protobuf.ByteString getLanguageBytes(); - - /** - * string seqNum = 11. - */ - String getSeqNum(); - - /** - * string seqNum = 11. - */ - com.google.protobuf.ByteString getSeqNumBytes(); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java deleted file mode 100644 index b54fc330c8..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Response.java +++ /dev/null @@ -1,972 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.Response} - */ -public final class Response extends - com.google.protobuf.GeneratedMessageV3 implements ResponseOrBuilder { - private static final long serialVersionUID = 0L; - - // Use Response.newBuilder() to construct. - private Response(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Response() { - respCode_ = ""; - respMsg_ = ""; - respTime_ = ""; - seqNum_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private Response( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - respCode_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - respMsg_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - respTime_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - seqNum_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Response_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Response_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Response.class, Builder.class); - } - - public static final int RESPCODE_FIELD_NUMBER = 1; - private volatile Object respCode_; - - /** - * string respCode = 1; - */ - public String getRespCode() { - Object ref = respCode_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respCode_ = s; - return s; - } - } - - /** - * string respCode = 1; - */ - public com.google.protobuf.ByteString - getRespCodeBytes() { - Object ref = respCode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respCode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RESPMSG_FIELD_NUMBER = 2; - private volatile Object respMsg_; - - /** - * string respMsg = 2; - */ - public String getRespMsg() { - Object ref = respMsg_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respMsg_ = s; - return s; - } - } - - /** - * string respMsg = 2; - */ - public com.google.protobuf.ByteString - getRespMsgBytes() { - Object ref = respMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RESPTIME_FIELD_NUMBER = 3; - private volatile Object respTime_; - - /** - * string respTime = 3; - */ - public String getRespTime() { - Object ref = respTime_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respTime_ = s; - return s; - } - } - - /** - * string respTime = 3; - */ - public com.google.protobuf.ByteString - getRespTimeBytes() { - Object ref = respTime_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respTime_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SEQNUM_FIELD_NUMBER = 4; - private volatile Object seqNum_; - - /** - * string seqNum = 4; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } - } - - /** - * string seqNum = 4; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getRespCodeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, respCode_); - } - if (!getRespMsgBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, respMsg_); - } - if (!getRespTimeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, respTime_); - } - if (!getSeqNumBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, seqNum_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getRespCodeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, respCode_); - } - if (!getRespMsgBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, respMsg_); - } - if (!getRespTimeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, respTime_); - } - if (!getSeqNumBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, seqNum_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Response)) { - return super.equals(obj); - } - Response other = (Response) obj; - - boolean result = true; - result = result && getRespCode() - .equals(other.getRespCode()); - result = result && getRespMsg() - .equals(other.getRespMsg()); - result = result && getRespTime() - .equals(other.getRespTime()); - result = result && getSeqNum() - .equals(other.getSeqNum()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + RESPCODE_FIELD_NUMBER; - hash = (53 * hash) + getRespCode().hashCode(); - hash = (37 * hash) + RESPMSG_FIELD_NUMBER; - hash = (53 * hash) + getRespMsg().hashCode(); - hash = (37 * hash) + RESPTIME_FIELD_NUMBER; - hash = (53 * hash) + getRespTime().hashCode(); - hash = (37 * hash) + SEQNUM_FIELD_NUMBER; - hash = (53 * hash) + getSeqNum().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static Response parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Response parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Response parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Response parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Response parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Response parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Response parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Response 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 Response parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static Response 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 Response parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Response parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Response prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Response} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Response) - ResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Response_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Response_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Response.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Response.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - respCode_ = ""; - - respMsg_ = ""; - - respTime_ = ""; - - seqNum_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Response_descriptor; - } - - public Response getDefaultInstanceForType() { - return Response.getDefaultInstance(); - } - - public Response build() { - Response result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Response buildPartial() { - Response result = new Response(this); - result.respCode_ = respCode_; - result.respMsg_ = respMsg_; - result.respTime_ = respTime_; - result.seqNum_ = seqNum_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Response) { - return mergeFrom((Response) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Response other) { - if (other == Response.getDefaultInstance()) return this; - if (!other.getRespCode().isEmpty()) { - respCode_ = other.respCode_; - onChanged(); - } - if (!other.getRespMsg().isEmpty()) { - respMsg_ = other.respMsg_; - onChanged(); - } - if (!other.getRespTime().isEmpty()) { - respTime_ = other.respTime_; - onChanged(); - } - if (!other.getSeqNum().isEmpty()) { - seqNum_ = other.seqNum_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Response parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Response) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object respCode_ = ""; - - /** - * string respCode = 1; - */ - public String getRespCode() { - Object ref = respCode_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respCode_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string respCode = 1; - */ - public com.google.protobuf.ByteString - getRespCodeBytes() { - Object ref = respCode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respCode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string respCode = 1; - */ - public Builder setRespCode( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - respCode_ = value; - onChanged(); - return this; - } - - /** - * string respCode = 1; - */ - public Builder clearRespCode() { - - respCode_ = getDefaultInstance().getRespCode(); - onChanged(); - return this; - } - - /** - * string respCode = 1; - */ - public Builder setRespCodeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - respCode_ = value; - onChanged(); - return this; - } - - private Object respMsg_ = ""; - - /** - * string respMsg = 2; - */ - public String getRespMsg() { - Object ref = respMsg_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respMsg_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string respMsg = 2; - */ - public com.google.protobuf.ByteString - getRespMsgBytes() { - Object ref = respMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string respMsg = 2; - */ - public Builder setRespMsg( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - respMsg_ = value; - onChanged(); - return this; - } - - /** - * string respMsg = 2; - */ - public Builder clearRespMsg() { - - respMsg_ = getDefaultInstance().getRespMsg(); - onChanged(); - return this; - } - - /** - * string respMsg = 2; - */ - public Builder setRespMsgBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - respMsg_ = value; - onChanged(); - return this; - } - - private Object respTime_ = ""; - - /** - * string respTime = 3; - */ - public String getRespTime() { - Object ref = respTime_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - respTime_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string respTime = 3; - */ - public com.google.protobuf.ByteString - getRespTimeBytes() { - Object ref = respTime_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - respTime_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string respTime = 3; - */ - public Builder setRespTime( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - respTime_ = value; - onChanged(); - return this; - } - - /** - * string respTime = 3; - */ - public Builder clearRespTime() { - - respTime_ = getDefaultInstance().getRespTime(); - onChanged(); - return this; - } - - /** - * string respTime = 3; - */ - public Builder setRespTimeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - respTime_ = value; - onChanged(); - return this; - } - - private Object seqNum_ = ""; - - /** - * string seqNum = 4; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string seqNum = 4; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string seqNum = 4; - */ - public Builder setSeqNum( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - seqNum_ = value; - onChanged(); - return this; - } - - /** - * string seqNum = 4; - */ - public Builder clearSeqNum() { - - seqNum_ = getDefaultInstance().getSeqNum(); - onChanged(); - return this; - } - - /** - * string seqNum = 4; - */ - public Builder setSeqNumBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - seqNum_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Response) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Response) - private static final Response DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new Response(); - } - - public static Response getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Response parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Response(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Response getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java deleted file mode 100644 index 0b4acd2fe4..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/ResponseOrBuilder.java +++ /dev/null @@ -1,67 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * ResponseOrBuilder interface. - */ -public interface ResponseOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * string respCode = 1. - */ - String getRespCode(); - - /** - * string respCode = 1. - */ - com.google.protobuf.ByteString getRespCodeBytes(); - - /** - * string respMsg = 2. - */ - String getRespMsg(); - - /** - * string respMsg = 2. - */ - com.google.protobuf.ByteString getRespMsgBytes(); - - /** - * string respTime = 3. - */ - String getRespTime(); - - /** - * string respTime = 3. - */ - com.google.protobuf.ByteString getRespTimeBytes(); - - /** - * string seqNum = 4. - */ - String getSeqNum(); - - /** - * string seqNum = 4. - */ - com.google.protobuf.ByteString getSeqNumBytes(); -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java deleted file mode 100644 index 803e1daf5c..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/Subscription.java +++ /dev/null @@ -1,2138 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * Protobuf type {@code eventmesh.client.Subscription} - */ -public final class Subscription extends - com.google.protobuf.GeneratedMessageV3 implements SubscriptionOrBuilder { - private static final long serialVersionUID = 0L; - - // Use Subscription.newBuilder() to construct. - private Subscription(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Subscription() { - consumerGroup_ = ""; - subscriptionItems_ = java.util.Collections.emptyList(); - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private Subscription( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - RequestHeader.Builder subBuilder = null; - if (header_ != null) { - subBuilder = header_.toBuilder(); - } - header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(header_); - header_ = subBuilder.buildPartial(); - } - - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - consumerGroup_ = s; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - subscriptionItems_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - subscriptionItems_.add( - input.readMessage(SubscriptionItem.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Subscription.class, Builder.class); - } - - public interface SubscriptionItemOrBuilder extends - // @@protoc_insertion_point(interface_extends:eventmesh.client.Subscription.SubscriptionItem) - com.google.protobuf.MessageOrBuilder { - - /** - * string topic = 1; - */ - String getTopic(); - - /** - * string topic = 1; - */ - com.google.protobuf.ByteString - getTopicBytes(); - - /** - * string mode = 2; - */ - String getMode(); - - /** - * string mode = 2; - */ - com.google.protobuf.ByteString - getModeBytes(); - - /** - * string type = 3; - */ - String getType(); - - /** - * string type = 3; - */ - com.google.protobuf.ByteString - getTypeBytes(); - - /** - * string url = 4; - */ - String getUrl(); - - /** - * string url = 4; - */ - com.google.protobuf.ByteString - getUrlBytes(); - } - - /** - * Protobuf type {@code eventmesh.client.Subscription.SubscriptionItem} - */ - public static final class SubscriptionItem extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:eventmesh.client.Subscription.SubscriptionItem) - SubscriptionItemOrBuilder { - private static final long serialVersionUID = 0L; - - // Use SubscriptionItem.newBuilder() to construct. - private SubscriptionItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private SubscriptionItem() { - topic_ = ""; - mode_ = ""; - type_ = ""; - url_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - private SubscriptionItem( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - mode_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - type_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - url_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SubscriptionItem.class, Builder.class); - } - - public static final int TOPIC_FIELD_NUMBER = 1; - private volatile Object topic_; - - /** - * string topic = 1; - */ - public String getTopic() { - Object ref = topic_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - - /** - * string topic = 1; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int MODE_FIELD_NUMBER = 2; - private volatile Object mode_; - - /** - * string mode = 2; - */ - public String getMode() { - Object ref = mode_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - mode_ = s; - return s; - } - } - - /** - * string mode = 2; - */ - public com.google.protobuf.ByteString - getModeBytes() { - Object ref = mode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - mode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TYPE_FIELD_NUMBER = 3; - private volatile Object type_; - - /** - * string type = 3; - */ - public String getType() { - Object ref = type_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - type_ = s; - return s; - } - } - - /** - * string type = 3; - */ - public com.google.protobuf.ByteString - getTypeBytes() { - Object ref = type_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - type_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int URL_FIELD_NUMBER = 4; - private volatile Object url_; - - /** - * string url = 4; - */ - public String getUrl() { - Object ref = url_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } - } - - /** - * string url = 4; - */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); - } - if (!getModeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, mode_); - } - if (!getTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_); - } - if (!getUrlBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, url_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); - } - if (!getModeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, mode_); - } - if (!getTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_); - } - if (!getUrlBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, url_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SubscriptionItem)) { - return super.equals(obj); - } - SubscriptionItem other = (SubscriptionItem) obj; - - boolean result = true; - result = result && getTopic() - .equals(other.getTopic()); - result = result && getMode() - .equals(other.getMode()); - result = result && getType() - .equals(other.getType()); - result = result && getUrl() - .equals(other.getUrl()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + TOPIC_FIELD_NUMBER; - hash = (53 * hash) + getTopic().hashCode(); - hash = (37 * hash) + MODE_FIELD_NUMBER; - hash = (53 * hash) + getMode().hashCode(); - hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + getType().hashCode(); - hash = (37 * hash) + URL_FIELD_NUMBER; - hash = (53 * hash) + getUrl().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static SubscriptionItem parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static SubscriptionItem parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static SubscriptionItem parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static SubscriptionItem parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static SubscriptionItem parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static SubscriptionItem parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static SubscriptionItem parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static SubscriptionItem 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 SubscriptionItem parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static SubscriptionItem 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 SubscriptionItem parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static SubscriptionItem parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(SubscriptionItem prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Subscription.SubscriptionItem} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Subscription.SubscriptionItem) - SubscriptionItemOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_fieldAccessorTable - .ensureFieldAccessorsInitialized( - SubscriptionItem.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Subscription.SubscriptionItem.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - topic_ = ""; - - mode_ = ""; - - type_ = ""; - - url_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_SubscriptionItem_descriptor; - } - - public SubscriptionItem getDefaultInstanceForType() { - return SubscriptionItem.getDefaultInstance(); - } - - public SubscriptionItem build() { - SubscriptionItem result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public SubscriptionItem buildPartial() { - SubscriptionItem result = new SubscriptionItem(this); - result.topic_ = topic_; - result.mode_ = mode_; - result.type_ = type_; - result.url_ = url_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SubscriptionItem) { - return mergeFrom((SubscriptionItem) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(SubscriptionItem other) { - if (other == SubscriptionItem.getDefaultInstance()) return this; - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - if (!other.getMode().isEmpty()) { - mode_ = other.mode_; - onChanged(); - } - if (!other.getType().isEmpty()) { - type_ = other.type_; - onChanged(); - } - if (!other.getUrl().isEmpty()) { - url_ = other.url_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - SubscriptionItem parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (SubscriptionItem) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object topic_ = ""; - - /** - * string topic = 1; - */ - public String getTopic() { - Object ref = topic_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string topic = 1; - */ - public com.google.protobuf.ByteString - getTopicBytes() { - Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string topic = 1; - */ - public Builder setTopic( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - - /** - * string topic = 1; - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - - /** - * string topic = 1; - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - - private Object mode_ = ""; - - /** - * string mode = 2; - */ - public String getMode() { - Object ref = mode_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - mode_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string mode = 2; - */ - public com.google.protobuf.ByteString - getModeBytes() { - Object ref = mode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - mode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string mode = 2; - */ - public Builder setMode( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - mode_ = value; - onChanged(); - return this; - } - - /** - * string mode = 2; - */ - public Builder clearMode() { - - mode_ = getDefaultInstance().getMode(); - onChanged(); - return this; - } - - /** - * string mode = 2; - */ - public Builder setModeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - mode_ = value; - onChanged(); - return this; - } - - private Object type_ = ""; - - /** - * string type = 3; - */ - public String getType() { - Object ref = type_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - type_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string type = 3; - */ - public com.google.protobuf.ByteString - getTypeBytes() { - Object ref = type_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - type_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string type = 3; - */ - public Builder setType( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - type_ = value; - onChanged(); - return this; - } - - /** - * string type = 3; - */ - public Builder clearType() { - - type_ = getDefaultInstance().getType(); - onChanged(); - return this; - } - - /** - * string type = 3; - */ - public Builder setTypeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - type_ = value; - onChanged(); - return this; - } - - private Object url_ = ""; - - /** - * string url = 4; - */ - public String getUrl() { - Object ref = url_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string url = 4; - */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string url = 4; - */ - public Builder setUrl( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - url_ = value; - onChanged(); - return this; - } - - /** - * string url = 4; - */ - public Builder clearUrl() { - - url_ = getDefaultInstance().getUrl(); - onChanged(); - return this; - } - - /** - * string url = 4; - */ - public Builder setUrlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - url_ = value; - onChanged(); - return this; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Subscription.SubscriptionItem) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Subscription.SubscriptionItem) - private static final SubscriptionItem DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new SubscriptionItem(); - } - - public static SubscriptionItem getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public SubscriptionItem parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new SubscriptionItem(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public SubscriptionItem getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private int bitField0_; - public static final int HEADER_FIELD_NUMBER = 1; - private RequestHeader header_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - return getHeader(); - } - - public static final int CONSUMERGROUP_FIELD_NUMBER = 2; - private volatile Object consumerGroup_; - - /** - * string consumerGroup = 2; - */ - public String getConsumerGroup() { - Object ref = consumerGroup_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - consumerGroup_ = s; - return s; - } - } - - /** - * string consumerGroup = 2; - */ - public com.google.protobuf.ByteString - getConsumerGroupBytes() { - Object ref = consumerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - consumerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SUBSCRIPTIONITEMS_FIELD_NUMBER = 3; - private java.util.List subscriptionItems_; - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List getSubscriptionItemsList() { - return subscriptionItems_; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List - getSubscriptionItemsOrBuilderList() { - return subscriptionItems_; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public int getSubscriptionItemsCount() { - return subscriptionItems_.size(); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem getSubscriptionItems(int index) { - return subscriptionItems_.get(index); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( - int index) { - return subscriptionItems_.get(index); - } - - private byte memoizedIsInitialized = -1; - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (header_ != null) { - output.writeMessage(1, getHeader()); - } - if (!getConsumerGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, consumerGroup_); - } - for (int i = 0; i < subscriptionItems_.size(); i++) { - output.writeMessage(3, subscriptionItems_.get(i)); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (header_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getHeader()); - } - if (!getConsumerGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, consumerGroup_); - } - for (int i = 0; i < subscriptionItems_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, subscriptionItems_.get(i)); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Subscription)) { - return super.equals(obj); - } - Subscription other = (Subscription) obj; - - boolean result = true; - result = result && (hasHeader() == other.hasHeader()); - if (hasHeader()) { - result = result && getHeader() - .equals(other.getHeader()); - } - result = result && getConsumerGroup() - .equals(other.getConsumerGroup()); - result = result && getSubscriptionItemsList() - .equals(other.getSubscriptionItemsList()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasHeader()) { - hash = (37 * hash) + HEADER_FIELD_NUMBER; - hash = (53 * hash) + getHeader().hashCode(); - } - hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; - hash = (53 * hash) + getConsumerGroup().hashCode(); - if (getSubscriptionItemsCount() > 0) { - hash = (37 * hash) + SUBSCRIPTIONITEMS_FIELD_NUMBER; - hash = (53 * hash) + getSubscriptionItemsList().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static Subscription parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Subscription parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Subscription parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Subscription parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Subscription parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Subscription parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Subscription parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Subscription 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 Subscription parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static Subscription 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 Subscription parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - - public static Subscription parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Subscription prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - * Protobuf type {@code eventmesh.client.Subscription} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.client.Subscription) - SubscriptionOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_fieldAccessorTable - .ensureFieldAccessorsInitialized( - Subscription.class, Builder.class); - } - - // Construct using org.apache.eventmesh.client.grpc.protos.Subscription.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getSubscriptionItemsFieldBuilder(); - } - } - - public Builder clear() { - super.clear(); - if (headerBuilder_ == null) { - header_ = null; - } else { - header_ = null; - headerBuilder_ = null; - } - consumerGroup_ = ""; - - if (subscriptionItemsBuilder_ == null) { - subscriptionItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - } else { - subscriptionItemsBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return EventmeshClient.internal_static_eventmesh_client_Subscription_descriptor; - } - - public Subscription getDefaultInstanceForType() { - return Subscription.getDefaultInstance(); - } - - public Subscription build() { - Subscription result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Subscription buildPartial() { - Subscription result = new Subscription(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (headerBuilder_ == null) { - result.header_ = header_; - } else { - result.header_ = headerBuilder_.build(); - } - result.consumerGroup_ = consumerGroup_; - if (subscriptionItemsBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004)) { - subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.subscriptionItems_ = subscriptionItems_; - } else { - result.subscriptionItems_ = subscriptionItemsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Subscription) { - return mergeFrom((Subscription) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Subscription other) { - if (other == Subscription.getDefaultInstance()) return this; - if (other.hasHeader()) { - mergeHeader(other.getHeader()); - } - if (!other.getConsumerGroup().isEmpty()) { - consumerGroup_ = other.consumerGroup_; - onChanged(); - } - if (subscriptionItemsBuilder_ == null) { - if (!other.subscriptionItems_.isEmpty()) { - if (subscriptionItems_.isEmpty()) { - subscriptionItems_ = other.subscriptionItems_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.addAll(other.subscriptionItems_); - } - onChanged(); - } - } else { - if (!other.subscriptionItems_.isEmpty()) { - if (subscriptionItemsBuilder_.isEmpty()) { - subscriptionItemsBuilder_.dispose(); - subscriptionItemsBuilder_ = null; - subscriptionItems_ = other.subscriptionItems_; - bitField0_ = (bitField0_ & ~0x00000004); - subscriptionItemsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getSubscriptionItemsFieldBuilder() : null; - } else { - subscriptionItemsBuilder_.addAllMessages(other.subscriptionItems_); - } - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Subscription parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Subscription) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int bitField0_; - - private RequestHeader header_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public boolean hasHeader() { - return headerBuilder_ != null || header_ != null; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader getHeader() { - if (headerBuilder_ == null) { - return header_ == null ? RequestHeader.getDefaultInstance() : header_; - } else { - return headerBuilder_.getMessage(); - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - header_ = value; - onChanged(); - } else { - headerBuilder_.setMessage(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder setHeader( - RequestHeader.Builder builderForValue) { - if (headerBuilder_ == null) { - header_ = builderForValue.build(); - onChanged(); - } else { - headerBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder mergeHeader(RequestHeader value) { - if (headerBuilder_ == null) { - if (header_ != null) { - header_ = - RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); - } else { - header_ = value; - } - onChanged(); - } else { - headerBuilder_.mergeFrom(value); - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public Builder clearHeader() { - if (headerBuilder_ == null) { - header_ = null; - onChanged(); - } else { - header_ = null; - headerBuilder_ = null; - } - - return this; - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeader.Builder getHeaderBuilder() { - - onChanged(); - return getHeaderFieldBuilder().getBuilder(); - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - public RequestHeaderOrBuilder getHeaderOrBuilder() { - if (headerBuilder_ != null) { - return headerBuilder_.getMessageOrBuilder(); - } else { - return header_ == null ? - RequestHeader.getDefaultInstance() : header_; - } - } - - /** - * .eventmesh.client.RequestHeader header = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> - getHeaderFieldBuilder() { - if (headerBuilder_ == null) { - headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( - getHeader(), - getParentForChildren(), - isClean()); - header_ = null; - } - return headerBuilder_; - } - - private Object consumerGroup_ = ""; - - /** - * string consumerGroup = 2; - */ - public String getConsumerGroup() { - Object ref = consumerGroup_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - consumerGroup_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string consumerGroup = 2; - */ - public com.google.protobuf.ByteString - getConsumerGroupBytes() { - Object ref = consumerGroup_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - consumerGroup_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string consumerGroup = 2; - */ - public Builder setConsumerGroup( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - consumerGroup_ = value; - onChanged(); - return this; - } - - /** - * string consumerGroup = 2; - */ - public Builder clearConsumerGroup() { - - consumerGroup_ = getDefaultInstance().getConsumerGroup(); - onChanged(); - return this; - } - - /** - * string consumerGroup = 2; - */ - public Builder setConsumerGroupBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - consumerGroup_ = value; - onChanged(); - return this; - } - - private java.util.List subscriptionItems_ = - java.util.Collections.emptyList(); - - private void ensureSubscriptionItemsIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - subscriptionItems_ = new java.util.ArrayList(subscriptionItems_); - bitField0_ |= 0x00000004; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> subscriptionItemsBuilder_; - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List getSubscriptionItemsList() { - if (subscriptionItemsBuilder_ == null) { - return java.util.Collections.unmodifiableList(subscriptionItems_); - } else { - return subscriptionItemsBuilder_.getMessageList(); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public int getSubscriptionItemsCount() { - if (subscriptionItemsBuilder_ == null) { - return subscriptionItems_.size(); - } else { - return subscriptionItemsBuilder_.getCount(); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem getSubscriptionItems(int index) { - if (subscriptionItemsBuilder_ == null) { - return subscriptionItems_.get(index); - } else { - return subscriptionItemsBuilder_.getMessage(index); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder setSubscriptionItems( - int index, SubscriptionItem value) { - if (subscriptionItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.set(index, value); - onChanged(); - } else { - subscriptionItemsBuilder_.setMessage(index, value); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder setSubscriptionItems( - int index, SubscriptionItem.Builder builderForValue) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.set(index, builderForValue.build()); - onChanged(); - } else { - subscriptionItemsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addSubscriptionItems(SubscriptionItem value) { - if (subscriptionItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.add(value); - onChanged(); - } else { - subscriptionItemsBuilder_.addMessage(value); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addSubscriptionItems( - int index, SubscriptionItem value) { - if (subscriptionItemsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.add(index, value); - onChanged(); - } else { - subscriptionItemsBuilder_.addMessage(index, value); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addSubscriptionItems( - SubscriptionItem.Builder builderForValue) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.add(builderForValue.build()); - onChanged(); - } else { - subscriptionItemsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addSubscriptionItems( - int index, SubscriptionItem.Builder builderForValue) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.add(index, builderForValue.build()); - onChanged(); - } else { - subscriptionItemsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder addAllSubscriptionItems( - Iterable values) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, subscriptionItems_); - onChanged(); - } else { - subscriptionItemsBuilder_.addAllMessages(values); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder clearSubscriptionItems() { - if (subscriptionItemsBuilder_ == null) { - subscriptionItems_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - subscriptionItemsBuilder_.clear(); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public Builder removeSubscriptionItems(int index) { - if (subscriptionItemsBuilder_ == null) { - ensureSubscriptionItemsIsMutable(); - subscriptionItems_.remove(index); - onChanged(); - } else { - subscriptionItemsBuilder_.remove(index); - } - return this; - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem.Builder getSubscriptionItemsBuilder( - int index) { - return getSubscriptionItemsFieldBuilder().getBuilder(index); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( - int index) { - if (subscriptionItemsBuilder_ == null) { - return subscriptionItems_.get(index); - } else { - return subscriptionItemsBuilder_.getMessageOrBuilder(index); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List - getSubscriptionItemsOrBuilderList() { - if (subscriptionItemsBuilder_ != null) { - return subscriptionItemsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(subscriptionItems_); - } - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem.Builder addSubscriptionItemsBuilder() { - return getSubscriptionItemsFieldBuilder().addBuilder( - SubscriptionItem.getDefaultInstance()); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public SubscriptionItem.Builder addSubscriptionItemsBuilder( - int index) { - return getSubscriptionItemsFieldBuilder().addBuilder( - index, SubscriptionItem.getDefaultInstance()); - } - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3; - */ - public java.util.List - getSubscriptionItemsBuilderList() { - return getSubscriptionItemsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> - getSubscriptionItemsFieldBuilder() { - if (subscriptionItemsBuilder_ == null) { - subscriptionItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder>( - subscriptionItems_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - subscriptionItems_ = null; - } - return subscriptionItemsBuilder_; - } - - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:eventmesh.client.Subscription) - } - - // @@protoc_insertion_point(class_scope:eventmesh.client.Subscription) - private static final Subscription DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new Subscription(); - } - - public static Subscription getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Subscription parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Subscription(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Subscription getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java deleted file mode 100644 index b47e54826d..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/protos/SubscriptionOrBuilder.java +++ /dev/null @@ -1,78 +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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: eventmesh-client.proto - -package org.apache.eventmesh.client.grpc.protos; - -/** - * SubscriptionOrBuilder interface. - */ -public interface SubscriptionOrBuilder extends com.google.protobuf.MessageOrBuilder { - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - boolean hasHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeader getHeader(); - - /** - * .eventmesh.client.RequestHeader header = 1. - */ - RequestHeaderOrBuilder getHeaderOrBuilder(); - - /** - * string consumerGroup = 2. - */ - String getConsumerGroup(); - - /** - * string consumerGroup = 2. - */ - com.google.protobuf.ByteString getConsumerGroupBytes(); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - java.util.List getSubscriptionItemsList(); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - Subscription.SubscriptionItem getSubscriptionItems(int index); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - int getSubscriptionItemsCount(); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - java.util.List - getSubscriptionItemsOrBuilderList(); - - /** - * repeated .eventmesh.client.Subscription.SubscriptionItem subscriptionItems = 3. - */ - Subscription.SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder(int index); -} From 69d69d698db712ea826e621b0733e2b72dbc2d17 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Mon, 13 Dec 2021 18:15:04 -0500 Subject: [PATCH 03/21] grpc publish with cloudevents --- .../grpc/common/EventMeshMessageWrapper.java | 17 + .../protocol/grpc/common/ProtocolKey.java | 23 ++ .../protocol/grpc/common/StatusCode.java | 68 +++ .../grpc/protos/ConsumerServiceGrpc.java | 141 +++---- .../{Message.java => EventMeshMessage.java} | 387 ++++++++++++++---- ...er.java => EventMeshMessageOrBuilder.java} | 41 +- .../protocol/grpc/protos/EventmeshGrpc.java | 121 +++--- .../protocol/grpc/protos/Heartbeat.java | 17 - .../grpc/protos/HeartbeatOrBuilder.java | 17 - .../grpc/protos/HeartbeatServiceGrpc.java | 59 +-- .../grpc/protos/PublisherServiceGrpc.java | 143 +++---- .../protocol/grpc/protos/RequestHeader.java | 384 ++++++++++------- .../grpc/protos/RequestHeaderOrBuilder.java | 51 +-- .../common/protocol/grpc/protos/Response.java | 17 - .../grpc/protos/ResponseOrBuilder.java | 17 - .../protocol/grpc/protos/Subscription.java | 17 - .../grpc/protos/SubscriptionOrBuilder.java | 17 - .../src/main/proto/eventmesh-client.proto | 19 +- .../build.gradle | 1 + .../MeshMessageProtocolAdaptor.java | 10 + .../grpc/GrpcMessageProtocolResolver.java | 97 +++++ .../runtime/boot/EventMeshGrpcServer.java | 6 +- .../processor/SendAsyncMessageProcessor.java | 27 +- .../grpc/service/ProducerService.java | 12 +- .../protocol/grpc/service/ServiceUtils.java | 14 +- .../client/grpc/EventMeshGrpcProducer.java | 69 ++++ .../eventmesh/client/grpc/Producer.java | 42 -- .../client/grpc/config/ClientConfig.java | 172 -------- .../config/EventMeshGrpcClientConfig.java | 84 ++++ .../client/grpc/AsyncPublishInstance.java | 65 +++ settings.gradle | 2 + 31 files changed, 1283 insertions(+), 874 deletions(-) create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java rename eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/{Message.java => EventMeshMessage.java} (77%) rename eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/{MessageOrBuilder.java => EventMeshMessageOrBuilder.java} (63%) create mode 100644 eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/Producer.java delete mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/ClientConfig.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java create mode 100644 eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/grpc/AsyncPublishInstance.java diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java new file mode 100644 index 0000000000..e19214f13b --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java @@ -0,0 +1,17 @@ +package org.apache.eventmesh.common.protocol.grpc.common; + +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; + +public class EventMeshMessageWrapper implements ProtocolTransportObject { + + private EventMeshMessage eventMeshMessage; + + public EventMeshMessageWrapper(EventMeshMessage eventMeshMessage) { + this.eventMeshMessage = eventMeshMessage; + } + + public EventMeshMessage getMessage() { + return eventMeshMessage; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java new file mode 100644 index 0000000000..d8d41a67eb --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java @@ -0,0 +1,23 @@ +package org.apache.eventmesh.common.protocol.grpc.common; + +public class ProtocolKey { + + public static final String ENV = "env"; + public static final String IDC = "idc"; + public static final String SYS = "sys"; + public static final String PID = "pid"; + public static final String IP = "ip"; + public static final String USERNAME = "username"; + public static final String PASSWD = "passwd"; + public static final String LANGUAGE = "language"; + + public static final String PROTOCOL_TYPE = "protocoltype"; + public static final String PROTOCOL_VERSION = "protocolversion"; + public static final String PROTOCOL_DESC = "protocoldesc"; + + public static final String SEQ_NUM = "seqnum"; + public static final String UNIQUE_ID = "uniqueid"; + public static final String TTL = "ttl"; + public static final String PRODUCERGROUP = "producergroup"; + public static final String TAG = "tag"; +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java new file mode 100644 index 0000000000..3b930e1803 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java @@ -0,0 +1,68 @@ +/* + * 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.eventmesh.common.protocol.grpc.common; + +public enum StatusCode { + + SUCCESS("0", "success"), + OVERLOAD("1", "eventMesh overload, try later, "), + EVENTMESH_REQUESTCODE_INVALID("2", "requestCode can't be null, or must be number, "), + EVENTMESH_SEND_SYNC_MSG_ERR("3", "eventMesh send rr msg err, "), + EVENTMESH_WAITING_RR_MSG_ERR("4", "eventMesh waiting rr msg err, "), + EVENTMESH_PROTOCOL_HEADER_ERR("6", "eventMesh protocol[header] err, "), + EVENTMESH_PROTOCOL_BODY_ERR("7", "eventMesh protocol[body] err, "), + EVENTMESH_STOP("8", "eventMesh will stop or had stopped, "), + EVENTMESH_REJECT_BY_PROCESSOR_ERROR("9", "eventMesh reject by processor error, "), + EVENTMESH_BATCH_PRODUCER_STOPED_ERR("10", "eventMesh batch msg producer stopped, "), + EVENTMESH_SEND_BATCHLOG_MSG_ERR("17", "eventMesh send batchlog msg err, "), + EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR("11", "eventMesh batch msg speed over the limit, "), + EVENTMESH_PACKAGE_MSG_ERR("12", "eventMesh package msg err, "), + EVENTMESH_GROUP_PRODUCER_STOPED_ERR("13", "eventMesh group producer stopped, "), + EVENTMESH_SEND_ASYNC_MSG_ERR("14", "eventMesh send async msg err, "), + EVENTMESH_REPLY_MSG_ERR("15", "eventMesh reply msg err, "), + EVENTMESH_RUNTIME_ERR("16", "eventMesh runtime err, "), + EVENTMESH_SUBSCRIBE_ERR("17", "eventMesh subscribe err"), + EVENTMESH_UNSUBSCRIBE_ERR("18", "eventMesh unsubscribe err"), + EVENTMESH_HEARTBEAT_ERR("19", "eventMesh heartbeat err"), + EVENTMESH_ACL_ERR("20", "eventMesh acl err"); + + private String retCode; + + private String errMsg; + + StatusCode(String retCode, String errMsg) { + this.retCode = retCode; + this.errMsg = errMsg; + } + + public String getRetCode() { + return retCode; + } + + public void setRetCode(String retCode) { + this.retCode = retCode; + } + + public String getErrMsg() { + return errMsg; + } + + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java index c9791a88a5..579e516bb2 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java @@ -1,20 +1,3 @@ -/* - * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; @@ -44,30 +27,30 @@ private ConsumerServiceGrpc() {} public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.ConsumerService"; // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getSubscribeMethod; + private static volatile io.grpc.MethodDescriptor getSubscribeMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "subscribe", - requestType = Subscription.class, - responseType = Response.class, + requestType = org.apache.eventmesh.common.protocol.grpc.protos.Subscription.class, + responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getSubscribeMethod() { - io.grpc.MethodDescriptor getSubscribeMethod; + public static io.grpc.MethodDescriptor getSubscribeMethod() { + io.grpc.MethodDescriptor getSubscribeMethod; if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { synchronized (ConsumerServiceGrpc.class) { if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { ConsumerServiceGrpc.getSubscribeMethod = getSubscribeMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.ConsumerService", "subscribe")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Subscription.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Subscription.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Response.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribe")) .build(); } @@ -76,30 +59,30 @@ Response> getSubscribeMethod() { return getSubscribeMethod; } - private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod; + private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "subscribeStream", - requestType = Subscription.class, - responseType = Message.class, + requestType = org.apache.eventmesh.common.protocol.grpc.protos.Subscription.class, + responseType = org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.class, methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - public static io.grpc.MethodDescriptor getSubscribeStreamMethod() { - io.grpc.MethodDescriptor getSubscribeStreamMethod; + public static io.grpc.MethodDescriptor getSubscribeStreamMethod() { + io.grpc.MethodDescriptor getSubscribeStreamMethod; if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { synchronized (ConsumerServiceGrpc.class) { if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { ConsumerServiceGrpc.getSubscribeStreamMethod = getSubscribeStreamMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.ConsumerService", "subscribeStream")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Subscription.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Subscription.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Message.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.getDefaultInstance())) .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribeStream")) .build(); } @@ -108,30 +91,30 @@ Message> getSubscribeStreamMethod() { return getSubscribeStreamMethod; } - private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod; + private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "unsubscribe", - requestType = Subscription.class, - responseType = Response.class, + requestType = org.apache.eventmesh.common.protocol.grpc.protos.Subscription.class, + responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getUnsubscribeMethod() { - io.grpc.MethodDescriptor getUnsubscribeMethod; + public static io.grpc.MethodDescriptor getUnsubscribeMethod() { + io.grpc.MethodDescriptor getUnsubscribeMethod; if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { synchronized (ConsumerServiceGrpc.class) { if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { ConsumerServiceGrpc.getUnsubscribeMethod = getUnsubscribeMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.ConsumerService", "unsubscribe")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Subscription.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Subscription.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Response.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("unsubscribe")) .build(); } @@ -169,22 +152,22 @@ public static abstract class ConsumerServiceImplBase implements io.grpc.Bindable /** */ - public void subscribe(Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void subscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getSubscribeMethod(), responseObserver); } /** */ - public void subscribeStream(Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void subscribeStream(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getSubscribeStreamMethod(), responseObserver); } /** */ - public void unsubscribe(Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void unsubscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getUnsubscribeMethod(), responseObserver); } @@ -194,22 +177,22 @@ public void unsubscribe(Subscription request, getSubscribeMethod(), asyncUnaryCall( new MethodHandlers< - Subscription, - Response>( + org.apache.eventmesh.common.protocol.grpc.protos.Subscription, + org.apache.eventmesh.common.protocol.grpc.protos.Response>( this, METHODID_SUBSCRIBE))) .addMethod( getSubscribeStreamMethod(), asyncServerStreamingCall( new MethodHandlers< - Subscription, - Message>( + org.apache.eventmesh.common.protocol.grpc.protos.Subscription, + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage>( this, METHODID_SUBSCRIBE_STREAM))) .addMethod( getUnsubscribeMethod(), asyncUnaryCall( new MethodHandlers< - Subscription, - Response>( + org.apache.eventmesh.common.protocol.grpc.protos.Subscription, + org.apache.eventmesh.common.protocol.grpc.protos.Response>( this, METHODID_UNSUBSCRIBE))) .build(); } @@ -235,24 +218,24 @@ protected ConsumerServiceStub build(io.grpc.Channel channel, /** */ - public void subscribe(Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void subscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getSubscribeMethod(), getCallOptions()), request, responseObserver); } /** */ - public void subscribeStream(Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void subscribeStream(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncServerStreamingCall( getChannel().newCall(getSubscribeStreamMethod(), getCallOptions()), request, responseObserver); } /** */ - public void unsubscribe(Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void unsubscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request, responseObserver); } @@ -278,22 +261,22 @@ protected ConsumerServiceBlockingStub build(io.grpc.Channel channel, /** */ - public Response subscribe(Subscription request) { + public org.apache.eventmesh.common.protocol.grpc.protos.Response subscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { return blockingUnaryCall( getChannel(), getSubscribeMethod(), getCallOptions(), request); } /** */ - public java.util.Iterator subscribeStream( - Subscription request) { + public java.util.Iterator subscribeStream( + org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { return blockingServerStreamingCall( getChannel(), getSubscribeStreamMethod(), getCallOptions(), request); } /** */ - public Response unsubscribe(Subscription request) { + public org.apache.eventmesh.common.protocol.grpc.protos.Response unsubscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { return blockingUnaryCall( getChannel(), getUnsubscribeMethod(), getCallOptions(), request); } @@ -319,16 +302,16 @@ protected ConsumerServiceFutureStub build(io.grpc.Channel channel, /** */ - public com.google.common.util.concurrent.ListenableFuture subscribe( - Subscription request) { + public com.google.common.util.concurrent.ListenableFuture subscribe( + org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { return futureUnaryCall( getChannel().newCall(getSubscribeMethod(), getCallOptions()), request); } /** */ - public com.google.common.util.concurrent.ListenableFuture unsubscribe( - Subscription request) { + public com.google.common.util.concurrent.ListenableFuture unsubscribe( + org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { return futureUnaryCall( getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request); } @@ -356,16 +339,16 @@ private static final class MethodHandlers implements public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { switch (methodId) { case METHODID_SUBSCRIBE: - serviceImpl.subscribe((Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.subscribe((org.apache.eventmesh.common.protocol.grpc.protos.Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); break; case METHODID_SUBSCRIBE_STREAM: - serviceImpl.subscribeStream((Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.subscribeStream((org.apache.eventmesh.common.protocol.grpc.protos.Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); break; case METHODID_UNSUBSCRIBE: - serviceImpl.unsubscribe((Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.unsubscribe((org.apache.eventmesh.common.protocol.grpc.protos.Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); break; default: throw new AssertionError(); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Message.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java similarity index 77% rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Message.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java index afa82dd075..c36fa52ee7 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Message.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java @@ -1,43 +1,28 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto package org.apache.eventmesh.common.protocol.grpc.protos; /** - * Protobuf type {@code eventmesh.common.protocol.grpc.Message} + * Protobuf type {@code eventmesh.common.protocol.grpc.EventMeshMessage} */ -public final class Message extends +public final class EventMeshMessage extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Message) - MessageOrBuilder { + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.EventMeshMessage) + EventMeshMessageOrBuilder { private static final long serialVersionUID = 0L; - // Use Message.newBuilder() to construct. - private Message(com.google.protobuf.GeneratedMessageV3.Builder builder) { + // Use EventMeshMessage.newBuilder() to construct. + private EventMeshMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } - private Message() { + private EventMeshMessage() { producerGroup_ = ""; topic_ = ""; content_ = ""; ttl_ = ""; uniqueId_ = ""; + seqNum_ = ""; + tag_ = ""; } @Override @@ -45,7 +30,7 @@ private Message() { getUnknownFields() { return this.unknownFields; } - private Message( + private EventMeshMessage( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { @@ -114,6 +99,18 @@ private Message( uniqueId_ = s; break; } + case 58: { + String s = input.readStringRequireUtf8(); + + seqNum_ = s; + break; + } + case 66: { + String s = input.readStringRequireUtf8(); + + tag_ = s; + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -128,14 +125,14 @@ private Message( } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_descriptor; + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; } protected FieldAccessorTable internalGetFieldAccessorTable() { - return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_fieldAccessorTable + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable .ensureFieldAccessorsInitialized( - Message.class, Builder.class); + EventMeshMessage.class, Builder.class); } public static final int HEADER_FIELD_NUMBER = 1; @@ -329,6 +326,74 @@ public String getUniqueId() { } } + public static final int SEQNUM_FIELD_NUMBER = 7; + private volatile Object seqNum_; + /** + * string seqNum = 7; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } + } + /** + * string seqNum = 7; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TAG_FIELD_NUMBER = 8; + private volatile Object tag_; + /** + * string tag = 8; + */ + public String getTag() { + Object ref = tag_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + tag_ = s; + return s; + } + } + /** + * string tag = 8; + */ + public com.google.protobuf.ByteString + getTagBytes() { + Object ref = tag_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + tag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; @@ -359,6 +424,12 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!getUniqueIdBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 6, uniqueId_); } + if (!getSeqNumBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, seqNum_); + } + if (!getTagBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, tag_); + } unknownFields.writeTo(output); } @@ -386,6 +457,12 @@ public int getSerializedSize() { if (!getUniqueIdBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, uniqueId_); } + if (!getSeqNumBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, seqNum_); + } + if (!getTagBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, tag_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -396,10 +473,10 @@ public boolean equals(final Object obj) { if (obj == this) { return true; } - if (!(obj instanceof Message)) { + if (!(obj instanceof EventMeshMessage)) { return super.equals(obj); } - Message other = (Message) obj; + EventMeshMessage other = (EventMeshMessage) obj; boolean result = true; result = result && (hasHeader() == other.hasHeader()); @@ -417,6 +494,10 @@ public boolean equals(final Object obj) { .equals(other.getTtl()); result = result && getUniqueId() .equals(other.getUniqueId()); + result = result && getSeqNum() + .equals(other.getSeqNum()); + result = result && getTag() + .equals(other.getTag()); result = result && unknownFields.equals(other.unknownFields); return result; } @@ -442,74 +523,78 @@ public int hashCode() { hash = (53 * hash) + getTtl().hashCode(); hash = (37 * hash) + UNIQUEID_FIELD_NUMBER; hash = (53 * hash) + getUniqueId().hashCode(); + hash = (37 * hash) + SEQNUM_FIELD_NUMBER; + hash = (53 * hash) + getSeqNum().hashCode(); + hash = (37 * hash) + TAG_FIELD_NUMBER; + hash = (53 * hash) + getTag().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } - public static Message parseFrom( + public static EventMeshMessage parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static Message parseFrom( + public static EventMeshMessage parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static Message parseFrom( + public static EventMeshMessage parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static Message parseFrom( + public static EventMeshMessage parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static Message parseFrom(byte[] data) + public static EventMeshMessage parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static Message parseFrom( + public static EventMeshMessage parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static Message parseFrom(java.io.InputStream input) + public static EventMeshMessage parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } - public static Message parseFrom( + public static EventMeshMessage 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 Message parseDelimitedFrom(java.io.InputStream input) + public static EventMeshMessage parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } - public static Message parseDelimitedFrom( + public static EventMeshMessage 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 Message parseFrom( + public static EventMeshMessage parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } - public static Message parseFrom( + public static EventMeshMessage parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -521,7 +606,7 @@ public static Message parseFrom( public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } - public static Builder newBuilder(Message prototype) { + public static Builder newBuilder(EventMeshMessage prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } public Builder toBuilder() { @@ -536,25 +621,25 @@ protected Builder newBuilderForType( return builder; } /** - * Protobuf type {@code eventmesh.common.protocol.grpc.Message} + * Protobuf type {@code eventmesh.common.protocol.grpc.EventMeshMessage} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Message) - MessageOrBuilder { + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.EventMeshMessage) + EventMeshMessageOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_descriptor; + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; } protected FieldAccessorTable internalGetFieldAccessorTable() { - return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_fieldAccessorTable + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable .ensureFieldAccessorsInitialized( - Message.class, Builder.class); + EventMeshMessage.class, Builder.class); } - // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Message.newBuilder() + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -587,28 +672,32 @@ public Builder clear() { uniqueId_ = ""; + seqNum_ = ""; + + tag_ = ""; + return this; } public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Message_descriptor; + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; } - public Message getDefaultInstanceForType() { - return Message.getDefaultInstance(); + public EventMeshMessage getDefaultInstanceForType() { + return EventMeshMessage.getDefaultInstance(); } - public Message build() { - Message result = buildPartial(); + public EventMeshMessage build() { + EventMeshMessage result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } - public Message buildPartial() { - Message result = new Message(this); + public EventMeshMessage buildPartial() { + EventMeshMessage result = new EventMeshMessage(this); if (headerBuilder_ == null) { result.header_ = header_; } else { @@ -619,6 +708,8 @@ public Message buildPartial() { result.content_ = content_; result.ttl_ = ttl_; result.uniqueId_ = uniqueId_; + result.seqNum_ = seqNum_; + result.tag_ = tag_; onBuilt(); return result; } @@ -650,16 +741,16 @@ public Builder addRepeatedField( return (Builder) super.addRepeatedField(field, value); } public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Message) { - return mergeFrom((Message)other); + if (other instanceof EventMeshMessage) { + return mergeFrom((EventMeshMessage)other); } else { super.mergeFrom(other); return this; } } - public Builder mergeFrom(Message other) { - if (other == Message.getDefaultInstance()) return this; + public Builder mergeFrom(EventMeshMessage other) { + if (other == EventMeshMessage.getDefaultInstance()) return this; if (other.hasHeader()) { mergeHeader(other.getHeader()); } @@ -683,6 +774,14 @@ public Builder mergeFrom(Message other) { uniqueId_ = other.uniqueId_; onChanged(); } + if (!other.getSeqNum().isEmpty()) { + seqNum_ = other.seqNum_; + onChanged(); + } + if (!other.getTag().isEmpty()) { + tag_ = other.tag_; + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -696,11 +795,11 @@ public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - Message parsedMessage = null; + EventMeshMessage parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Message) e.getUnfinishedMessage(); + parsedMessage = (EventMeshMessage) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { @@ -1171,6 +1270,144 @@ public Builder setUniqueIdBytes( onChanged(); return this; } + + private Object seqNum_ = ""; + /** + * string seqNum = 7; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string seqNum = 7; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string seqNum = 7; + */ + public Builder setSeqNum( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + seqNum_ = value; + onChanged(); + return this; + } + /** + * string seqNum = 7; + */ + public Builder clearSeqNum() { + + seqNum_ = getDefaultInstance().getSeqNum(); + onChanged(); + return this; + } + /** + * string seqNum = 7; + */ + public Builder setSeqNumBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + seqNum_ = value; + onChanged(); + return this; + } + + private Object tag_ = ""; + /** + * string tag = 8; + */ + public String getTag() { + Object ref = tag_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + tag_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string tag = 8; + */ + public com.google.protobuf.ByteString + getTagBytes() { + Object ref = tag_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + tag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string tag = 8; + */ + public Builder setTag( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + tag_ = value; + onChanged(); + return this; + } + /** + * string tag = 8; + */ + public Builder clearTag() { + + tag_ = getDefaultInstance().getTag(); + onChanged(); + return this; + } + /** + * string tag = 8; + */ + public Builder setTagBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + tag_ = value; + onChanged(); + return this; + } public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFieldsProto3(unknownFields); @@ -1182,39 +1419,39 @@ public final Builder mergeUnknownFields( } - // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Message) + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.EventMeshMessage) } - // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Message) - private static final Message DEFAULT_INSTANCE; + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.EventMeshMessage) + private static final EventMeshMessage DEFAULT_INSTANCE; static { - DEFAULT_INSTANCE = new Message(); + DEFAULT_INSTANCE = new EventMeshMessage(); } - public static Message getDefaultInstance() { + public static EventMeshMessage getDefaultInstance() { return DEFAULT_INSTANCE; } - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Message parsePartialFrom( + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public EventMeshMessage parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return new Message(input, extensionRegistry); + return new EventMeshMessage(input, extensionRegistry); } }; - public static com.google.protobuf.Parser parser() { + public static com.google.protobuf.Parser parser() { return PARSER; } @Override - public com.google.protobuf.Parser getParserForType() { + public com.google.protobuf.Parser getParserForType() { return PARSER; } - public Message getDefaultInstanceForType() { + public EventMeshMessage getDefaultInstanceForType() { return DEFAULT_INSTANCE; } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/MessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java similarity index 63% rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/MessageOrBuilder.java rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java index 698f020916..505bbdd1cc 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/MessageOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java @@ -1,27 +1,10 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto package org.apache.eventmesh.common.protocol.grpc.protos; -public interface MessageOrBuilder extends - // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Message) +public interface EventMeshMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.EventMeshMessage) com.google.protobuf.MessageOrBuilder { /** @@ -86,4 +69,24 @@ public interface MessageOrBuilder extends */ com.google.protobuf.ByteString getUniqueIdBytes(); + + /** + * string seqNum = 7; + */ + String getSeqNum(); + /** + * string seqNum = 7; + */ + com.google.protobuf.ByteString + getSeqNumBytes(); + + /** + * string tag = 8; + */ + String getTag(); + /** + * string tag = 8; + */ + com.google.protobuf.ByteString + getTagBytes(); } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java index 2e815e41b4..cf21626684 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto @@ -37,10 +20,10 @@ public static void registerAllExtensions( com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor - internal_static_eventmesh_common_protocol_grpc_Message_descriptor; + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_eventmesh_common_protocol_grpc_Message_fieldAccessorTable; + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_eventmesh_common_protocol_grpc_Response_descriptor; static final @@ -76,52 +59,54 @@ public static void registerAllExtensions( static { String[] descriptorData = { "\n\026eventmesh-client.proto\022\036eventmesh.comm" + - "on.protocol.grpc\"\266\001\n\rRequestHeader\022\013\n\003en" + + "on.protocol.grpc\"\332\001\n\rRequestHeader\022\013\n\003en" + "v\030\001 \001(\t\022\016\n\006region\030\002 \001(\t\022\013\n\003idc\030\003 \001(\t\022\n\n\002" + "ip\030\004 \001(\t\022\013\n\003pid\030\005 \001(\t\022\013\n\003sys\030\006 \001(\t\022\020\n\010us" + - "ername\030\007 \001(\t\022\020\n\010password\030\010 \001(\t\022\017\n\007versio" + - "n\030\t \001(\t\022\020\n\010language\030\n \001(\t\022\016\n\006seqNum\030\013 \001(" + - "\t\"\236\001\n\007Message\022=\n\006header\030\001 \001(\0132-.eventmes" + - "h.common.protocol.grpc.RequestHeader\022\025\n\r" + - "producerGroup\030\002 \001(\t\022\r\n\005topic\030\003 \001(\t\022\017\n\007co" + - "ntent\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020\n\010uniqueId\030\006 \001" + - "(\t\"O\n\010Response\022\020\n\010respCode\030\001 \001(\t\022\017\n\007resp" + - "Msg\030\002 \001(\t\022\020\n\010respTime\030\003 \001(\t\022\016\n\006seqNum\030\004 " + - "\001(\t\"\212\002\n\014Subscription\022=\n\006header\030\001 \001(\0132-.e" + - "ventmesh.common.protocol.grpc.RequestHea" + - "der\022\025\n\rconsumerGroup\030\002 \001(\t\022X\n\021subscripti" + - "onItems\030\003 \003(\0132=.eventmesh.common.protoco" + - "l.grpc.Subscription.SubscriptionItem\032J\n\020" + - "SubscriptionItem\022\r\n\005topic\030\001 \001(\t\022\014\n\004mode\030" + - "\002 \001(\t\022\014\n\004type\030\003 \001(\t\022\013\n\003url\030\004 \001(\t\"\212\002\n\tHea" + - "rtbeat\022=\n\006header\030\001 \001(\0132-.eventmesh.commo" + - "n.protocol.grpc.RequestHeader\022\022\n\nclientT" + - "ype\030\002 \001(\t\022\025\n\rproducerGroup\030\003 \001(\t\022\025\n\rcons" + - "umerGroup\030\004 \001(\t\022O\n\016heartbeatItems\030\005 \003(\0132" + - "7.eventmesh.common.protocol.grpc.Heartbe" + - "at.HeartbeatItem\032+\n\rHeartbeatItem\022\r\n\005top" + - "ic\030\001 \001(\t\022\013\n\003url\030\002 \001(\t2\263\002\n\020PublisherServi" + - "ce\022\\\n\007publish\022\'.eventmesh.common.protoco" + - "l.grpc.Message\032(.eventmesh.common.protoc" + - "ol.grpc.Response\022a\n\014requestReply\022\'.event" + - "mesh.common.protocol.grpc.Message\032(.even" + - "tmesh.common.protocol.grpc.Response\022^\n\tb" + - "roadcast\022\'.eventmesh.common.protocol.grp" + - "c.Message\032(.eventmesh.common.protocol.gr" + - "pc.Response2\311\002\n\017ConsumerService\022c\n\tsubsc" + - "ribe\022,.eventmesh.common.protocol.grpc.Su" + - "bscription\032(.eventmesh.common.protocol.g" + - "rpc.Response\022j\n\017subscribeStream\022,.eventm" + - "esh.common.protocol.grpc.Subscription\032\'." + - "eventmesh.common.protocol.grpc.Message0\001" + - "\022e\n\013unsubscribe\022,.eventmesh.common.proto" + - "col.grpc.Subscription\032(.eventmesh.common" + - ".protocol.grpc.Response2t\n\020HeartbeatServ" + - "ice\022`\n\theartbeat\022).eventmesh.common.prot" + - "ocol.grpc.Heartbeat\032(.eventmesh.common.p" + - "rotocol.grpc.ResponseBC\n0org.apache.even" + - "tmesh.common.protocol.grpc.protosB\rEvent" + - "meshGrpcP\001b\006proto3" + "ername\030\007 \001(\t\022\020\n\010password\030\010 \001(\t\022\020\n\010langua" + + "ge\030\t \001(\t\022\024\n\014protocolType\030\n \001(\t\022\027\n\017protoc" + + "olVersion\030\013 \001(\t\022\024\n\014protocolDesc\030\014 \001(\t\"\267\001" + + "\n\020EventMeshMessage\022=\n\006header\030\001 \001(\0132-.eve" + + "ntmesh.common.protocol.grpc.RequestHeade" + + "r\022\025\n\rproducerGroup\030\002 \001(\t\022\r\n\005topic\030\003 \001(\t\022" + + "\017\n\007content\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020\n\010uniqueI" + + "d\030\006 \001(\t\022\016\n\006seqNum\030\007 \001(\t\"O\n\010Response\022\020\n\010r" + + "espCode\030\001 \001(\t\022\017\n\007respMsg\030\002 \001(\t\022\020\n\010respTi" + + "me\030\003 \001(\t\022\016\n\006seqNum\030\004 \001(\t\"\212\002\n\014Subscriptio" + + "n\022=\n\006header\030\001 \001(\0132-.eventmesh.common.pro" + + "tocol.grpc.RequestHeader\022\025\n\rconsumerGrou" + + "p\030\002 \001(\t\022X\n\021subscriptionItems\030\003 \003(\0132=.eve" + + "ntmesh.common.protocol.grpc.Subscription" + + ".SubscriptionItem\032J\n\020SubscriptionItem\022\r\n" + + "\005topic\030\001 \001(\t\022\014\n\004mode\030\002 \001(\t\022\014\n\004type\030\003 \001(\t" + + "\022\013\n\003url\030\004 \001(\t\"\212\002\n\tHeartbeat\022=\n\006header\030\001 " + + "\001(\0132-.eventmesh.common.protocol.grpc.Req" + + "uestHeader\022\022\n\nclientType\030\002 \001(\t\022\025\n\rproduc" + + "erGroup\030\003 \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022O\n\016" + + "heartbeatItems\030\005 \003(\01327.eventmesh.common." + + "protocol.grpc.Heartbeat.HeartbeatItem\032+\n" + + "\rHeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030\002 \001" + + "(\t2\316\002\n\020PublisherService\022e\n\007publish\0220.eve" + + "ntmesh.common.protocol.grpc.EventMeshMes" + + "sage\032(.eventmesh.common.protocol.grpc.Re" + + "sponse\022j\n\014requestReply\0220.eventmesh.commo" + + "n.protocol.grpc.EventMeshMessage\032(.event" + + "mesh.common.protocol.grpc.Response\022g\n\tbr" + + "oadcast\0220.eventmesh.common.protocol.grpc" + + ".EventMeshMessage\032(.eventmesh.common.pro" + + "tocol.grpc.Response2\322\002\n\017ConsumerService\022" + + "c\n\tsubscribe\022,.eventmesh.common.protocol" + + ".grpc.Subscription\032(.eventmesh.common.pr" + + "otocol.grpc.Response\022s\n\017subscribeStream\022" + + ",.eventmesh.common.protocol.grpc.Subscri" + + "ption\0320.eventmesh.common.protocol.grpc.E" + + "ventMeshMessage0\001\022e\n\013unsubscribe\022,.event" + + "mesh.common.protocol.grpc.Subscription\032(" + + ".eventmesh.common.protocol.grpc.Response" + + "2t\n\020HeartbeatService\022`\n\theartbeat\022).even" + + "tmesh.common.protocol.grpc.Heartbeat\032(.e" + + "ventmesh.common.protocol.grpc.ResponseBC" + + "\n0org.apache.eventmesh.common.protocol.g" + + "rpc.protosB\rEventmeshGrpcP\001b\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -140,13 +125,13 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor, - new String[] { "Env", "Region", "Idc", "Ip", "Pid", "Sys", "Username", "Password", "Version", "Language", "SeqNum", }); - internal_static_eventmesh_common_protocol_grpc_Message_descriptor = + new String[] { "Env", "Region", "Idc", "Ip", "Pid", "Sys", "Username", "Password", "Language", "ProtocolType", "ProtocolVersion", "ProtocolDesc", }); + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor = getDescriptor().getMessageTypes().get(1); - internal_static_eventmesh_common_protocol_grpc_Message_fieldAccessorTable = new + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_eventmesh_common_protocol_grpc_Message_descriptor, - new String[] { "Header", "ProducerGroup", "Topic", "Content", "Ttl", "UniqueId", }); + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor, + new String[] { "Header", "ProducerGroup", "Topic", "Content", "Ttl", "UniqueId", "SeqNum", }); internal_static_eventmesh_common_protocol_grpc_Response_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable = new diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java index f616a65790..ca1b1b1307 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java index 7bbe0aba1c..ac25165c77 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java index 8f8f500cc0..8736ffbac3 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java @@ -1,20 +1,3 @@ -/* - * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; @@ -44,30 +27,30 @@ private HeartbeatServiceGrpc() {} public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.HeartbeatService"; // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getHeartbeatMethod; + private static volatile io.grpc.MethodDescriptor getHeartbeatMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "heartbeat", - requestType = Heartbeat.class, - responseType = Response.class, + requestType = org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.class, + responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getHeartbeatMethod() { - io.grpc.MethodDescriptor getHeartbeatMethod; + public static io.grpc.MethodDescriptor getHeartbeatMethod() { + io.grpc.MethodDescriptor getHeartbeatMethod; if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { synchronized (HeartbeatServiceGrpc.class) { if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { HeartbeatServiceGrpc.getHeartbeatMethod = getHeartbeatMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.HeartbeatService", "heartbeat")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Heartbeat.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Response.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) .setSchemaDescriptor(new HeartbeatServiceMethodDescriptorSupplier("heartbeat")) .build(); } @@ -105,8 +88,8 @@ public static abstract class HeartbeatServiceImplBase implements io.grpc.Bindabl /** */ - public void heartbeat(Heartbeat request, - io.grpc.stub.StreamObserver responseObserver) { + public void heartbeat(org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getHeartbeatMethod(), responseObserver); } @@ -116,8 +99,8 @@ public void heartbeat(Heartbeat request, getHeartbeatMethod(), asyncUnaryCall( new MethodHandlers< - Heartbeat, - Response>( + org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat, + org.apache.eventmesh.common.protocol.grpc.protos.Response>( this, METHODID_HEARTBEAT))) .build(); } @@ -143,8 +126,8 @@ protected HeartbeatServiceStub build(io.grpc.Channel channel, /** */ - public void heartbeat(Heartbeat request, - io.grpc.stub.StreamObserver responseObserver) { + public void heartbeat(org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request, responseObserver); } @@ -170,7 +153,7 @@ protected HeartbeatServiceBlockingStub build(io.grpc.Channel channel, /** */ - public Response heartbeat(Heartbeat request) { + public org.apache.eventmesh.common.protocol.grpc.protos.Response heartbeat(org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat request) { return blockingUnaryCall( getChannel(), getHeartbeatMethod(), getCallOptions(), request); } @@ -196,8 +179,8 @@ protected HeartbeatServiceFutureStub build(io.grpc.Channel channel, /** */ - public com.google.common.util.concurrent.ListenableFuture heartbeat( - Heartbeat request) { + public com.google.common.util.concurrent.ListenableFuture heartbeat( + org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat request) { return futureUnaryCall( getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request); } @@ -223,8 +206,8 @@ private static final class MethodHandlers implements public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { switch (methodId) { case METHODID_HEARTBEAT: - serviceImpl.heartbeat((Heartbeat) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.heartbeat((org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat) request, + (io.grpc.stub.StreamObserver) responseObserver); break; default: throw new AssertionError(); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java index 64c5fea15f..853d47cac2 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java @@ -1,20 +1,3 @@ -/* - * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; @@ -44,30 +27,30 @@ private PublisherServiceGrpc() {} public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.PublisherService"; // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getPublishMethod; + private static volatile io.grpc.MethodDescriptor getPublishMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "publish", - requestType = Message.class, - responseType = Response.class, + requestType = org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.class, + responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getPublishMethod() { - io.grpc.MethodDescriptor getPublishMethod; + public static io.grpc.MethodDescriptor getPublishMethod() { + io.grpc.MethodDescriptor getPublishMethod; if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { synchronized (PublisherServiceGrpc.class) { if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { PublisherServiceGrpc.getPublishMethod = getPublishMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.PublisherService", "publish")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Message.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Response.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("publish")) .build(); } @@ -76,30 +59,30 @@ Response> getPublishMethod() { return getPublishMethod; } - private static volatile io.grpc.MethodDescriptor getRequestReplyMethod; + private static volatile io.grpc.MethodDescriptor getRequestReplyMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "requestReply", - requestType = Message.class, - responseType = Response.class, + requestType = org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.class, + responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getRequestReplyMethod() { - io.grpc.MethodDescriptor getRequestReplyMethod; + public static io.grpc.MethodDescriptor getRequestReplyMethod() { + io.grpc.MethodDescriptor getRequestReplyMethod; if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { synchronized (PublisherServiceGrpc.class) { if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { PublisherServiceGrpc.getRequestReplyMethod = getRequestReplyMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.PublisherService", "requestReply")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Message.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Response.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("requestReply")) .build(); } @@ -108,30 +91,30 @@ Response> getRequestReplyMethod() { return getRequestReplyMethod; } - private static volatile io.grpc.MethodDescriptor getBroadcastMethod; + private static volatile io.grpc.MethodDescriptor getBroadcastMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "broadcast", - requestType = Message.class, - responseType = Response.class, + requestType = org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.class, + responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getBroadcastMethod() { - io.grpc.MethodDescriptor getBroadcastMethod; + public static io.grpc.MethodDescriptor getBroadcastMethod() { + io.grpc.MethodDescriptor getBroadcastMethod; if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { synchronized (PublisherServiceGrpc.class) { if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { PublisherServiceGrpc.getBroadcastMethod = getBroadcastMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.PublisherService", "broadcast")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Message.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Response.getDefaultInstance())) + org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("broadcast")) .build(); } @@ -169,22 +152,22 @@ public static abstract class PublisherServiceImplBase implements io.grpc.Bindabl /** */ - public void publish(Message request, - io.grpc.stub.StreamObserver responseObserver) { + public void publish(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getPublishMethod(), responseObserver); } /** */ - public void requestReply(Message request, - io.grpc.stub.StreamObserver responseObserver) { + public void requestReply(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getRequestReplyMethod(), responseObserver); } /** */ - public void broadcast(Message request, - io.grpc.stub.StreamObserver responseObserver) { + public void broadcast(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getBroadcastMethod(), responseObserver); } @@ -194,22 +177,22 @@ public void broadcast(Message request, getPublishMethod(), asyncUnaryCall( new MethodHandlers< - Message, - Response>( + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage, + org.apache.eventmesh.common.protocol.grpc.protos.Response>( this, METHODID_PUBLISH))) .addMethod( getRequestReplyMethod(), asyncUnaryCall( new MethodHandlers< - Message, - Response>( + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage, + org.apache.eventmesh.common.protocol.grpc.protos.Response>( this, METHODID_REQUEST_REPLY))) .addMethod( getBroadcastMethod(), asyncUnaryCall( new MethodHandlers< - Message, - Response>( + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage, + org.apache.eventmesh.common.protocol.grpc.protos.Response>( this, METHODID_BROADCAST))) .build(); } @@ -235,24 +218,24 @@ protected PublisherServiceStub build(io.grpc.Channel channel, /** */ - public void publish(Message request, - io.grpc.stub.StreamObserver responseObserver) { + public void publish(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getPublishMethod(), getCallOptions()), request, responseObserver); } /** */ - public void requestReply(Message request, - io.grpc.stub.StreamObserver responseObserver) { + public void requestReply(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request, responseObserver); } /** */ - public void broadcast(Message request, - io.grpc.stub.StreamObserver responseObserver) { + public void broadcast(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getBroadcastMethod(), getCallOptions()), request, responseObserver); } @@ -278,21 +261,21 @@ protected PublisherServiceBlockingStub build(io.grpc.Channel channel, /** */ - public Response publish(Message request) { + public org.apache.eventmesh.common.protocol.grpc.protos.Response publish(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { return blockingUnaryCall( getChannel(), getPublishMethod(), getCallOptions(), request); } /** */ - public Response requestReply(Message request) { + public org.apache.eventmesh.common.protocol.grpc.protos.Response requestReply(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { return blockingUnaryCall( getChannel(), getRequestReplyMethod(), getCallOptions(), request); } /** */ - public Response broadcast(Message request) { + public org.apache.eventmesh.common.protocol.grpc.protos.Response broadcast(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { return blockingUnaryCall( getChannel(), getBroadcastMethod(), getCallOptions(), request); } @@ -318,24 +301,24 @@ protected PublisherServiceFutureStub build(io.grpc.Channel channel, /** */ - public com.google.common.util.concurrent.ListenableFuture publish( - Message request) { + public com.google.common.util.concurrent.ListenableFuture publish( + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { return futureUnaryCall( getChannel().newCall(getPublishMethod(), getCallOptions()), request); } /** */ - public com.google.common.util.concurrent.ListenableFuture requestReply( - Message request) { + public com.google.common.util.concurrent.ListenableFuture requestReply( + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { return futureUnaryCall( getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request); } /** */ - public com.google.common.util.concurrent.ListenableFuture broadcast( - Message request) { + public com.google.common.util.concurrent.ListenableFuture broadcast( + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { return futureUnaryCall( getChannel().newCall(getBroadcastMethod(), getCallOptions()), request); } @@ -363,16 +346,16 @@ private static final class MethodHandlers implements public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { switch (methodId) { case METHODID_PUBLISH: - serviceImpl.publish((Message) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.publish((org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); break; case METHODID_REQUEST_REPLY: - serviceImpl.requestReply((Message) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.requestReply((org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); break; case METHODID_BROADCAST: - serviceImpl.broadcast((Message) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.broadcast((org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); break; default: throw new AssertionError(); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java index 6a0c2ed007..d53cbcbfef 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto @@ -41,9 +24,10 @@ private RequestHeader() { sys_ = ""; username_ = ""; password_ = ""; - version_ = ""; language_ = ""; - seqNum_ = ""; + protocolType_ = ""; + protocolVersion_ = ""; + protocolDesc_ = ""; } @Override @@ -128,19 +112,25 @@ private RequestHeader( case 74: { String s = input.readStringRequireUtf8(); - version_ = s; + language_ = s; break; } case 82: { String s = input.readStringRequireUtf8(); - language_ = s; + protocolType_ = s; break; } case 90: { String s = input.readStringRequireUtf8(); - seqNum_ = s; + protocolVersion_ = s; + break; + } + case 98: { + String s = input.readStringRequireUtf8(); + + protocolDesc_ = s; break; } } @@ -439,102 +429,136 @@ public String getPassword() { } } - public static final int VERSION_FIELD_NUMBER = 9; - private volatile Object version_; + public static final int LANGUAGE_FIELD_NUMBER = 9; + private volatile Object language_; /** - * string version = 9; + * string language = 9; */ - public String getVersion() { - Object ref = version_; + public String getLanguage() { + Object ref = language_; if (ref instanceof String) { return (String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; String s = bs.toStringUtf8(); - version_ = s; + language_ = s; return s; } } /** - * string version = 9; + * string language = 9; */ public com.google.protobuf.ByteString - getVersionBytes() { - Object ref = version_; + getLanguageBytes() { + Object ref = language_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (String) ref); - version_ = b; + language_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } - public static final int LANGUAGE_FIELD_NUMBER = 10; - private volatile Object language_; + public static final int PROTOCOLTYPE_FIELD_NUMBER = 10; + private volatile Object protocolType_; /** - * string language = 10; + * string protocolType = 10; */ - public String getLanguage() { - Object ref = language_; + public String getProtocolType() { + Object ref = protocolType_; if (ref instanceof String) { return (String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; String s = bs.toStringUtf8(); - language_ = s; + protocolType_ = s; return s; } } /** - * string language = 10; + * string protocolType = 10; */ public com.google.protobuf.ByteString - getLanguageBytes() { - Object ref = language_; + getProtocolTypeBytes() { + Object ref = protocolType_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (String) ref); - language_ = b; + protocolType_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } - public static final int SEQNUM_FIELD_NUMBER = 11; - private volatile Object seqNum_; + public static final int PROTOCOLVERSION_FIELD_NUMBER = 11; + private volatile Object protocolVersion_; /** - * string seqNum = 11; + * string protocolVersion = 11; */ - public String getSeqNum() { - Object ref = seqNum_; + public String getProtocolVersion() { + Object ref = protocolVersion_; if (ref instanceof String) { return (String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; String s = bs.toStringUtf8(); - seqNum_ = s; + protocolVersion_ = s; return s; } } /** - * string seqNum = 11; + * string protocolVersion = 11; */ public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; + getProtocolVersionBytes() { + Object ref = protocolVersion_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (String) ref); - seqNum_ = b; + protocolVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROTOCOLDESC_FIELD_NUMBER = 12; + private volatile Object protocolDesc_; + /** + * string protocolDesc = 12; + */ + public String getProtocolDesc() { + Object ref = protocolDesc_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + protocolDesc_ = s; + return s; + } + } + /** + * string protocolDesc = 12; + */ + public com.google.protobuf.ByteString + getProtocolDescBytes() { + Object ref = protocolDesc_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + protocolDesc_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; @@ -577,14 +601,17 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!getPasswordBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 8, password_); } - if (!getVersionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 9, version_); - } if (!getLanguageBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 10, language_); + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, language_); + } + if (!getProtocolTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, protocolType_); } - if (!getSeqNumBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 11, seqNum_); + if (!getProtocolVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 11, protocolVersion_); + } + if (!getProtocolDescBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 12, protocolDesc_); } unknownFields.writeTo(output); } @@ -618,14 +645,17 @@ public int getSerializedSize() { if (!getPasswordBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, password_); } - if (!getVersionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, version_); - } if (!getLanguageBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, language_); + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, language_); + } + if (!getProtocolTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, protocolType_); + } + if (!getProtocolVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, protocolVersion_); } - if (!getSeqNumBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, seqNum_); + if (!getProtocolDescBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(12, protocolDesc_); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -659,12 +689,14 @@ public boolean equals(final Object obj) { .equals(other.getUsername()); result = result && getPassword() .equals(other.getPassword()); - result = result && getVersion() - .equals(other.getVersion()); result = result && getLanguage() .equals(other.getLanguage()); - result = result && getSeqNum() - .equals(other.getSeqNum()); + result = result && getProtocolType() + .equals(other.getProtocolType()); + result = result && getProtocolVersion() + .equals(other.getProtocolVersion()); + result = result && getProtocolDesc() + .equals(other.getProtocolDesc()); result = result && unknownFields.equals(other.unknownFields); return result; } @@ -692,12 +724,14 @@ public int hashCode() { hash = (53 * hash) + getUsername().hashCode(); hash = (37 * hash) + PASSWORD_FIELD_NUMBER; hash = (53 * hash) + getPassword().hashCode(); - hash = (37 * hash) + VERSION_FIELD_NUMBER; - hash = (53 * hash) + getVersion().hashCode(); hash = (37 * hash) + LANGUAGE_FIELD_NUMBER; hash = (53 * hash) + getLanguage().hashCode(); - hash = (37 * hash) + SEQNUM_FIELD_NUMBER; - hash = (53 * hash) + getSeqNum().hashCode(); + hash = (37 * hash) + PROTOCOLTYPE_FIELD_NUMBER; + hash = (53 * hash) + getProtocolType().hashCode(); + hash = (37 * hash) + PROTOCOLVERSION_FIELD_NUMBER; + hash = (53 * hash) + getProtocolVersion().hashCode(); + hash = (37 * hash) + PROTOCOLDESC_FIELD_NUMBER; + hash = (53 * hash) + getProtocolDesc().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -843,11 +877,13 @@ public Builder clear() { password_ = ""; - version_ = ""; - language_ = ""; - seqNum_ = ""; + protocolType_ = ""; + + protocolVersion_ = ""; + + protocolDesc_ = ""; return this; } @@ -879,9 +915,10 @@ public RequestHeader buildPartial() { result.sys_ = sys_; result.username_ = username_; result.password_ = password_; - result.version_ = version_; result.language_ = language_; - result.seqNum_ = seqNum_; + result.protocolType_ = protocolType_; + result.protocolVersion_ = protocolVersion_; + result.protocolDesc_ = protocolDesc_; onBuilt(); return result; } @@ -955,16 +992,20 @@ public Builder mergeFrom(RequestHeader other) { password_ = other.password_; onChanged(); } - if (!other.getVersion().isEmpty()) { - version_ = other.version_; - onChanged(); - } if (!other.getLanguage().isEmpty()) { language_ = other.language_; onChanged(); } - if (!other.getSeqNum().isEmpty()) { - seqNum_ = other.seqNum_; + if (!other.getProtocolType().isEmpty()) { + protocolType_ = other.protocolType_; + onChanged(); + } + if (!other.getProtocolVersion().isEmpty()) { + protocolVersion_ = other.protocolVersion_; + onChanged(); + } + if (!other.getProtocolDesc().isEmpty()) { + protocolDesc_ = other.protocolDesc_; onChanged(); } this.mergeUnknownFields(other.unknownFields); @@ -1546,209 +1587,278 @@ public Builder setPasswordBytes( return this; } - private Object version_ = ""; + private Object language_ = ""; + /** + * string language = 9; + */ + public String getLanguage() { + Object ref = language_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + language_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string language = 9; + */ + public com.google.protobuf.ByteString + getLanguageBytes() { + Object ref = language_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string language = 9; + */ + public Builder setLanguage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + language_ = value; + onChanged(); + return this; + } + /** + * string language = 9; + */ + public Builder clearLanguage() { + + language_ = getDefaultInstance().getLanguage(); + onChanged(); + return this; + } + /** + * string language = 9; + */ + public Builder setLanguageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + language_ = value; + onChanged(); + return this; + } + + private Object protocolType_ = ""; /** - * string version = 9; + * string protocolType = 10; */ - public String getVersion() { - Object ref = version_; + public String getProtocolType() { + Object ref = protocolType_; if (!(ref instanceof String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; String s = bs.toStringUtf8(); - version_ = s; + protocolType_ = s; return s; } else { return (String) ref; } } /** - * string version = 9; + * string protocolType = 10; */ public com.google.protobuf.ByteString - getVersionBytes() { - Object ref = version_; + getProtocolTypeBytes() { + Object ref = protocolType_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (String) ref); - version_ = b; + protocolType_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string version = 9; + * string protocolType = 10; */ - public Builder setVersion( + public Builder setProtocolType( String value) { if (value == null) { throw new NullPointerException(); } - version_ = value; + protocolType_ = value; onChanged(); return this; } /** - * string version = 9; + * string protocolType = 10; */ - public Builder clearVersion() { + public Builder clearProtocolType() { - version_ = getDefaultInstance().getVersion(); + protocolType_ = getDefaultInstance().getProtocolType(); onChanged(); return this; } /** - * string version = 9; + * string protocolType = 10; */ - public Builder setVersionBytes( + public Builder setProtocolTypeBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - version_ = value; + protocolType_ = value; onChanged(); return this; } - private Object language_ = ""; + private Object protocolVersion_ = ""; /** - * string language = 10; + * string protocolVersion = 11; */ - public String getLanguage() { - Object ref = language_; + public String getProtocolVersion() { + Object ref = protocolVersion_; if (!(ref instanceof String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; String s = bs.toStringUtf8(); - language_ = s; + protocolVersion_ = s; return s; } else { return (String) ref; } } /** - * string language = 10; + * string protocolVersion = 11; */ public com.google.protobuf.ByteString - getLanguageBytes() { - Object ref = language_; + getProtocolVersionBytes() { + Object ref = protocolVersion_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (String) ref); - language_ = b; + protocolVersion_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string language = 10; + * string protocolVersion = 11; */ - public Builder setLanguage( + public Builder setProtocolVersion( String value) { if (value == null) { throw new NullPointerException(); } - language_ = value; + protocolVersion_ = value; onChanged(); return this; } /** - * string language = 10; + * string protocolVersion = 11; */ - public Builder clearLanguage() { + public Builder clearProtocolVersion() { - language_ = getDefaultInstance().getLanguage(); + protocolVersion_ = getDefaultInstance().getProtocolVersion(); onChanged(); return this; } /** - * string language = 10; + * string protocolVersion = 11; */ - public Builder setLanguageBytes( + public Builder setProtocolVersionBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - language_ = value; + protocolVersion_ = value; onChanged(); return this; } - private Object seqNum_ = ""; + private Object protocolDesc_ = ""; /** - * string seqNum = 11; + * string protocolDesc = 12; */ - public String getSeqNum() { - Object ref = seqNum_; + public String getProtocolDesc() { + Object ref = protocolDesc_; if (!(ref instanceof String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; String s = bs.toStringUtf8(); - seqNum_ = s; + protocolDesc_ = s; return s; } else { return (String) ref; } } /** - * string seqNum = 11; + * string protocolDesc = 12; */ public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; + getProtocolDescBytes() { + Object ref = protocolDesc_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (String) ref); - seqNum_ = b; + protocolDesc_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string seqNum = 11; + * string protocolDesc = 12; */ - public Builder setSeqNum( + public Builder setProtocolDesc( String value) { if (value == null) { throw new NullPointerException(); } - seqNum_ = value; + protocolDesc_ = value; onChanged(); return this; } /** - * string seqNum = 11; + * string protocolDesc = 12; */ - public Builder clearSeqNum() { + public Builder clearProtocolDesc() { - seqNum_ = getDefaultInstance().getSeqNum(); + protocolDesc_ = getDefaultInstance().getProtocolDesc(); onChanged(); return this; } /** - * string seqNum = 11; + * string protocolDesc = 12; */ - public Builder setSeqNumBytes( + public Builder setProtocolDescBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - seqNum_ = value; + protocolDesc_ = value; onChanged(); return this; } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java index 3f8d4eabbd..ab28df49f2 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto @@ -105,32 +88,42 @@ public interface RequestHeaderOrBuilder extends getPasswordBytes(); /** - * string version = 9; + * string language = 9; */ - String getVersion(); + String getLanguage(); /** - * string version = 9; + * string language = 9; */ com.google.protobuf.ByteString - getVersionBytes(); + getLanguageBytes(); /** - * string language = 10; + * string protocolType = 10; */ - String getLanguage(); + String getProtocolType(); /** - * string language = 10; + * string protocolType = 10; */ com.google.protobuf.ByteString - getLanguageBytes(); + getProtocolTypeBytes(); + + /** + * string protocolVersion = 11; + */ + String getProtocolVersion(); + /** + * string protocolVersion = 11; + */ + com.google.protobuf.ByteString + getProtocolVersionBytes(); /** - * string seqNum = 11; + * string protocolDesc = 12; */ - String getSeqNum(); + String getProtocolDesc(); /** - * string seqNum = 11; + * string protocolDesc = 12; */ com.google.protobuf.ByteString - getSeqNumBytes(); + getProtocolDescBytes(); } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java index 9c087d2a12..008b0a1210 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java index 4c3abd6326..701507deb9 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java index cd2f799e22..e23864a901 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java index 713ae21717..f2fa8f5b57 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto index 9ecaaa661b..97dc39a434 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto @@ -32,18 +32,21 @@ message RequestHeader { string sys = 6; string username = 7; string password = 8; - string version = 9; - string language = 10; - string seqNum = 11; + string language = 9; + string protocolType = 10; + string protocolVersion = 11; + string protocolDesc = 12; } -message Message { +message EventMeshMessage { RequestHeader header = 1; string producerGroup = 2; string topic = 3; string content = 4; string ttl = 5; string uniqueId = 6; + string seqNum = 7; + string tag = 8; } message Response { @@ -82,17 +85,17 @@ message Heartbeat { } service PublisherService { - rpc publish(Message) returns (Response); + rpc publish(EventMeshMessage) returns (Response); - rpc requestReply(Message) returns (Response); + rpc requestReply(EventMeshMessage) returns (Response); - rpc broadcast(Message) returns (Response); + rpc broadcast(EventMeshMessage) returns (Response); } service ConsumerService { rpc subscribe(Subscription) returns (Response); - rpc subscribeStream(Subscription) returns (stream Message); + rpc subscribeStream(Subscription) returns (stream EventMeshMessage); rpc unsubscribe(Subscription) returns (Response); } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle index 2b0455c35b..9ea07e10f6 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/build.gradle @@ -18,6 +18,7 @@ dependencies { implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") implementation "io.cloudevents:cloudevents-core" + implementation "io.grpc:grpc-protobuf:1.15.0" testImplementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api") testImplementation "io.cloudevents:cloudevents-core" diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java index f1be1af82e..e94508a1ff 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java @@ -19,6 +19,7 @@ import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.Body; import org.apache.eventmesh.common.protocol.http.common.RequestCode; @@ -28,6 +29,7 @@ import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.protocol.api.ProtocolAdaptor; import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; +import org.apache.eventmesh.protocol.meshmessage.resolver.grpc.GrpcMessageProtocolResolver; import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageBatchProtocolResolver; import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageBatchV2ProtocolResolver; import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageRequestProtocolResolver; @@ -59,11 +61,19 @@ public CloudEvent toCloudEvent(ProtocolTransportObject protocol) throws Protocol String requestCode = ((HttpCommand) protocol).getRequestCode(); return deserializeHttpProtocol(requestCode, header, body); + } else if (protocol instanceof EventMeshMessageWrapper) { + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage message = ((EventMeshMessageWrapper)protocol).getMessage(); + return deserializeGrpcProtocol(message); } else { throw new ProtocolHandleException(String.format("protocol class: %s", protocol.getClass())); } } + private CloudEvent deserializeGrpcProtocol(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage message) + throws ProtocolHandleException { + return GrpcMessageProtocolResolver.buildEvent(message); + } + private CloudEvent deserializeTcpProtocol(Header header, String bodyJson) throws ProtocolHandleException { return TcpMessageProtocolResolver.buildEvent(header, JsonUtils.deserialize(bodyJson, EventMeshMessage.class)); } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java new file mode 100644 index 0000000000..f7fccb1680 --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java @@ -0,0 +1,97 @@ +package org.apache.eventmesh.protocol.meshmessage.resolver.grpc; + +import io.cloudevents.CloudEvent; +import io.cloudevents.SpecVersion; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.grpc.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; + +import java.net.URI; +import java.nio.charset.StandardCharsets; + +public class GrpcMessageProtocolResolver { + + public static CloudEvent buildEvent(EventMeshMessage message) throws ProtocolHandleException { + try { + RequestHeader requestHeader = message.getHeader(); + + String protocolType = requestHeader.getProtocolType(); + String protocolDesc = requestHeader.getProtocolDesc(); + String protocolVersion = requestHeader.getProtocolVersion(); + + String env = requestHeader.getEnv(); + String idc = requestHeader.getIdc(); + String ip = requestHeader.getIp(); + String pid = requestHeader.getPid(); + String sys = requestHeader.getSys(); + String username = requestHeader.getUsername(); + String passwd = requestHeader.getPassword(); + String language = requestHeader.getLanguage(); + + String content = message.getContent(); + + CloudEvent event = null; + CloudEventBuilder cloudEventBuilder; + if (StringUtils.equals(SpecVersion.V1.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v1(); + + cloudEventBuilder = cloudEventBuilder.withId(message.getSeqNum()) + .withSubject(message.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.ENV, env) + .withExtension(ProtocolKey.IDC, idc) + .withExtension(ProtocolKey.IP, ip) + .withExtension(ProtocolKey.PID, pid) + .withExtension(ProtocolKey.SYS, sys) + .withExtension(ProtocolKey.USERNAME, username) + .withExtension(ProtocolKey.PASSWD, passwd) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(ProtocolKey.SEQ_NUM, message.getSeqNum()) + .withExtension(ProtocolKey.UNIQUE_ID, message.getUniqueId()) + .withExtension(ProtocolKey.PRODUCERGROUP, message.getProducerGroup()) + .withExtension(ProtocolKey.TTL, message.getTtl()); + if (StringUtils.isNotEmpty(message.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(ProtocolKey.TAG, message.getTag()); + } + event = cloudEventBuilder.build(); + } else if (StringUtils.equals(SpecVersion.V03.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v03(); + cloudEventBuilder = cloudEventBuilder.withId(message.getSeqNum()) + .withSubject(message.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.ENV, env) + .withExtension(ProtocolKey.IDC, idc) + .withExtension(ProtocolKey.IP, ip) + .withExtension(ProtocolKey.PID, pid) + .withExtension(ProtocolKey.SYS, sys) + .withExtension(ProtocolKey.USERNAME, username) + .withExtension(ProtocolKey.PASSWD, passwd) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(ProtocolKey.SEQ_NUM, message.getSeqNum()) + .withExtension(ProtocolKey.UNIQUE_ID, message.getUniqueId()) + .withExtension(ProtocolKey.PRODUCERGROUP, message.getProducerGroup()) + .withExtension(ProtocolKey.TTL, message.getTtl()); + if (StringUtils.isNotEmpty(message.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(ProtocolKey.TAG, message.getTag()); + } + event = cloudEventBuilder.build(); + } + return event; + } catch (Exception e) { + throw new ProtocolHandleException(e.getMessage(), e.getCause()); + } + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java index ff034ffe42..fbeeb24f4e 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java @@ -35,15 +35,17 @@ public void init() throws Exception { initThreadPool(); + int serverPort = eventMeshGrpcConfiguration.grpcServerPort; + producerManager = new ProducerManager(this); producerManager.init(); - server = ServerBuilder.forPort(5005) + server = ServerBuilder.forPort(serverPort) .intercept(new MetricsInterceptor()) .addService(new ProducerService(this, sendMsgExecutor)) .build(); - logger.info("GRPCServer[port=5005] started"); + logger.info("GRPCServer[port={}] started", serverPort); logger.info("-----------------EventMeshGRPCServer initialized"); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java index 077275a25b..9c11649ed8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java @@ -17,14 +17,19 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.processor; +import io.cloudevents.CloudEvent; import io.grpc.stub.StreamObserver; import org.apache.eventmesh.api.SendCallback; import org.apache.eventmesh.api.SendResult; import org.apache.eventmesh.api.exception.OnExceptionContext; -import org.apache.eventmesh.common.protocol.grpc.protos.Message; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; -import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; @@ -40,37 +45,39 @@ public SendAsyncMessageProcessor(EventMeshGrpcServer eventMeshGrpcServer) { this.eventMeshGrpcServer = eventMeshGrpcServer; } - public void process(Object request, StreamObserver responseObserver) throws Exception { - Message message = (Message) request; + public void process(EventMeshMessage message, StreamObserver responseObserver) throws Exception { RequestHeader requestHeader = message.getHeader(); if (!ServiceUtils.validateHeader(requestHeader)) { - ServiceUtils.sendResp(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); return; } if (!ServiceUtils.validateMessage(message)) { - ServiceUtils.sendResp(EventMeshRetCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); return; } + String protocolType = requestHeader.getProtocolType(); + ProtocolAdaptor grpcCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + CloudEvent cloudEvent = grpcCommandProtocolAdaptor.toCloudEvent(new EventMeshMessageWrapper(message)); + String producerGroup = message.getProducerGroup(); ProducerManager producerManager = eventMeshGrpcServer.getProducerManager(); EventMeshProducer eventMeshProducer = producerManager.getEventMeshProducer(producerGroup); - SendMessageContext sendMessageContext = new SendMessageContext(requestHeader.getSeqNum(), null, - eventMeshProducer, eventMeshGrpcServer); + SendMessageContext sendMessageContext = new SendMessageContext(message.getSeqNum(), cloudEvent, eventMeshProducer, eventMeshGrpcServer); eventMeshProducer.send(sendMessageContext, new SendCallback() { @Override public void onSuccess(SendResult sendResult) { - ServiceUtils.sendResp(EventMeshRetCode.SUCCESS, sendResult.toString(), responseObserver); + ServiceUtils.sendResp(StatusCode.SUCCESS, sendResult.toString(), responseObserver); } @Override public void onException(OnExceptionContext context) { - ServiceUtils.sendResp(EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR, + ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, EventMeshUtil.stackTrace(context.getException(), 2), responseObserver); } }); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java index 88bbe680cb..edd2d17e74 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java @@ -1,14 +1,13 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.service; import io.grpc.stub.StreamObserver; -import org.apache.eventmesh.common.protocol.grpc.protos.Message; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; -import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SendAsyncMessageProcessor; -import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,15 +27,16 @@ public ProducerService(EventMeshGrpcServer eventMeshGrpcServer, this.threadPoolExecutor = threadPoolExecutor; } - public void publish(Message request, StreamObserver responseObserver) { + public void publish(EventMeshMessage request, StreamObserver responseObserver) { threadPoolExecutor.submit(() -> { SendAsyncMessageProcessor sendAsyncMessageProcessor = new SendAsyncMessageProcessor(eventMeshGrpcServer); try { sendAsyncMessageProcessor.process(request, responseObserver); } catch (Exception e) { logger.error("Error code {}, error message {}", EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getRetCode(), - EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getErrMsg(), e); - ServiceUtils.sendResp(EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR, e.getMessage(), responseObserver); + StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getErrMsg(), e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, e.getMessage(), + responseObserver); } }); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java index c560034903..0cf9a89bac 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -2,10 +2,10 @@ import io.grpc.stub.StreamObserver; import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.protocol.grpc.protos.Message; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; -import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; public class ServiceUtils { @@ -19,7 +19,7 @@ static public boolean validateHeader(RequestHeader header) { return true; } - static public boolean validateMessage(Message message) { + static public boolean validateMessage(EventMeshMessage message) { if (StringUtils.isBlank(message.getUniqueId()) || StringUtils.isBlank(message.getProducerGroup()) || StringUtils.isBlank(message.getTopic()) @@ -30,17 +30,17 @@ static public boolean validateMessage(Message message) { return true; } - static public void sendResp(EventMeshRetCode code, StreamObserver responseObserver) { + static public void sendResp(StatusCode code, StreamObserver responseObserver) { Response response = Response.newBuilder() - .setRespCode(code.getRetCode().toString()) + .setRespCode(code.getRetCode()) .setRespMsg(code.getErrMsg()).build(); responseObserver.onNext(response); responseObserver.onCompleted(); } - static public void sendResp(EventMeshRetCode code, String message, StreamObserver responseObserver) { + static public void sendResp(StatusCode code, String message, StreamObserver responseObserver) { Response response = Response.newBuilder() - .setRespCode(code.getRetCode().toString()) + .setRespCode(code.getRetCode()) .setRespMsg(code.getErrMsg() + " " + message).build(); responseObserver.onNext(response); responseObserver.onCompleted(); diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java new file mode 100644 index 0000000000..44c3a9cea3 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java @@ -0,0 +1,69 @@ +package org.apache.eventmesh.client.grpc; + +import io.cloudevents.SpecVersion; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EventMeshGrpcProducer implements AutoCloseable { + + private static Logger logger = LoggerFactory.getLogger(EventMeshGrpcProducer.class); + + private final static String PROTOCOL_TYPE = "eventmeshmessage"; + private final static String PROTOCOL_DESC = "grpc"; + + private EventMeshGrpcClientConfig clientConfig; + + private ManagedChannel channel; + + public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) { + this.clientConfig = clientConfig; + } + + public void init() { + channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) + .usePlaintext().build(); + } + + public Response publish(EventMeshMessage message) { + logger.info("Publish message " + message.toString()); + PublisherServiceGrpc.PublisherServiceBlockingStub publisherClient = PublisherServiceGrpc.newBlockingStub(channel); + EventMeshMessage newMessage = enhanceMessage(message); + Response response = publisherClient.publish(newMessage); + logger.info("Received response " + response.toString()); + return response; + } + + public void close() { + channel.shutdown(); + } + + private EventMeshMessage enhanceMessage(EventMeshMessage message) { + RequestHeader header = RequestHeader.newBuilder() + .setEnv(clientConfig.getEnv()) + .setIdc(clientConfig.getIdc()) + .setIp(clientConfig.getIp()) + .setPid(clientConfig.getPid()) + .setSys(clientConfig.getSys()) + .setLanguage(clientConfig.getLanguage()) + .setUsername(clientConfig.getUserName()) + .setPassword(clientConfig.getPassword()) + .setProtocolType(PROTOCOL_TYPE) + .setProtocolDesc(PROTOCOL_DESC) + // default CloudEvents version is V1 + .setProtocolVersion(SpecVersion.V1.toString()) + .build(); + + EventMeshMessage newMessage = EventMeshMessage.newBuilder(message) + .setHeader(header) + .setProducerGroup(clientConfig.getProducerGroup()) + .build(); + return newMessage; + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/Producer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/Producer.java deleted file mode 100644 index a15801528e..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/Producer.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.eventmesh.client.grpc; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import org.apache.eventmesh.client.grpc.config.ClientConfig; -import org.apache.eventmesh.common.protocol.grpc.protos.Message; -import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; -import org.apache.eventmesh.common.protocol.grpc.protos.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Producer { - - private static Logger logger = LoggerFactory.getLogger(Producer.class); - - private ClientConfig clientConfig; - - private ManagedChannel channel; - - public Producer(ClientConfig clientConfig) { - this.clientConfig = clientConfig; - } - - public void start() { - channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) - .usePlaintext().build(); - } - - public boolean publish(String content) { - PublisherServiceGrpc.PublisherServiceBlockingStub publisherClient = PublisherServiceGrpc.newBlockingStub(channel); - - Message message = Message.newBuilder().setContent(content).build(); - - Response response = publisherClient.publish(message); - logger.info("===========" + response.getRespCode() + " " + response.getRespMsg()); - return true; - } - - public void stop() { - channel.shutdown(); - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/ClientConfig.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/ClientConfig.java deleted file mode 100644 index 4703630d69..0000000000 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/ClientConfig.java +++ /dev/null @@ -1,172 +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.eventmesh.client.grpc.config; - -public class ClientConfig { - - private String serverAddr = ""; - - private int serverPort = 0; - - private String env; - - private String consumerGroup = "DefaultConsumerGroup"; - - private String producerGroup = "DefaultProducerGroup"; - - private String idc; - - private String ip = "127.0.0.1"; - - private String pid; - - private String sys; - - private String userName; - - private String password; - - private boolean useTls = false; - - public ClientConfig setServerAddr(String serverAddr) { - this.serverAddr = serverAddr; - return this; - } - - public String getServerAddr() { - return this.serverAddr; - } - - public ClientConfig setServerPort(int serverPort) { - this.serverPort = serverPort; - return this; - } - - public int getServerPort() { - return this.serverPort; - } - - public String getEnv() { - return env; - } - - public ClientConfig setEnv(String env) { - this.env = env; - return this; - } - - public String getIdc() { - return idc; - } - - public ClientConfig setIdc(String idc) { - this.idc = idc; - return this; - } - - public String getIp() { - return ip; - } - - public ClientConfig setIp(String ip) { - this.ip = ip; - return this; - } - - public String getPid() { - return pid; - } - - public ClientConfig setPid(String pid) { - this.pid = pid; - return this; - } - - public String getSys() { - return sys; - } - - public ClientConfig setSys(String sys) { - this.sys = sys; - return this; - } - - public String getUserName() { - return userName; - } - - public ClientConfig setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getPassword() { - return password; - } - - public ClientConfig setPassword(String password) { - this.password = password; - return this; - } - - public boolean isUseTls() { - return useTls; - } - - public ClientConfig setUseTls(boolean useTls) { - this.useTls = useTls; - return this; - } - - public String getConsumerGroup() { - return consumerGroup; - } - - public ClientConfig setConsumerGroup(String consumerGroup) { - this.consumerGroup = consumerGroup; - return this; - } - - public String getProducerGroup() { - return producerGroup; - } - - public ClientConfig setProducerGroup(String producerGroup) { - this.producerGroup = producerGroup; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ClientConfig={") - .append("ServerAddr=").append(serverAddr).append(",") - .append("ServerPort=").append(serverPort).append(",") - .append("env=").append(env).append(",") - .append("idc=").append(idc).append(",") - .append("producerGroup=").append(producerGroup).append(",") - .append("consumerGroup=").append(consumerGroup).append(",") - .append("ip=").append(ip).append(",") - .append("pid=").append(pid).append(",") - .append("sys=").append(sys).append(",") - .append("userName=").append(userName).append(",") - .append("password=").append("***").append(",") - .append("useTls=").append(useTls).append("}"); - return sb.toString(); - } -} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java new file mode 100644 index 0000000000..cadbd830b8 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java @@ -0,0 +1,84 @@ +/* + * 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.eventmesh.client.grpc.config; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class EventMeshGrpcClientConfig { + + @Builder.Default + private String serverAddr = ""; + + @Builder.Default + private int serverPort = 10205; + + @Builder.Default + private String env = ""; + + @Builder.Default + private String consumerGroup = "DefaultConsumerGroup"; + + @Builder.Default + private String producerGroup = "DefaultProducerGroup"; + + @Builder.Default + private String idc = ""; + + @Builder.Default + private String ip = "127.0.0.1"; + + @Builder.Default + private String pid ="0"; + + @Builder.Default + private String sys = "sys123"; + + @Builder.Default + private String userName = ""; + + @Builder.Default + private String password = ""; + + @Builder.Default + private String language = "JAVA"; + + @Builder.Default + private boolean useTls = false; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("ClientConfig={") + .append("ServerAddr=").append(serverAddr).append(",") + .append("ServerPort=").append(serverPort).append(",") + .append("env=").append(env).append(",") + .append("idc=").append(idc).append(",") + .append("producerGroup=").append(producerGroup).append(",") + .append("consumerGroup=").append(consumerGroup).append(",") + .append("ip=").append(ip).append(",") + .append("pid=").append(pid).append(",") + .append("sys=").append(sys).append(",") + .append("userName=").append(userName).append(",") + .append("password=").append("***").append(",") + .append("useTls=").append(useTls).append("}"); + return sb.toString(); + } +} diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/grpc/AsyncPublishInstance.java b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/grpc/AsyncPublishInstance.java new file mode 100644 index 0000000000..107383446a --- /dev/null +++ b/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/grpc/AsyncPublishInstance.java @@ -0,0 +1,65 @@ +/* + * 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.eventmesh.client.grpc; + +import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; + +@Slf4j +public class AsyncPublishInstance { + + public static void main(String[] args) throws Exception { + + final String topic = "FT0-e-80010001-01-1"; + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr("127.0.0.1") + .serverPort(10205) + .producerGroup("EventMeshTest-producerGroup") + .env("env") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())).build(); + + EventMeshGrpcProducer eventMeshGrpcProducer = new EventMeshGrpcProducer(eventMeshClientConfig); + + eventMeshGrpcProducer.init(); + + for (int i = 0; i < 1; i++) { + EventMeshMessage message = EventMeshMessage.newBuilder() + .setContent("testPublishMessage") + .setTopic(topic) + .setUniqueId(RandomStringUtils.generateNum(30)) + .setSeqNum(RandomStringUtils.generateNum(30)) + .setTtl(String.valueOf(4 * 1000)) + .build(); + + eventMeshGrpcProducer.publish(message); + Thread.sleep(1000); + } + Thread.sleep(30000); + try (EventMeshGrpcProducer ignore = eventMeshGrpcProducer) { + // ignore + } + } +} diff --git a/settings.gradle b/settings.gradle index 946abdf6ae..c96b4be21a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -37,4 +37,6 @@ include 'eventmesh-protocol-plugin:eventmesh-protocol-cloudevents' include 'eventmesh-protocol-plugin:eventmesh-protocol-meshmessage' include 'eventmesh-admin:eventmesh-admin-rocketmq' include 'eventmesh-protocol-plugin:eventmesh-protocol-grpc' +include 'eventmesh-protocol-plugin:eventmesh-protocol-grpcmessage' +findProject(':eventmesh-protocol-plugin:eventmesh-protocol-grpcmessage')?.name = 'eventmesh-protocol-grpcmessage' From 160b9a4db337efcb4e7a43aa1973eb13e3f8b920 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Tue, 14 Dec 2021 11:30:51 -0500 Subject: [PATCH 04/21] [Issue #417] grpc publish API --- .../grpc/common/EventMeshMessageWrapper.java | 17 +++++++++++++++++ .../protocol/grpc/common/ProtocolKey.java | 17 +++++++++++++++++ .../grpc/protos/ConsumerServiceGrpc.java | 17 +++++++++++++++++ .../protocol/grpc/protos/EventMeshMessage.java | 17 +++++++++++++++++ .../grpc/protos/EventMeshMessageOrBuilder.java | 17 +++++++++++++++++ .../protocol/grpc/protos/EventmeshGrpc.java | 17 +++++++++++++++++ .../common/protocol/grpc/protos/Heartbeat.java | 17 +++++++++++++++++ .../grpc/protos/HeartbeatOrBuilder.java | 17 +++++++++++++++++ .../grpc/protos/HeartbeatServiceGrpc.java | 17 +++++++++++++++++ .../grpc/protos/PublisherServiceGrpc.java | 17 +++++++++++++++++ .../protocol/grpc/protos/RequestHeader.java | 17 +++++++++++++++++ .../grpc/protos/RequestHeaderOrBuilder.java | 17 +++++++++++++++++ .../common/protocol/grpc/protos/Response.java | 17 +++++++++++++++++ .../protocol/grpc/protos/ResponseOrBuilder.java | 17 +++++++++++++++++ .../protocol/grpc/protos/Subscription.java | 17 +++++++++++++++++ .../grpc/protos/SubscriptionOrBuilder.java | 17 +++++++++++++++++ .../runtime/constants/EventMeshConstants.java | 2 ++ .../grpc/interceptor/MetricsInterceptor.java | 10 +++++++--- .../processor/SendAsyncMessageProcessor.java | 14 ++++++++++++++ 19 files changed, 295 insertions(+), 3 deletions(-) diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java index e19214f13b..07bd66f968 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java @@ -1,3 +1,20 @@ +/* + * 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.eventmesh.common.protocol.grpc.common; import org.apache.eventmesh.common.protocol.ProtocolTransportObject; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java index d8d41a67eb..62d171bc76 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java @@ -1,3 +1,20 @@ +/* + * 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.eventmesh.common.protocol.grpc.common; public class ProtocolKey { diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java index 579e516bb2..594715f395 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java @@ -1,3 +1,20 @@ +/* + * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java index c36fa52ee7..f41c536f38 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java index 505bbdd1cc..84dad94fb4 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java index cf21626684..a54d2e1bf7 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java index ca1b1b1307..f616a65790 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java index ac25165c77..7bbe0aba1c 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java index 8736ffbac3..3516afd9af 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java @@ -1,3 +1,20 @@ +/* + * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java index 853d47cac2..794a721487 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java @@ -1,3 +1,20 @@ +/* + * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java index d53cbcbfef..4fe0c49c5b 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java index ab28df49f2..2041119264 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java index 008b0a1210..9c087d2a12 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java index 701507deb9..4c3abd6326 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java index e23864a901..cd2f799e22 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java index f2fa8f5b57..713ae21717 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java index 3f85225935..64166a1ce1 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java @@ -29,6 +29,8 @@ public class EventMeshConstants { public static final String PROTOCOL_TCP = "tcp"; + public static final String PROTOCOL_GRPC = "grpc"; + public static final String DEFAULT_CHARSET = "UTF-8"; public static final String IP_PORT_SEPARATOR = ":"; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java index 7e22377d77..5b7df16cd7 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java @@ -1,20 +1,24 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.interceptor; +import io.grpc.Grpc; import io.grpc.Metadata; import io.grpc.ServerCall; import io.grpc.ServerCallHandler; import io.grpc.ServerInterceptor; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MetricsInterceptor implements ServerInterceptor { - private Logger logger = LoggerFactory.getLogger("grpc-services"); + private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); @Override public ServerCall.Listener interceptCall( ServerCall call, Metadata headers, ServerCallHandler next) { - logger.info("Call: {}", call.getMethodDescriptor().getFullMethodName()); + logger.info("cmd={}|{}|client2eventMesh|from={}|to={}", call.getMethodDescriptor().getFullMethodName(), + EventMeshConstants.PROTOCOL_GRPC, call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR),IPUtils.getLocalAddress()); return next.startCall(call, headers); } -} +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java index 9c11649ed8..efc3e9a1bd 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java @@ -36,9 +36,13 @@ import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SendAsyncMessageProcessor { + private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private EventMeshGrpcServer eventMeshGrpcServer; public SendAsyncMessageProcessor(EventMeshGrpcServer eventMeshGrpcServer) { @@ -62,6 +66,9 @@ public void process(EventMeshMessage message, StreamObserver responseO ProtocolAdaptor grpcCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); CloudEvent cloudEvent = grpcCommandProtocolAdaptor.toCloudEvent(new EventMeshMessageWrapper(message)); + String seqNum = message.getSeqNum(); + String uniqueId = message.getUniqueId(); + String topic = message.getTopic(); String producerGroup = message.getProducerGroup(); ProducerManager producerManager = eventMeshGrpcServer.getProducerManager(); @@ -69,16 +76,23 @@ public void process(EventMeshMessage message, StreamObserver responseO SendMessageContext sendMessageContext = new SendMessageContext(message.getSeqNum(), cloudEvent, eventMeshProducer, eventMeshGrpcServer); + long startTime = System.currentTimeMillis(); eventMeshProducer.send(sendMessageContext, new SendCallback() { @Override public void onSuccess(SendResult sendResult) { ServiceUtils.sendResp(StatusCode.SUCCESS, sendResult.toString(), responseObserver); + long endTime = System.currentTimeMillis(); + logger.info("message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", + endTime - startTime, topic, seqNum, uniqueId); } @Override public void onException(OnExceptionContext context) { ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, EventMeshUtil.stackTrace(context.getException(), 2), responseObserver); + long endTime = System.currentTimeMillis(); + logger.error("message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", + endTime - startTime, topic, seqNum, uniqueId, context.getException()); } }); From cf1be5010ea3e1c763716210e97757b12badf5df Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Fri, 17 Dec 2021 09:38:14 -0500 Subject: [PATCH 05/21] grpc consumer work --- .../grpc/protos/ConsumerServiceGrpc.java | 143 ++-- .../grpc/protos/EventMeshMessage.java | 17 - .../protos/EventMeshMessageOrBuilder.java | 17 - .../protocol/grpc/protos/EventmeshGrpc.java | 108 ++- .../protocol/grpc/protos/Heartbeat.java | 247 +++--- .../grpc/protos/HeartbeatOrBuilder.java | 26 +- .../grpc/protos/HeartbeatServiceGrpc.java | 61 +- .../grpc/protos/PublisherServiceGrpc.java | 145 ++-- .../protocol/grpc/protos/RequestHeader.java | 17 - .../grpc/protos/RequestHeaderOrBuilder.java | 17 - .../common/protocol/grpc/protos/Response.java | 17 - .../grpc/protos/ResponseOrBuilder.java | 17 - .../protocol/grpc/protos/Subscription.java | 747 ++++++++++-------- .../grpc/protos/SubscriptionOrBuilder.java | 27 +- .../src/main/proto/eventmesh-client.proto | 23 +- eventmesh-runtime/build.gradle | 3 + .../runtime/boot/EventMeshGrpcServer.java | 69 +- .../EventMeshGrpcConfiguration.java | 8 +- .../grpc/consumer/ConsumerManager.java | 138 ++++ .../grpc/consumer/EventMeshConsumer.java | 195 +++++ .../grpc/consumer/HandleMsgContext.java | 178 +++++ .../grpc/consumer/MessageHandler.java | 22 + .../consumergroup/ConsumerGroupClient.java | 72 ++ .../ConsumerGroupTopicConfig.java | 88 +++ .../grpc/processor/SubscribeProcessor.java | 41 + .../grpc/push/AbstractHttpPushRequest.java | 116 +++ .../grpc/push/AsyncHTTPPushRequest.java | 306 +++++++ .../protocol/grpc/push/HTTPClientPool.java | 57 ++ .../grpc/push/HTTPMessageHandler.java | 85 ++ .../grpc/service/ConsumerService.java | 43 + .../protocol/grpc/service/ServiceUtils.java | 43 +- .../client/grpc/EventMeshGrpcConsumer.java | 38 + 32 files changed, 2267 insertions(+), 864 deletions(-) create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java index 594715f395..12454c8ab5 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java @@ -1,20 +1,3 @@ -/* - * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; @@ -44,30 +27,30 @@ private ConsumerServiceGrpc() {} public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.ConsumerService"; // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getSubscribeMethod; + private static volatile io.grpc.MethodDescriptor getSubscribeMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "subscribe", - requestType = org.apache.eventmesh.common.protocol.grpc.protos.Subscription.class, - responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, + requestType = Subscription.class, + responseType = Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getSubscribeMethod() { - io.grpc.MethodDescriptor getSubscribeMethod; + public static io.grpc.MethodDescriptor getSubscribeMethod() { + io.grpc.MethodDescriptor getSubscribeMethod; if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { synchronized (ConsumerServiceGrpc.class) { if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) { ConsumerServiceGrpc.getSubscribeMethod = getSubscribeMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.ConsumerService", "subscribe")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Subscription.getDefaultInstance())) + Subscription.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) + Response.getDefaultInstance())) .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribe")) .build(); } @@ -76,30 +59,30 @@ org.apache.eventmesh.common.protocol.grpc.protos.Response> getSubscribeMethod() return getSubscribeMethod; } - private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod; + private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "subscribeStream", - requestType = org.apache.eventmesh.common.protocol.grpc.protos.Subscription.class, - responseType = org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.class, + requestType = Subscription.class, + responseType = EventMeshMessage.class, methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) - public static io.grpc.MethodDescriptor getSubscribeStreamMethod() { - io.grpc.MethodDescriptor getSubscribeStreamMethod; + public static io.grpc.MethodDescriptor getSubscribeStreamMethod() { + io.grpc.MethodDescriptor getSubscribeStreamMethod; if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { synchronized (ConsumerServiceGrpc.class) { if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) { ConsumerServiceGrpc.getSubscribeStreamMethod = getSubscribeStreamMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.ConsumerService", "subscribeStream")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Subscription.getDefaultInstance())) + Subscription.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.getDefaultInstance())) + EventMeshMessage.getDefaultInstance())) .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribeStream")) .build(); } @@ -108,30 +91,30 @@ org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage> getSubscribeS return getSubscribeStreamMethod; } - private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod; + private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "unsubscribe", - requestType = org.apache.eventmesh.common.protocol.grpc.protos.Subscription.class, - responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, + requestType = Subscription.class, + responseType = Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getUnsubscribeMethod() { - io.grpc.MethodDescriptor getUnsubscribeMethod; + public static io.grpc.MethodDescriptor getUnsubscribeMethod() { + io.grpc.MethodDescriptor getUnsubscribeMethod; if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { synchronized (ConsumerServiceGrpc.class) { if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) { ConsumerServiceGrpc.getUnsubscribeMethod = getUnsubscribeMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.ConsumerService", "unsubscribe")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Subscription.getDefaultInstance())) + Subscription.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) + Response.getDefaultInstance())) .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("unsubscribe")) .build(); } @@ -169,22 +152,22 @@ public static abstract class ConsumerServiceImplBase implements io.grpc.Bindable /** */ - public void subscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void subscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getSubscribeMethod(), responseObserver); } /** */ - public void subscribeStream(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void subscribeStream(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getSubscribeStreamMethod(), responseObserver); } /** */ - public void unsubscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void unsubscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getUnsubscribeMethod(), responseObserver); } @@ -194,22 +177,22 @@ public void unsubscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscri getSubscribeMethod(), asyncUnaryCall( new MethodHandlers< - org.apache.eventmesh.common.protocol.grpc.protos.Subscription, - org.apache.eventmesh.common.protocol.grpc.protos.Response>( + Subscription, + Response>( this, METHODID_SUBSCRIBE))) .addMethod( getSubscribeStreamMethod(), asyncServerStreamingCall( new MethodHandlers< - org.apache.eventmesh.common.protocol.grpc.protos.Subscription, - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage>( + Subscription, + EventMeshMessage>( this, METHODID_SUBSCRIBE_STREAM))) .addMethod( getUnsubscribeMethod(), asyncUnaryCall( new MethodHandlers< - org.apache.eventmesh.common.protocol.grpc.protos.Subscription, - org.apache.eventmesh.common.protocol.grpc.protos.Response>( + Subscription, + Response>( this, METHODID_UNSUBSCRIBE))) .build(); } @@ -235,24 +218,24 @@ protected ConsumerServiceStub build(io.grpc.Channel channel, /** */ - public void subscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void subscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getSubscribeMethod(), getCallOptions()), request, responseObserver); } /** */ - public void subscribeStream(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void subscribeStream(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncServerStreamingCall( getChannel().newCall(getSubscribeStreamMethod(), getCallOptions()), request, responseObserver); } /** */ - public void unsubscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { + public void unsubscribe(Subscription request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request, responseObserver); } @@ -278,22 +261,22 @@ protected ConsumerServiceBlockingStub build(io.grpc.Channel channel, /** */ - public org.apache.eventmesh.common.protocol.grpc.protos.Response subscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { + public Response subscribe(Subscription request) { return blockingUnaryCall( getChannel(), getSubscribeMethod(), getCallOptions(), request); } /** */ - public java.util.Iterator subscribeStream( - org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { + public java.util.Iterator subscribeStream( + Subscription request) { return blockingServerStreamingCall( getChannel(), getSubscribeStreamMethod(), getCallOptions(), request); } /** */ - public org.apache.eventmesh.common.protocol.grpc.protos.Response unsubscribe(org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { + public Response unsubscribe(Subscription request) { return blockingUnaryCall( getChannel(), getUnsubscribeMethod(), getCallOptions(), request); } @@ -319,16 +302,16 @@ protected ConsumerServiceFutureStub build(io.grpc.Channel channel, /** */ - public com.google.common.util.concurrent.ListenableFuture subscribe( - org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { + public com.google.common.util.concurrent.ListenableFuture subscribe( + Subscription request) { return futureUnaryCall( getChannel().newCall(getSubscribeMethod(), getCallOptions()), request); } /** */ - public com.google.common.util.concurrent.ListenableFuture unsubscribe( - org.apache.eventmesh.common.protocol.grpc.protos.Subscription request) { + public com.google.common.util.concurrent.ListenableFuture unsubscribe( + Subscription request) { return futureUnaryCall( getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request); } @@ -356,16 +339,16 @@ private static final class MethodHandlers implements public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { switch (methodId) { case METHODID_SUBSCRIBE: - serviceImpl.subscribe((org.apache.eventmesh.common.protocol.grpc.protos.Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.subscribe((Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); break; case METHODID_SUBSCRIBE_STREAM: - serviceImpl.subscribeStream((org.apache.eventmesh.common.protocol.grpc.protos.Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.subscribeStream((Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); break; case METHODID_UNSUBSCRIBE: - serviceImpl.unsubscribe((org.apache.eventmesh.common.protocol.grpc.protos.Subscription) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.unsubscribe((Subscription) request, + (io.grpc.stub.StreamObserver) responseObserver); break; default: throw new AssertionError(); @@ -389,7 +372,7 @@ private static abstract class ConsumerServiceBaseDescriptorSupplier @Override public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return org.apache.eventmesh.common.protocol.grpc.protos.EventmeshGrpc.getDescriptor(); + return EventmeshGrpc.getDescriptor(); } @Override diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java index f41c536f38..c36fa52ee7 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java index 84dad94fb4..505bbdd1cc 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java index a54d2e1bf7..2506c9bfbd 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto @@ -81,49 +64,58 @@ public static void registerAllExtensions( "ip\030\004 \001(\t\022\013\n\003pid\030\005 \001(\t\022\013\n\003sys\030\006 \001(\t\022\020\n\010us" + "ername\030\007 \001(\t\022\020\n\010password\030\010 \001(\t\022\020\n\010langua" + "ge\030\t \001(\t\022\024\n\014protocolType\030\n \001(\t\022\027\n\017protoc" + - "olVersion\030\013 \001(\t\022\024\n\014protocolDesc\030\014 \001(\t\"\267\001" + + "olVersion\030\013 \001(\t\022\024\n\014protocolDesc\030\014 \001(\t\"\304\001" + "\n\020EventMeshMessage\022=\n\006header\030\001 \001(\0132-.eve" + "ntmesh.common.protocol.grpc.RequestHeade" + "r\022\025\n\rproducerGroup\030\002 \001(\t\022\r\n\005topic\030\003 \001(\t\022" + "\017\n\007content\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020\n\010uniqueI" + - "d\030\006 \001(\t\022\016\n\006seqNum\030\007 \001(\t\"O\n\010Response\022\020\n\010r" + - "espCode\030\001 \001(\t\022\017\n\007respMsg\030\002 \001(\t\022\020\n\010respTi" + - "me\030\003 \001(\t\022\016\n\006seqNum\030\004 \001(\t\"\212\002\n\014Subscriptio" + - "n\022=\n\006header\030\001 \001(\0132-.eventmesh.common.pro" + - "tocol.grpc.RequestHeader\022\025\n\rconsumerGrou" + - "p\030\002 \001(\t\022X\n\021subscriptionItems\030\003 \003(\0132=.eve" + + "d\030\006 \001(\t\022\016\n\006seqNum\030\007 \001(\t\022\013\n\003tag\030\010 \001(\t\"O\n\010" + + "Response\022\020\n\010respCode\030\001 \001(\t\022\017\n\007respMsg\030\002 " + + "\001(\t\022\020\n\010respTime\030\003 \001(\t\022\016\n\006seqNum\030\004 \001(\t\"\212\004" + + "\n\014Subscription\022=\n\006header\030\001 \001(\0132-.eventme" + + "sh.common.protocol.grpc.RequestHeader\022\025\n" + + "\rconsumerGroup\030\002 \001(\t\022X\n\021subscriptionItem" + + "s\030\003 \003(\0132=.eventmesh.common.protocol.grpc" + + ".Subscription.SubscriptionItem\022\013\n\003url\030\004 " + + "\001(\t\032\274\002\n\020SubscriptionItem\022\r\n\005topic\030\001 \001(\t\022" + + "\\\n\004mode\030\002 \001(\0162N.eventmesh.common.protoco" + + "l.grpc.Subscription.SubscriptionItem.Sub" + + "scriptionMode\022\\\n\004type\030\003 \001(\0162N.eventmesh." + + "common.protocol.grpc.Subscription.Subscr" + + "iptionItem.SubscriptionType\"4\n\020Subscript" + + "ionMode\022\016\n\nCLUSTERING\020\000\022\020\n\014BROADCASTING\020" + + "\001\"\'\n\020SubscriptionType\022\t\n\005ASYNC\020\000\022\010\n\004SYNC" + + "\020\001\"\340\002\n\tHeartbeat\022=\n\006header\030\001 \001(\0132-.event" + + "mesh.common.protocol.grpc.RequestHeader\022" + + "H\n\nclientType\030\002 \001(\01624.eventmesh.common.p" + + "rotocol.grpc.Heartbeat.ClientType\022\025\n\rpro" + + "ducerGroup\030\003 \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022" + + "O\n\016heartbeatItems\030\005 \003(\01327.eventmesh.comm" + + "on.protocol.grpc.Heartbeat.HeartbeatItem" + + "\032+\n\rHeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030" + + "\002 \001(\t\"\036\n\nClientType\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\316\002" + + "\n\020PublisherService\022e\n\007publish\0220.eventmes" + + "h.common.protocol.grpc.EventMeshMessage\032" + + "(.eventmesh.common.protocol.grpc.Respons" + + "e\022j\n\014requestReply\0220.eventmesh.common.pro" + + "tocol.grpc.EventMeshMessage\032(.eventmesh." + + "common.protocol.grpc.Response\022g\n\tbroadca" + + "st\0220.eventmesh.common.protocol.grpc.Even" + + "tMeshMessage\032(.eventmesh.common.protocol" + + ".grpc.Response2\322\002\n\017ConsumerService\022c\n\tsu" + + "bscribe\022,.eventmesh.common.protocol.grpc" + + ".Subscription\032(.eventmesh.common.protoco" + + "l.grpc.Response\022s\n\017subscribeStream\022,.eve" + "ntmesh.common.protocol.grpc.Subscription" + - ".SubscriptionItem\032J\n\020SubscriptionItem\022\r\n" + - "\005topic\030\001 \001(\t\022\014\n\004mode\030\002 \001(\t\022\014\n\004type\030\003 \001(\t" + - "\022\013\n\003url\030\004 \001(\t\"\212\002\n\tHeartbeat\022=\n\006header\030\001 " + - "\001(\0132-.eventmesh.common.protocol.grpc.Req" + - "uestHeader\022\022\n\nclientType\030\002 \001(\t\022\025\n\rproduc" + - "erGroup\030\003 \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022O\n\016" + - "heartbeatItems\030\005 \003(\01327.eventmesh.common." + - "protocol.grpc.Heartbeat.HeartbeatItem\032+\n" + - "\rHeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030\002 \001" + - "(\t2\316\002\n\020PublisherService\022e\n\007publish\0220.eve" + - "ntmesh.common.protocol.grpc.EventMeshMes" + - "sage\032(.eventmesh.common.protocol.grpc.Re" + - "sponse\022j\n\014requestReply\0220.eventmesh.commo" + - "n.protocol.grpc.EventMeshMessage\032(.event" + - "mesh.common.protocol.grpc.Response\022g\n\tbr" + - "oadcast\0220.eventmesh.common.protocol.grpc" + - ".EventMeshMessage\032(.eventmesh.common.pro" + - "tocol.grpc.Response2\322\002\n\017ConsumerService\022" + - "c\n\tsubscribe\022,.eventmesh.common.protocol" + - ".grpc.Subscription\032(.eventmesh.common.pr" + - "otocol.grpc.Response\022s\n\017subscribeStream\022" + - ",.eventmesh.common.protocol.grpc.Subscri" + - "ption\0320.eventmesh.common.protocol.grpc.E" + - "ventMeshMessage0\001\022e\n\013unsubscribe\022,.event" + - "mesh.common.protocol.grpc.Subscription\032(" + - ".eventmesh.common.protocol.grpc.Response" + - "2t\n\020HeartbeatService\022`\n\theartbeat\022).even" + - "tmesh.common.protocol.grpc.Heartbeat\032(.e" + - "ventmesh.common.protocol.grpc.ResponseBC" + - "\n0org.apache.eventmesh.common.protocol.g" + - "rpc.protosB\rEventmeshGrpcP\001b\006proto3" + "\0320.eventmesh.common.protocol.grpc.EventM" + + "eshMessage0\001\022e\n\013unsubscribe\022,.eventmesh." + + "common.protocol.grpc.Subscription\032(.even" + + "tmesh.common.protocol.grpc.Response2t\n\020H" + + "eartbeatService\022`\n\theartbeat\022).eventmesh" + + ".common.protocol.grpc.Heartbeat\032(.eventm" + + "esh.common.protocol.grpc.ResponseBC\n0org" + + ".apache.eventmesh.common.protocol.grpc.p" + + "rotosB\rEventmeshGrpcP\001b\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -148,7 +140,7 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor, - new String[] { "Header", "ProducerGroup", "Topic", "Content", "Ttl", "UniqueId", "SeqNum", }); + new String[] { "Header", "ProducerGroup", "Topic", "Content", "Ttl", "UniqueId", "SeqNum", "Tag", }); internal_static_eventmesh_common_protocol_grpc_Response_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable = new @@ -160,13 +152,13 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor, - new String[] { "Header", "ConsumerGroup", "SubscriptionItems", }); + new String[] { "Header", "ConsumerGroup", "SubscriptionItems", "Url", }); internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor = internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor.getNestedTypes().get(0); internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor, - new String[] { "Topic", "Mode", "Type", "Url", }); + new String[] { "Topic", "Mode", "Type", }); internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor = getDescriptor().getMessageTypes().get(4); internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable = new diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java index f616a65790..64e95fd3d8 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto @@ -33,7 +16,7 @@ private Heartbeat(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } private Heartbeat() { - clientType_ = ""; + clientType_ = 0; producerGroup_ = ""; consumerGroup_ = ""; heartbeatItems_ = java.util.Collections.emptyList(); @@ -83,10 +66,10 @@ private Heartbeat( break; } - case 18: { - String s = input.readStringRequireUtf8(); + case 16: { + int rawValue = input.readEnum(); - clientType_ = s; + clientType_ = rawValue; break; } case 26: { @@ -137,6 +120,104 @@ private Heartbeat( Heartbeat.class, Builder.class); } + /** + * Protobuf enum {@code eventmesh.common.protocol.grpc.Heartbeat.ClientType} + */ + public enum ClientType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * PUB = 0; + */ + PUB(0), + /** + * SUB = 1; + */ + SUB(1), + UNRECOGNIZED(-1), + ; + + /** + * PUB = 0; + */ + public static final int PUB_VALUE = 0; + /** + * SUB = 1; + */ + public static final int SUB_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @Deprecated + public static ClientType valueOf(int value) { + return forNumber(value); + } + + public static ClientType forNumber(int value) { + switch (value) { + case 0: return PUB; + case 1: return SUB; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + ClientType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ClientType findValueByNumber(int number) { + return ClientType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return Heartbeat.getDescriptor().getEnumTypes().get(0); + } + + private static final ClientType[] VALUES = values(); + + public static ClientType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ClientType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:eventmesh.common.protocol.grpc.Heartbeat.ClientType) + } + public interface HeartbeatItemOrBuilder extends // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem) com.google.protobuf.MessageOrBuilder { @@ -822,37 +903,19 @@ public RequestHeaderOrBuilder getHeaderOrBuilder() { } public static final int CLIENTTYPE_FIELD_NUMBER = 2; - private volatile Object clientType_; + private int clientType_; /** - * string clientType = 2; + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; */ - public String getClientType() { - Object ref = clientType_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - clientType_ = s; - return s; - } + public int getClientTypeValue() { + return clientType_; } /** - * string clientType = 2; + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; */ - public com.google.protobuf.ByteString - getClientTypeBytes() { - Object ref = clientType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - clientType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public ClientType getClientType() { + ClientType result = ClientType.valueOf(clientType_); + return result == null ? ClientType.UNRECOGNIZED : result; } public static final int PRODUCERGROUP_FIELD_NUMBER = 3; @@ -973,8 +1036,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (header_ != null) { output.writeMessage(1, getHeader()); } - if (!getClientTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, clientType_); + if (clientType_ != ClientType.PUB.getNumber()) { + output.writeEnum(2, clientType_); } if (!getProducerGroupBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 3, producerGroup_); @@ -997,8 +1060,9 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, getHeader()); } - if (!getClientTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, clientType_); + if (clientType_ != ClientType.PUB.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, clientType_); } if (!getProducerGroupBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, producerGroup_); @@ -1031,8 +1095,7 @@ public boolean equals(final Object obj) { result = result && getHeader() .equals(other.getHeader()); } - result = result && getClientType() - .equals(other.getClientType()); + result = result && clientType_ == other.clientType_; result = result && getProducerGroup() .equals(other.getProducerGroup()); result = result && getConsumerGroup() @@ -1055,7 +1118,7 @@ public int hashCode() { hash = (53 * hash) + getHeader().hashCode(); } hash = (37 * hash) + CLIENTTYPE_FIELD_NUMBER; - hash = (53 * hash) + getClientType().hashCode(); + hash = (53 * hash) + clientType_; hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER; hash = (53 * hash) + getProducerGroup().hashCode(); hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER; @@ -1200,7 +1263,7 @@ public Builder clear() { header_ = null; headerBuilder_ = null; } - clientType_ = ""; + clientType_ = 0; producerGroup_ = ""; @@ -1298,9 +1361,8 @@ public Builder mergeFrom(Heartbeat other) { if (other.hasHeader()) { mergeHeader(other.getHeader()); } - if (!other.getClientType().isEmpty()) { - clientType_ = other.clientType_; - onChanged(); + if (other.clientType_ != 0) { + setClientTypeValue(other.getClientTypeValue()); } if (!other.getProducerGroup().isEmpty()) { producerGroup_ = other.producerGroup_; @@ -1481,71 +1543,46 @@ public RequestHeaderOrBuilder getHeaderOrBuilder() { return headerBuilder_; } - private Object clientType_ = ""; + private int clientType_ = 0; /** - * string clientType = 2; + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; */ - public String getClientType() { - Object ref = clientType_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - clientType_ = s; - return s; - } else { - return (String) ref; - } + public int getClientTypeValue() { + return clientType_; } /** - * string clientType = 2; + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; */ - public com.google.protobuf.ByteString - getClientTypeBytes() { - Object ref = clientType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - clientType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string clientType = 2; - */ - public Builder setClientType( - String value) { - if (value == null) { - throw new NullPointerException(); - } - + public Builder setClientTypeValue(int value) { clientType_ = value; onChanged(); return this; } /** - * string clientType = 2; + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; */ - public Builder clearClientType() { + public ClientType getClientType() { + ClientType result = ClientType.valueOf(clientType_); + return result == null ? ClientType.UNRECOGNIZED : result; + } + /** + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; + */ + public Builder setClientType(ClientType value) { + if (value == null) { + throw new NullPointerException(); + } - clientType_ = getDefaultInstance().getClientType(); + clientType_ = value.getNumber(); onChanged(); return this; } /** - * string clientType = 2; + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; */ - public Builder setClientTypeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); + public Builder clearClientType() { - clientType_ = value; + clientType_ = 0; onChanged(); return this; } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java index 7bbe0aba1c..7c900099a2 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto @@ -38,14 +21,13 @@ public interface HeartbeatOrBuilder extends RequestHeaderOrBuilder getHeaderOrBuilder(); /** - * string clientType = 2; + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; */ - String getClientType(); + int getClientTypeValue(); /** - * string clientType = 2; + * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2; */ - com.google.protobuf.ByteString - getClientTypeBytes(); + Heartbeat.ClientType getClientType(); /** * string producerGroup = 3; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java index 3516afd9af..5224e01d0a 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java @@ -1,20 +1,3 @@ -/* - * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; @@ -44,30 +27,30 @@ private HeartbeatServiceGrpc() {} public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.HeartbeatService"; // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getHeartbeatMethod; + private static volatile io.grpc.MethodDescriptor getHeartbeatMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "heartbeat", - requestType = org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.class, - responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, + requestType = Heartbeat.class, + responseType = Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getHeartbeatMethod() { - io.grpc.MethodDescriptor getHeartbeatMethod; + public static io.grpc.MethodDescriptor getHeartbeatMethod() { + io.grpc.MethodDescriptor getHeartbeatMethod; if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { synchronized (HeartbeatServiceGrpc.class) { if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) { HeartbeatServiceGrpc.getHeartbeatMethod = getHeartbeatMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.HeartbeatService", "heartbeat")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.getDefaultInstance())) + Heartbeat.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) + Response.getDefaultInstance())) .setSchemaDescriptor(new HeartbeatServiceMethodDescriptorSupplier("heartbeat")) .build(); } @@ -105,8 +88,8 @@ public static abstract class HeartbeatServiceImplBase implements io.grpc.Bindabl /** */ - public void heartbeat(org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat request, - io.grpc.stub.StreamObserver responseObserver) { + public void heartbeat(Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getHeartbeatMethod(), responseObserver); } @@ -116,8 +99,8 @@ public void heartbeat(org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat getHeartbeatMethod(), asyncUnaryCall( new MethodHandlers< - org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat, - org.apache.eventmesh.common.protocol.grpc.protos.Response>( + Heartbeat, + Response>( this, METHODID_HEARTBEAT))) .build(); } @@ -143,8 +126,8 @@ protected HeartbeatServiceStub build(io.grpc.Channel channel, /** */ - public void heartbeat(org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat request, - io.grpc.stub.StreamObserver responseObserver) { + public void heartbeat(Heartbeat request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request, responseObserver); } @@ -170,7 +153,7 @@ protected HeartbeatServiceBlockingStub build(io.grpc.Channel channel, /** */ - public org.apache.eventmesh.common.protocol.grpc.protos.Response heartbeat(org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat request) { + public Response heartbeat(Heartbeat request) { return blockingUnaryCall( getChannel(), getHeartbeatMethod(), getCallOptions(), request); } @@ -196,8 +179,8 @@ protected HeartbeatServiceFutureStub build(io.grpc.Channel channel, /** */ - public com.google.common.util.concurrent.ListenableFuture heartbeat( - org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat request) { + public com.google.common.util.concurrent.ListenableFuture heartbeat( + Heartbeat request) { return futureUnaryCall( getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request); } @@ -223,8 +206,8 @@ private static final class MethodHandlers implements public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { switch (methodId) { case METHODID_HEARTBEAT: - serviceImpl.heartbeat((org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.heartbeat((Heartbeat) request, + (io.grpc.stub.StreamObserver) responseObserver); break; default: throw new AssertionError(); @@ -248,7 +231,7 @@ private static abstract class HeartbeatServiceBaseDescriptorSupplier @Override public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return org.apache.eventmesh.common.protocol.grpc.protos.EventmeshGrpc.getDescriptor(); + return EventmeshGrpc.getDescriptor(); } @Override diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java index 794a721487..c23bb07cc2 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java @@ -1,20 +1,3 @@ -/* - * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; @@ -44,30 +27,30 @@ private PublisherServiceGrpc() {} public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.PublisherService"; // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor getPublishMethod; + private static volatile io.grpc.MethodDescriptor getPublishMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "publish", - requestType = org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.class, - responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, + requestType = EventMeshMessage.class, + responseType = Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getPublishMethod() { - io.grpc.MethodDescriptor getPublishMethod; + public static io.grpc.MethodDescriptor getPublishMethod() { + io.grpc.MethodDescriptor getPublishMethod; if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { synchronized (PublisherServiceGrpc.class) { if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) { PublisherServiceGrpc.getPublishMethod = getPublishMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.PublisherService", "publish")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.getDefaultInstance())) + EventMeshMessage.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) + Response.getDefaultInstance())) .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("publish")) .build(); } @@ -76,30 +59,30 @@ org.apache.eventmesh.common.protocol.grpc.protos.Response> getPublishMethod() { return getPublishMethod; } - private static volatile io.grpc.MethodDescriptor getRequestReplyMethod; + private static volatile io.grpc.MethodDescriptor getRequestReplyMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "requestReply", - requestType = org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.class, - responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, + requestType = EventMeshMessage.class, + responseType = Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getRequestReplyMethod() { - io.grpc.MethodDescriptor getRequestReplyMethod; + public static io.grpc.MethodDescriptor getRequestReplyMethod() { + io.grpc.MethodDescriptor getRequestReplyMethod; if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { synchronized (PublisherServiceGrpc.class) { if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) { PublisherServiceGrpc.getRequestReplyMethod = getRequestReplyMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.PublisherService", "requestReply")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.getDefaultInstance())) + EventMeshMessage.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) + Response.getDefaultInstance())) .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("requestReply")) .build(); } @@ -108,30 +91,30 @@ org.apache.eventmesh.common.protocol.grpc.protos.Response> getRequestReplyMethod return getRequestReplyMethod; } - private static volatile io.grpc.MethodDescriptor getBroadcastMethod; + private static volatile io.grpc.MethodDescriptor getBroadcastMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "broadcast", - requestType = org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.class, - responseType = org.apache.eventmesh.common.protocol.grpc.protos.Response.class, + requestType = EventMeshMessage.class, + responseType = Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getBroadcastMethod() { - io.grpc.MethodDescriptor getBroadcastMethod; + public static io.grpc.MethodDescriptor getBroadcastMethod() { + io.grpc.MethodDescriptor getBroadcastMethod; if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { synchronized (PublisherServiceGrpc.class) { if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { PublisherServiceGrpc.getBroadcastMethod = getBroadcastMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.PublisherService", "broadcast")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.getDefaultInstance())) + EventMeshMessage.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.Response.getDefaultInstance())) + Response.getDefaultInstance())) .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("broadcast")) .build(); } @@ -169,22 +152,22 @@ public static abstract class PublisherServiceImplBase implements io.grpc.Bindabl /** */ - public void publish(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, - io.grpc.stub.StreamObserver responseObserver) { + public void publish(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getPublishMethod(), responseObserver); } /** */ - public void requestReply(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, - io.grpc.stub.StreamObserver responseObserver) { + public void requestReply(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getRequestReplyMethod(), responseObserver); } /** */ - public void broadcast(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, - io.grpc.stub.StreamObserver responseObserver) { + public void broadcast(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getBroadcastMethod(), responseObserver); } @@ -194,22 +177,22 @@ public void broadcast(org.apache.eventmesh.common.protocol.grpc.protos.EventMesh getPublishMethod(), asyncUnaryCall( new MethodHandlers< - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage, - org.apache.eventmesh.common.protocol.grpc.protos.Response>( + EventMeshMessage, + Response>( this, METHODID_PUBLISH))) .addMethod( getRequestReplyMethod(), asyncUnaryCall( new MethodHandlers< - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage, - org.apache.eventmesh.common.protocol.grpc.protos.Response>( + EventMeshMessage, + Response>( this, METHODID_REQUEST_REPLY))) .addMethod( getBroadcastMethod(), asyncUnaryCall( new MethodHandlers< - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage, - org.apache.eventmesh.common.protocol.grpc.protos.Response>( + EventMeshMessage, + Response>( this, METHODID_BROADCAST))) .build(); } @@ -235,24 +218,24 @@ protected PublisherServiceStub build(io.grpc.Channel channel, /** */ - public void publish(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, - io.grpc.stub.StreamObserver responseObserver) { + public void publish(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getPublishMethod(), getCallOptions()), request, responseObserver); } /** */ - public void requestReply(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, - io.grpc.stub.StreamObserver responseObserver) { + public void requestReply(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request, responseObserver); } /** */ - public void broadcast(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request, - io.grpc.stub.StreamObserver responseObserver) { + public void broadcast(EventMeshMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getBroadcastMethod(), getCallOptions()), request, responseObserver); } @@ -278,21 +261,21 @@ protected PublisherServiceBlockingStub build(io.grpc.Channel channel, /** */ - public org.apache.eventmesh.common.protocol.grpc.protos.Response publish(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { + public Response publish(EventMeshMessage request) { return blockingUnaryCall( getChannel(), getPublishMethod(), getCallOptions(), request); } /** */ - public org.apache.eventmesh.common.protocol.grpc.protos.Response requestReply(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { + public Response requestReply(EventMeshMessage request) { return blockingUnaryCall( getChannel(), getRequestReplyMethod(), getCallOptions(), request); } /** */ - public org.apache.eventmesh.common.protocol.grpc.protos.Response broadcast(org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { + public Response broadcast(EventMeshMessage request) { return blockingUnaryCall( getChannel(), getBroadcastMethod(), getCallOptions(), request); } @@ -318,24 +301,24 @@ protected PublisherServiceFutureStub build(io.grpc.Channel channel, /** */ - public com.google.common.util.concurrent.ListenableFuture publish( - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { + public com.google.common.util.concurrent.ListenableFuture publish( + EventMeshMessage request) { return futureUnaryCall( getChannel().newCall(getPublishMethod(), getCallOptions()), request); } /** */ - public com.google.common.util.concurrent.ListenableFuture requestReply( - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { + public com.google.common.util.concurrent.ListenableFuture requestReply( + EventMeshMessage request) { return futureUnaryCall( getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request); } /** */ - public com.google.common.util.concurrent.ListenableFuture broadcast( - org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage request) { + public com.google.common.util.concurrent.ListenableFuture broadcast( + EventMeshMessage request) { return futureUnaryCall( getChannel().newCall(getBroadcastMethod(), getCallOptions()), request); } @@ -363,16 +346,16 @@ private static final class MethodHandlers implements public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { switch (methodId) { case METHODID_PUBLISH: - serviceImpl.publish((org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.publish((EventMeshMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); break; case METHODID_REQUEST_REPLY: - serviceImpl.requestReply((org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.requestReply((EventMeshMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); break; case METHODID_BROADCAST: - serviceImpl.broadcast((org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage) request, - (io.grpc.stub.StreamObserver) responseObserver); + serviceImpl.broadcast((EventMeshMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); break; default: throw new AssertionError(); @@ -396,7 +379,7 @@ private static abstract class PublisherServiceBaseDescriptorSupplier @Override public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return org.apache.eventmesh.common.protocol.grpc.protos.EventmeshGrpc.getDescriptor(); + return EventmeshGrpc.getDescriptor(); } @Override diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java index 4fe0c49c5b..d53cbcbfef 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java index 2041119264..ab28df49f2 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java index 9c087d2a12..008b0a1210 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java index 4c3abd6326..701507deb9 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java index cd2f799e22..76efe7dc6c 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto @@ -35,6 +18,7 @@ private Subscription(com.google.protobuf.GeneratedMessageV3.Builder builder) private Subscription() { consumerGroup_ = ""; subscriptionItems_ = java.util.Collections.emptyList(); + url_ = ""; } @Override @@ -96,6 +80,12 @@ private Subscription( input.readMessage(SubscriptionItem.parser(), extensionRegistry)); break; } + case 34: { + String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -138,34 +128,22 @@ public interface SubscriptionItemOrBuilder extends getTopicBytes(); /** - * string mode = 2; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; */ - String getMode(); + int getModeValue(); /** - * string mode = 2; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; */ - com.google.protobuf.ByteString - getModeBytes(); + SubscriptionItem.SubscriptionMode getMode(); /** - * string type = 3; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; */ - String getType(); + int getTypeValue(); /** - * string type = 3; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; */ - com.google.protobuf.ByteString - getTypeBytes(); - - /** - * string url = 4; - */ - String getUrl(); - /** - * string url = 4; - */ - com.google.protobuf.ByteString - getUrlBytes(); + SubscriptionItem.SubscriptionType getType(); } /** * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem} @@ -181,9 +159,8 @@ private SubscriptionItem(com.google.protobuf.GeneratedMessageV3.Builder build } private SubscriptionItem() { topic_ = ""; - mode_ = ""; - type_ = ""; - url_ = ""; + mode_ = 0; + type_ = 0; } @Override @@ -223,22 +200,16 @@ private SubscriptionItem( topic_ = s; break; } - case 18: { - String s = input.readStringRequireUtf8(); - - mode_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); + case 16: { + int rawValue = input.readEnum(); - type_ = s; + mode_ = rawValue; break; } - case 34: { - String s = input.readStringRequireUtf8(); + case 24: { + int rawValue = input.readEnum(); - url_ = s; + type_ = rawValue; break; } } @@ -265,6 +236,202 @@ private SubscriptionItem( SubscriptionItem.class, Builder.class); } + /** + * Protobuf enum {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode} + */ + public enum SubscriptionMode + implements com.google.protobuf.ProtocolMessageEnum { + /** + * CLUSTERING = 0; + */ + CLUSTERING(0), + /** + * BROADCASTING = 1; + */ + BROADCASTING(1), + UNRECOGNIZED(-1), + ; + + /** + * CLUSTERING = 0; + */ + public static final int CLUSTERING_VALUE = 0; + /** + * BROADCASTING = 1; + */ + public static final int BROADCASTING_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @Deprecated + public static SubscriptionMode valueOf(int value) { + return forNumber(value); + } + + public static SubscriptionMode forNumber(int value) { + switch (value) { + case 0: return CLUSTERING; + case 1: return BROADCASTING; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + SubscriptionMode> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public SubscriptionMode findValueByNumber(int number) { + return SubscriptionMode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return SubscriptionItem.getDescriptor().getEnumTypes().get(0); + } + + private static final SubscriptionMode[] VALUES = values(); + + public static SubscriptionMode valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private SubscriptionMode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode) + } + + /** + * Protobuf enum {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType} + */ + public enum SubscriptionType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * ASYNC = 0; + */ + ASYNC(0), + /** + * SYNC = 1; + */ + SYNC(1), + UNRECOGNIZED(-1), + ; + + /** + * ASYNC = 0; + */ + public static final int ASYNC_VALUE = 0; + /** + * SYNC = 1; + */ + public static final int SYNC_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @Deprecated + public static SubscriptionType valueOf(int value) { + return forNumber(value); + } + + public static SubscriptionType forNumber(int value) { + switch (value) { + case 0: return ASYNC; + case 1: return SYNC; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + SubscriptionType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public SubscriptionType findValueByNumber(int number) { + return SubscriptionType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return SubscriptionItem.getDescriptor().getEnumTypes().get(1); + } + + private static final SubscriptionType[] VALUES = values(); + + public static SubscriptionType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private SubscriptionType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType) + } + public static final int TOPIC_FIELD_NUMBER = 1; private volatile Object topic_; /** @@ -300,105 +467,35 @@ public String getTopic() { } public static final int MODE_FIELD_NUMBER = 2; - private volatile Object mode_; + private int mode_; /** - * string mode = 2; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; */ - public String getMode() { - Object ref = mode_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - mode_ = s; - return s; - } + public int getModeValue() { + return mode_; } /** - * string mode = 2; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; */ - public com.google.protobuf.ByteString - getModeBytes() { - Object ref = mode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - mode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public SubscriptionMode getMode() { + SubscriptionMode result = SubscriptionMode.valueOf(mode_); + return result == null ? SubscriptionMode.UNRECOGNIZED : result; } public static final int TYPE_FIELD_NUMBER = 3; - private volatile Object type_; + private int type_; /** - * string type = 3; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; */ - public String getType() { - Object ref = type_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - type_ = s; - return s; - } + public int getTypeValue() { + return type_; } /** - * string type = 3; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; */ - public com.google.protobuf.ByteString - getTypeBytes() { - Object ref = type_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - type_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int URL_FIELD_NUMBER = 4; - private volatile Object url_; - /** - * string url = 4; - */ - public String getUrl() { - Object ref = url_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } - } - /** - * string url = 4; - */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public SubscriptionType getType() { + SubscriptionType result = SubscriptionType.valueOf(type_); + return result == null ? SubscriptionType.UNRECOGNIZED : result; } private byte memoizedIsInitialized = -1; @@ -416,14 +513,11 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!getTopicBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); } - if (!getModeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, mode_); - } - if (!getTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_); + if (mode_ != SubscriptionMode.CLUSTERING.getNumber()) { + output.writeEnum(2, mode_); } - if (!getUrlBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, url_); + if (type_ != SubscriptionType.ASYNC.getNumber()) { + output.writeEnum(3, type_); } unknownFields.writeTo(output); } @@ -436,14 +530,13 @@ public int getSerializedSize() { if (!getTopicBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); } - if (!getModeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, mode_); + if (mode_ != SubscriptionMode.CLUSTERING.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, mode_); } - if (!getTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_); - } - if (!getUrlBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, url_); + if (type_ != SubscriptionType.ASYNC.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(3, type_); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -463,12 +556,8 @@ public boolean equals(final Object obj) { boolean result = true; result = result && getTopic() .equals(other.getTopic()); - result = result && getMode() - .equals(other.getMode()); - result = result && getType() - .equals(other.getType()); - result = result && getUrl() - .equals(other.getUrl()); + result = result && mode_ == other.mode_; + result = result && type_ == other.type_; result = result && unknownFields.equals(other.unknownFields); return result; } @@ -483,11 +572,9 @@ public int hashCode() { hash = (37 * hash) + TOPIC_FIELD_NUMBER; hash = (53 * hash) + getTopic().hashCode(); hash = (37 * hash) + MODE_FIELD_NUMBER; - hash = (53 * hash) + getMode().hashCode(); + hash = (53 * hash) + mode_; hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + getType().hashCode(); - hash = (37 * hash) + URL_FIELD_NUMBER; - hash = (53 * hash) + getUrl().hashCode(); + hash = (53 * hash) + type_; hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -619,11 +706,9 @@ public Builder clear() { super.clear(); topic_ = ""; - mode_ = ""; - - type_ = ""; + mode_ = 0; - url_ = ""; + type_ = 0; return this; } @@ -650,7 +735,6 @@ public SubscriptionItem buildPartial() { result.topic_ = topic_; result.mode_ = mode_; result.type_ = type_; - result.url_ = url_; onBuilt(); return result; } @@ -696,17 +780,11 @@ public Builder mergeFrom(SubscriptionItem other) { topic_ = other.topic_; onChanged(); } - if (!other.getMode().isEmpty()) { - mode_ = other.mode_; - onChanged(); - } - if (!other.getType().isEmpty()) { - type_ = other.type_; - onChanged(); + if (other.mode_ != 0) { + setModeValue(other.getModeValue()); } - if (!other.getUrl().isEmpty()) { - url_ = other.url_; - onChanged(); + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); } this.mergeUnknownFields(other.unknownFields); onChanged(); @@ -804,209 +882,90 @@ public Builder setTopicBytes( return this; } - private Object mode_ = ""; + private int mode_ = 0; /** - * string mode = 2; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; */ - public String getMode() { - Object ref = mode_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - mode_ = s; - return s; - } else { - return (String) ref; - } + public int getModeValue() { + return mode_; } /** - * string mode = 2; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; */ - public com.google.protobuf.ByteString - getModeBytes() { - Object ref = mode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - mode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string mode = 2; - */ - public Builder setMode( - String value) { - if (value == null) { - throw new NullPointerException(); - } - + public Builder setModeValue(int value) { mode_ = value; onChanged(); return this; } /** - * string mode = 2; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; */ - public Builder clearMode() { - - mode_ = getDefaultInstance().getMode(); - onChanged(); - return this; + public SubscriptionMode getMode() { + SubscriptionMode result = SubscriptionMode.valueOf(mode_); + return result == null ? SubscriptionMode.UNRECOGNIZED : result; } /** - * string mode = 2; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; */ - public Builder setModeBytes( - com.google.protobuf.ByteString value) { + public Builder setMode(SubscriptionMode value) { if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); + throw new NullPointerException(); + } - mode_ = value; + mode_ = value.getNumber(); onChanged(); return this; } - - private Object type_ = ""; /** - * string type = 3; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2; */ - public String getType() { - Object ref = type_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - type_ = s; - return s; - } else { - return (String) ref; - } - } - /** - * string type = 3; - */ - public com.google.protobuf.ByteString - getTypeBytes() { - Object ref = type_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - type_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string type = 3; - */ - public Builder setType( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - type_ = value; + public Builder clearMode() { + + mode_ = 0; onChanged(); return this; } + + private int type_ = 0; /** - * string type = 3; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; */ - public Builder clearType() { - - type_ = getDefaultInstance().getType(); - onChanged(); - return this; + public int getTypeValue() { + return type_; } /** - * string type = 3; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; */ - public Builder setTypeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - + public Builder setTypeValue(int value) { type_ = value; onChanged(); return this; } - - private Object url_ = ""; - /** - * string url = 4; - */ - public String getUrl() { - Object ref = url_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - url_ = s; - return s; - } else { - return (String) ref; - } - } /** - * string url = 4; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; */ - public com.google.protobuf.ByteString - getUrlBytes() { - Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public SubscriptionType getType() { + SubscriptionType result = SubscriptionType.valueOf(type_); + return result == null ? SubscriptionType.UNRECOGNIZED : result; } /** - * string url = 4; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; */ - public Builder setUrl( - String value) { + public Builder setType(SubscriptionType value) { if (value == null) { - throw new NullPointerException(); - } - - url_ = value; - onChanged(); - return this; - } - /** - * string url = 4; - */ - public Builder clearUrl() { + throw new NullPointerException(); + } - url_ = getDefaultInstance().getUrl(); + type_ = value.getNumber(); onChanged(); return this; } /** - * string url = 4; + * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3; */ - public Builder setUrlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); + public Builder clearType() { - url_ = value; + type_ = 0; onChanged(); return this; } @@ -1150,6 +1109,40 @@ public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( return subscriptionItems_.get(index); } + public static final int URL_FIELD_NUMBER = 4; + private volatile Object url_; + /** + * string url = 4; + */ + public String getUrl() { + Object ref = url_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; @@ -1171,6 +1164,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < subscriptionItems_.size(); i++) { output.writeMessage(3, subscriptionItems_.get(i)); } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, url_); + } unknownFields.writeTo(output); } @@ -1190,6 +1186,9 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, subscriptionItems_.get(i)); } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, url_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -1215,6 +1214,8 @@ public boolean equals(final Object obj) { .equals(other.getConsumerGroup()); result = result && getSubscriptionItemsList() .equals(other.getSubscriptionItemsList()); + result = result && getUrl() + .equals(other.getUrl()); result = result && unknownFields.equals(other.unknownFields); return result; } @@ -1236,6 +1237,8 @@ public int hashCode() { hash = (37 * hash) + SUBSCRIPTIONITEMS_FIELD_NUMBER; hash = (53 * hash) + getSubscriptionItemsList().hashCode(); } + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -1380,6 +1383,8 @@ public Builder clear() { } else { subscriptionItemsBuilder_.clear(); } + url_ = ""; + return this; } @@ -1419,6 +1424,7 @@ public Subscription buildPartial() { } else { result.subscriptionItems_ = subscriptionItemsBuilder_.build(); } + result.url_ = url_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -1494,6 +1500,10 @@ public Builder mergeFrom(Subscription other) { } } } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1947,6 +1957,75 @@ public SubscriptionItem.Builder addSubscriptionItemsBuilder( } return subscriptionItemsBuilder_; } + + private Object url_ = ""; + /** + * string url = 4; + */ + public String getUrl() { + Object ref = url_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string url = 4; + */ + public Builder setUrl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * string url = 4; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + /** + * string url = 4; + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFieldsProto3(unknownFields); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java index 713ae21717..2f98079eb6 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java @@ -1,20 +1,3 @@ -/* - * 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. - */ - // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto @@ -70,4 +53,14 @@ public interface SubscriptionOrBuilder extends */ Subscription.SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder( int index); + + /** + * string url = 4; + */ + String getUrl(); + /** + * string url = 4; + */ + com.google.protobuf.ByteString + getUrlBytes(); } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto index 97dc39a434..da4c61e935 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto @@ -61,18 +61,33 @@ message Subscription { string consumerGroup = 2; message SubscriptionItem { + enum SubscriptionMode { + CLUSTERING = 0; + BROADCASTING = 1; + } + + enum SubscriptionType { + ASYNC = 0; + SYNC = 1; + } + string topic = 1; - string mode = 2; - string type = 3; - string url = 4; + SubscriptionMode mode = 2; + SubscriptionType type = 3; } repeated SubscriptionItem subscriptionItems = 3; + string url = 4; } message Heartbeat { + enum ClientType { + PUB = 0; + SUB = 1; + } + RequestHeader header = 1; - string clientType = 2; + ClientType clientType = 2; string producerGroup = 3; string consumerGroup = 4; diff --git a/eventmesh-runtime/build.gradle b/eventmesh-runtime/build.gradle index e0ede31026..980c3cd2fc 100644 --- a/eventmesh-runtime/build.gradle +++ b/eventmesh-runtime/build.gradle @@ -48,6 +48,9 @@ dependencies { implementation "io.grpc:grpc-netty:${grpcVersion}" implementation "io.grpc:grpc-netty-shaded:${grpcVersion}" + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + // for debug only, can be removed implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-cloudevents") implementation project(":eventmesh-protocol-plugin:eventmesh-protocol-meshmessage") diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java index fbeeb24f4e..ee88ee9c6b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java @@ -4,8 +4,11 @@ import io.grpc.ServerBuilder; import org.apache.eventmesh.common.ThreadPoolFactory; import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.interceptor.MetricsInterceptor; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.retry.GrpcRetryer; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ConsumerService; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ProducerService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,8 +27,16 @@ public class EventMeshGrpcServer { private ProducerManager producerManager; + private ConsumerManager consumerManager; + + private GrpcRetryer grpcRetryer; + private ThreadPoolExecutor sendMsgExecutor; + private ThreadPoolExecutor subscribeMsgExecutor; + + private ThreadPoolExecutor pushMsgExecutor; + public EventMeshGrpcServer(EventMeshGrpcConfiguration eventMeshGrpcConfiguration) { this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; } @@ -40,9 +51,16 @@ public void init() throws Exception { producerManager = new ProducerManager(this); producerManager.init(); + consumerManager = new ConsumerManager(this); + consumerManager.init(); + + grpcRetryer = new GrpcRetryer(this); + grpcRetryer.init(); + server = ServerBuilder.forPort(serverPort) .intercept(new MetricsInterceptor()) .addService(new ProducerService(this, sendMsgExecutor)) + .addService(new ConsumerService(this, subscribeMsgExecutor)) .build(); logger.info("GRPCServer[port={}] started", serverPort); @@ -53,6 +71,8 @@ public void start() throws Exception { logger.info("---------------EventMeshGRPCServer starting-------------------"); producerManager.start(); + consumerManager.start(); + grpcRetryer.start(); server.start(); logger.info("---------------EventMeshGRPCServer running-------------------"); @@ -62,6 +82,11 @@ public void shutdown() throws Exception { logger.info("---------------EventMeshGRPCServer stopping-------------------"); producerManager.shutdown(); + consumerManager.shutdown(); + grpcRetryer.shutdown(); + + shutdownThreadPools(); + server.shutdown(); logger.info("---------------EventMeshGRPCServer stopped-------------------"); @@ -75,11 +100,51 @@ public ProducerManager getProducerManager() { return producerManager; } + public ConsumerManager getConsumerManager() { + return consumerManager; + } + + public GrpcRetryer getGrpcRetryer() { + return grpcRetryer; + } + + public ThreadPoolExecutor getSendMsgExecutor() { + return sendMsgExecutor; + } + + public ThreadPoolExecutor getSubscribeMsgExecutor() { + return subscribeMsgExecutor; + } + + public ThreadPoolExecutor getPushMsgExecutor() { + return pushMsgExecutor; + } + private void initThreadPool() { BlockingQueue sendMsgThreadPoolQueue = new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSendMsgBlockQSize); sendMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, - eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, "eventMesh-grpc-sendMsg-", true); + eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, + "eventMesh-grpc-sendMsg-", true); + + BlockingQueue subscribeMsgThreadPoolQueue = + new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgBlockQSize); + + subscribeMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgThreadNum, + eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgThreadNum, subscribeMsgThreadPoolQueue, + "eventMesh-grpc-subscribeMsg-", true); + + BlockingQueue pushMsgThreadPoolQueue = + new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerPushMsgBlockQSize); + pushMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerPushMsgThreadNum, + eventMeshGrpcConfiguration.eventMeshServerPushMsgThreadNum, pushMsgThreadPoolQueue, + "eventMesh-grpc-pushMsg-", true); + } + + private void shutdownThreadPools() { + sendMsgExecutor.shutdown(); + subscribeMsgExecutor.shutdown(); + pushMsgExecutor.shutdown(); } -} +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java index aa450dda82..7278594eb9 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java @@ -36,7 +36,7 @@ public class EventMeshGrpcConfiguration extends CommonConfiguration { public int eventMeshServerReplyMsgThreadNum = 8; - public int eventMeshServerClientManageThreadNum = 4; + public int eventMeshServerSubscribeMsgThreadNum = 4; public int eventMeshServerRegistryThreadNum = 10; @@ -56,7 +56,7 @@ public class EventMeshGrpcConfiguration extends CommonConfiguration { public int eventMeshServerPushMsgBlockQSize = 1000; - public int eventMeshServerClientManageBlockQSize = 1000; + public int eventMeshServerSubscribeMsgBlockQSize = 1000; public int eventMeshServerBusyCheckInterval = 1000; @@ -121,7 +121,7 @@ public void init() { String eventMeshServerClientManageThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_CLIENTMANAGE_THREAD_NUM); if (StringUtils.isNotEmpty(eventMeshServerClientManageThreadNumStr) && StringUtils.isNumeric(eventMeshServerClientManageThreadNumStr)) { - eventMeshServerClientManageThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageThreadNumStr)); + eventMeshServerSubscribeMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageThreadNumStr)); } String eventMeshServerPullRegistryIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_PULL_REGISTRY_INTERVAL); @@ -156,7 +156,7 @@ public void init() { String eventMeshServerClientManageBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_CLIENTM_BLOCKQ_SIZE); if (StringUtils.isNotEmpty(eventMeshServerClientManageBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerClientManageBlockQSizeStr)) { - eventMeshServerClientManageBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageBlockQSizeStr)); + eventMeshServerSubscribeMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageBlockQSizeStr)); } String eventMeshServerBusyCheckIntervalStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_BUSY_CHECK_INTERVAL); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java new file mode 100644 index 0000000000..bd5c25f65f --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -0,0 +1,138 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; + +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +public class ConsumerManager { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final EventMeshGrpcServer eventMeshGrpcServer; + + // key: ConsumerGroup + private final Map> clientTable = new ConcurrentHashMap<>(); + + // key: ConsumerGroup + private final Map consumerTable = new ConcurrentHashMap<>(); + + public ConsumerManager(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void init() throws Exception { + logger.info("Grpc ConsumerManager initialized......"); + } + + public void start() throws Exception { + logger.info("Grpc ConsumerManager started......"); + } + + public void shutdown() throws Exception { + for (EventMeshConsumer consumer: consumerTable.values()) { + consumer.shutdown(); + } + logger.info("Grpc ConsumerManager shutdown......"); + } + + public void handleSubscription(Subscription subscription) throws Exception { + RequestHeader header = subscription.getHeader(); + String consumerGroup = subscription.getConsumerGroup(); + String url = subscription.getUrl(); + List subscriptionItems = subscription.getSubscriptionItemsList(); + + for (Subscription.SubscriptionItem item : subscriptionItems) { + ConsumerGroupClient newClient = ConsumerGroupClient.builder() + .env(header.getEnv()) + .idc(header.getIdc()) + .sys(header.getSys()) + .ip(header.getIp()) + .pid(header.getPid()) + .consumerGroup(consumerGroup) + .topic(item.getTopic()) + .subscriptionMode(item.getMode()) + .url(url) + .lastUpTime(new Date()) + .build(); + + registerClient(newClient); + } + + restartEventMeshConsumer(consumerGroup); + } + + private void registerClient(ConsumerGroupClient newClient) { + String consumerGroup = newClient.getConsumerGroup(); + String topic = newClient.getTopic(); + String url = newClient.getUrl(); + SubscriptionMode subscriptionMode = newClient.getSubscriptionMode(); + List localClients = clientTable.get(consumerGroup); + + if (localClients == null) { + List newClients = new ArrayList<>(); + newClients.add(newClient); + clientTable.put(consumerGroup, newClients); + } else { + boolean isContains = false; + for (ConsumerGroupClient localClient : localClients) { + if (StringUtils.equals(localClient.getTopic(), topic) && StringUtils.equals(localClient.getUrl(), url) + && localClient.getSubscriptionMode().equals(subscriptionMode)) { + isContains = true; + localClient.setLastUpTime(newClient.getLastUpTime()); + break; + } + } + if (!isContains) { + localClients.add(newClient); + } + } + } + + private void restartEventMeshConsumer(String consumerGroup) throws Exception { + EventMeshConsumer eventMeshConsumer = consumerTable.get(consumerGroup); + + if (eventMeshConsumer == null) { + eventMeshConsumer = new EventMeshConsumer(eventMeshGrpcServer, consumerGroup); + consumerTable.put(consumerGroup, eventMeshConsumer); + eventMeshConsumer.init(); + } + + Set oldTopicConfigs = eventMeshConsumer.buildTopicConfig(); + List localClients = clientTable.get(consumerGroup); + for (ConsumerGroupClient client : localClients) { + String topic = client.getTopic(); + String idc = client.getIdc(); + String url = client.getUrl(); + SubscriptionMode subscriptionMode = client.getSubscriptionMode(); + eventMeshConsumer.addTopicConfig(topic, subscriptionMode, idc, url); + } + + // start up eventMeshConsumer the first time + if (ServiceState.INITED.equals(eventMeshConsumer.getStatus())) { + eventMeshConsumer.start(); + return; + } + + // determine if restart eventMeshConsumer required + Set newTopicConfigs = eventMeshConsumer.buildTopicConfig(); + if (!oldTopicConfigs.equals(newTopicConfigs)) { + if (ServiceState.RUNNING.equals(eventMeshConsumer.getStatus())) { + eventMeshConsumer.shutdown(); + } + eventMeshConsumer.start(); + } + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java new file mode 100644 index 0000000000..81953241c6 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java @@ -0,0 +1,195 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; + +import com.google.common.collect.Maps; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.api.EventListener; +import org.apache.eventmesh.api.EventMeshAction; +import org.apache.eventmesh.api.EventMeshAsyncConsumeContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.plugin.MQConsumerWrapper; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; +import org.apache.eventmesh.runtime.core.protocol.grpc.push.HTTPMessageHandler; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +public class EventMeshConsumer { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final String consumerGroup; + + private final EventMeshGrpcServer eventMeshGrpcServer; + + private final EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + + private final MQConsumerWrapper persistentMqConsumer; + + private final MQConsumerWrapper broadcastMqConsumer; + + private final HTTPMessageHandler httpMessageHandler; + + private ServiceState serviceState; + + /** + * Key: topic + * Value: ConsumerGroupTopicConfig + **/ + private Map consumerGroupTopicConfig = Maps.newConcurrentMap(); + + public EventMeshConsumer(EventMeshGrpcServer eventMeshGrpcServer, String consumerGroup) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.eventMeshGrpcConfiguration = eventMeshGrpcServer.getEventMeshGrpcConfiguration(); + this.consumerGroup = consumerGroup; + this.httpMessageHandler = new HTTPMessageHandler(consumerGroup, eventMeshGrpcServer.getPushMsgExecutor()); + this.persistentMqConsumer = new MQConsumerWrapper(eventMeshGrpcConfiguration.eventMeshConnectorPluginType); + this.broadcastMqConsumer = new MQConsumerWrapper(eventMeshGrpcConfiguration.eventMeshConnectorPluginType); + } + + public synchronized void addTopicConfig(String topic, SubscriptionMode subscriptionMode, String idc, String url) { + ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); + if (topicConfig == null) { + topicConfig = new ConsumerGroupTopicConfig(consumerGroup, topic, subscriptionMode); + consumerGroupTopicConfig.put(topic, topicConfig); + } + topicConfig.addUrl(idc, url); + } + + public Set buildTopicConfig() { + Set topicConfigs = new HashSet<>(); + for (ConsumerGroupTopicConfig topicConfig : consumerGroupTopicConfig.values()) { + topicConfigs.add(topicConfig.getTopic() + topicConfig.getSubscriptionMode().name()); + } + return topicConfigs; + } + + public synchronized void init() throws Exception { + Properties keyValue = new Properties(); + keyValue.put("isBroadcast", "false"); + keyValue.put("consumerGroup", consumerGroup); + keyValue.put("eventMeshIDC", eventMeshGrpcConfiguration.eventMeshIDC); + keyValue.put("instanceName", EventMeshUtil.buildMeshClientID(consumerGroup, + eventMeshGrpcConfiguration.eventMeshCluster)); + persistentMqConsumer.init(keyValue); + + Properties broadcastKeyValue = new Properties(); + broadcastKeyValue.put("isBroadcast", "true"); + broadcastKeyValue.put("consumerGroup", consumerGroup); + broadcastKeyValue.put("eventMeshIDC", eventMeshGrpcConfiguration.eventMeshIDC); + broadcastKeyValue.put("instanceName", EventMeshUtil.buildMeshClientID(consumerGroup, + eventMeshGrpcConfiguration.eventMeshCluster)); + broadcastMqConsumer.init(broadcastKeyValue); + + serviceState = ServiceState.INITED; + logger.info("EventMeshConsumer [{}] initialized.............", consumerGroup); + } + + public synchronized void start() throws Exception { + for (Map.Entry entry : consumerGroupTopicConfig.entrySet()) { + subscribe(entry.getKey(), entry.getValue().getSubscriptionMode()); + } + + persistentMqConsumer.start(); + broadcastMqConsumer.start(); + + serviceState = ServiceState.RUNNING; + logger.info("EventMeshConsumer [{}] started..........", consumerGroup); + } + + public synchronized void shutdown() throws Exception { + persistentMqConsumer.shutdown(); + broadcastMqConsumer.shutdown(); + + serviceState = ServiceState.STOPED; + logger.info("EventMeshConsumer [{}] shutdown.........", consumerGroup); + } + + public ServiceState getStatus() { + return serviceState; + } + + public void subscribe(String topic, SubscriptionMode subscriptionMode) throws Exception { + if (SubscriptionMode.CLUSTERING.equals(subscriptionMode)) { + persistentMqConsumer.subscribe(topic, createEventListener(subscriptionMode)); + } else if (SubscriptionMode.BROADCASTING.equals(subscriptionMode)) { + broadcastMqConsumer.subscribe(topic, createEventListener(subscriptionMode)); + } else { + logger.error("Subscribe Failed. Incorrect Subscription Mode"); + throw new Exception("Subscribe Failed. Incorrect Subscription Mode"); + } + } + + public void unsubscribe(Subscription.SubscriptionItem subscriptionItem) throws Exception { + SubscriptionMode mode = subscriptionItem.getMode(); + String topic = subscriptionItem.getTopic(); + if (SubscriptionMode.CLUSTERING.equals(mode)) { + persistentMqConsumer.unsubscribe(topic); + } else if (SubscriptionMode.BROADCASTING.equals(mode)) { + broadcastMqConsumer.unsubscribe(topic); + } else { + logger.error("Unsubscribe Failed. Incorrect Subscription Mode"); + throw new Exception("Unsubscribe Failed. Incorrect Subscription Mode"); + } + } + + public void updateOffset(SubscriptionMode subscriptionMode, List events, + AbstractContext context) throws Exception { + if (SubscriptionMode.CLUSTERING.equals(subscriptionMode)) { + persistentMqConsumer.updateOffset(events, context); + } else if (SubscriptionMode.BROADCASTING.equals(subscriptionMode)) { + broadcastMqConsumer.updateOffset(events, context); + } else { + logger.error("Subscribe Failed. Incorrect Subscription Mode"); + throw new Exception("Subscribe Failed. Incorrect Subscription Mode"); + } + } + + private EventListener createEventListener(SubscriptionMode subscriptionMode) { + return (event, context) -> { + + event = CloudEventBuilder.from(event) + .withExtension(EventMeshConstants.REQ_MQ2EVENTMESH_TIMESTAMP, String.valueOf(System.currentTimeMillis())) + .build(); + + String topic = event.getSubject(); + Object bizSeqNo = event.getExtension(Constants.PROPERTY_MESSAGE_SEARCH_KEYS); + String strBizSeqNo = bizSeqNo == null ? "" : bizSeqNo.toString(); + + Object uniqueId = event.getExtension(Constants.RMB_UNIQ_ID); + String strUniqueId = uniqueId == null ? "" : uniqueId.toString(); + + if (logger.isDebugEnabled()) { + logger.debug("message|mq2eventMesh|topic={}|msg={}", topic, event); + } else { + logger.info("message|mq2eventMesh|topic={}|bizSeqNo={}|uniqueId={}", topic, bizSeqNo, uniqueId); + } + + EventMeshAsyncConsumeContext eventMeshAsyncConsumeContext = (EventMeshAsyncConsumeContext) context; + + ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); + if (topicConfig != null) { + + HandleMsgContext handleMsgContext = new HandleMsgContext(EventMeshUtil.buildPushMsgSeqNo(), consumerGroup, + this, + topic, event, subscriptionMode, eventMeshAsyncConsumeContext.getAbstractContext(), eventMeshGrpcServer, strBizSeqNo, strUniqueId, + topicConfig); + httpMessageHandler.handle(handleMsgContext); + } + eventMeshAsyncConsumeContext.commit(EventMeshAction.CommitMessage); + }; + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java new file mode 100644 index 0000000000..9135dabbe9 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java @@ -0,0 +1,178 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.consumer; + +import io.cloudevents.CloudEvent; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collections; + +public class HandleMsgContext { + + private final String msgRandomNo; + private final SubscriptionMode subscriptionMode; + private final EventMeshGrpcServer eventMeshGrpcServer; + private final ConsumerGroupTopicConfig consumeTopicConfig; + public Logger messageLogger = LoggerFactory.getLogger("message"); + private String consumerGroup; + private EventMeshConsumer eventMeshConsumer; + private String bizSeqNo; + private String uniqueId; + private String topic; + private CloudEvent event; + private int ttl; + private long createTime = System.currentTimeMillis(); + private AbstractContext context; + + public HandleMsgContext(String msgRandomNo, String consumerGroup, EventMeshConsumer eventMeshConsumer, + String topic, CloudEvent event, SubscriptionMode subscriptionMode, + AbstractContext context, EventMeshGrpcServer eventMeshGrpcServer, + String bizSeqNo, String uniqueId, ConsumerGroupTopicConfig consumeTopicConfig) { + this.msgRandomNo = msgRandomNo; + this.consumerGroup = consumerGroup; + this.eventMeshConsumer = eventMeshConsumer; + this.topic = topic; + this.subscriptionMode = subscriptionMode; + this.event = event; + this.context = context; + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.bizSeqNo = bizSeqNo; + this.uniqueId = uniqueId; + this.consumeTopicConfig = consumeTopicConfig; + + String ttlStr = (String) event.getExtension(Constants.PROPERTY_MESSAGE_TIMEOUT); + this.ttl = StringUtils.isNumeric(ttlStr) ? Integer.parseInt(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; + } + + public String getMsgRandomNo() { + return msgRandomNo; + } + + public ConsumerGroupTopicConfig getConsumeTopicConfig() { + return consumeTopicConfig; + } + + public String getBizSeqNo() { + return bizSeqNo; + } + + public void setBizSeqNo(String bizSeqNo) { + this.bizSeqNo = bizSeqNo; + } + + public String getConsumerGroup() { + return consumerGroup; + } + + public void setConsumerGroup(String consumerGroup) { + this.consumerGroup = consumerGroup; + } + + public EventMeshConsumer getEventMeshConsumer() { + return eventMeshConsumer; + } + + public void setEventMeshConsumer(EventMeshConsumer eventMeshConsumer) { + this.eventMeshConsumer = eventMeshConsumer; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public CloudEvent getEvent() { + return event; + } + + public void setEvent(CloudEvent event) { + this.event = event; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public AbstractContext getContext() { + return context; + } + + public void setContext(AbstractContext context) { + this.context = context; + } + + public EventMeshGrpcServer getEventMeshGrpcServer() { + return eventMeshGrpcServer; + } + + public void finish() { + if (eventMeshConsumer != null && context != null && event != null) { + try { + eventMeshConsumer.updateOffset(subscriptionMode, Collections.singletonList(event), context); + } catch (Exception e) { + messageLogger.error("Error in updating offset in EventMeshConsumer", e); + } + } + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public int getTtl() { + return ttl; + } + + public void setTtl(int ttl) { + this.ttl = ttl; + } + + @Override + public String toString() { + return "handleMsgContext={" + + "consumerGroup=" + consumerGroup + + ",topic=" + topic + + ",subscriptionMode=" + subscriptionMode + + ",consumeTopicConfig=" + consumeTopicConfig + + ",bizSeqNo=" + bizSeqNo + + ",uniqueId=" + uniqueId + + ",ttl=" + ttl + + ",createTime=" + DateFormatUtils.format(createTime, Constants.DATE_FORMAT) + "}"; + } + +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java new file mode 100644 index 0000000000..708af0fa8a --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java @@ -0,0 +1,22 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.consumer; + +public interface MessageHandler { + boolean handle(HandleMsgContext handleMsgContext); +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java new file mode 100644 index 0000000000..7192b3321f --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java @@ -0,0 +1,72 @@ +/* + * Licensed to 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. Apache Software Foundation (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.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; + +import lombok.Builder; +import lombok.Data; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; + +import java.util.Date; + +@Builder +@Data +public class ConsumerGroupClient { + + private String env; + + private String idc; + + private String consumerGroup; + + private String topic; + + private String url; + + private SubscriptionMode subscriptionMode; + + private String sys; + + private String ip; + + private String pid; + + private String hostname; + + private String apiVersion; + + private Date lastUpTime; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("endPoint={env=").append(env) + .append(",idc=").append(idc) + .append(",consumerGroup=").append(consumerGroup) + .append(",topic=").append(topic) + .append(",url=").append(url) + .append(",sys=").append(sys) + .append(",ip=").append(ip) + .append(",pid=").append(pid) + .append(",hostname=").append(hostname) + .append(",apiVersion=").append(apiVersion) + .append(",registerTime=").append("}"); + return sb.toString(); + } +} + diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java new file mode 100644 index 0000000000..9b75486efd --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java @@ -0,0 +1,88 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; + +import com.google.common.collect.Maps; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public class ConsumerGroupTopicConfig { + public static Logger logger = LoggerFactory.getLogger(ConsumerGroupTopicConfig.class); + + private String consumerGroup; + + private String topic; + + private SubscriptionMode subscriptionMode; + + /** + * PUSH URL + *

+ * Key: IDC + * Value: list of URls + */ + private Map> idcUrls = Maps.newConcurrentMap(); + + public ConsumerGroupTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode) { + this.consumerGroup = consumerGroup; + this.topic = topic; + this.subscriptionMode = subscriptionMode; + } + + public synchronized void addUrl(String idc, String url) { + List urls = idcUrls.get(idc); + if (urls == null) { + urls = new ArrayList<>(); + urls.add(url); + idcUrls.put(idc, urls); + } else if (!urls.contains(url)) { + urls.add(url); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConsumerGroupTopicConfig that = (ConsumerGroupTopicConfig) o; + return consumerGroup.equals(that.consumerGroup) + && Objects.equals(topic, that.topic) + && Objects.equals(idcUrls, that.idcUrls); + } + + @Override + public int hashCode() { + return Objects.hash(consumerGroup, topic, idcUrls); + } + + @Override + public String toString() { + return "consumeTopicConfig={consumerGroup=" + consumerGroup + + ",topic=" + topic + + ",idcUrls=" + idcUrls + "}"; + } + + public String getConsumerGroup() { + return consumerGroup; + } + + public String getTopic() { + return topic; + } + + public SubscriptionMode getSubscriptionMode() { + return subscriptionMode; + } + + public Map> getIdcUrls() { + return idcUrls; + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java new file mode 100644 index 0000000000..f99ea2d0ef --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java @@ -0,0 +1,41 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.processor; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SubscribeProcessor { + + private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + public SubscribeProcessor(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { + + RequestHeader header = subscription.getHeader(); + + if (!ServiceUtils.validateHeader(header)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + return; + } + + if (!ServiceUtils.validateSubscription(subscription)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + return; + } + + ConsumerManager consumerManager = eventMeshGrpcServer.getConsumerManager(); + consumerManager.handleSubscription(subscription); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java new file mode 100644 index 0000000000..bcb3590707 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java @@ -0,0 +1,116 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.push; + +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.HandleMsgContext; +import org.apache.eventmesh.runtime.core.protocol.grpc.retry.GrpcRetryer; +import org.apache.eventmesh.runtime.core.protocol.grpc.retry.RetryContext; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.RandomUtils; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +public abstract class AbstractHttpPushRequest extends RetryContext { + + protected static HTTPClientPool httpClientPool = new HTTPClientPool(10); + protected EventMeshGrpcServer eventMeshGrpcServer; + protected long createTime = System.currentTimeMillis(); + protected long lastPushTime = System.currentTimeMillis(); + + /** **/ + protected Map> urls; + + protected volatile int startIdx; + protected EventMeshGrpcConfiguration eventMeshGrpcConfiguration; + protected GrpcRetryer retryer; + protected int ttl; + protected HandleMsgContext handleMsgContext; + private AtomicBoolean complete = new AtomicBoolean(Boolean.FALSE); + + private List totalUrls; + + public AbstractHttpPushRequest(HandleMsgContext handleMsgContext) { + this.eventMeshGrpcServer = handleMsgContext.getEventMeshGrpcServer(); + this.handleMsgContext = handleMsgContext; + this.urls = handleMsgContext.getConsumeTopicConfig().getIdcUrls(); + this.eventMeshGrpcConfiguration = handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration(); + this.retryer = handleMsgContext.getEventMeshGrpcServer().getGrpcRetryer(); + this.ttl = handleMsgContext.getTtl(); + + this.totalUrls = buildTotalUrls(); + this.startIdx = RandomUtils.nextInt(0, totalUrls.size()); + } + + public abstract void tryHttpRequest(); + + public void delayRetry() { + if (retryTimes < EventMeshConstants.DEFAULT_PUSH_RETRY_TIMES) { + retryTimes++; + delay(retryTimes * EventMeshConstants.DEFAULT_PUSH_RETRY_TIME_DISTANCE_IN_MILLSECONDS); + retryer.pushRetry(this); + } else { + complete.compareAndSet(Boolean.FALSE, Boolean.TRUE); + } + } + + public String getUrl() { + List localIdcUrl = MapUtils.getObject(urls, + eventMeshGrpcConfiguration.eventMeshIDC, null); + if (CollectionUtils.isNotEmpty(localIdcUrl)) { + return localIdcUrl.get((startIdx + retryTimes) % localIdcUrl.size()); + } + + if (CollectionUtils.isNotEmpty(totalUrls)) { + return totalUrls.get((startIdx + retryTimes) % totalUrls.size()); + } + + return null; + } + + private List buildTotalUrls() { + Set totalUrls = new HashSet<>(); + for (List idcUrls : urls.values()) { + totalUrls.addAll(idcUrls); + } + return new ArrayList<>(totalUrls); + } + + public boolean isComplete() { + return complete.get(); + } + + public void complete() { + complete.compareAndSet(Boolean.FALSE, Boolean.TRUE); + } + + public void timeout() { + if (!isComplete() && System.currentTimeMillis() - lastPushTime >= ttl) { + delayRetry(); + } + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java new file mode 100644 index 0000000000..e30ad238bc --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java @@ -0,0 +1,306 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.push; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.common.collect.Sets; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.exception.JsonException; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.http.HttpCommand; +import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; +import org.apache.eventmesh.common.protocol.http.common.ClientRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.HandleMsgContext; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +public class AsyncHTTPPushRequest extends AbstractHttpPushRequest { + + public Logger messageLogger = LoggerFactory.getLogger("message"); + + public Logger cmdLogger = LoggerFactory.getLogger("cmd"); + + public Logger logger = LoggerFactory.getLogger(this.getClass()); + public String currPushUrl; + private Map> waitingRequests; + + public AsyncHTTPPushRequest(HandleMsgContext handleMsgContext, + Map> waitingRequests) { + super(handleMsgContext); + this.waitingRequests = waitingRequests; + } + + @Override + public void tryHttpRequest() { + + currPushUrl = getUrl(); + + if (StringUtils.isBlank(currPushUrl)) { + return; + } + + HttpPost builder = new HttpPost(currPushUrl); + + String requestCode = String.valueOf(RequestCode.HTTP_PUSH_CLIENT_ASYNC.getRequestCode()); + + builder.addHeader(ProtocolKey.REQUEST_CODE, requestCode); + builder.addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA); + builder.addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHCLUSTER, + handleMsgContext.getEventMeshGrpcServer() + .getEventMeshGrpcConfiguration().eventMeshCluster); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIP, IPUtils.getLocalAddress()); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHENV, + handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration().eventMeshEnv); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIDC, + handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration().eventMeshIDC); + + CloudEvent event = CloudEventBuilder.from(handleMsgContext.getEvent()) + .withExtension(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .build(); + handleMsgContext.setEvent(event); + + String content = ""; + try { + String protocolType = Objects.requireNonNull(event.getExtension(Constants.PROTOCOL_TYPE)).toString(); + + ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + + ProtocolTransportObject protocolTransportObject = + protocolAdaptor.fromCloudEvent(handleMsgContext.getEvent()); + content = ((HttpCommand) protocolTransportObject).getBody().toMap().get("content").toString(); + } catch (Exception ex) { + return; + } + + List body = new ArrayList<>(); + body.add(new BasicNameValuePair(PushMessageRequestBody.CONTENT, content)); + if (StringUtils.isBlank(handleMsgContext.getBizSeqNo())) { + body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, + RandomStringUtils.generateNum(20))); + } else { + body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, + handleMsgContext.getBizSeqNo())); + } + if (StringUtils.isBlank(handleMsgContext.getUniqueId())) { + body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, + RandomStringUtils.generateNum(20))); + } else { + body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, + handleMsgContext.getUniqueId())); + } + + body.add(new BasicNameValuePair(PushMessageRequestBody.RANDOMNO, + handleMsgContext.getMsgRandomNo())); + body.add(new BasicNameValuePair(PushMessageRequestBody.TOPIC, handleMsgContext.getTopic())); + + body.add(new BasicNameValuePair(PushMessageRequestBody.EXTFIELDS, + JsonUtils.serialize(EventMeshUtil.getEventProp(handleMsgContext.getEvent())))); + + builder.setEntity(new UrlEncodedFormEntity(body, StandardCharsets.UTF_8)); + + //eventMeshHTTPServer.metrics.summaryMetrics.recordPushMsg(); + + this.lastPushTime = System.currentTimeMillis(); + + addToWaitingMap(this); + + cmdLogger.info("cmd={}|eventMesh2client|from={}|to={}", requestCode, + IPUtils.getLocalAddress(), currPushUrl); + + try { + httpClientPool.getClient().execute(builder, new ResponseHandler() { + @Override + public Object handleResponse(HttpResponse response) { + removeWaitingMap(AsyncHTTPPushRequest.this); + long cost = System.currentTimeMillis() - lastPushTime; + //eventMeshHTTPServer.metrics.summaryMetrics.recordHTTPPushTimeCost(cost); + if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { + //eventMeshHTTPServer.metrics.summaryMetrics.recordHttpPushMsgFailed(); + messageLogger.info( + "message|eventMesh2client|exception|url={}|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", currPushUrl, handleMsgContext.getTopic(), + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), cost); + + delayRetry(); + if (isComplete()) { + handleMsgContext.finish(); + } + } else { + String res = ""; + try { + res = EntityUtils.toString(response.getEntity(), + Charset.forName(EventMeshConstants.DEFAULT_CHARSET)); + } catch (IOException e) { + handleMsgContext.finish(); + return new Object(); + } + ClientRetCode result = processResponseContent(res); + messageLogger.info( + "message|eventMesh2client|{}|url={}|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", + result, currPushUrl, handleMsgContext.getTopic(), + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), cost); + if (result == ClientRetCode.OK) { + complete(); + if (isComplete()) { + handleMsgContext.finish(); + } + } else if (result == ClientRetCode.RETRY) { + delayRetry(); + if (isComplete()) { + handleMsgContext.finish(); + } + } else if (result == ClientRetCode.NOLISTEN) { + delayRetry(); + if (isComplete()) { + handleMsgContext.finish(); + } + } else if (result == ClientRetCode.FAIL) { + complete(); + if (isComplete()) { + handleMsgContext.finish(); + } + } + } + return new Object(); + } + }); + + if (messageLogger.isDebugEnabled()) { + messageLogger.debug("message|eventMesh2client|url={}|topic={}|event={}", currPushUrl, + handleMsgContext.getTopic(), + handleMsgContext.getEvent()); + } else { + messageLogger + .info("message|eventMesh2client|url={}|topic={}|bizSeqNo={}|uniqueId={}", + currPushUrl, handleMsgContext.getTopic(), + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId()); + } + } catch (IOException e) { + messageLogger.error("push2client err", e); + removeWaitingMap(this); + delayRetry(); + if (isComplete()) { + handleMsgContext.finish(); + } + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("asyncPushRequest={") + .append("bizSeqNo=").append(handleMsgContext.getBizSeqNo()) + .append(",startIdx=").append(startIdx) + .append(",retryTimes=").append(retryTimes) + .append(",uniqueId=").append(handleMsgContext.getUniqueId()) + .append(",executeTime=") + .append(DateFormatUtils.format(executeTime, Constants.DATE_FORMAT)) + .append(",lastPushTime=") + .append(DateFormatUtils.format(lastPushTime, Constants.DATE_FORMAT)) + .append(",createTime=") + .append(DateFormatUtils.format(createTime, Constants.DATE_FORMAT)).append("}"); + return sb.toString(); + } + + ClientRetCode processResponseContent(String content) { + if (StringUtils.isBlank(content)) { + return ClientRetCode.FAIL; + } + + try { + Map ret = + JsonUtils.deserialize(content, new TypeReference>() { + }); + Integer retCode = (Integer) ret.get("retCode"); + if (retCode != null && ClientRetCode.contains(retCode)) { + return ClientRetCode.get(retCode); + } + + return ClientRetCode.FAIL; + } catch (NumberFormatException e) { + messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), content); + return ClientRetCode.FAIL; + } catch (JsonException e) { + messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), content); + return ClientRetCode.FAIL; + } catch (Throwable t) { + messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, + handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), content); + return ClientRetCode.FAIL; + } + } + + private void addToWaitingMap(AsyncHTTPPushRequest request) { + if (waitingRequests.containsKey(request.handleMsgContext.getConsumerGroup())) { + waitingRequests.get(request.handleMsgContext.getConsumerGroup()).add(request); + return; + } + waitingRequests + .put(request.handleMsgContext.getConsumerGroup(), Sets.newConcurrentHashSet()); + waitingRequests.get(request.handleMsgContext.getConsumerGroup()).add(request); + } + + private void removeWaitingMap(AsyncHTTPPushRequest request) { + if (waitingRequests.containsKey(request.handleMsgContext.getConsumerGroup())) { + waitingRequests.get(request.handleMsgContext.getConsumerGroup()).remove(request); + } + } + + @Override + public boolean retry() { + tryHttpRequest(); + return true; + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java new file mode 100644 index 0000000000..7cfba65c3b --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java @@ -0,0 +1,57 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.push; + +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.RandomUtils; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; + +import java.util.Iterator; +import java.util.List; + +public class HTTPClientPool { + + private List clients = Lists.newArrayList(); + + private int core = 1; + + public HTTPClientPool(int core) { + this.core = core; + } + + public CloseableHttpClient getClient() { + if (CollectionUtils.size(clients) < core) { + CloseableHttpClient client = HttpClients.createDefault(); + clients.add(client); + return client; + } + return clients.get(RandomUtils.nextInt(core, 2 * core) % core); + } + + + public void shutdown() throws Exception { + Iterator itr = clients.iterator(); + while (itr.hasNext()) { + CloseableHttpClient client = itr.next(); + client.close(); + itr.remove(); + } + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java new file mode 100644 index 0000000000..3e961ed7d7 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java @@ -0,0 +1,85 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.push; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.commons.collections4.MapUtils; +import org.apache.eventmesh.common.ThreadPoolFactory; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.MessageHandler; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.HandleMsgContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public class HTTPMessageHandler implements MessageHandler { + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + private static final ScheduledExecutorService SCHEDULER = ThreadPoolFactory.createSingleScheduledExecutor("eventMesh-pushMsgTimeout-"); + + private ThreadPoolExecutor pushExecutor; + + private final Integer CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD = 10000; + + private static Map> waitingRequests = Maps.newConcurrentMap(); + + public HTTPMessageHandler(String consumerGroup, ThreadPoolExecutor pushMsgExecutor) { + this.pushExecutor = pushMsgExecutor; + waitingRequests.put(consumerGroup, Sets.newConcurrentHashSet()); + SCHEDULER.scheduleAtFixedRate(this::checkTimeout, 0, 1000, TimeUnit.MILLISECONDS); + } + + private void checkTimeout() { + waitingRequests.entrySet().stream().forEach(entry -> { + for (AbstractHttpPushRequest request : entry.getValue()) { + request.timeout(); + waitingRequests.get(request.handleMsgContext.getConsumerGroup()).remove(request); + } + }); + } + + @Override + public boolean handle(final HandleMsgContext handleMsgContext) { + Set waitingRequests4Group = MapUtils.getObject(waitingRequests, + handleMsgContext.getConsumerGroup(), Sets.newConcurrentHashSet()); + if (waitingRequests4Group.size() > CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD) { + logger.warn("waitingRequests is too many, so reject, this message will be send back to MQ, consumerGroup:{}, threshold:{}", + handleMsgContext.getConsumerGroup(), CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD); + return false; + } + + try { + pushExecutor.submit(() -> { + AsyncHTTPPushRequest asyncPushRequest = new AsyncHTTPPushRequest(handleMsgContext, waitingRequests); + asyncPushRequest.tryHttpRequest(); + }); + return true; + } catch (RejectedExecutionException e) { + //logger.warn("pushMsgThreadPoolQueue is full, so reject, current task size {}", + //handleMsgContext.getEventMeshHTTPServer().getPushMsgExecutor().getQueue().size(), e); + return false; + } + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java new file mode 100644 index 0000000000..312a4dc503 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java @@ -0,0 +1,43 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.service; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.ConsumerServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SubscribeProcessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.ThreadPoolExecutor; + +public class ConsumerService extends ConsumerServiceGrpc.ConsumerServiceImplBase { + + private Logger logger = LoggerFactory.getLogger(ProducerService.class); + + private EventMeshGrpcServer eventMeshGrpcServer; + + private ThreadPoolExecutor threadPoolExecutor; + + public ConsumerService(EventMeshGrpcServer eventMeshGrpcServer, + ThreadPoolExecutor threadPoolExecutor) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.threadPoolExecutor = threadPoolExecutor; + } + + public void subscribe(Subscription request, StreamObserver responseObserver) { + threadPoolExecutor.submit(() -> { + SubscribeProcessor subscribeProcessor = new SubscribeProcessor(eventMeshGrpcServer); + try { + subscribeProcessor.process(request, responseObserver); + } catch (Exception e) { + logger.error("Error code {}, error message {}", EventMeshRetCode.EVENTMESH_SUBSCRIBE_ERR.getRetCode(), + StatusCode.EVENTMESH_SUBSCRIBE_ERR.getErrMsg(), e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_SUBSCRIBE_ERR, e.getMessage(), + responseObserver); + } + }); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java index 0cf9a89bac..5a03286e37 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -1,36 +1,47 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.service; import io.grpc.stub.StreamObserver; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; public class ServiceUtils { - static public boolean validateHeader(RequestHeader header) { - if (StringUtils.isBlank(header.getIdc()) - || StringUtils.isBlank(header.getPid()) - || !StringUtils.isNumeric(header.getPid()) - || StringUtils.isBlank(header.getSys())) { - return false; - } - return true; + public static boolean validateHeader(RequestHeader header) { + return !StringUtils.isBlank(header.getIdc()) + && !StringUtils.isBlank(header.getPid()) + && StringUtils.isNumeric(header.getPid()) + && !StringUtils.isBlank(header.getSys()); } - static public boolean validateMessage(EventMeshMessage message) { - if (StringUtils.isBlank(message.getUniqueId()) - || StringUtils.isBlank(message.getProducerGroup()) - || StringUtils.isBlank(message.getTopic()) - || StringUtils.isBlank(message.getContent()) - || (StringUtils.isBlank(message.getTtl()))) { + public static boolean validateMessage(EventMeshMessage message) { + return !StringUtils.isBlank(message.getUniqueId()) + && !StringUtils.isBlank(message.getProducerGroup()) + && !StringUtils.isBlank(message.getTopic()) + && !StringUtils.isBlank(message.getContent()) + && (!StringUtils.isBlank(message.getTtl())); + } + + public static boolean validateSubscription(Subscription subscription) { + if (CollectionUtils.isEmpty(subscription.getSubscriptionItemsList()) + || StringUtils.isBlank(subscription.getConsumerGroup())) { return false; } + for (Subscription.SubscriptionItem item : subscription.getSubscriptionItemsList()) { + if (StringUtils.isBlank(item.getTopic()) + || item.getMode() == Subscription.SubscriptionItem.SubscriptionMode.UNRECOGNIZED + || item.getType() == Subscription.SubscriptionItem.SubscriptionType.UNRECOGNIZED) { + return false; + } + } return true; } - static public void sendResp(StatusCode code, StreamObserver responseObserver) { + public static void sendResp(StatusCode code, StreamObserver responseObserver) { Response response = Response.newBuilder() .setRespCode(code.getRetCode()) .setRespMsg(code.getErrMsg()).build(); @@ -38,7 +49,7 @@ static public void sendResp(StatusCode code, StreamObserver responseOb responseObserver.onCompleted(); } - static public void sendResp(StatusCode code, String message, StreamObserver responseObserver) { + public static void sendResp(StatusCode code, String message, StreamObserver responseObserver) { Response response = Response.newBuilder() .setRespCode(code.getRetCode()) .setRespMsg(code.getErrMsg() + " " + message).build(); diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java new file mode 100644 index 0000000000..7f55919bba --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java @@ -0,0 +1,38 @@ +package org.apache.eventmesh.client.grpc; + +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.ConsumerServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EventMeshGrpcConsumer implements AutoCloseable { + + private static Logger logger = LoggerFactory.getLogger(EventMeshGrpcConsumer.class); + + private EventMeshGrpcClientConfig clientConfig; + + private ManagedChannel channel; + + public EventMeshGrpcConsumer(EventMeshGrpcClientConfig clientConfig) { + this.clientConfig = clientConfig; + } + + public void init() { + channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) + .usePlaintext().build(); + } + + public boolean subscribe(Subscription subscription) { + ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); + consumerClient.subscribe(subscription); + return true; + } + + @Override + public void close() throws Exception { + channel.shutdown(); + } +} From 2c97cd9d9803064b0ab3e25dd7e46b3a005483dc Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Fri, 17 Dec 2021 11:39:25 -0500 Subject: [PATCH 06/21] Adding grpc publish and subscribe API examples --- eventmesh-examples/build.gradle | 7 + .../grpc/pub}/AsyncPublishInstance.java | 14 +- .../grpc/sub/SpringBootDemoApplication.java | 30 ++++ .../apache/eventmesh/grpc/sub/SubService.java | 129 ++++++++++++++++++ .../grpc/sub/controller/SubController.java | 67 +++++++++ .../src/main/resources/application.properties | 3 +- .../grpc/processor/SubscribeProcessor.java | 2 +- .../client/grpc/EventMeshGrpcConsumer.java | 15 +- .../client/grpc/EventMeshGrpcProducer.java | 35 +---- .../client/grpc/util/EventMeshClientUtil.java | 29 ++++ 10 files changed, 295 insertions(+), 36 deletions(-) rename {eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/grpc => eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub}/AsyncPublishInstance.java (82%) create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SubService.java create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java diff --git a/eventmesh-examples/build.gradle b/eventmesh-examples/build.gradle index 7b3d7f6537..b46eaa2df7 100644 --- a/eventmesh-examples/build.gradle +++ b/eventmesh-examples/build.gradle @@ -15,6 +15,8 @@ * limitations under the License. */ +def grpcVersion = '1.15.0' + configurations { implementation.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' } @@ -29,6 +31,11 @@ dependencies { implementation "io.cloudevents:cloudevents-json-jackson" implementation "io.openmessaging:openmessaging-api" + implementation "io.grpc:grpc-protobuf:${grpcVersion}" + implementation "io.grpc:grpc-stub:${grpcVersion}" + implementation "io.grpc:grpc-netty:${grpcVersion}" + implementation "io.grpc:grpc-netty-shaded:${grpcVersion}" + compileOnly 'org.projectlombok:lombok:1.18.22' annotationProcessor 'org.projectlombok:lombok:1.18.22' diff --git a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/grpc/AsyncPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java similarity index 82% rename from eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/grpc/AsyncPublishInstance.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java index 107383446a..88c9eb6ef5 100644 --- a/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/grpc/AsyncPublishInstance.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java @@ -15,25 +15,33 @@ * limitations under the License. */ -package org.apache.eventmesh.client.grpc; +package org.apache.eventmesh.grpc.pub; import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.utils.IPUtils; import org.apache.eventmesh.common.utils.RandomStringUtils; import org.apache.eventmesh.common.utils.ThreadUtils; +import org.apache.eventmesh.util.Utils; + +import java.util.Properties; @Slf4j public class AsyncPublishInstance { public static void main(String[] args) throws Exception { + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + final String topic = "FT0-e-80010001-01-1"; EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() - .serverAddr("127.0.0.1") - .serverPort(10205) + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) .producerGroup("EventMeshTest-producerGroup") .env("env") .idc("idc") diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java new file mode 100644 index 0000000000..cf8ffb14b0 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java @@ -0,0 +1,30 @@ +/* + * 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.eventmesh.grpc.sub; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class SpringBootDemoApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootDemoApplication.class, args); + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SubService.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SubService.java new file mode 100644 index 0000000000..b71d4b7381 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SubService.java @@ -0,0 +1,129 @@ +/* + * 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.eventmesh.grpc.sub; + +import org.apache.eventmesh.client.grpc.EventMeshGrpcConsumer; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionType; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; +import org.apache.eventmesh.http.demo.pub.eventmeshmessage.AsyncPublishInstance; +import org.apache.eventmesh.util.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; +import javax.annotation.PreDestroy; +import java.util.Properties; +import java.util.concurrent.CountDownLatch; + +@Component +public class SubService implements InitializingBean { + + public static Logger logger = LoggerFactory.getLogger(SubService.class); + + private EventMeshGrpcConsumer eventMeshGrpcConsumer; + + final Properties properties = Utils.readPropertiesFile("application.properties"); + + final SubscriptionItem subscriptionItem = SubscriptionItem.newBuilder() + .setTopic("TEST-TOPIC-HTTP-ASYNC") + .setMode(SubscriptionMode.CLUSTERING) + .setType(SubscriptionType.ASYNC) + .build(); + + final String localIp = IPUtils.getLocalAddress(); + final String localPort = properties.getProperty("server.port"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + final String url = "http://" + localIp + ":" + localPort + "/sub/test"; + final String env = "P"; + final String idc = "FT"; + final String subsys = "1234"; + + final Subscription subscription = Subscription.newBuilder() + .setUrl(url) + .addSubscriptionItems(subscriptionItem) + .build(); + + // CountDownLatch size is the same as messageSize in AsyncPublishInstance.java (Publisher) + private CountDownLatch countDownLatch = new CountDownLatch(AsyncPublishInstance.messageSize); + + @Override + public void afterPropertiesSet() throws Exception { + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .consumerGroup("EventMeshTest-consumerGroup") + .env(env) + .idc(idc) + .ip(IPUtils.getLocalAddress()) + .sys(subsys) + .pid(String.valueOf(ThreadUtils.getPID())).build(); + + eventMeshGrpcConsumer = new EventMeshGrpcConsumer(eventMeshClientConfig); + eventMeshGrpcConsumer.subscribe(subscription); + + // Wait for all messaged to be consumed + Thread stopThread = new Thread(() -> { + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + logger.info("stopThread start...."); + System.exit(0); + }); + stopThread.start(); + } + + @PreDestroy + public void cleanup() { + logger.info("start destory ...."); + try { + /* List unSubList = new ArrayList<>(); + for (SubscriptionItem item : topicList) { + unSubList.add(item.getTopic()); + }*/ + // eventMeshHttpConsumer.unsubscribe(unSubList, url); + } catch (Exception e) { + e.printStackTrace(); + } + try (final EventMeshGrpcConsumer ignore = eventMeshGrpcConsumer) { + // close consumer + } catch (Exception e) { + e.printStackTrace(); + } + logger.info("end destory."); + } + + /** + * Count the message already consumed + */ + public void consumeMessage(String msg) { + logger.info("consume message {}", msg); + countDownLatch.countDown(); + logger.info("remaining number of messages to be consumed {}", countDownLatch.getCount()); + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java new file mode 100644 index 0000000000..1cf550dc23 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java @@ -0,0 +1,67 @@ +/* + * 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.eventmesh.grpc.sub.controller; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.jackson.JsonFormat; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.grpc.sub.SubService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + + +@Slf4j +@RestController +@RequestMapping("/sub") +public class SubController { + + @Autowired + private SubService subService; + + @RequestMapping(value = "/test", method = RequestMethod.POST) + public String subTest(HttpServletRequest request) { + String content = request.getParameter("content"); + log.info("=======receive message======= {}", content); + Map contentMap = JsonUtils.deserialize(content, HashMap.class); + if (StringUtils.equals(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME, contentMap.get(ProtocolKey.PROTOCOL_TYPE))) { + CloudEvent event = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + .deserialize(content.getBytes(StandardCharsets.UTF_8)); + String data = new String(event.getData().toBytes(), StandardCharsets.UTF_8); + log.info("=======receive data======= {}", data); + } + + subService.consumeMessage(content); + + Map map = new HashMap<>(); + map.put("retCode", 1); + return JsonUtils.serialize(map); + } + +} diff --git a/eventmesh-examples/src/main/resources/application.properties b/eventmesh-examples/src/main/resources/application.properties index 8289cb6b01..51640d82b3 100644 --- a/eventmesh-examples/src/main/resources/application.properties +++ b/eventmesh-examples/src/main/resources/application.properties @@ -17,4 +17,5 @@ server.port=8088 eventmesh.ip=127.0.0.1 eventmesh.http.port=10105 -eventmesh.tcp.port=10000 \ No newline at end of file +eventmesh.tcp.port=10000 +eventmesh.grpc.port=10205 \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java index f99ea2d0ef..d7fbda9cf7 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java @@ -38,4 +38,4 @@ public void process(Subscription subscription, StreamObserver response ConsumerManager consumerManager = eventMeshGrpcServer.getConsumerManager(); consumerManager.handleSubscription(subscription); } -} +} \ No newline at end of file diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java index 7f55919bba..5f1083d5e4 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java @@ -3,7 +3,9 @@ import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; import org.apache.eventmesh.common.protocol.grpc.protos.ConsumerServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,10 +27,17 @@ public void init() { .usePlaintext().build(); } - public boolean subscribe(Subscription subscription) { + public Response subscribe(Subscription subscription) { + logger.info("Subscribe topic " + subscription.toString()); ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); - consumerClient.subscribe(subscription); - return true; + + Subscription enhancedSubscription = Subscription.newBuilder(subscription) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setConsumerGroup(clientConfig.getConsumerGroup()) + .build(); + Response response = consumerClient.subscribe(enhancedSubscription); + logger.info("Received response " + response.toString()); + return response; } @Override diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java index 44c3a9cea3..01203c84bb 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java @@ -4,6 +4,7 @@ import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; @@ -15,9 +16,6 @@ public class EventMeshGrpcProducer implements AutoCloseable { private static Logger logger = LoggerFactory.getLogger(EventMeshGrpcProducer.class); - private final static String PROTOCOL_TYPE = "eventmeshmessage"; - private final static String PROTOCOL_DESC = "grpc"; - private EventMeshGrpcClientConfig clientConfig; private ManagedChannel channel; @@ -34,8 +32,12 @@ public void init() { public Response publish(EventMeshMessage message) { logger.info("Publish message " + message.toString()); PublisherServiceGrpc.PublisherServiceBlockingStub publisherClient = PublisherServiceGrpc.newBlockingStub(channel); - EventMeshMessage newMessage = enhanceMessage(message); - Response response = publisherClient.publish(newMessage); + + EventMeshMessage enhancedMessage = EventMeshMessage.newBuilder(message) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setProducerGroup(clientConfig.getProducerGroup()) + .build(); + Response response = publisherClient.publish(enhancedMessage); logger.info("Received response " + response.toString()); return response; } @@ -43,27 +45,4 @@ public Response publish(EventMeshMessage message) { public void close() { channel.shutdown(); } - - private EventMeshMessage enhanceMessage(EventMeshMessage message) { - RequestHeader header = RequestHeader.newBuilder() - .setEnv(clientConfig.getEnv()) - .setIdc(clientConfig.getIdc()) - .setIp(clientConfig.getIp()) - .setPid(clientConfig.getPid()) - .setSys(clientConfig.getSys()) - .setLanguage(clientConfig.getLanguage()) - .setUsername(clientConfig.getUserName()) - .setPassword(clientConfig.getPassword()) - .setProtocolType(PROTOCOL_TYPE) - .setProtocolDesc(PROTOCOL_DESC) - // default CloudEvents version is V1 - .setProtocolVersion(SpecVersion.V1.toString()) - .build(); - - EventMeshMessage newMessage = EventMeshMessage.newBuilder(message) - .setHeader(header) - .setProducerGroup(clientConfig.getProducerGroup()) - .build(); - return newMessage; - } } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java new file mode 100644 index 0000000000..5cb2907f88 --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java @@ -0,0 +1,29 @@ +package org.apache.eventmesh.client.grpc.util; + +import io.cloudevents.SpecVersion; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; + +public class EventMeshClientUtil { + + private final static String PROTOCOL_TYPE = "eventmeshmessage"; + private final static String PROTOCOL_DESC = "grpc"; + + public static RequestHeader buildHeader(EventMeshGrpcClientConfig clientConfig) { + RequestHeader header = RequestHeader.newBuilder() + .setEnv(clientConfig.getEnv()) + .setIdc(clientConfig.getIdc()) + .setIp(clientConfig.getIp()) + .setPid(clientConfig.getPid()) + .setSys(clientConfig.getSys()) + .setLanguage(clientConfig.getLanguage()) + .setUsername(clientConfig.getUserName()) + .setPassword(clientConfig.getPassword()) + .setProtocolType(PROTOCOL_TYPE) + .setProtocolDesc(PROTOCOL_DESC) + // default CloudEvents version is V1 + .setProtocolVersion(SpecVersion.V1.toString()) + .build(); + return header; + } +} From 3298e3dfd6cc44d63b85e45cefb36faa880f96d6 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Fri, 17 Dec 2021 16:15:25 -0500 Subject: [PATCH 07/21] grpc consumer api testing and bug fixing --- .../grpc/pub/AsyncPublishInstance.java | 15 ++++-- .../grpc/sub/controller/SubController.java | 2 +- .../grpc/sub/{ => service}/SubService.java | 5 +- .../MeshMessageProtocolAdaptor.java | 3 +- .../grpc/consumer/ConsumerManager.java | 41 +++------------- .../grpc/consumer/EventMeshConsumer.java | 48 +++++++++++++++++-- .../ConsumerGroupTopicConfig.java | 4 +- .../grpc/processor/SubscribeProcessor.java | 30 +++++++++++- .../grpc/push/AsyncHTTPPushRequest.java | 1 - 9 files changed, 99 insertions(+), 50 deletions(-) rename eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/{ => service}/SubService.java (97%) diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java index 88c9eb6ef5..d8de043604 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java @@ -22,22 +22,28 @@ import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.common.utils.RandomStringUtils; import org.apache.eventmesh.common.utils.ThreadUtils; import org.apache.eventmesh.util.Utils; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; @Slf4j public class AsyncPublishInstance { + // This messageSize is also used in SubService.java (Subscriber) + public static int messageSize = 5; + public static void main(String[] args) throws Exception { Properties properties = Utils.readPropertiesFile("application.properties"); final String eventMeshIp = properties.getProperty("eventmesh.ip"); final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); - final String topic = "FT0-e-80010001-01-1"; + final String topic = "TEST-TOPIC-HTTP-ASYNC"; EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() .serverAddr(eventMeshIp) @@ -53,9 +59,12 @@ public static void main(String[] args) throws Exception { eventMeshGrpcProducer.init(); - for (int i = 0; i < 1; i++) { + Map content = new HashMap<>(); + content.put("content", "testAsyncMessage"); + + for (int i = 0; i < messageSize; i++) { EventMeshMessage message = EventMeshMessage.newBuilder() - .setContent("testPublishMessage") + .setContent(JsonUtils.serialize(content)) .setTopic(topic) .setUniqueId(RandomStringUtils.generateNum(30)) .setSeqNum(RandomStringUtils.generateNum(30)) diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java index 1cf550dc23..91ebec357d 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java @@ -25,7 +25,7 @@ import org.apache.eventmesh.client.tcp.common.EventMeshCommon; import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.grpc.sub.SubService; +import org.apache.eventmesh.grpc.sub.service.SubService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SubService.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/service/SubService.java similarity index 97% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SubService.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/service/SubService.java index b71d4b7381..90ff0c7190 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SubService.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/service/SubService.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.eventmesh.grpc.sub; +package org.apache.eventmesh.grpc.sub.service; import org.apache.eventmesh.client.grpc.EventMeshGrpcConsumer; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; @@ -27,7 +27,7 @@ import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionType; import org.apache.eventmesh.common.utils.IPUtils; import org.apache.eventmesh.common.utils.ThreadUtils; -import org.apache.eventmesh.http.demo.pub.eventmeshmessage.AsyncPublishInstance; +import org.apache.eventmesh.grpc.pub.AsyncPublishInstance; import org.apache.eventmesh.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -83,6 +83,7 @@ public void afterPropertiesSet() throws Exception { .pid(String.valueOf(ThreadUtils.getPID())).build(); eventMeshGrpcConsumer = new EventMeshGrpcConsumer(eventMeshClientConfig); + eventMeshGrpcConsumer.init(); eventMeshGrpcConsumer.subscribe(subscription); // Wait for all messaged to be consumed diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java index e94508a1ff..1aef89f721 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java @@ -105,7 +105,8 @@ public List toBatchCloudEvent(ProtocolTransportObject protocol) thro public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException { String protocolDesc = cloudEvent.getExtension(Constants.PROTOCOL_DESC).toString(); - if (StringUtils.equals("http", protocolDesc)) { + // both http and grpc consumers are using HTTP webhook to send send message to target URL + if (StringUtils.equals("http", protocolDesc) || StringUtils.equals("grpc", protocolDesc)) { HttpCommand httpCommand = new HttpCommand(); Body body = new Body() { final Map map = new HashMap<>(); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java index bd5c25f65f..aafc9d01c4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -1,8 +1,6 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; import org.apache.commons.lang3.StringUtils; -import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; -import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.common.ServiceState; @@ -11,7 +9,6 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; @@ -42,39 +39,13 @@ public void start() throws Exception { } public void shutdown() throws Exception { - for (EventMeshConsumer consumer: consumerTable.values()) { + for (EventMeshConsumer consumer : consumerTable.values()) { consumer.shutdown(); } logger.info("Grpc ConsumerManager shutdown......"); } - public void handleSubscription(Subscription subscription) throws Exception { - RequestHeader header = subscription.getHeader(); - String consumerGroup = subscription.getConsumerGroup(); - String url = subscription.getUrl(); - List subscriptionItems = subscription.getSubscriptionItemsList(); - - for (Subscription.SubscriptionItem item : subscriptionItems) { - ConsumerGroupClient newClient = ConsumerGroupClient.builder() - .env(header.getEnv()) - .idc(header.getIdc()) - .sys(header.getSys()) - .ip(header.getIp()) - .pid(header.getPid()) - .consumerGroup(consumerGroup) - .topic(item.getTopic()) - .subscriptionMode(item.getMode()) - .url(url) - .lastUpTime(new Date()) - .build(); - - registerClient(newClient); - } - - restartEventMeshConsumer(consumerGroup); - } - - private void registerClient(ConsumerGroupClient newClient) { + public void registerClient(ConsumerGroupClient newClient) { String consumerGroup = newClient.getConsumerGroup(); String topic = newClient.getTopic(); String url = newClient.getUrl(); @@ -82,9 +53,9 @@ private void registerClient(ConsumerGroupClient newClient) { List localClients = clientTable.get(consumerGroup); if (localClients == null) { - List newClients = new ArrayList<>(); - newClients.add(newClient); - clientTable.put(consumerGroup, newClients); + localClients = new ArrayList<>(); + localClients.add(newClient); + clientTable.put(consumerGroup, localClients); } else { boolean isContains = false; for (ConsumerGroupClient localClient : localClients) { @@ -101,7 +72,7 @@ private void registerClient(ConsumerGroupClient newClient) { } } - private void restartEventMeshConsumer(String consumerGroup) throws Exception { + public void restartEventMeshConsumer(String consumerGroup) throws Exception { EventMeshConsumer eventMeshConsumer = consumerTable.get(consumerGroup); if (eventMeshConsumer == null) { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java index 81953241c6..f49ca39fdb 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java @@ -1,12 +1,14 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; -import com.google.common.collect.Maps; import io.cloudevents.CloudEvent; import io.cloudevents.core.builder.CloudEventBuilder; import org.apache.eventmesh.api.AbstractContext; import org.apache.eventmesh.api.EventListener; import org.apache.eventmesh.api.EventMeshAction; import org.apache.eventmesh.api.EventMeshAsyncConsumeContext; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.OnExceptionContext; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; @@ -16,6 +18,8 @@ import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.plugin.MQConsumerWrapper; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; import org.apache.eventmesh.runtime.core.protocol.grpc.push.HTTPMessageHandler; import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.slf4j.Logger; @@ -26,6 +30,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; public class EventMeshConsumer { @@ -49,7 +54,7 @@ public class EventMeshConsumer { * Key: topic * Value: ConsumerGroupTopicConfig **/ - private Map consumerGroupTopicConfig = Maps.newConcurrentMap(); + private final Map consumerGroupTopicConfig = new ConcurrentHashMap<>(); public EventMeshConsumer(EventMeshGrpcServer eventMeshGrpcServer, String consumerGroup) { this.eventMeshGrpcServer = eventMeshGrpcServer; @@ -182,14 +187,49 @@ private EventListener createEventListener(SubscriptionMode subscriptionMode) { ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); if (topicConfig != null) { - HandleMsgContext handleMsgContext = new HandleMsgContext(EventMeshUtil.buildPushMsgSeqNo(), consumerGroup, this, topic, event, subscriptionMode, eventMeshAsyncConsumeContext.getAbstractContext(), eventMeshGrpcServer, strBizSeqNo, strUniqueId, topicConfig); - httpMessageHandler.handle(handleMsgContext); + + if (httpMessageHandler.handle(handleMsgContext)) { + eventMeshAsyncConsumeContext.commit(EventMeshAction.ManualAck); + return; + } else { + // can not handle the message due to the capacity limit is reached + // wait for sometime and send this message back to mq and consume again + try { + Thread.sleep(5000); + sendMessageBack(consumerGroup, event, strUniqueId, strBizSeqNo); + } catch (Exception ignored) { + // ignore exception + } + } } eventMeshAsyncConsumeContext.commit(EventMeshAction.CommitMessage); }; } + + public void sendMessageBack(String consumerGroup, final CloudEvent event, final String uniqueId, String bizSeqNo) throws Exception { + EventMeshProducer producer + = eventMeshGrpcServer.getProducerManager().getEventMeshProducer(consumerGroup); + + if (producer == null) { + logger.warn("consumer:{} consume fail, sendMessageBack, bizSeqNo:{}, uniqueId:{}", consumerGroup, bizSeqNo, uniqueId); + return; + } + + final SendMessageContext sendMessageBackContext = new SendMessageContext(bizSeqNo, event, producer, eventMeshGrpcServer); + + producer.send(sendMessageBackContext, new SendCallback() { + @Override + public void onSuccess(SendResult sendResult) { + } + + @Override + public void onException(OnExceptionContext context) { + logger.warn("consumer:{} consume fail, sendMessageBack, bizSeqNo:{}, uniqueId:{}", consumerGroup, bizSeqNo, uniqueId); + } + }); + } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java index 9b75486efd..d477ddb1ba 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java @@ -1,6 +1,5 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; -import com.google.common.collect.Maps; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -9,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; public class ConsumerGroupTopicConfig { public static Logger logger = LoggerFactory.getLogger(ConsumerGroupTopicConfig.class); @@ -25,7 +25,7 @@ public class ConsumerGroupTopicConfig { * Key: IDC * Value: list of URls */ - private Map> idcUrls = Maps.newConcurrentMap(); + private Map> idcUrls = new ConcurrentHashMap<>(); public ConsumerGroupTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode) { this.consumerGroup = consumerGroup; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java index d7fbda9cf7..0eee34ece4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java @@ -7,10 +7,14 @@ import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Date; +import java.util.List; + public class SubscribeProcessor { private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); @@ -36,6 +40,30 @@ public void process(Subscription subscription, StreamObserver response } ConsumerManager consumerManager = eventMeshGrpcServer.getConsumerManager(); - consumerManager.handleSubscription(subscription); + + String consumerGroup = subscription.getConsumerGroup(); + String url = subscription.getUrl(); + List subscriptionItems = subscription.getSubscriptionItemsList(); + + for (Subscription.SubscriptionItem item : subscriptionItems) { + ConsumerGroupClient newClient = ConsumerGroupClient.builder() + .env(header.getEnv()) + .idc(header.getIdc()) + .sys(header.getSys()) + .ip(header.getIp()) + .pid(header.getPid()) + .consumerGroup(consumerGroup) + .topic(item.getTopic()) + .subscriptionMode(item.getMode()) + .url(url) + .lastUpTime(new Date()) + .build(); + + consumerManager.registerClient(newClient); + } + + consumerManager.restartEventMeshConsumer(consumerGroup); + + ServiceUtils.sendResp(StatusCode.SUCCESS, "subscribe success", responseObserver); } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java index e30ad238bc..2a4b39a81c 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java @@ -26,7 +26,6 @@ import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.exception.JsonException; import org.apache.eventmesh.common.protocol.ProtocolTransportObject; -import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; import org.apache.eventmesh.common.protocol.http.common.ClientRetCode; From 120addc34bf1ffa058bd6357e67904b4d70c2a75 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Fri, 17 Dec 2021 16:47:02 -0500 Subject: [PATCH 08/21] minor enhancement to grpc consumer --- .../runtime/core/protocol/grpc/consumer/ConsumerManager.java | 3 ++- .../runtime/core/protocol/grpc/consumer/EventMeshConsumer.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java index aafc9d01c4..fcf414e5ad 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -45,7 +45,7 @@ public void shutdown() throws Exception { logger.info("Grpc ConsumerManager shutdown......"); } - public void registerClient(ConsumerGroupClient newClient) { + public synchronized void registerClient(ConsumerGroupClient newClient) { String consumerGroup = newClient.getConsumerGroup(); String topic = newClient.getTopic(); String url = newClient.getUrl(); @@ -100,6 +100,7 @@ public void restartEventMeshConsumer(String consumerGroup) throws Exception { // determine if restart eventMeshConsumer required Set newTopicConfigs = eventMeshConsumer.buildTopicConfig(); if (!oldTopicConfigs.equals(newTopicConfigs)) { + logger.info("Consumergroup {} topic info changed, restart EventMeshConsumer.", consumerGroup); if (ServiceState.RUNNING.equals(eventMeshConsumer.getStatus())) { eventMeshConsumer.shutdown(); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java index f49ca39fdb..735f85ffb3 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java @@ -74,7 +74,7 @@ public synchronized void addTopicConfig(String topic, SubscriptionMode subscript topicConfig.addUrl(idc, url); } - public Set buildTopicConfig() { + public synchronized Set buildTopicConfig() { Set topicConfigs = new HashSet<>(); for (ConsumerGroupTopicConfig topicConfig : consumerGroupTopicConfig.values()) { topicConfigs.add(topicConfig.getTopic() + topicConfig.getSubscriptionMode().name()); From 77f0d74fb522d60113d8f9941be4a22224535a13 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Tue, 21 Dec 2021 14:45:45 -0500 Subject: [PATCH 09/21] GRPC consumer Stream API --- .../grpc/pub/AsyncPublishInstance.java | 9 +- .../eventmesh/grpc/sub/AsyncSubscribe.java | 60 +++++++++ .../{ => app}/SpringBootDemoApplication.java | 2 +- .../{ => app}/controller/SubController.java | 4 +- .../sub/{ => app}/service/SubService.java | 12 +- .../MeshMessageProtocolAdaptor.java | 5 +- .../grpc/GrpcMessageProtocolResolver.java | 46 +++++++ .../runtime/boot/EventMeshGrpcServer.java | 40 +++++- .../grpc/consumer/ConsumerManager.java | 21 +++- .../grpc/consumer/EventMeshConsumer.java | 25 +++- .../consumergroup/ConsumerGroupClient.java | 37 +++--- .../ConsumerGroupTopicConfig.java | 46 ++++++- .../grpc/interceptor/MetricsInterceptor.java | 2 +- .../grpc/processor/SubscribeProcessor.java | 4 +- .../processor/SubscribeStreamProcessor.java | 87 +++++++++++++ ...hRequest.java => AbstractPushRequest.java} | 54 ++------ .../protocol/grpc/push/HTTPClientPool.java | 57 --------- .../{consumer => push}/HandleMsgContext.java | 3 +- ...PPushRequest.java => HttpPushRequest.java} | 80 +++++++++--- ...essageHandler.java => MessageHandler.java} | 34 +++-- .../protocol/grpc/push/StreamPushRequest.java | 118 ++++++++++++++++++ .../grpc/service/ConsumerService.java | 43 ++++++- .../grpc/service/ProducerService.java | 3 +- .../protocol/grpc/service/ServiceUtils.java | 9 +- .../client/grpc/EventMeshGrpcConsumer.java | 63 +++++++++- .../eventmesh/client/grpc/ReceiveMsgHook.java | 19 ++- .../config/EventMeshGrpcClientConfig.java | 8 -- .../client/grpc/util/EventMeshClientUtil.java | 6 +- 28 files changed, 686 insertions(+), 211 deletions(-) create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java rename eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/{ => app}/SpringBootDemoApplication.java (96%) rename eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/{ => app}/controller/SubController.java (95%) rename eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/{ => app}/service/SubService.java (93%) create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java rename eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/{AbstractHttpPushRequest.java => AbstractPushRequest.java} (62%) delete mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java rename eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/{consumer => push}/HandleMsgContext.java (97%) rename eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/{AsyncHTTPPushRequest.java => HttpPushRequest.java} (83%) rename eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/{HTTPMessageHandler.java => MessageHandler.java} (70%) create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java rename eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java => eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/ReceiveMsgHook.java (70%) diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java index d8de043604..53dd34d8b4 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java @@ -43,17 +43,14 @@ public static void main(String[] args) throws Exception { final String eventMeshIp = properties.getProperty("eventmesh.ip"); final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); - final String topic = "TEST-TOPIC-HTTP-ASYNC"; + final String topic = "TEST-TOPIC-GRPC-ASYNC"; EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() .serverAddr(eventMeshIp) .serverPort(Integer.parseInt(eventMeshGrpcPort)) .producerGroup("EventMeshTest-producerGroup") - .env("env") - .idc("idc") - .ip(IPUtils.getLocalAddress()) - .sys("1234") - .pid(String.valueOf(ThreadUtils.getPID())).build(); + .env("env").idc("idc") + .sys("1234").build(); EventMeshGrpcProducer eventMeshGrpcProducer = new EventMeshGrpcProducer(eventMeshClientConfig); diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java new file mode 100644 index 0000000000..1f41ae4d5c --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java @@ -0,0 +1,60 @@ +package org.apache.eventmesh.grpc.sub; + +import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.EventMeshGrpcConsumer; +import org.apache.eventmesh.client.grpc.ReceiveMsgHook; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem; +import org.apache.eventmesh.util.Utils; + +import java.util.Optional; +import java.util.Properties; + +@Slf4j +public class AsyncSubscribe implements ReceiveMsgHook { + + public static AsyncSubscribe handler = new AsyncSubscribe(); + + public static void main(String[] args) { + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + + final String topic = "TEST-TOPIC-GRPC-ASYNC"; + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .producerGroup("EventMeshTest-consumerGroup") + .env("env").idc("idc") + .sys("1234").build(); + + SubscriptionItem subscriptionItem = SubscriptionItem.newBuilder() + .setTopic(topic) + .setMode(Subscription.SubscriptionItem.SubscriptionMode.CLUSTERING) + .setType(Subscription.SubscriptionItem.SubscriptionType.ASYNC) + .build(); + + Subscription subscription = Subscription.newBuilder() + .addSubscriptionItems(subscriptionItem) + .build(); + + + EventMeshGrpcConsumer eventMeshGrpcConsumer = new EventMeshGrpcConsumer(eventMeshClientConfig); + + eventMeshGrpcConsumer.init(); + + eventMeshGrpcConsumer.registerListener(handler); + + eventMeshGrpcConsumer.subscribeStream(subscription); + + } + + @Override + public Optional handle(EventMeshMessage msg) { + log.info("receive async msg====================={}", msg); + return Optional.empty(); + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/SpringBootDemoApplication.java similarity index 96% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/SpringBootDemoApplication.java index cf8ffb14b0..0168b4f727 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/SpringBootDemoApplication.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/SpringBootDemoApplication.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.grpc.sub; +package org.apache.eventmesh.grpc.sub.app; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/controller/SubController.java similarity index 95% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/controller/SubController.java index 91ebec357d..cb5b8489ed 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/controller/SubController.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/controller/SubController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.grpc.sub.controller; +package org.apache.eventmesh.grpc.sub.app.controller; import io.cloudevents.CloudEvent; import io.cloudevents.core.provider.EventFormatProvider; @@ -25,7 +25,7 @@ import org.apache.eventmesh.client.tcp.common.EventMeshCommon; import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.grpc.sub.service.SubService; +import org.apache.eventmesh.grpc.sub.app.service.SubService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/service/SubService.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java similarity index 93% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/service/SubService.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java index 90ff0c7190..995cf734cf 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/service/SubService.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.eventmesh.grpc.sub.service; +package org.apache.eventmesh.grpc.sub.app.service; import org.apache.eventmesh.client.grpc.EventMeshGrpcConsumer; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; @@ -26,7 +26,6 @@ import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionType; import org.apache.eventmesh.common.utils.IPUtils; -import org.apache.eventmesh.common.utils.ThreadUtils; import org.apache.eventmesh.grpc.pub.AsyncPublishInstance; import org.apache.eventmesh.util.Utils; import org.slf4j.Logger; @@ -47,7 +46,7 @@ public class SubService implements InitializingBean { final Properties properties = Utils.readPropertiesFile("application.properties"); final SubscriptionItem subscriptionItem = SubscriptionItem.newBuilder() - .setTopic("TEST-TOPIC-HTTP-ASYNC") + .setTopic("TEST-TOPIC-GRPC-ASYNC") .setMode(SubscriptionMode.CLUSTERING) .setType(SubscriptionType.ASYNC) .build(); @@ -76,11 +75,8 @@ public void afterPropertiesSet() throws Exception { .serverAddr(eventMeshIp) .serverPort(Integer.parseInt(eventMeshGrpcPort)) .consumerGroup("EventMeshTest-consumerGroup") - .env(env) - .idc(idc) - .ip(IPUtils.getLocalAddress()) - .sys(subsys) - .pid(String.valueOf(ThreadUtils.getPID())).build(); + .env(env).idc(idc) + .sys(subsys).build(); eventMeshGrpcConsumer = new EventMeshGrpcConsumer(eventMeshClientConfig); eventMeshGrpcConsumer.init(); diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java index 1aef89f721..f4992ed574 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java @@ -105,8 +105,7 @@ public List toBatchCloudEvent(ProtocolTransportObject protocol) thro public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException { String protocolDesc = cloudEvent.getExtension(Constants.PROTOCOL_DESC).toString(); - // both http and grpc consumers are using HTTP webhook to send send message to target URL - if (StringUtils.equals("http", protocolDesc) || StringUtils.equals("grpc", protocolDesc)) { + if (StringUtils.equals("http", protocolDesc)) { HttpCommand httpCommand = new HttpCommand(); Body body = new Body() { final Map map = new HashMap<>(); @@ -120,6 +119,8 @@ public Map toMap() { body.toMap(); httpCommand.setBody(body); return httpCommand; + } else if (StringUtils.equals("grpc", protocolDesc)) { + return GrpcMessageProtocolResolver.buildEventMeshMessage(cloudEvent); } else if (StringUtils.equals("tcp", protocolDesc)) { return TcpMessageProtocolResolver.buildEventMeshMessage(cloudEvent); } else { diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java index f7fccb1680..50e3f002a6 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java @@ -4,13 +4,17 @@ import io.cloudevents.SpecVersion; import io.cloudevents.core.builder.CloudEventBuilder; import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; import org.apache.eventmesh.common.protocol.grpc.common.ProtocolKey; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; import java.net.URI; import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; public class GrpcMessageProtocolResolver { @@ -94,4 +98,46 @@ public static CloudEvent buildEvent(EventMeshMessage message) throws ProtocolHan throw new ProtocolHandleException(e.getMessage(), e.getCause()); } } + + public static EventMeshMessageWrapper buildEventMeshMessage(CloudEvent cloudEvent) { + String env = cloudEvent.getExtension(ProtocolKey.ENV) == null ? null : cloudEvent.getExtension(ProtocolKey.ENV).toString(); + String idc = cloudEvent.getExtension(ProtocolKey.IDC) == null ? null : cloudEvent.getExtension(ProtocolKey.IDC).toString(); + String ip = cloudEvent.getExtension(ProtocolKey.IP) == null ? null : cloudEvent.getExtension(ProtocolKey.IP).toString(); + String pid = cloudEvent.getExtension(ProtocolKey.PID) == null ? null : cloudEvent.getExtension(ProtocolKey.PID).toString(); + String sys = cloudEvent.getExtension(ProtocolKey.SYS) == null ? null : cloudEvent.getExtension(ProtocolKey.SYS).toString(); + String userName = cloudEvent.getExtension(ProtocolKey.USERNAME) == null ? null : cloudEvent.getExtension(ProtocolKey.USERNAME).toString(); + String passwd = cloudEvent.getExtension(ProtocolKey.PASSWD) == null ? null : cloudEvent.getExtension(ProtocolKey.PASSWD).toString(); + String language = cloudEvent.getExtension(ProtocolKey.LANGUAGE) == null ? null : cloudEvent.getExtension(ProtocolKey.LANGUAGE).toString(); + String protocol = cloudEvent.getExtension(ProtocolKey.PROTOCOL_TYPE) == null ? null : + cloudEvent.getExtension(ProtocolKey.PROTOCOL_TYPE).toString(); + String protocolDesc = cloudEvent.getExtension(ProtocolKey.PROTOCOL_DESC) == null ? null : + cloudEvent.getExtension(ProtocolKey.PROTOCOL_DESC).toString(); + String protocolVersion = cloudEvent.getExtension(ProtocolKey.PROTOCOL_VERSION) == null ? null : + cloudEvent.getExtension(ProtocolKey.PROTOCOL_VERSION).toString(); + String seqNum = cloudEvent.getExtension(ProtocolKey.SEQ_NUM) == null ? null : cloudEvent.getExtension(ProtocolKey.SEQ_NUM).toString(); + String uniqueId = cloudEvent.getExtension(ProtocolKey.UNIQUE_ID) == null ? null : cloudEvent.getExtension(ProtocolKey.UNIQUE_ID).toString(); + String producerGroup = cloudEvent.getExtension(ProtocolKey.PRODUCERGROUP) == null ? null : + cloudEvent.getExtension(ProtocolKey.PRODUCERGROUP).toString(); + String ttl = cloudEvent.getExtension(ProtocolKey.TTL) == null ? null : cloudEvent.getExtension(ProtocolKey.TTL).toString(); + + RequestHeader header = RequestHeader.newBuilder() + .setEnv(env).setIdc(idc) + .setIp(ip).setPid(pid) + .setSys(sys).setUsername(userName).setPassword(passwd) + .setLanguage(language).setProtocolType(protocol) + .setProtocolDesc(protocolDesc).setProtocolVersion(protocolVersion) + .build(); + + EventMeshMessage eventMeshMessage = EventMeshMessage.newBuilder() + .setHeader(header) + .setContent(new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8)) + .setProducerGroup(producerGroup) + .setSeqNum(seqNum) + .setUniqueId(uniqueId) + .setTopic(cloudEvent.getSubject()) + .setTtl(ttl) + .build(); + + return new EventMeshMessageWrapper(eventMeshMessage); + } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java index ee88ee9c6b..ac87e66219 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java @@ -2,6 +2,7 @@ import io.grpc.Server; import io.grpc.ServerBuilder; +import org.apache.commons.lang3.RandomUtils; import org.apache.eventmesh.common.ThreadPoolFactory; import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; @@ -10,9 +11,15 @@ import org.apache.eventmesh.runtime.core.protocol.grpc.retry.GrpcRetryer; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ConsumerService; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ProducerService; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; @@ -37,6 +44,8 @@ public class EventMeshGrpcServer { private ThreadPoolExecutor pushMsgExecutor; + private List httpClientPool; + public EventMeshGrpcServer(EventMeshGrpcConfiguration eventMeshGrpcConfiguration) { this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; } @@ -46,7 +55,7 @@ public void init() throws Exception { initThreadPool(); - int serverPort = eventMeshGrpcConfiguration.grpcServerPort; + initHttpClientPool(); producerManager = new ProducerManager(this); producerManager.init(); @@ -57,6 +66,8 @@ public void init() throws Exception { grpcRetryer = new GrpcRetryer(this); grpcRetryer.init(); + int serverPort = eventMeshGrpcConfiguration.grpcServerPort; + server = ServerBuilder.forPort(serverPort) .intercept(new MetricsInterceptor()) .addService(new ProducerService(this, sendMsgExecutor)) @@ -86,6 +97,7 @@ public void shutdown() throws Exception { grpcRetryer.shutdown(); shutdownThreadPools(); + shutdownHttpClientPool(); server.shutdown(); @@ -120,6 +132,11 @@ public ThreadPoolExecutor getPushMsgExecutor() { return pushMsgExecutor; } + public CloseableHttpClient getHttpClient() { + int size = httpClientPool.size(); + return httpClientPool.get(RandomUtils.nextInt(size, 2 * size) % size); + } + private void initThreadPool() { BlockingQueue sendMsgThreadPoolQueue = new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSendMsgBlockQSize); @@ -142,9 +159,30 @@ private void initThreadPool() { "eventMesh-grpc-pushMsg-", true); } + private void initHttpClientPool() { + httpClientPool = new LinkedList<>(); + for (int i = 0; i < 8; i++) { + CloseableHttpClient client = HttpClients.createDefault(); + httpClientPool.add(client); + } + } + private void shutdownThreadPools() { sendMsgExecutor.shutdown(); subscribeMsgExecutor.shutdown(); pushMsgExecutor.shutdown(); } + + private void shutdownHttpClientPool() { + Iterator itr = httpClientPool.iterator(); + while (itr.hasNext()) { + CloseableHttpClient client = itr.next(); + try { + client.close(); + } catch (Exception e) { + // ignored + } + itr.remove(); + } + } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java index fcf414e5ad..fc3f4230ca 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -48,7 +48,10 @@ public void shutdown() throws Exception { public synchronized void registerClient(ConsumerGroupClient newClient) { String consumerGroup = newClient.getConsumerGroup(); String topic = newClient.getTopic(); + String protocol = newClient.getProtocolDesc(); String url = newClient.getUrl(); + String ip = newClient.getIp(); + String pid = newClient.getPid(); SubscriptionMode subscriptionMode = newClient.getSubscriptionMode(); List localClients = clientTable.get(consumerGroup); @@ -59,7 +62,14 @@ public synchronized void registerClient(ConsumerGroupClient newClient) { } else { boolean isContains = false; for (ConsumerGroupClient localClient : localClients) { - if (StringUtils.equals(localClient.getTopic(), topic) && StringUtils.equals(localClient.getUrl(), url) + if ("grpc".equals(protocol) && StringUtils.equals(localClient.getTopic(), topic) + && StringUtils.equals(localClient.getUrl(), url) + && localClient.getSubscriptionMode().equals(subscriptionMode)) { + isContains = true; + localClient.setLastUpTime(newClient.getLastUpTime()); + break; + } else if ("grpc_stream".equals(protocol) && StringUtils.equals(localClient.getTopic(), topic) + && StringUtils.equals(localClient.getIp(), ip) && StringUtils.equals(localClient.getPid(), pid) && localClient.getSubscriptionMode().equals(subscriptionMode)) { isContains = true; localClient.setLastUpTime(newClient.getLastUpTime()); @@ -84,11 +94,18 @@ public void restartEventMeshConsumer(String consumerGroup) throws Exception { Set oldTopicConfigs = eventMeshConsumer.buildTopicConfig(); List localClients = clientTable.get(consumerGroup); for (ConsumerGroupClient client : localClients) { + String protocolDesc = client.getProtocolDesc(); String topic = client.getTopic(); String idc = client.getIdc(); String url = client.getUrl(); + String ip = client.getIp(); + String pid = client.getPid(); SubscriptionMode subscriptionMode = client.getSubscriptionMode(); - eventMeshConsumer.addTopicConfig(topic, subscriptionMode, idc, url); + if ("grpc".equals(protocolDesc)) { + eventMeshConsumer.addTopicConfig(topic, subscriptionMode, protocolDesc, idc, url); + } else if ("grpc_stream".equals(protocolDesc)) { + eventMeshConsumer.addTopicConfig(topic, subscriptionMode, protocolDesc, idc, ip, pid, client.getEventEmitter()); + } } // start up eventMeshConsumer the first time diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java index 735f85ffb3..9b33dc7fd9 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java @@ -2,6 +2,7 @@ import io.cloudevents.CloudEvent; import io.cloudevents.core.builder.CloudEventBuilder; +import io.grpc.stub.StreamObserver; import org.apache.eventmesh.api.AbstractContext; import org.apache.eventmesh.api.EventListener; import org.apache.eventmesh.api.EventMeshAction; @@ -10,6 +11,7 @@ import org.apache.eventmesh.api.SendResult; import org.apache.eventmesh.api.exception.OnExceptionContext; import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; @@ -20,7 +22,8 @@ import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; -import org.apache.eventmesh.runtime.core.protocol.grpc.push.HTTPMessageHandler; +import org.apache.eventmesh.runtime.core.protocol.grpc.push.HandleMsgContext; +import org.apache.eventmesh.runtime.core.protocol.grpc.push.MessageHandler; import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +49,7 @@ public class EventMeshConsumer { private final MQConsumerWrapper broadcastMqConsumer; - private final HTTPMessageHandler httpMessageHandler; + private final MessageHandler messageHandler; private ServiceState serviceState; @@ -60,15 +63,25 @@ public EventMeshConsumer(EventMeshGrpcServer eventMeshGrpcServer, String consume this.eventMeshGrpcServer = eventMeshGrpcServer; this.eventMeshGrpcConfiguration = eventMeshGrpcServer.getEventMeshGrpcConfiguration(); this.consumerGroup = consumerGroup; - this.httpMessageHandler = new HTTPMessageHandler(consumerGroup, eventMeshGrpcServer.getPushMsgExecutor()); + this.messageHandler = new MessageHandler(consumerGroup, eventMeshGrpcServer.getPushMsgExecutor()); this.persistentMqConsumer = new MQConsumerWrapper(eventMeshGrpcConfiguration.eventMeshConnectorPluginType); this.broadcastMqConsumer = new MQConsumerWrapper(eventMeshGrpcConfiguration.eventMeshConnectorPluginType); } - public synchronized void addTopicConfig(String topic, SubscriptionMode subscriptionMode, String idc, String url) { + public synchronized void addTopicConfig(String topic, SubscriptionMode subscriptionMode, String protocolDesc, String idc, + String clientIp, String clientPid, StreamObserver eventEmitter) { ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); if (topicConfig == null) { - topicConfig = new ConsumerGroupTopicConfig(consumerGroup, topic, subscriptionMode); + topicConfig = new ConsumerGroupTopicConfig(consumerGroup, topic, subscriptionMode, protocolDesc); + consumerGroupTopicConfig.put(topic, topicConfig); + } + topicConfig.addEmitter(idc, clientIp, clientPid, eventEmitter); + } + + public synchronized void addTopicConfig(String topic, SubscriptionMode subscriptionMode, String protocolDesc, String idc, String url) { + ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); + if (topicConfig == null) { + topicConfig = new ConsumerGroupTopicConfig(consumerGroup, topic, subscriptionMode, protocolDesc); consumerGroupTopicConfig.put(topic, topicConfig); } topicConfig.addUrl(idc, url); @@ -192,7 +205,7 @@ private EventListener createEventListener(SubscriptionMode subscriptionMode) { topic, event, subscriptionMode, eventMeshAsyncConsumeContext.getAbstractContext(), eventMeshGrpcServer, strBizSeqNo, strUniqueId, topicConfig); - if (httpMessageHandler.handle(handleMsgContext)) { + if (messageHandler.handle(topicConfig.getProtocolDesc(), handleMsgContext)) { eventMeshAsyncConsumeContext.commit(EventMeshAction.ManualAck); return; } else { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java index 7192b3321f..8297cd6927 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java @@ -16,14 +16,18 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; -import lombok.Builder; -import lombok.Data; +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import java.util.Date; +import lombok.Builder; +import lombok.Data; + @Builder @Data public class ConsumerGroupClient { @@ -36,8 +40,12 @@ public class ConsumerGroupClient { private String topic; + private String protocolDesc; + private String url; + private StreamObserver eventEmitter; + private SubscriptionMode subscriptionMode; private String sys; @@ -54,19 +62,18 @@ public class ConsumerGroupClient { @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("endPoint={env=").append(env) - .append(",idc=").append(idc) - .append(",consumerGroup=").append(consumerGroup) - .append(",topic=").append(topic) - .append(",url=").append(url) - .append(",sys=").append(sys) - .append(",ip=").append(ip) - .append(",pid=").append(pid) - .append(",hostname=").append(hostname) - .append(",apiVersion=").append(apiVersion) - .append(",registerTime=").append("}"); - return sb.toString(); + return "endPoint={env=" + env + + ",idc=" + idc + + ",consumerGroup=" + consumerGroup + + ",topic=" + topic + + ",protocolDesc=" + protocolDesc + + ",url=" + url + + ",sys=" + sys + + ",ip=" + ip + + ",pid=" + pid + + ",hostname=" + hostname + + ",apiVersion=" + apiVersion + + ",registerTime=" + "}"; } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java index d477ddb1ba..38a65e2791 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java @@ -1,10 +1,14 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; @@ -13,11 +17,13 @@ public class ConsumerGroupTopicConfig { public static Logger logger = LoggerFactory.getLogger(ConsumerGroupTopicConfig.class); - private String consumerGroup; + private final String consumerGroup; - private String topic; + private final String topic; - private SubscriptionMode subscriptionMode; + private final SubscriptionMode subscriptionMode; + + private final String protocolDesc; /** * PUSH URL @@ -25,18 +31,27 @@ public class ConsumerGroupTopicConfig { * Key: IDC * Value: list of URls */ - private Map> idcUrls = new ConcurrentHashMap<>(); + private final Map> idcUrls = new ConcurrentHashMap<>(); + + /** + * Event streaming emitter + *
+ * Key: IDC + * Value: list of emitters + */ + private final Map>> idcEmitters = new ConcurrentHashMap<>(); - public ConsumerGroupTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode) { + public ConsumerGroupTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode, String protocolDesc) { this.consumerGroup = consumerGroup; this.topic = topic; this.subscriptionMode = subscriptionMode; + this.protocolDesc = protocolDesc; } public synchronized void addUrl(String idc, String url) { List urls = idcUrls.get(idc); if (urls == null) { - urls = new ArrayList<>(); + urls = new LinkedList<>(); urls.add(url); idcUrls.put(idc, urls); } else if (!urls.contains(url)) { @@ -44,6 +59,17 @@ public synchronized void addUrl(String idc, String url) { } } + public synchronized void addEmitter(String idc, String clientIp, String clientPid, StreamObserver emitter) { + Map> emitters = idcEmitters.get(idc); + if (emitters == null) { + emitters = new HashMap<>(); + emitters.put(clientIp + clientPid, emitter); + idcEmitters.put(idc, emitters); + } else if (!emitters.containsKey(clientIp + clientPid)) { + emitters.put(clientIp + clientPid, emitter); + } + } + @Override public boolean equals(Object o) { if (this == o) { @@ -82,7 +108,15 @@ public SubscriptionMode getSubscriptionMode() { return subscriptionMode; } + public String getProtocolDesc() { + return protocolDesc; + } + public Map> getIdcUrls() { return idcUrls; } + + public Map>> getIdcEmitters() { + return idcEmitters; + } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java index 5b7df16cd7..98706a0f51 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java @@ -18,7 +18,7 @@ public class MetricsInterceptor implements ServerInterceptor { public ServerCall.Listener interceptCall( ServerCall call, Metadata headers, ServerCallHandler next) { logger.info("cmd={}|{}|client2eventMesh|from={}|to={}", call.getMethodDescriptor().getFullMethodName(), - EventMeshConstants.PROTOCOL_GRPC, call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR),IPUtils.getLocalAddress()); + EventMeshConstants.PROTOCOL_GRPC, call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR), IPUtils.getLocalAddress()); return next.startCall(call, headers); } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java index 0eee34ece4..cf38de53a8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java @@ -28,13 +28,14 @@ public SubscribeProcessor(EventMeshGrpcServer eventMeshGrpcServer) { public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { RequestHeader header = subscription.getHeader(); + String protocolDesc = header.getProtocolDesc(); if (!ServiceUtils.validateHeader(header)) { ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); return; } - if (!ServiceUtils.validateSubscription(subscription)) { + if (!ServiceUtils.validateSubscription(protocolDesc, subscription)) { ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); return; } @@ -54,6 +55,7 @@ public void process(Subscription subscription, StreamObserver response .pid(header.getPid()) .consumerGroup(consumerGroup) .topic(item.getTopic()) + .protocolDesc(protocolDesc) .subscriptionMode(item.getMode()) .url(url) .lastUpTime(new Date()) diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java new file mode 100644 index 0000000000..6fe5b255c9 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java @@ -0,0 +1,87 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.processor; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SubscribeStreamProcessor { + + private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + public SubscribeStreamProcessor(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { + + RequestHeader header = subscription.getHeader(); + String protocolDesc = header.getProtocolDesc(); + + if (!ServiceUtils.validateHeader(header)) { + sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + return; + } + + if (!ServiceUtils.validateSubscription(protocolDesc, subscription)) { + sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + return; + } + + ConsumerManager consumerManager = eventMeshGrpcServer.getConsumerManager(); + + String consumerGroup = subscription.getConsumerGroup(); + List subscriptionItems = subscription.getSubscriptionItemsList(); + + for (Subscription.SubscriptionItem item : subscriptionItems) { + ConsumerGroupClient newClient = ConsumerGroupClient.builder() + .env(header.getEnv()) + .idc(header.getIdc()) + .sys(header.getSys()) + .ip(header.getIp()) + .pid(header.getPid()) + .consumerGroup(consumerGroup) + .topic(item.getTopic()) + .subscriptionMode(item.getMode()) + .protocolDesc(protocolDesc) + .eventEmitter(responseObserver) + .lastUpTime(new Date()) + .build(); + + consumerManager.registerClient(newClient); + } + + consumerManager.restartEventMeshConsumer(consumerGroup); + } + + private void sendResp(Subscription subscription, StatusCode code, StreamObserver responseObserver) { + Map resp = new HashMap<>(); + resp.put("respCode", code.getRetCode()); + resp.put("respMsg", code.getErrMsg()); + + RequestHeader header = subscription.getHeader(); + EventMeshMessage eventMeshMessage = EventMeshMessage.newBuilder() + .setHeader(header) + .setContent(JsonUtils.serialize(resp)) + .build(); + + responseObserver.onNext(eventMeshMessage); + responseObserver.onCompleted(); + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java similarity index 62% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java index bcb3590707..1f9085ead6 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractHttpPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java @@ -20,53 +20,33 @@ import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.constants.EventMeshConstants; -import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.HandleMsgContext; import org.apache.eventmesh.runtime.core.protocol.grpc.retry.GrpcRetryer; import org.apache.eventmesh.runtime.core.protocol.grpc.retry.RetryContext; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.RandomUtils; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -public abstract class AbstractHttpPushRequest extends RetryContext { +public abstract class AbstractPushRequest extends RetryContext { - protected static HTTPClientPool httpClientPool = new HTTPClientPool(10); protected EventMeshGrpcServer eventMeshGrpcServer; protected long createTime = System.currentTimeMillis(); protected long lastPushTime = System.currentTimeMillis(); - /** **/ - protected Map> urls; - - protected volatile int startIdx; protected EventMeshGrpcConfiguration eventMeshGrpcConfiguration; protected GrpcRetryer retryer; protected int ttl; protected HandleMsgContext handleMsgContext; private AtomicBoolean complete = new AtomicBoolean(Boolean.FALSE); - private List totalUrls; - - public AbstractHttpPushRequest(HandleMsgContext handleMsgContext) { + public AbstractPushRequest(HandleMsgContext handleMsgContext) { this.eventMeshGrpcServer = handleMsgContext.getEventMeshGrpcServer(); this.handleMsgContext = handleMsgContext; - this.urls = handleMsgContext.getConsumeTopicConfig().getIdcUrls(); + this.eventMeshGrpcConfiguration = handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration(); this.retryer = handleMsgContext.getEventMeshGrpcServer().getGrpcRetryer(); this.ttl = handleMsgContext.getTtl(); - - this.totalUrls = buildTotalUrls(); - this.startIdx = RandomUtils.nextInt(0, totalUrls.size()); } - public abstract void tryHttpRequest(); + public abstract void tryPushRequest(); public void delayRetry() { if (retryTimes < EventMeshConstants.DEFAULT_PUSH_RETRY_TIMES) { @@ -78,28 +58,6 @@ public void delayRetry() { } } - public String getUrl() { - List localIdcUrl = MapUtils.getObject(urls, - eventMeshGrpcConfiguration.eventMeshIDC, null); - if (CollectionUtils.isNotEmpty(localIdcUrl)) { - return localIdcUrl.get((startIdx + retryTimes) % localIdcUrl.size()); - } - - if (CollectionUtils.isNotEmpty(totalUrls)) { - return totalUrls.get((startIdx + retryTimes) % totalUrls.size()); - } - - return null; - } - - private List buildTotalUrls() { - Set totalUrls = new HashSet<>(); - for (List idcUrls : urls.values()) { - totalUrls.addAll(idcUrls); - } - return new ArrayList<>(totalUrls); - } - public boolean isComplete() { return complete.get(); } @@ -113,4 +71,8 @@ public void timeout() { delayRetry(); } } + + public HandleMsgContext getHandleMsgContext() { + return handleMsgContext; + } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java deleted file mode 100644 index 7cfba65c3b..0000000000 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPClientPool.java +++ /dev/null @@ -1,57 +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.eventmesh.runtime.core.protocol.grpc.push; - -import com.google.common.collect.Lists; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.RandomUtils; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; - -import java.util.Iterator; -import java.util.List; - -public class HTTPClientPool { - - private List clients = Lists.newArrayList(); - - private int core = 1; - - public HTTPClientPool(int core) { - this.core = core; - } - - public CloseableHttpClient getClient() { - if (CollectionUtils.size(clients) < core) { - CloseableHttpClient client = HttpClients.createDefault(); - clients.add(client); - return client; - } - return clients.get(RandomUtils.nextInt(core, 2 * core) % core); - } - - - public void shutdown() throws Exception { - Iterator itr = clients.iterator(); - while (itr.hasNext()) { - CloseableHttpClient client = itr.next(); - client.close(); - itr.remove(); - } - } -} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HandleMsgContext.java similarity index 97% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HandleMsgContext.java index 9135dabbe9..5ca1367946 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/HandleMsgContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HandleMsgContext.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; +package org.apache.eventmesh.runtime.core.protocol.grpc.push; import io.cloudevents.CloudEvent; import org.apache.commons.lang3.StringUtils; @@ -25,6 +25,7 @@ import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HttpPushRequest.java similarity index 83% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HttpPushRequest.java index 2a4b39a81c..13f0ccd9a3 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AsyncHTTPPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HttpPushRequest.java @@ -21,12 +21,16 @@ import com.google.common.collect.Sets; import io.cloudevents.CloudEvent; import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.exception.JsonException; import org.apache.eventmesh.common.protocol.ProtocolTransportObject; -import org.apache.eventmesh.common.protocol.http.HttpCommand; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; import org.apache.eventmesh.common.protocol.http.common.ClientRetCode; import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; @@ -38,7 +42,6 @@ import org.apache.eventmesh.protocol.api.ProtocolAdaptor; import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.constants.EventMeshConstants; -import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.HandleMsgContext; import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -55,29 +58,46 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -public class AsyncHTTPPushRequest extends AbstractHttpPushRequest { +public class HttpPushRequest extends AbstractPushRequest { - public Logger messageLogger = LoggerFactory.getLogger("message"); + private Logger messageLogger = LoggerFactory.getLogger("message"); - public Logger cmdLogger = LoggerFactory.getLogger("cmd"); + private Logger cmdLogger = LoggerFactory.getLogger("cmd"); - public Logger logger = LoggerFactory.getLogger(this.getClass()); - public String currPushUrl; - private Map> waitingRequests; + private Logger logger = LoggerFactory.getLogger(this.getClass()); - public AsyncHTTPPushRequest(HandleMsgContext handleMsgContext, - Map> waitingRequests) { + /** + * Key: idc + * Value: list of URLs + **/ + private final Map> urls; + + private List totalUrls; + + private volatile int startIdx; + + private String currPushUrl; + + private Map> waitingRequests; + + public HttpPushRequest(HandleMsgContext handleMsgContext, + Map> waitingRequests) { super(handleMsgContext); this.waitingRequests = waitingRequests; + + this.urls = handleMsgContext.getConsumeTopicConfig().getIdcUrls(); + this.totalUrls = buildTotalUrls(); + this.startIdx = RandomUtils.nextInt(0, totalUrls.size()); } @Override - public void tryHttpRequest() { + public void tryPushRequest() { currPushUrl = getUrl(); @@ -115,7 +135,9 @@ public void tryHttpRequest() { ProtocolTransportObject protocolTransportObject = protocolAdaptor.fromCloudEvent(handleMsgContext.getEvent()); - content = ((HttpCommand) protocolTransportObject).getBody().toMap().get("content").toString(); + + EventMeshMessage eventMeshMessage = ((EventMeshMessageWrapper) protocolTransportObject).getMessage(); + content = eventMeshMessage.getContent(); } catch (Exception ex) { return; } @@ -156,10 +178,10 @@ public void tryHttpRequest() { IPUtils.getLocalAddress(), currPushUrl); try { - httpClientPool.getClient().execute(builder, new ResponseHandler() { + eventMeshGrpcServer.getHttpClient().execute(builder, new ResponseHandler() { @Override public Object handleResponse(HttpResponse response) { - removeWaitingMap(AsyncHTTPPushRequest.this); + removeWaitingMap(HttpPushRequest.this); long cost = System.currentTimeMillis() - lastPushTime; //eventMeshHTTPServer.metrics.summaryMetrics.recordHTTPPushTimeCost(cost); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { @@ -251,7 +273,7 @@ public String toString() { return sb.toString(); } - ClientRetCode processResponseContent(String content) { + private ClientRetCode processResponseContent(String content) { if (StringUtils.isBlank(content)) { return ClientRetCode.FAIL; } @@ -281,7 +303,7 @@ ClientRetCode processResponseContent(String content) { } } - private void addToWaitingMap(AsyncHTTPPushRequest request) { + private void addToWaitingMap(HttpPushRequest request) { if (waitingRequests.containsKey(request.handleMsgContext.getConsumerGroup())) { waitingRequests.get(request.handleMsgContext.getConsumerGroup()).add(request); return; @@ -291,7 +313,7 @@ private void addToWaitingMap(AsyncHTTPPushRequest request) { waitingRequests.get(request.handleMsgContext.getConsumerGroup()).add(request); } - private void removeWaitingMap(AsyncHTTPPushRequest request) { + private void removeWaitingMap(HttpPushRequest request) { if (waitingRequests.containsKey(request.handleMsgContext.getConsumerGroup())) { waitingRequests.get(request.handleMsgContext.getConsumerGroup()).remove(request); } @@ -299,7 +321,29 @@ private void removeWaitingMap(AsyncHTTPPushRequest request) { @Override public boolean retry() { - tryHttpRequest(); + tryPushRequest(); return true; } + + private String getUrl() { + List localIdcUrl = MapUtils.getObject(urls, + eventMeshGrpcConfiguration.eventMeshIDC, null); + if (CollectionUtils.isNotEmpty(localIdcUrl)) { + return localIdcUrl.get((startIdx + retryTimes) % localIdcUrl.size()); + } + + if (CollectionUtils.isNotEmpty(totalUrls)) { + return totalUrls.get((startIdx + retryTimes) % totalUrls.size()); + } + + return null; + } + + private List buildTotalUrls() { + Set totalUrls = new HashSet<>(); + for (List idcUrls : urls.values()) { + totalUrls.addAll(idcUrls); + } + return new ArrayList<>(totalUrls); + } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java similarity index 70% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java index 3e961ed7d7..3060fb2032 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HTTPMessageHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java @@ -21,8 +21,6 @@ import com.google.common.collect.Sets; import org.apache.commons.collections4.MapUtils; import org.apache.eventmesh.common.ThreadPoolFactory; -import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.MessageHandler; -import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.HandleMsgContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +31,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -public class HTTPMessageHandler implements MessageHandler { +public class MessageHandler { private Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -43,26 +41,25 @@ public class HTTPMessageHandler implements MessageHandler { private final Integer CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD = 10000; - private static Map> waitingRequests = Maps.newConcurrentMap(); + private static Map> waitingRequests = Maps.newConcurrentMap(); - public HTTPMessageHandler(String consumerGroup, ThreadPoolExecutor pushMsgExecutor) { + public MessageHandler(String consumerGroup, ThreadPoolExecutor pushMsgExecutor) { this.pushExecutor = pushMsgExecutor; waitingRequests.put(consumerGroup, Sets.newConcurrentHashSet()); SCHEDULER.scheduleAtFixedRate(this::checkTimeout, 0, 1000, TimeUnit.MILLISECONDS); } private void checkTimeout() { - waitingRequests.entrySet().stream().forEach(entry -> { - for (AbstractHttpPushRequest request : entry.getValue()) { + waitingRequests.forEach((key, value) -> { + for (AbstractPushRequest request : value) { request.timeout(); - waitingRequests.get(request.handleMsgContext.getConsumerGroup()).remove(request); + waitingRequests.get(request.getHandleMsgContext().getConsumerGroup()).remove(request); } }); } - @Override - public boolean handle(final HandleMsgContext handleMsgContext) { - Set waitingRequests4Group = MapUtils.getObject(waitingRequests, + public boolean handle(String protocol, final HandleMsgContext handleMsgContext) { + Set waitingRequests4Group = MapUtils.getObject(waitingRequests, handleMsgContext.getConsumerGroup(), Sets.newConcurrentHashSet()); if (waitingRequests4Group.size() > CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD) { logger.warn("waitingRequests is too many, so reject, this message will be send back to MQ, consumerGroup:{}, threshold:{}", @@ -72,8 +69,10 @@ public boolean handle(final HandleMsgContext handleMsgContext) { try { pushExecutor.submit(() -> { - AsyncHTTPPushRequest asyncPushRequest = new AsyncHTTPPushRequest(handleMsgContext, waitingRequests); - asyncPushRequest.tryHttpRequest(); + AbstractPushRequest pushRequest = createHttpPushRequest(protocol, handleMsgContext); + if (pushRequest != null) { + pushRequest.tryPushRequest(); + } }); return true; } catch (RejectedExecutionException e) { @@ -82,4 +81,13 @@ public boolean handle(final HandleMsgContext handleMsgContext) { return false; } } + + private AbstractPushRequest createHttpPushRequest(String protocol, HandleMsgContext handleMsgContext) { + if ("grpc".equals(protocol)) { + return new HttpPushRequest(handleMsgContext, waitingRequests); + } else if ("grpc_stream".equals(protocol)) { + return new StreamPushRequest(handleMsgContext, waitingRequests); + } + return null; + } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java new file mode 100644 index 0000000000..0d52d1aa9b --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java @@ -0,0 +1,118 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.push; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.grpc.stub.StreamObserver; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.RandomUtils; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; +import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +public class StreamPushRequest extends AbstractPushRequest { + + private HandleMsgContext handleMsgContext; + + private Map> waitingRequests; + + private EventMeshGrpcConfiguration grpcConfiguration; + + private ConsumerGroupTopicConfig topicConfig; + + private Map>> idcEmitters; + + private List> totalEmitters; + + private volatile int startIdx; + + public StreamPushRequest(HandleMsgContext handleMsgContext, Map> waitingRequests) { + super(handleMsgContext); + this.handleMsgContext = handleMsgContext; + this.waitingRequests = waitingRequests; + this.grpcConfiguration = handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration(); + this.topicConfig = handleMsgContext.getConsumeTopicConfig(); + this.idcEmitters = buildIdcEmitter(this.topicConfig.getIdcEmitters()); + this.totalEmitters = buildTotalEmitter(); + this.startIdx = RandomUtils.nextInt(0, totalEmitters.size()); + } + + @Override + public void tryPushRequest() { + StreamObserver eventEmitter = selectEmitter(); + + CloudEvent event = CloudEventBuilder.from(handleMsgContext.getEvent()) + .withExtension(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .build(); + handleMsgContext.setEvent(event); + + try { + String protocolType = Objects.requireNonNull(event.getExtension(Constants.PROTOCOL_TYPE)).toString(); + + ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + + ProtocolTransportObject protocolTransportObject = + protocolAdaptor.fromCloudEvent(handleMsgContext.getEvent()); + + EventMeshMessage eventMeshMessage = ((EventMeshMessageWrapper) protocolTransportObject).getMessage(); + if (eventMeshMessage != null) { + eventEmitter.onNext(eventMeshMessage); + } + } catch (Exception e) { + e.printStackTrace(); + } + + complete(); + if (isComplete()) { + handleMsgContext.finish(); + } + } + + @Override + public boolean retry() throws Exception { + return false; + } + + private StreamObserver selectEmitter() { + List> emitterList = MapUtils.getObject(idcEmitters, grpcConfiguration.eventMeshIDC, null); + if (CollectionUtils.isNotEmpty(emitterList)) { + return emitterList.get((startIdx + retryTimes) % emitterList.size()); + } + if (CollectionUtils.isNotEmpty(totalEmitters)) { + return totalEmitters.get((startIdx + retryTimes) % totalEmitters.size()); + } + return null; + } + + private Map>> buildIdcEmitter( + Map>> idcEmitterMap) { + Map>> result = new HashMap<>(); + for (Map.Entry>> entry : idcEmitterMap.entrySet()) { + List> emitterList = new LinkedList<>(entry.getValue().values()); + result.put(entry.getKey(), emitterList); + } + return result; + } + + private List> buildTotalEmitter() { + List> emitterList = new LinkedList<>(); + for (List> emitters : this.idcEmitters.values()) { + emitterList.addAll(emitters); + } + return emitterList; + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java index 312a4dc503..4ae4eef2ed 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java @@ -3,23 +3,28 @@ import io.grpc.stub.StreamObserver; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.ConsumerServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; -import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SubscribeProcessor; +import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SubscribeStreamProcessor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ThreadPoolExecutor; public class ConsumerService extends ConsumerServiceGrpc.ConsumerServiceImplBase { - private Logger logger = LoggerFactory.getLogger(ProducerService.class); + private final Logger logger = LoggerFactory.getLogger(ProducerService.class); - private EventMeshGrpcServer eventMeshGrpcServer; + private final EventMeshGrpcServer eventMeshGrpcServer; - private ThreadPoolExecutor threadPoolExecutor; + private final ThreadPoolExecutor threadPoolExecutor; public ConsumerService(EventMeshGrpcServer eventMeshGrpcServer, ThreadPoolExecutor threadPoolExecutor) { @@ -33,11 +38,39 @@ public void subscribe(Subscription request, StreamObserver responseObs try { subscribeProcessor.process(request, responseObserver); } catch (Exception e) { - logger.error("Error code {}, error message {}", EventMeshRetCode.EVENTMESH_SUBSCRIBE_ERR.getRetCode(), + logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_SUBSCRIBE_ERR.getRetCode(), StatusCode.EVENTMESH_SUBSCRIBE_ERR.getErrMsg(), e); ServiceUtils.sendResp(StatusCode.EVENTMESH_SUBSCRIBE_ERR, e.getMessage(), responseObserver); } }); } + + public void subscribeStream(Subscription request, StreamObserver responseObserver) { + threadPoolExecutor.submit(() -> { + SubscribeStreamProcessor streamProcessor = new SubscribeStreamProcessor(eventMeshGrpcServer); + try { + streamProcessor.process(request, responseObserver); + } catch (Exception e) { + StatusCode code = StatusCode.EVENTMESH_SUBSCRIBE_ERR; + logger.error("Error code {}, error message {}", code.getRetCode(), code.getErrMsg(), e); + + Map resp = new HashMap<>(); + resp.put("respCode", code.getRetCode()); + resp.put("respMsg", code.getErrMsg() + " " + e.getMessage()); + + RequestHeader header = request.getHeader(); + EventMeshMessage eventMeshMessage = EventMeshMessage.newBuilder() + .setHeader(header) + .setContent(JsonUtils.serialize(resp)) + .build(); + + responseObserver.onNext(eventMeshMessage); + responseObserver.onCompleted(); + } + }); + } + + public void unsubscribe(Subscription request, StreamObserver responseObserver) { + } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java index edd2d17e74..f3ee56967d 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java @@ -5,7 +5,6 @@ import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; import org.apache.eventmesh.common.protocol.grpc.protos.Response; -import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SendAsyncMessageProcessor; import org.slf4j.Logger; @@ -33,7 +32,7 @@ public void publish(EventMeshMessage request, StreamObserver responseO try { sendAsyncMessageProcessor.process(request, responseObserver); } catch (Exception e) { - logger.error("Error code {}, error message {}", EventMeshRetCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getRetCode(), + logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getRetCode(), StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getErrMsg(), e); ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, e.getMessage(), responseObserver); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java index 5a03286e37..75f10335c8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -26,7 +26,13 @@ public static boolean validateMessage(EventMeshMessage message) { && (!StringUtils.isBlank(message.getTtl())); } - public static boolean validateSubscription(Subscription subscription) { + public static boolean validateSubscription(String protocol, Subscription subscription) { + if (!"grpc".equals(protocol) && !"grpc_stream".equals(protocol)) { + return false; + } + if ("grpc".equals(protocol) && StringUtils.isBlank(subscription.getUrl())) { + return false; + } if (CollectionUtils.isEmpty(subscription.getSubscriptionItemsList()) || StringUtils.isBlank(subscription.getConsumerGroup())) { return false; @@ -56,4 +62,5 @@ public static void sendResp(StatusCode code, String message, StreamObserver listener; + + private final List listenerThreads = new LinkedList<>(); + public EventMeshGrpcConsumer(EventMeshGrpcClientConfig clientConfig) { this.clientConfig = clientConfig; } @@ -40,8 +50,55 @@ public Response subscribe(Subscription subscription) { return response; } + public void subscribeStream(Subscription subscription) { + logger.info("Subscribe streaming topic " + subscription.toString()); + ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); + + RequestHeader header = EventMeshClientUtil.buildHeader(clientConfig); + header = RequestHeader.newBuilder(header) + .setProtocolDesc("grpc_stream") + .build(); + Subscription enhancedSubscription = Subscription.newBuilder(subscription) + .setHeader(header) + .setConsumerGroup(clientConfig.getConsumerGroup()) + .build(); + Iterator msgIterator = consumerClient.subscribeStream(enhancedSubscription); + + ListenerThread listenerThread = new ListenerThread(msgIterator, listener); + listenerThreads.add(listenerThread); + listenerThread.start(); + } + + public void registerListener(ReceiveMsgHook listener) { + if (this.listener == null) { + this.listener = listener; + } + } + @Override - public void close() throws Exception { + public void close() { + for (ListenerThread thread : listenerThreads) { + thread.stop(); + } channel.shutdown(); } + + static class ListenerThread extends Thread { + private final Iterator msgIterator; + + private final ReceiveMsgHook listener; + + ListenerThread(Iterator msgIterator, ReceiveMsgHook listener) { + this.msgIterator = msgIterator; + this.listener = listener; + } + + public void run() { + logger.info("start receiving..."); + while (msgIterator.hasNext()) { + logger.info("sdk received message "); + listener.handle(msgIterator.next()); + } + } + } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/ReceiveMsgHook.java similarity index 70% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java rename to eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/ReceiveMsgHook.java index 708af0fa8a..86ddd278c7 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/MessageHandler.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/ReceiveMsgHook.java @@ -15,8 +15,19 @@ * limitations under the License. */ -package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; +package org.apache.eventmesh.client.grpc; -public interface MessageHandler { - boolean handle(HandleMsgContext handleMsgContext); -} \ No newline at end of file +import java.util.Optional; + +@FunctionalInterface +public interface ReceiveMsgHook { + + /** + * Handle the received message, return the response message. + * + * @param msg + * @return + */ + Optional handle(EventMeshMessage msg); + +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java index cadbd830b8..3d93b9e9dc 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java @@ -42,12 +42,6 @@ public class EventMeshGrpcClientConfig { @Builder.Default private String idc = ""; - @Builder.Default - private String ip = "127.0.0.1"; - - @Builder.Default - private String pid ="0"; - @Builder.Default private String sys = "sys123"; @@ -73,8 +67,6 @@ public String toString() { .append("idc=").append(idc).append(",") .append("producerGroup=").append(producerGroup).append(",") .append("consumerGroup=").append(consumerGroup).append(",") - .append("ip=").append(ip).append(",") - .append("pid=").append(pid).append(",") .append("sys=").append(sys).append(",") .append("userName=").append(userName).append(",") .append("password=").append("***").append(",") diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java index 5cb2907f88..629ff93b52 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java @@ -3,6 +3,8 @@ import io.cloudevents.SpecVersion; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; public class EventMeshClientUtil { @@ -13,8 +15,8 @@ public static RequestHeader buildHeader(EventMeshGrpcClientConfig clientConfig) RequestHeader header = RequestHeader.newBuilder() .setEnv(clientConfig.getEnv()) .setIdc(clientConfig.getIdc()) - .setIp(clientConfig.getIp()) - .setPid(clientConfig.getPid()) + .setIp(IPUtils.getLocalAddress()) + .setPid(Long.toString(ThreadUtils.getPID())) .setSys(clientConfig.getSys()) .setLanguage(clientConfig.getLanguage()) .setUsername(clientConfig.getUserName()) From d7ce24abd403328a28184ba63007e90fcb20072b Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Wed, 22 Dec 2021 14:06:23 -0500 Subject: [PATCH 10/21] Grpc consumer API enhancement --- .../eventmesh/grpc/sub/AsyncSubscribe.java | 2 +- .../grpc/consumer/ConsumerManager.java | 26 +-- .../grpc/consumer/EventMeshConsumer.java | 32 ++-- .../consumergroup/ConsumerGroupClient.java | 60 +++--- .../ConsumerGroupTopicConfig.java | 105 ++-------- .../grpc/consumer/consumergroup/GrpcType.java | 5 + .../consumergroup/StreamTopicConfig.java | 78 ++++++++ .../consumergroup/WebhookTopicConfig.java | 73 +++++++ .../grpc/processor/SubscribeProcessor.java | 13 +- .../processor/SubscribeStreamProcessor.java | 14 +- .../grpc/push/AbstractPushRequest.java | 118 ++++++++++-- .../protocol/grpc/push/HandleMsgContext.java | 115 +++-------- .../protocol/grpc/push/MessageHandler.java | 21 +- .../protocol/grpc/push/StreamPushRequest.java | 76 ++------ ...shRequest.java => WebhookPushRequest.java} | 180 +++++------------- .../protocol/grpc/service/ServiceUtils.java | 8 +- .../client/grpc/EventMeshGrpcConsumer.java | 6 +- 17 files changed, 452 insertions(+), 480 deletions(-) create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/GrpcType.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java rename eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/{HttpPushRequest.java => WebhookPushRequest.java} (56%) diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java index 1f41ae4d5c..69ad3addb7 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java @@ -27,7 +27,7 @@ public static void main(String[] args) { EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() .serverAddr(eventMeshIp) .serverPort(Integer.parseInt(eventMeshGrpcPort)) - .producerGroup("EventMeshTest-consumerGroup") + .consumerGroup("EventMeshTest-consumerGroup") .env("env").idc("idc") .sys("1234").build(); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java index fc3f4230ca..ae366d8ec8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -5,6 +5,7 @@ import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.common.ServiceState; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,7 +49,7 @@ public void shutdown() throws Exception { public synchronized void registerClient(ConsumerGroupClient newClient) { String consumerGroup = newClient.getConsumerGroup(); String topic = newClient.getTopic(); - String protocol = newClient.getProtocolDesc(); + GrpcType grpcType = newClient.getGrpcType(); String url = newClient.getUrl(); String ip = newClient.getIp(); String pid = newClient.getPid(); @@ -62,13 +63,13 @@ public synchronized void registerClient(ConsumerGroupClient newClient) { } else { boolean isContains = false; for (ConsumerGroupClient localClient : localClients) { - if ("grpc".equals(protocol) && StringUtils.equals(localClient.getTopic(), topic) + if (GrpcType.WEBHOOK.equals(grpcType) && StringUtils.equals(localClient.getTopic(), topic) && StringUtils.equals(localClient.getUrl(), url) && localClient.getSubscriptionMode().equals(subscriptionMode)) { isContains = true; localClient.setLastUpTime(newClient.getLastUpTime()); break; - } else if ("grpc_stream".equals(protocol) && StringUtils.equals(localClient.getTopic(), topic) + } else if (GrpcType.STREAM.equals(grpcType) && StringUtils.equals(localClient.getTopic(), topic) && StringUtils.equals(localClient.getIp(), ip) && StringUtils.equals(localClient.getPid(), pid) && localClient.getSubscriptionMode().equals(subscriptionMode)) { isContains = true; @@ -82,7 +83,7 @@ public synchronized void registerClient(ConsumerGroupClient newClient) { } } - public void restartEventMeshConsumer(String consumerGroup) throws Exception { + public synchronized boolean restartEventMeshConsumer(String consumerGroup) throws Exception { EventMeshConsumer eventMeshConsumer = consumerTable.get(consumerGroup); if (eventMeshConsumer == null) { @@ -94,24 +95,13 @@ public void restartEventMeshConsumer(String consumerGroup) throws Exception { Set oldTopicConfigs = eventMeshConsumer.buildTopicConfig(); List localClients = clientTable.get(consumerGroup); for (ConsumerGroupClient client : localClients) { - String protocolDesc = client.getProtocolDesc(); - String topic = client.getTopic(); - String idc = client.getIdc(); - String url = client.getUrl(); - String ip = client.getIp(); - String pid = client.getPid(); - SubscriptionMode subscriptionMode = client.getSubscriptionMode(); - if ("grpc".equals(protocolDesc)) { - eventMeshConsumer.addTopicConfig(topic, subscriptionMode, protocolDesc, idc, url); - } else if ("grpc_stream".equals(protocolDesc)) { - eventMeshConsumer.addTopicConfig(topic, subscriptionMode, protocolDesc, idc, ip, pid, client.getEventEmitter()); - } + eventMeshConsumer.registerClient(client); } // start up eventMeshConsumer the first time if (ServiceState.INITED.equals(eventMeshConsumer.getStatus())) { eventMeshConsumer.start(); - return; + return true; } // determine if restart eventMeshConsumer required @@ -122,6 +112,8 @@ public void restartEventMeshConsumer(String consumerGroup) throws Exception { eventMeshConsumer.shutdown(); } eventMeshConsumer.start(); + return true; } + return false; } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java index 9b33dc7fd9..6f82f2fd4b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java @@ -19,7 +19,11 @@ import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.plugin.MQConsumerWrapper; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.StreamTopicConfig; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.WebhookTopicConfig; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; import org.apache.eventmesh.runtime.core.protocol.grpc.push.HandleMsgContext; @@ -68,23 +72,17 @@ public EventMeshConsumer(EventMeshGrpcServer eventMeshGrpcServer, String consume this.broadcastMqConsumer = new MQConsumerWrapper(eventMeshGrpcConfiguration.eventMeshConnectorPluginType); } - public synchronized void addTopicConfig(String topic, SubscriptionMode subscriptionMode, String protocolDesc, String idc, - String clientIp, String clientPid, StreamObserver eventEmitter) { - ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); - if (topicConfig == null) { - topicConfig = new ConsumerGroupTopicConfig(consumerGroup, topic, subscriptionMode, protocolDesc); - consumerGroupTopicConfig.put(topic, topicConfig); - } - topicConfig.addEmitter(idc, clientIp, clientPid, eventEmitter); - } + public synchronized void registerClient(ConsumerGroupClient client) { + GrpcType grpcType = client.getGrpcType(); + String topic = client.getTopic(); + SubscriptionMode subscriptionMode = client.getSubscriptionMode(); - public synchronized void addTopicConfig(String topic, SubscriptionMode subscriptionMode, String protocolDesc, String idc, String url) { ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); if (topicConfig == null) { - topicConfig = new ConsumerGroupTopicConfig(consumerGroup, topic, subscriptionMode, protocolDesc); + topicConfig = ConsumerGroupTopicConfig.buildTopicConfig(consumerGroup, topic, subscriptionMode, grpcType); consumerGroupTopicConfig.put(topic, topicConfig); } - topicConfig.addUrl(idc, url); + topicConfig.registerClient(client); } public synchronized Set buildTopicConfig() { @@ -199,13 +197,13 @@ private EventListener createEventListener(SubscriptionMode subscriptionMode) { EventMeshAsyncConsumeContext eventMeshAsyncConsumeContext = (EventMeshAsyncConsumeContext) context; ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); + if (topicConfig != null) { - HandleMsgContext handleMsgContext = new HandleMsgContext(EventMeshUtil.buildPushMsgSeqNo(), consumerGroup, - this, - topic, event, subscriptionMode, eventMeshAsyncConsumeContext.getAbstractContext(), eventMeshGrpcServer, strBizSeqNo, strUniqueId, - topicConfig); + GrpcType grpcType = topicConfig.getGrpcType(); + HandleMsgContext handleMsgContext = new HandleMsgContext(consumerGroup, event, subscriptionMode, grpcType, + eventMeshAsyncConsumeContext.getAbstractContext(), eventMeshGrpcServer, this, topicConfig); - if (messageHandler.handle(topicConfig.getProtocolDesc(), handleMsgContext)) { + if (messageHandler.handle(handleMsgContext)) { eventMeshAsyncConsumeContext.commit(EventMeshAction.ManualAck); return; } else { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java index 8297cd6927..54c4c2621c 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java @@ -20,60 +20,62 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; import io.grpc.stub.StreamObserver; +import lombok.Getter; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; - import java.util.Date; - import lombok.Builder; -import lombok.Data; @Builder -@Data +@Getter public class ConsumerGroupClient { - private String env; + private final String env; - private String idc; + private final String idc; - private String consumerGroup; + private final String consumerGroup; - private String topic; + private final String topic; - private String protocolDesc; + private final GrpcType grpcType; - private String url; + private final String url; - private StreamObserver eventEmitter; + private final StreamObserver eventEmitter; - private SubscriptionMode subscriptionMode; + private final SubscriptionMode subscriptionMode; - private String sys; + private final String sys; - private String ip; + private final String ip; - private String pid; + private final String pid; - private String hostname; + private final String hostname; - private String apiVersion; + private final String apiVersion; private Date lastUpTime; + public void setLastUpTime(Date lastUpTime) { + this.lastUpTime = lastUpTime; + } + @Override public String toString() { - return "endPoint={env=" + env + - ",idc=" + idc + - ",consumerGroup=" + consumerGroup + - ",topic=" + topic + - ",protocolDesc=" + protocolDesc + - ",url=" + url + - ",sys=" + sys + - ",ip=" + ip + - ",pid=" + pid + - ",hostname=" + hostname + - ",apiVersion=" + apiVersion + - ",registerTime=" + "}"; + return "endPoint={env=" + env + + ",idc=" + idc + + ",consumerGroup=" + consumerGroup + + ",topic=" + topic + + ",grpcType=" + grpcType + + ",url=" + url + + ",sys=" + sys + + ",ip=" + ip + + ",pid=" + pid + + ",hostname=" + hostname + + ",apiVersion=" + apiVersion + + ",lastUpTime=" + lastUpTime + "}"; } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java index 38a65e2791..6ec9f81963 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java @@ -1,100 +1,37 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; -import io.grpc.stub.StreamObserver; -import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; +public abstract class ConsumerGroupTopicConfig { + private final Logger logger = LoggerFactory.getLogger(ConsumerGroupTopicConfig.class); -public class ConsumerGroupTopicConfig { - public static Logger logger = LoggerFactory.getLogger(ConsumerGroupTopicConfig.class); + protected final String consumerGroup; - private final String consumerGroup; + protected final String topic; - private final String topic; + protected final SubscriptionMode subscriptionMode; - private final SubscriptionMode subscriptionMode; + protected final GrpcType grpcType; - private final String protocolDesc; - - /** - * PUSH URL - *

- * Key: IDC - * Value: list of URls - */ - private final Map> idcUrls = new ConcurrentHashMap<>(); - - /** - * Event streaming emitter - *
- * Key: IDC - * Value: list of emitters - */ - private final Map>> idcEmitters = new ConcurrentHashMap<>(); - - public ConsumerGroupTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode, String protocolDesc) { + protected ConsumerGroupTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode, GrpcType grpcType) { this.consumerGroup = consumerGroup; this.topic = topic; this.subscriptionMode = subscriptionMode; - this.protocolDesc = protocolDesc; + this.grpcType = grpcType; } - public synchronized void addUrl(String idc, String url) { - List urls = idcUrls.get(idc); - if (urls == null) { - urls = new LinkedList<>(); - urls.add(url); - idcUrls.put(idc, urls); - } else if (!urls.contains(url)) { - urls.add(url); + public static ConsumerGroupTopicConfig buildTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode, + GrpcType grpcType) { + if (GrpcType.STREAM.equals(grpcType)) { + return new StreamTopicConfig(consumerGroup, topic, subscriptionMode); + } else { + return new WebhookTopicConfig(consumerGroup, topic, subscriptionMode); } } - public synchronized void addEmitter(String idc, String clientIp, String clientPid, StreamObserver emitter) { - Map> emitters = idcEmitters.get(idc); - if (emitters == null) { - emitters = new HashMap<>(); - emitters.put(clientIp + clientPid, emitter); - idcEmitters.put(idc, emitters); - } else if (!emitters.containsKey(clientIp + clientPid)) { - emitters.put(clientIp + clientPid, emitter); - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ConsumerGroupTopicConfig that = (ConsumerGroupTopicConfig) o; - return consumerGroup.equals(that.consumerGroup) - && Objects.equals(topic, that.topic) - && Objects.equals(idcUrls, that.idcUrls); - } - - @Override - public int hashCode() { - return Objects.hash(consumerGroup, topic, idcUrls); - } - - @Override - public String toString() { - return "consumeTopicConfig={consumerGroup=" + consumerGroup - + ",topic=" + topic - + ",idcUrls=" + idcUrls + "}"; - } + public abstract void registerClient(ConsumerGroupClient client); public String getConsumerGroup() { return consumerGroup; @@ -108,15 +45,7 @@ public SubscriptionMode getSubscriptionMode() { return subscriptionMode; } - public String getProtocolDesc() { - return protocolDesc; - } - - public Map> getIdcUrls() { - return idcUrls; - } - - public Map>> getIdcEmitters() { - return idcEmitters; + public GrpcType getGrpcType() { + return grpcType; } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/GrpcType.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/GrpcType.java new file mode 100644 index 0000000000..0a14124bd6 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/GrpcType.java @@ -0,0 +1,5 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; + +public enum GrpcType { + WEBHOOK, STREAM +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java new file mode 100644 index 0000000000..58df08c97b --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java @@ -0,0 +1,78 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +public class StreamTopicConfig extends ConsumerGroupTopicConfig { + private final Logger logger = LoggerFactory.getLogger(StreamTopicConfig.class); + + /** + * Event streaming emitter + *
+ * Key: IDC + * Value: list of emitters + */ + private final Map>> idcEmitters = new ConcurrentHashMap<>(); + + public StreamTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode) { + super(consumerGroup, topic, subscriptionMode, GrpcType.STREAM); + } + + @Override + public synchronized void registerClient(ConsumerGroupClient client) { + if (!client.getGrpcType().equals(grpcType)) { + logger.warn("Invalid grpc type: {}, expecting grpc type: {}, can not register client {}", + client.getGrpcType(), grpcType, client.toString()); + return; + } + String idc = client.getIdc(); + String clientIp = client.getIp(); + String clientPid = client.getPid(); + StreamObserver emitter = client.getEventEmitter(); + Map> emitters = idcEmitters.get(idc); + if (emitters == null) { + emitters = new HashMap<>(); + emitters.put(clientIp + clientPid, emitter); + idcEmitters.put(idc, emitters); + } else if (!emitters.containsKey(clientIp + ":" + clientPid)) { + emitters.put(clientIp + clientPid, emitter); + } + } + + @Override + public String toString() { + return "StreamConsumeTopicConfig={consumerGroup=" + consumerGroup + + ",grpcType=" + grpcType + + ",topic=" + topic + "}"; + } + + public String getConsumerGroup() { + return consumerGroup; + } + + public String getTopic() { + return topic; + } + + public SubscriptionMode getSubscriptionMode() { + return subscriptionMode; + } + + public GrpcType getGrpcType() { + return grpcType; + } + + public Map>> getIdcEmitters() { + return idcEmitters; + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java new file mode 100644 index 0000000000..a4c1315d8c --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java @@ -0,0 +1,73 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; + +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class WebhookTopicConfig extends ConsumerGroupTopicConfig { + private final Logger logger = LoggerFactory.getLogger(WebhookTopicConfig.class); + + /** + * PUSH URL + *

+ * Key: IDC + * Value: list of URls + */ + private final Map> idcUrls = new ConcurrentHashMap<>(); + + public WebhookTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode) { + super(consumerGroup, topic, subscriptionMode, GrpcType.WEBHOOK); + } + + @Override + public synchronized void registerClient(ConsumerGroupClient client) { + if (!client.getGrpcType().equals(grpcType)) { + logger.warn("Invalid grpc type: {}, expecting grpc type: {}, can not register client {}", + client.getGrpcType(), grpcType, client.toString()); + return; + } + String idc = client.getIdc(); + String url = client.getUrl(); + List urls = idcUrls.get(idc); + if (urls == null) { + urls = new LinkedList<>(); + urls.add(url); + idcUrls.put(idc, urls); + } else if (!urls.contains(url)) { + urls.add(url); + } + } + + @Override + public String toString() { + return "WebhookConsumeTopicConfig={consumerGroup=" + consumerGroup + + ",grpcType=" + grpcType + + ",topic=" + topic + + ",idcUrls=" + idcUrls + "}"; + } + + public String getConsumerGroup() { + return consumerGroup; + } + + public String getTopic() { + return topic; + } + + public SubscriptionMode getSubscriptionMode() { + return subscriptionMode; + } + + public GrpcType getGrpcType() { + return grpcType; + } + + public Map> getIdcUrls() { + return idcUrls; + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java index cf38de53a8..7e9206eb40 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java @@ -8,6 +8,7 @@ import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,6 +22,8 @@ public class SubscribeProcessor { private EventMeshGrpcServer eventMeshGrpcServer; + private GrpcType grpcType = GrpcType.WEBHOOK; + public SubscribeProcessor(EventMeshGrpcServer eventMeshGrpcServer) { this.eventMeshGrpcServer = eventMeshGrpcServer; } @@ -28,14 +31,13 @@ public SubscribeProcessor(EventMeshGrpcServer eventMeshGrpcServer) { public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { RequestHeader header = subscription.getHeader(); - String protocolDesc = header.getProtocolDesc(); if (!ServiceUtils.validateHeader(header)) { ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); return; } - if (!ServiceUtils.validateSubscription(protocolDesc, subscription)) { + if (!ServiceUtils.validateSubscription(grpcType, subscription)) { ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); return; } @@ -55,7 +57,7 @@ public void process(Subscription subscription, StreamObserver response .pid(header.getPid()) .consumerGroup(consumerGroup) .topic(item.getTopic()) - .protocolDesc(protocolDesc) + .grpcType(grpcType) .subscriptionMode(item.getMode()) .url(url) .lastUpTime(new Date()) @@ -64,7 +66,10 @@ public void process(Subscription subscription, StreamObserver response consumerManager.registerClient(newClient); } - consumerManager.restartEventMeshConsumer(consumerGroup); + boolean restartResult = consumerManager.restartEventMeshConsumer(consumerGroup); + if (!restartResult) { + logger.warn("EventMesh consumer [{}] didn't restart.", consumerGroup); + } ServiceUtils.sendResp(StatusCode.SUCCESS, "subscribe success", responseObserver); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java index 6fe5b255c9..cc5a25ca8b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java @@ -4,12 +4,12 @@ import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; -import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,6 +25,8 @@ public class SubscribeStreamProcessor { private EventMeshGrpcServer eventMeshGrpcServer; + private GrpcType grpcType = GrpcType.STREAM; + public SubscribeStreamProcessor(EventMeshGrpcServer eventMeshGrpcServer) { this.eventMeshGrpcServer = eventMeshGrpcServer; } @@ -32,14 +34,13 @@ public SubscribeStreamProcessor(EventMeshGrpcServer eventMeshGrpcServer) { public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { RequestHeader header = subscription.getHeader(); - String protocolDesc = header.getProtocolDesc(); if (!ServiceUtils.validateHeader(header)) { sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); return; } - if (!ServiceUtils.validateSubscription(protocolDesc, subscription)) { + if (!ServiceUtils.validateSubscription(grpcType, subscription)) { sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); return; } @@ -59,7 +60,7 @@ public void process(Subscription subscription, StreamObserver .consumerGroup(consumerGroup) .topic(item.getTopic()) .subscriptionMode(item.getMode()) - .protocolDesc(protocolDesc) + .grpcType(grpcType) .eventEmitter(responseObserver) .lastUpTime(new Date()) .build(); @@ -67,7 +68,10 @@ public void process(Subscription subscription, StreamObserver consumerManager.registerClient(newClient); } - consumerManager.restartEventMeshConsumer(consumerGroup); + boolean restart = consumerManager.restartEventMeshConsumer(consumerGroup); + if (!restart) { + logger.warn("EventMesh consumer [{}] didn't restart.", consumerGroup); + } } private void sendResp(Subscription subscription, StatusCode code, StreamObserver responseObserver) { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java index 1f9085ead6..6ad5fa0e78 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java @@ -17,56 +17,135 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.push; +import com.google.common.collect.Sets; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.api.AbstractContext; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; import org.apache.eventmesh.runtime.core.protocol.grpc.retry.GrpcRetryer; import org.apache.eventmesh.runtime.core.protocol.grpc.retry.RetryContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.Collections; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; public abstract class AbstractPushRequest extends RetryContext { + private final Logger logger = LoggerFactory.getLogger(ConsumerGroupTopicConfig.class); + protected EventMeshGrpcServer eventMeshGrpcServer; protected long createTime = System.currentTimeMillis(); protected long lastPushTime = System.currentTimeMillis(); + protected EventMeshConsumer eventMeshConsumer; protected EventMeshGrpcConfiguration eventMeshGrpcConfiguration; - protected GrpcRetryer retryer; - protected int ttl; + protected GrpcRetryer grpcRetryer; + + protected Map> waitingRequests; + protected HandleMsgContext handleMsgContext; - private AtomicBoolean complete = new AtomicBoolean(Boolean.FALSE); + protected CloudEvent event; + protected String topic; + protected String bizSeqNum; + protected String uniqueId; + protected int ttl; + + private final AtomicBoolean complete = new AtomicBoolean(Boolean.FALSE); - public AbstractPushRequest(HandleMsgContext handleMsgContext) { + public AbstractPushRequest(HandleMsgContext handleMsgContext, Map> waitingRequests) { this.eventMeshGrpcServer = handleMsgContext.getEventMeshGrpcServer(); this.handleMsgContext = handleMsgContext; + this.waitingRequests = waitingRequests; this.eventMeshGrpcConfiguration = handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration(); - this.retryer = handleMsgContext.getEventMeshGrpcServer().getGrpcRetryer(); - this.ttl = handleMsgContext.getTtl(); + this.grpcRetryer = handleMsgContext.getEventMeshGrpcServer().getGrpcRetryer(); + + this.event = CloudEventBuilder.from(handleMsgContext.getEvent()) + .withExtension(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, + String.valueOf(System.currentTimeMillis())) + .build(); + + this.topic = event.getSubject(); + + Object objBizSeqNo = event.getExtension(Constants.PROPERTY_MESSAGE_SEARCH_KEYS); + this.bizSeqNum = objBizSeqNo == null ? RandomStringUtils.generateNum(20) : objBizSeqNo.toString(); + + Object objUniqueId = event.getExtension(Constants.RMB_UNIQ_ID); + this.uniqueId = objUniqueId == null ? RandomStringUtils.generateNum(20) : objUniqueId.toString(); + + String ttlStr = (String) event.getExtension(Constants.PROPERTY_MESSAGE_TIMEOUT); + this.ttl = StringUtils.isNumeric(ttlStr) ? Integer.parseInt(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; } public abstract void tryPushRequest(); - public void delayRetry() { + protected EventMeshMessage getEventMeshMessage(CloudEvent cloudEvent) { + try { + String protocolType = Objects.requireNonNull(cloudEvent.getExtension(Constants.PROTOCOL_TYPE)).toString(); + ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + ProtocolTransportObject protocolTransportObject = protocolAdaptor.fromCloudEvent(cloudEvent); + return ((EventMeshMessageWrapper) protocolTransportObject).getMessage(); + } catch (Exception e) { + logger.error("Error in getting EventMeshMessage from CloudEvent", e); + return null; + } + } + + @Override + public boolean retry() { + tryPushRequest(); + return true; + } + + protected void delayRetry() { if (retryTimes < EventMeshConstants.DEFAULT_PUSH_RETRY_TIMES) { retryTimes++; - delay(retryTimes * EventMeshConstants.DEFAULT_PUSH_RETRY_TIME_DISTANCE_IN_MILLSECONDS); - retryer.pushRetry(this); + delay((long) retryTimes * EventMeshConstants.DEFAULT_PUSH_RETRY_TIME_DISTANCE_IN_MILLSECONDS); + grpcRetryer.pushRetry(this); } else { complete.compareAndSet(Boolean.FALSE, Boolean.TRUE); } } - public boolean isComplete() { + protected boolean isComplete() { return complete.get(); } - public void complete() { + protected void finish() { + AbstractContext context = handleMsgContext.getContext(); + CloudEvent event = handleMsgContext.getEvent(); + SubscriptionMode subscriptionMode = handleMsgContext.getSubscriptionMode(); + if (eventMeshConsumer != null && context != null && event != null) { + try { + eventMeshConsumer.updateOffset(subscriptionMode, Collections.singletonList(event), context); + } catch (Exception e) { + logger.error("Error in updating offset in EventMeshConsumer", e); + } + } + } + + protected void complete() { complete.compareAndSet(Boolean.FALSE, Boolean.TRUE); } - public void timeout() { + protected void timeout() { if (!isComplete() && System.currentTimeMillis() - lastPushTime >= ttl) { delayRetry(); } @@ -75,4 +154,19 @@ public void timeout() { public HandleMsgContext getHandleMsgContext() { return handleMsgContext; } + + protected void addToWaitingMap(WebhookPushRequest request) { + if (waitingRequests.containsKey(handleMsgContext.getConsumerGroup())) { + waitingRequests.get(handleMsgContext.getConsumerGroup()).add(request); + return; + } + waitingRequests.put(handleMsgContext.getConsumerGroup(), Sets.newConcurrentHashSet()); + waitingRequests.get(handleMsgContext.getConsumerGroup()).add(request); + } + + protected void removeWaitingMap(WebhookPushRequest request) { + if (waitingRequests.containsKey(handleMsgContext.getConsumerGroup())) { + waitingRequests.get(handleMsgContext.getConsumerGroup()).remove(request); + } + } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HandleMsgContext.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HandleMsgContext.java index 5ca1367946..c9330d6afc 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HandleMsgContext.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HandleMsgContext.java @@ -22,51 +22,44 @@ import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.eventmesh.api.AbstractContext; import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; +import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collections; public class HandleMsgContext { - private final String msgRandomNo; private final SubscriptionMode subscriptionMode; private final EventMeshGrpcServer eventMeshGrpcServer; + private final EventMeshConsumer eventMeshConsumer; private final ConsumerGroupTopicConfig consumeTopicConfig; - public Logger messageLogger = LoggerFactory.getLogger("message"); - private String consumerGroup; - private EventMeshConsumer eventMeshConsumer; - private String bizSeqNo; - private String uniqueId; - private String topic; - private CloudEvent event; - private int ttl; - private long createTime = System.currentTimeMillis(); - private AbstractContext context; - - public HandleMsgContext(String msgRandomNo, String consumerGroup, EventMeshConsumer eventMeshConsumer, - String topic, CloudEvent event, SubscriptionMode subscriptionMode, + + private final GrpcType grpcType; + private final String consumerGroup; + + private final CloudEvent event; + private final AbstractContext context; + + public HandleMsgContext(String consumerGroup, CloudEvent event, SubscriptionMode subscriptionMode, GrpcType grpcType, AbstractContext context, EventMeshGrpcServer eventMeshGrpcServer, - String bizSeqNo, String uniqueId, ConsumerGroupTopicConfig consumeTopicConfig) { - this.msgRandomNo = msgRandomNo; + EventMeshConsumer eventMeshConsumer, ConsumerGroupTopicConfig consumeTopicConfig) { + this.msgRandomNo = EventMeshUtil.buildPushMsgSeqNo(); this.consumerGroup = consumerGroup; - this.eventMeshConsumer = eventMeshConsumer; - this.topic = topic; + this.grpcType = grpcType; this.subscriptionMode = subscriptionMode; this.event = event; this.context = context; this.eventMeshGrpcServer = eventMeshGrpcServer; - this.bizSeqNo = bizSeqNo; - this.uniqueId = uniqueId; + this.eventMeshConsumer = eventMeshConsumer; this.consumeTopicConfig = consumeTopicConfig; - - String ttlStr = (String) event.getExtension(Constants.PROPERTY_MESSAGE_TIMEOUT); - this.ttl = StringUtils.isNumeric(ttlStr) ? Integer.parseInt(ttlStr) : EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS; } public String getMsgRandomNo() { @@ -77,103 +70,41 @@ public ConsumerGroupTopicConfig getConsumeTopicConfig() { return consumeTopicConfig; } - public String getBizSeqNo() { - return bizSeqNo; - } - - public void setBizSeqNo(String bizSeqNo) { - this.bizSeqNo = bizSeqNo; - } - public String getConsumerGroup() { return consumerGroup; } - public void setConsumerGroup(String consumerGroup) { - this.consumerGroup = consumerGroup; - } - - public EventMeshConsumer getEventMeshConsumer() { - return eventMeshConsumer; - } - - public void setEventMeshConsumer(EventMeshConsumer eventMeshConsumer) { - this.eventMeshConsumer = eventMeshConsumer; - } - - public String getTopic() { - return topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - public CloudEvent getEvent() { return event; } - public void setEvent(CloudEvent event) { - this.event = event; - } - - public long getCreateTime() { - return createTime; - } - - public void setCreateTime(long createTime) { - this.createTime = createTime; - } - public AbstractContext getContext() { return context; } - public void setContext(AbstractContext context) { - this.context = context; - } - public EventMeshGrpcServer getEventMeshGrpcServer() { return eventMeshGrpcServer; } - public void finish() { - if (eventMeshConsumer != null && context != null && event != null) { - try { - eventMeshConsumer.updateOffset(subscriptionMode, Collections.singletonList(event), context); - } catch (Exception e) { - messageLogger.error("Error in updating offset in EventMeshConsumer", e); - } - } - } - - public String getUniqueId() { - return uniqueId; + public EventMeshConsumer getEventMeshConsumer() { + return eventMeshConsumer; } - public void setUniqueId(String uniqueId) { - this.uniqueId = uniqueId; + public SubscriptionMode getSubscriptionMode() { + return subscriptionMode; } - public int getTtl() { - return ttl; + public GrpcType getGrpcType() { + return grpcType; } - public void setTtl(int ttl) { - this.ttl = ttl; - } @Override public String toString() { return "handleMsgContext={" + "consumerGroup=" + consumerGroup - + ",topic=" + topic + ",subscriptionMode=" + subscriptionMode + ",consumeTopicConfig=" + consumeTopicConfig - + ",bizSeqNo=" + bizSeqNo - + ",uniqueId=" + uniqueId - + ",ttl=" + ttl - + ",createTime=" + DateFormatUtils.format(createTime, Constants.DATE_FORMAT) + "}"; + + "}"; } - } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java index 3060fb2032..f50a3d7c68 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java @@ -21,6 +21,7 @@ import com.google.common.collect.Sets; import org.apache.commons.collections4.MapUtils; import org.apache.eventmesh.common.ThreadPoolFactory; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +59,7 @@ private void checkTimeout() { }); } - public boolean handle(String protocol, final HandleMsgContext handleMsgContext) { + public boolean handle(HandleMsgContext handleMsgContext) { Set waitingRequests4Group = MapUtils.getObject(waitingRequests, handleMsgContext.getConsumerGroup(), Sets.newConcurrentHashSet()); if (waitingRequests4Group.size() > CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD) { @@ -69,25 +70,21 @@ public boolean handle(String protocol, final HandleMsgContext handleMsgContext) try { pushExecutor.submit(() -> { - AbstractPushRequest pushRequest = createHttpPushRequest(protocol, handleMsgContext); - if (pushRequest != null) { - pushRequest.tryPushRequest(); - } + AbstractPushRequest pushRequest = createHttpPushRequest(handleMsgContext); + pushRequest.tryPushRequest(); }); return true; } catch (RejectedExecutionException e) { - //logger.warn("pushMsgThreadPoolQueue is full, so reject, current task size {}", - //handleMsgContext.getEventMeshHTTPServer().getPushMsgExecutor().getQueue().size(), e); return false; } } - private AbstractPushRequest createHttpPushRequest(String protocol, HandleMsgContext handleMsgContext) { - if ("grpc".equals(protocol)) { - return new HttpPushRequest(handleMsgContext, waitingRequests); - } else if ("grpc_stream".equals(protocol)) { + private AbstractPushRequest createHttpPushRequest(HandleMsgContext handleMsgContext) { + GrpcType grpcType = handleMsgContext.getGrpcType(); + if (GrpcType.WEBHOOK.equals(grpcType)) { + return new WebhookPushRequest(handleMsgContext, waitingRequests); + } else { return new StreamPushRequest(handleMsgContext, waitingRequests); } - return null; } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java index 0d52d1aa9b..7624c0b76b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java @@ -1,51 +1,34 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.push; -import io.cloudevents.CloudEvent; -import io.cloudevents.core.builder.CloudEventBuilder; import io.grpc.stub.StreamObserver; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.RandomUtils; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.protocol.ProtocolTransportObject; -import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; -import org.apache.eventmesh.protocol.api.ProtocolAdaptor; -import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; -import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; -import org.apache.eventmesh.runtime.constants.EventMeshConstants; -import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupTopicConfig; - +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.StreamTopicConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Set; public class StreamPushRequest extends AbstractPushRequest { - private HandleMsgContext handleMsgContext; - - private Map> waitingRequests; - - private EventMeshGrpcConfiguration grpcConfiguration; - - private ConsumerGroupTopicConfig topicConfig; + private final Logger logger = LoggerFactory.getLogger(this.getClass()); - private Map>> idcEmitters; + private final Map>> idcEmitters; - private List> totalEmitters; + private final List> totalEmitters; - private volatile int startIdx; + private final int startIdx; public StreamPushRequest(HandleMsgContext handleMsgContext, Map> waitingRequests) { - super(handleMsgContext); - this.handleMsgContext = handleMsgContext; - this.waitingRequests = waitingRequests; - this.grpcConfiguration = handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration(); - this.topicConfig = handleMsgContext.getConsumeTopicConfig(); - this.idcEmitters = buildIdcEmitter(this.topicConfig.getIdcEmitters()); + super(handleMsgContext, waitingRequests); + + StreamTopicConfig topicConfig = (StreamTopicConfig) handleMsgContext.getConsumeTopicConfig(); + this.idcEmitters = buildIdcEmitter(topicConfig.getIdcEmitters()); this.totalEmitters = buildTotalEmitter(); this.startIdx = RandomUtils.nextInt(0, totalEmitters.size()); } @@ -54,41 +37,18 @@ public StreamPushRequest(HandleMsgContext handleMsgContext, Map eventEmitter = selectEmitter(); - CloudEvent event = CloudEventBuilder.from(handleMsgContext.getEvent()) - .withExtension(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, - String.valueOf(System.currentTimeMillis())) - .build(); - handleMsgContext.setEvent(event); - - try { - String protocolType = Objects.requireNonNull(event.getExtension(Constants.PROTOCOL_TYPE)).toString(); - - ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); - - ProtocolTransportObject protocolTransportObject = - protocolAdaptor.fromCloudEvent(handleMsgContext.getEvent()); - - EventMeshMessage eventMeshMessage = ((EventMeshMessageWrapper) protocolTransportObject).getMessage(); - if (eventMeshMessage != null) { - eventEmitter.onNext(eventMeshMessage); - } - } catch (Exception e) { - e.printStackTrace(); + EventMeshMessage eventMeshMessage = getEventMeshMessage(event); + if (eventMeshMessage == null) { + return; } - + eventEmitter.onNext(eventMeshMessage); complete(); - if (isComplete()) { - handleMsgContext.finish(); - } - } - - @Override - public boolean retry() throws Exception { - return false; + finish(); } private StreamObserver selectEmitter() { - List> emitterList = MapUtils.getObject(idcEmitters, grpcConfiguration.eventMeshIDC, null); + List> emitterList = MapUtils.getObject(idcEmitters, + eventMeshGrpcConfiguration.eventMeshIDC, null); if (CollectionUtils.isNotEmpty(emitterList)) { return emitterList.get((startIdx + retryTimes) % emitterList.size()); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HttpPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java similarity index 56% rename from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HttpPushRequest.java rename to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java index 13f0ccd9a3..4c7517b717 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/HttpPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java @@ -18,18 +18,12 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.push; import com.fasterxml.jackson.core.type.TypeReference; -import com.google.common.collect.Sets; -import io.cloudevents.CloudEvent; -import io.cloudevents.core.builder.CloudEventBuilder; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.exception.JsonException; -import org.apache.eventmesh.common.protocol.ProtocolTransportObject; -import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; import org.apache.eventmesh.common.protocol.http.common.ClientRetCode; @@ -38,10 +32,8 @@ import org.apache.eventmesh.common.protocol.http.common.RequestCode; import org.apache.eventmesh.common.utils.IPUtils; import org.apache.eventmesh.common.utils.JsonUtils; -import org.apache.eventmesh.common.utils.RandomStringUtils; -import org.apache.eventmesh.protocol.api.ProtocolAdaptor; -import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.WebhookTopicConfig; import org.apache.eventmesh.runtime.util.EventMeshUtil; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -61,37 +53,31 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Set; -public class HttpPushRequest extends AbstractPushRequest { +public class WebhookPushRequest extends AbstractPushRequest { - private Logger messageLogger = LoggerFactory.getLogger("message"); + private final Logger messageLogger = LoggerFactory.getLogger("message"); - private Logger cmdLogger = LoggerFactory.getLogger("cmd"); - - private Logger logger = LoggerFactory.getLogger(this.getClass()); + private final Logger cmdLogger = LoggerFactory.getLogger("cmd"); /** - * Key: idc - * Value: list of URLs + * Key: idc + * Value: list of URLs **/ private final Map> urls; - private List totalUrls; + private final List totalUrls; - private volatile int startIdx; + private final int startIdx; private String currPushUrl; - private Map> waitingRequests; - - public HttpPushRequest(HandleMsgContext handleMsgContext, - Map> waitingRequests) { - super(handleMsgContext); - this.waitingRequests = waitingRequests; + public WebhookPushRequest(HandleMsgContext handleMsgContext, + Map> waitingRequests) { + super(handleMsgContext, waitingRequests); - this.urls = handleMsgContext.getConsumeTopicConfig().getIdcUrls(); + this.urls = ((WebhookTopicConfig) handleMsgContext.getConsumeTopicConfig()).getIdcUrls(); this.totalUrls = buildTotalUrls(); this.startIdx = RandomUtils.nextInt(0, totalUrls.size()); } @@ -121,50 +107,23 @@ public void tryPushRequest() { builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIDC, handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration().eventMeshIDC); - CloudEvent event = CloudEventBuilder.from(handleMsgContext.getEvent()) - .withExtension(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, - String.valueOf(System.currentTimeMillis())) - .build(); - handleMsgContext.setEvent(event); - String content = ""; - try { - String protocolType = Objects.requireNonNull(event.getExtension(Constants.PROTOCOL_TYPE)).toString(); - - ProtocolAdaptor protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); - - ProtocolTransportObject protocolTransportObject = - protocolAdaptor.fromCloudEvent(handleMsgContext.getEvent()); - - EventMeshMessage eventMeshMessage = ((EventMeshMessageWrapper) protocolTransportObject).getMessage(); - content = eventMeshMessage.getContent(); - } catch (Exception ex) { + EventMeshMessage eventMeshMessage = getEventMeshMessage(event); + if (eventMeshMessage == null) { return; + } else { + content = eventMeshMessage.getContent(); } List body = new ArrayList<>(); body.add(new BasicNameValuePair(PushMessageRequestBody.CONTENT, content)); - if (StringUtils.isBlank(handleMsgContext.getBizSeqNo())) { - body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, - RandomStringUtils.generateNum(20))); - } else { - body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, - handleMsgContext.getBizSeqNo())); - } - if (StringUtils.isBlank(handleMsgContext.getUniqueId())) { - body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, - RandomStringUtils.generateNum(20))); - } else { - body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, - handleMsgContext.getUniqueId())); - } - + body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, bizSeqNum)); + body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, uniqueId)); body.add(new BasicNameValuePair(PushMessageRequestBody.RANDOMNO, handleMsgContext.getMsgRandomNo())); - body.add(new BasicNameValuePair(PushMessageRequestBody.TOPIC, handleMsgContext.getTopic())); - + body.add(new BasicNameValuePair(PushMessageRequestBody.TOPIC, topic)); body.add(new BasicNameValuePair(PushMessageRequestBody.EXTFIELDS, - JsonUtils.serialize(EventMeshUtil.getEventProp(handleMsgContext.getEvent())))); + JsonUtils.serialize(EventMeshUtil.getEventProp(event)))); builder.setEntity(new UrlEncodedFormEntity(body, StandardCharsets.UTF_8)); @@ -181,19 +140,18 @@ public void tryPushRequest() { eventMeshGrpcServer.getHttpClient().execute(builder, new ResponseHandler() { @Override public Object handleResponse(HttpResponse response) { - removeWaitingMap(HttpPushRequest.this); + removeWaitingMap(WebhookPushRequest.this); long cost = System.currentTimeMillis() - lastPushTime; //eventMeshHTTPServer.metrics.summaryMetrics.recordHTTPPushTimeCost(cost); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { //eventMeshHTTPServer.metrics.summaryMetrics.recordHttpPushMsgFailed(); messageLogger.info( "message|eventMesh2client|exception|url={}|topic={}|bizSeqNo={}" - + "|uniqueId={}|cost={}", currPushUrl, handleMsgContext.getTopic(), - handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), cost); + + "|uniqueId={}|cost={}", currPushUrl, topic, bizSeqNum, uniqueId, cost); delayRetry(); if (isComplete()) { - handleMsgContext.finish(); + finish(); } } else { String res = ""; @@ -201,34 +159,21 @@ public Object handleResponse(HttpResponse response) { res = EntityUtils.toString(response.getEntity(), Charset.forName(EventMeshConstants.DEFAULT_CHARSET)); } catch (IOException e) { - handleMsgContext.finish(); + finish(); return new Object(); } ClientRetCode result = processResponseContent(res); messageLogger.info( "message|eventMesh2client|{}|url={}|topic={}|bizSeqNo={}" + "|uniqueId={}|cost={}", - result, currPushUrl, handleMsgContext.getTopic(), - handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), cost); - if (result == ClientRetCode.OK) { + result, currPushUrl, topic, bizSeqNum, uniqueId, cost); + if (result == ClientRetCode.OK || result == ClientRetCode.FAIL) { complete(); - if (isComplete()) { - handleMsgContext.finish(); - } - } else if (result == ClientRetCode.RETRY) { - delayRetry(); - if (isComplete()) { - handleMsgContext.finish(); - } - } else if (result == ClientRetCode.NOLISTEN) { + finish(); + } else if (result == ClientRetCode.RETRY || result == ClientRetCode.NOLISTEN) { delayRetry(); if (isComplete()) { - handleMsgContext.finish(); - } - } else if (result == ClientRetCode.FAIL) { - complete(); - if (isComplete()) { - handleMsgContext.finish(); + finish(); } } } @@ -238,39 +183,35 @@ public Object handleResponse(HttpResponse response) { if (messageLogger.isDebugEnabled()) { messageLogger.debug("message|eventMesh2client|url={}|topic={}|event={}", currPushUrl, - handleMsgContext.getTopic(), - handleMsgContext.getEvent()); + topic, event); } else { messageLogger .info("message|eventMesh2client|url={}|topic={}|bizSeqNo={}|uniqueId={}", - currPushUrl, handleMsgContext.getTopic(), - handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId()); + currPushUrl, topic, bizSeqNum, uniqueId); } } catch (IOException e) { messageLogger.error("push2client err", e); removeWaitingMap(this); delayRetry(); if (isComplete()) { - handleMsgContext.finish(); + finish(); } } } @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("asyncPushRequest={") - .append("bizSeqNo=").append(handleMsgContext.getBizSeqNo()) - .append(",startIdx=").append(startIdx) - .append(",retryTimes=").append(retryTimes) - .append(",uniqueId=").append(handleMsgContext.getUniqueId()) - .append(",executeTime=") - .append(DateFormatUtils.format(executeTime, Constants.DATE_FORMAT)) - .append(",lastPushTime=") - .append(DateFormatUtils.format(lastPushTime, Constants.DATE_FORMAT)) - .append(",createTime=") - .append(DateFormatUtils.format(createTime, Constants.DATE_FORMAT)).append("}"); - return sb.toString(); + return "asyncPushRequest={" + + "bizSeqNo=" + bizSeqNum + + ",startIdx=" + startIdx + + ",retryTimes=" + retryTimes + + ",uniqueId=" + uniqueId + + ",executeTime=" + + DateFormatUtils.format(executeTime, Constants.DATE_FORMAT) + + ",lastPushTime=" + + DateFormatUtils.format(lastPushTime, Constants.DATE_FORMAT) + + ",createTime=" + + DateFormatUtils.format(createTime, Constants.DATE_FORMAT) + "}"; } private ClientRetCode processResponseContent(String content) { @@ -286,45 +227,14 @@ private ClientRetCode processResponseContent(String content) { if (retCode != null && ClientRetCode.contains(retCode)) { return ClientRetCode.get(retCode); } - - return ClientRetCode.FAIL; - } catch (NumberFormatException e) { - messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, - handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), content); return ClientRetCode.FAIL; - } catch (JsonException e) { + } catch (Exception e) { messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, - handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), content); - return ClientRetCode.FAIL; - } catch (Throwable t) { - messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, - handleMsgContext.getBizSeqNo(), handleMsgContext.getUniqueId(), content); + bizSeqNum, uniqueId, content); return ClientRetCode.FAIL; } } - private void addToWaitingMap(HttpPushRequest request) { - if (waitingRequests.containsKey(request.handleMsgContext.getConsumerGroup())) { - waitingRequests.get(request.handleMsgContext.getConsumerGroup()).add(request); - return; - } - waitingRequests - .put(request.handleMsgContext.getConsumerGroup(), Sets.newConcurrentHashSet()); - waitingRequests.get(request.handleMsgContext.getConsumerGroup()).add(request); - } - - private void removeWaitingMap(HttpPushRequest request) { - if (waitingRequests.containsKey(request.handleMsgContext.getConsumerGroup())) { - waitingRequests.get(request.handleMsgContext.getConsumerGroup()).remove(request); - } - } - - @Override - public boolean retry() { - tryPushRequest(); - return true; - } - private String getUrl() { List localIdcUrl = MapUtils.getObject(urls, eventMeshGrpcConfiguration.eventMeshIDC, null); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java index 75f10335c8..e3cd7571d3 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -8,6 +8,7 @@ import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; public class ServiceUtils { @@ -26,11 +27,8 @@ public static boolean validateMessage(EventMeshMessage message) { && (!StringUtils.isBlank(message.getTtl())); } - public static boolean validateSubscription(String protocol, Subscription subscription) { - if (!"grpc".equals(protocol) && !"grpc_stream".equals(protocol)) { - return false; - } - if ("grpc".equals(protocol) && StringUtils.isBlank(subscription.getUrl())) { + public static boolean validateSubscription(GrpcType grpcType, Subscription subscription) { + if (GrpcType.WEBHOOK.equals(grpcType) && StringUtils.isBlank(subscription.getUrl())) { return false; } if (CollectionUtils.isEmpty(subscription.getSubscriptionItemsList()) diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java index ad0d845903..7d13dabf98 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java @@ -54,12 +54,8 @@ public void subscribeStream(Subscription subscription) { logger.info("Subscribe streaming topic " + subscription.toString()); ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); - RequestHeader header = EventMeshClientUtil.buildHeader(clientConfig); - header = RequestHeader.newBuilder(header) - .setProtocolDesc("grpc_stream") - .build(); Subscription enhancedSubscription = Subscription.newBuilder(subscription) - .setHeader(header) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) .setConsumerGroup(clientConfig.getConsumerGroup()) .build(); Iterator msgIterator = consumerClient.subscribeStream(enhancedSubscription); From d20f0293828be8dd49e77af1b39d101b56ddc0be Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Wed, 22 Dec 2021 16:26:29 -0500 Subject: [PATCH 11/21] Grpc unsubscribe API --- .../eventmesh/grpc/sub/AsyncSubscribe.java | 6 ++ .../grpc/sub/app/service/SubService.java | 8 +- .../runtime/boot/EventMeshGrpcServer.java | 20 ++-- .../grpc/consumer/ConsumerManager.java | 71 +++++++++----- .../grpc/consumer/EventMeshConsumer.java | 36 +++++-- .../ConsumerGroupTopicConfig.java | 4 + .../consumergroup/StreamTopicConfig.java | 29 +++++- .../consumergroup/WebhookTopicConfig.java | 32 +++++- .../grpc/processor/SubscribeProcessor.java | 26 ++++- .../processor/SubscribeStreamProcessor.java | 37 ++++++- .../grpc/processor/UnsubscribeProcessor.java | 97 +++++++++++++++++++ .../grpc/service/ConsumerService.java | 12 +++ .../client/grpc/EventMeshGrpcConsumer.java | 17 +++- 13 files changed, 333 insertions(+), 62 deletions(-) create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/UnsubscribeProcessor.java diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java index 69ad3addb7..d958eeec63 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java @@ -50,6 +50,12 @@ public static void main(String[] args) { eventMeshGrpcConsumer.subscribeStream(subscription); + try { + Thread.sleep(12000); + } catch (Exception e) { + + } + eventMeshGrpcConsumer.unsubscribe(subscription); } @Override diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java index 995cf734cf..4bc755c4d8 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java @@ -74,7 +74,7 @@ public void afterPropertiesSet() throws Exception { EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() .serverAddr(eventMeshIp) .serverPort(Integer.parseInt(eventMeshGrpcPort)) - .consumerGroup("EventMeshTest-consumerGroup") + .consumerGroup("EventMeshTest-consumerGroup2") .env(env).idc(idc) .sys(subsys).build(); @@ -99,11 +99,7 @@ public void afterPropertiesSet() throws Exception { public void cleanup() { logger.info("start destory ...."); try { - /* List unSubList = new ArrayList<>(); - for (SubscriptionItem item : topicList) { - unSubList.add(item.getTopic()); - }*/ - // eventMeshHttpConsumer.unsubscribe(unSubList, url); + eventMeshGrpcConsumer.unsubscribe(subscription); } catch (Exception e) { e.printStackTrace(); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java index ac87e66219..313800c0fe 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java @@ -16,7 +16,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -40,7 +39,7 @@ public class EventMeshGrpcServer { private ThreadPoolExecutor sendMsgExecutor; - private ThreadPoolExecutor subscribeMsgExecutor; + private ThreadPoolExecutor clientMgmtExecutor; private ThreadPoolExecutor pushMsgExecutor; @@ -71,7 +70,7 @@ public void init() throws Exception { server = ServerBuilder.forPort(serverPort) .intercept(new MetricsInterceptor()) .addService(new ProducerService(this, sendMsgExecutor)) - .addService(new ConsumerService(this, subscribeMsgExecutor)) + .addService(new ConsumerService(this, clientMgmtExecutor)) .build(); logger.info("GRPCServer[port={}] started", serverPort); @@ -124,8 +123,8 @@ public ThreadPoolExecutor getSendMsgExecutor() { return sendMsgExecutor; } - public ThreadPoolExecutor getSubscribeMsgExecutor() { - return subscribeMsgExecutor; + public ThreadPoolExecutor getClientMgmtExecutor() { + return clientMgmtExecutor; } public ThreadPoolExecutor getPushMsgExecutor() { @@ -143,20 +142,21 @@ private void initThreadPool() { sendMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, - "eventMesh-grpc-sendMsg-", true); + "eventMesh-grpc-sendMsg-%d", true); BlockingQueue subscribeMsgThreadPoolQueue = new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgBlockQSize); - subscribeMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgThreadNum, + clientMgmtExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgThreadNum, eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgThreadNum, subscribeMsgThreadPoolQueue, - "eventMesh-grpc-subscribeMsg-", true); + "eventMesh-grpc-clientMgmt-%d", true); BlockingQueue pushMsgThreadPoolQueue = new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerPushMsgBlockQSize); + pushMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerPushMsgThreadNum, eventMeshGrpcConfiguration.eventMeshServerPushMsgThreadNum, pushMsgThreadPoolQueue, - "eventMesh-grpc-pushMsg-", true); + "eventMesh-grpc-pushMsg-%d", true); } private void initHttpClientPool() { @@ -169,7 +169,7 @@ private void initHttpClientPool() { private void shutdownThreadPools() { sendMsgExecutor.shutdown(); - subscribeMsgExecutor.shutdown(); + clientMgmtExecutor.shutdown(); pushMsgExecutor.shutdown(); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java index ae366d8ec8..b0f998720d 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -1,5 +1,6 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; @@ -9,7 +10,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.awt.Event; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -46,6 +49,15 @@ public void shutdown() throws Exception { logger.info("Grpc ConsumerManager shutdown......"); } + public EventMeshConsumer getEventMeshConsumer(String consumerGroup) { + EventMeshConsumer consumer = consumerTable.get(consumerGroup); + if (consumer == null) { + consumer = new EventMeshConsumer(eventMeshGrpcServer, consumerGroup); + consumerTable.put(consumerGroup, consumer); + } + return consumer; + } + public synchronized void registerClient(ConsumerGroupClient newClient) { String consumerGroup = newClient.getConsumerGroup(); String topic = newClient.getTopic(); @@ -83,37 +95,48 @@ public synchronized void registerClient(ConsumerGroupClient newClient) { } } - public synchronized boolean restartEventMeshConsumer(String consumerGroup) throws Exception { - EventMeshConsumer eventMeshConsumer = consumerTable.get(consumerGroup); + public synchronized void deregisterClient(ConsumerGroupClient client) { + String consumerGroup = client.getConsumerGroup(); + List localClients = clientTable.get(consumerGroup); + if (CollectionUtils.isEmpty(localClients)) { + return; + } - if (eventMeshConsumer == null) { - eventMeshConsumer = new EventMeshConsumer(eventMeshGrpcServer, consumerGroup); - consumerTable.put(consumerGroup, eventMeshConsumer); - eventMeshConsumer.init(); + Iterator iterator = localClients.iterator(); + while (iterator.hasNext()) { + ConsumerGroupClient localClient = iterator.next(); + if (StringUtils.equals(localClient.getTopic(), client.getTopic()) + && localClient.getSubscriptionMode().equals(client.getSubscriptionMode())) { + + // close the GRPC client stream before removing it + closeEventStream(localClient); + iterator.remove(); + } } - Set oldTopicConfigs = eventMeshConsumer.buildTopicConfig(); - List localClients = clientTable.get(consumerGroup); - for (ConsumerGroupClient client : localClients) { - eventMeshConsumer.registerClient(client); + if (localClients.size() == 0) { + clientTable.remove(consumerGroup); } + } - // start up eventMeshConsumer the first time - if (ServiceState.INITED.equals(eventMeshConsumer.getStatus())) { - eventMeshConsumer.start(); - return true; + private void closeEventStream(ConsumerGroupClient client) { + if (client.getEventEmitter() != null) { + client.getEventEmitter().onCompleted(); } + } - // determine if restart eventMeshConsumer required - Set newTopicConfigs = eventMeshConsumer.buildTopicConfig(); - if (!oldTopicConfigs.equals(newTopicConfigs)) { - logger.info("Consumergroup {} topic info changed, restart EventMeshConsumer.", consumerGroup); - if (ServiceState.RUNNING.equals(eventMeshConsumer.getStatus())) { - eventMeshConsumer.shutdown(); - } - eventMeshConsumer.start(); - return true; + public synchronized void restartEventMeshConsumer(String consumerGroup) throws Exception { + EventMeshConsumer eventMeshConsumer = consumerTable.get(consumerGroup); + + if (eventMeshConsumer == null) { + return; + } + + if (eventMeshConsumer.getStatus() == null) { + eventMeshConsumer.init(); + } else if (ServiceState.RUNNING.equals(eventMeshConsumer.getStatus())) { + eventMeshConsumer.shutdown(); } - return false; + eventMeshConsumer.start(); } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java index 6f82f2fd4b..e458e1be02 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java @@ -72,7 +72,13 @@ public EventMeshConsumer(EventMeshGrpcServer eventMeshGrpcServer, String consume this.broadcastMqConsumer = new MQConsumerWrapper(eventMeshGrpcConfiguration.eventMeshConnectorPluginType); } - public synchronized void registerClient(ConsumerGroupClient client) { + /** + * Register client's topic information and return true if this EventMeshConsumer required restart because of the topic changes + * @param client ConsumerGroupClient + * @return true if the underlining EventMeshConsumer needs to restart later; false otherwise + */ + public synchronized boolean registerClient(ConsumerGroupClient client) { + boolean requireRestart = false; GrpcType grpcType = client.getGrpcType(); String topic = client.getTopic(); SubscriptionMode subscriptionMode = client.getSubscriptionMode(); @@ -81,16 +87,29 @@ public synchronized void registerClient(ConsumerGroupClient client) { if (topicConfig == null) { topicConfig = ConsumerGroupTopicConfig.buildTopicConfig(consumerGroup, topic, subscriptionMode, grpcType); consumerGroupTopicConfig.put(topic, topicConfig); + requireRestart = true; } topicConfig.registerClient(client); + return requireRestart; } - public synchronized Set buildTopicConfig() { - Set topicConfigs = new HashSet<>(); - for (ConsumerGroupTopicConfig topicConfig : consumerGroupTopicConfig.values()) { - topicConfigs.add(topicConfig.getTopic() + topicConfig.getSubscriptionMode().name()); + /** + * Deregister client's topic information and return true if this EventMeshConsumer required restart because of the topic changes + * @param client ConsumerGroupClient + * @return true if the underlining EventMeshConsumer needs to restart later; false otherwise + */ + public synchronized boolean deregisterClient(ConsumerGroupClient client) { + boolean requireRestart = false; + String topic = client.getTopic(); + ConsumerGroupTopicConfig topicConfig = consumerGroupTopicConfig.get(topic); + if (topicConfig != null) { + topicConfig.deregisterClient(client); + if (topicConfig.getSize() == 0) { + consumerGroupTopicConfig.remove(topic); + requireRestart = true; + } } - return topicConfigs; + return requireRestart; } public synchronized void init() throws Exception { @@ -115,6 +134,11 @@ public synchronized void init() throws Exception { } public synchronized void start() throws Exception { + if (consumerGroupTopicConfig.size() == 0) { + // no topics, don't start the consumer + return; + } + for (Map.Entry entry : consumerGroupTopicConfig.entrySet()) { subscribe(entry.getKey(), entry.getValue().getSubscriptionMode()); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java index 6ec9f81963..c3d10afdd4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupTopicConfig.java @@ -33,6 +33,10 @@ public static ConsumerGroupTopicConfig buildTopicConfig(String consumerGroup, St public abstract void registerClient(ConsumerGroupClient client); + public abstract void deregisterClient(ConsumerGroupClient client); + + public abstract int getSize(); + public String getConsumerGroup() { return consumerGroup; } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java index 58df08c97b..35b87f490c 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java @@ -39,14 +39,33 @@ public synchronized void registerClient(ConsumerGroupClient client) { String clientIp = client.getIp(); String clientPid = client.getPid(); StreamObserver emitter = client.getEventEmitter(); + Map> emitters = idcEmitters.computeIfAbsent(idc, k -> new HashMap<>()); + emitters.put(clientIp + ":" + clientPid, emitter); + } + + @Override + public void deregisterClient(ConsumerGroupClient client) { + String idc = client.getIdc(); + String clientIp = client.getIp(); + String clientPid = client.getPid(); + Map> emitters = idcEmitters.get(idc); if (emitters == null) { - emitters = new HashMap<>(); - emitters.put(clientIp + clientPid, emitter); - idcEmitters.put(idc, emitters); - } else if (!emitters.containsKey(clientIp + ":" + clientPid)) { - emitters.put(clientIp + clientPid, emitter); + return; + } + emitters.remove(clientIp + ":" + clientPid); + if (emitters.size() == 0) { + idcEmitters.remove(idc); + } + } + + @Override + public int getSize() { + int total = 0; + for (Map> emitters : idcEmitters.values()) { + total += emitters.size(); } + return total; } @Override diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java index a4c1315d8c..3af7d98ae4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java @@ -1,5 +1,7 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,14 +35,34 @@ public synchronized void registerClient(ConsumerGroupClient client) { } String idc = client.getIdc(); String url = client.getUrl(); + List urls = idcUrls.computeIfAbsent(idc, k -> new LinkedList<>()); + if (!urls.contains(url)) { + urls.add(url); + } + } + + @Override + public void deregisterClient(ConsumerGroupClient client) { + String idc = client.getIdc(); + String url = client.getUrl(); + List urls = idcUrls.get(idc); if (urls == null) { - urls = new LinkedList<>(); - urls.add(url); - idcUrls.put(idc, urls); - } else if (!urls.contains(url)) { - urls.add(url); + return; + } + urls.remove(url); + if (urls.size() == 0) { + idcUrls.remove(idc); + } + } + + @Override + public int getSize() { + int total = 0; + for (List urls : idcUrls.values()) { + total += urls.size(); } + return total; } @Override diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java index 7e9206eb40..d9826bb145 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java @@ -7,6 +7,7 @@ import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; @@ -14,7 +15,9 @@ import org.slf4j.LoggerFactory; import java.util.Date; +import java.util.LinkedList; import java.util.List; +import java.util.Set; public class SubscribeProcessor { @@ -48,6 +51,8 @@ public void process(Subscription subscription, StreamObserver response String url = subscription.getUrl(); List subscriptionItems = subscription.getSubscriptionItemsList(); + // Collect new clients in the subscription + List newClients = new LinkedList<>(); for (Subscription.SubscriptionItem item : subscriptionItems) { ConsumerGroupClient newClient = ConsumerGroupClient.builder() .env(header.getEnv()) @@ -62,12 +67,29 @@ public void process(Subscription subscription, StreamObserver response .url(url) .lastUpTime(new Date()) .build(); + newClients.add(newClient); + } + // register new clients into ConsumerManager + for (ConsumerGroupClient newClient : newClients) { consumerManager.registerClient(newClient); } - boolean restartResult = consumerManager.restartEventMeshConsumer(consumerGroup); - if (!restartResult) { + // register new clients into EventMeshConsumer + EventMeshConsumer eventMeshConsumer = consumerManager.getEventMeshConsumer(consumerGroup); + + boolean requireRestart = false; + for (ConsumerGroupClient newClient : newClients) { + if (eventMeshConsumer.registerClient(newClient)) { + requireRestart = true; + } + } + + // restart consumer group if required + if (requireRestart) { + logger.info("ConsumerGroup {} topic info changed, restart EventMesh Consumer", consumerGroup); + consumerManager.restartEventMeshConsumer(consumerGroup); + } else { logger.warn("EventMesh consumer [{}] didn't restart.", consumerGroup); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java index cc5a25ca8b..eb317e45f7 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java @@ -8,6 +8,7 @@ import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; @@ -16,8 +17,10 @@ import java.util.Date; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; public class SubscribeStreamProcessor { @@ -50,6 +53,8 @@ public void process(Subscription subscription, StreamObserver String consumerGroup = subscription.getConsumerGroup(); List subscriptionItems = subscription.getSubscriptionItemsList(); + // Collect new clients in subscription + List newClients = new LinkedList<>(); for (Subscription.SubscriptionItem item : subscriptionItems) { ConsumerGroupClient newClient = ConsumerGroupClient.builder() .env(header.getEnv()) @@ -64,14 +69,42 @@ public void process(Subscription subscription, StreamObserver .eventEmitter(responseObserver) .lastUpTime(new Date()) .build(); + newClients.add(newClient); + } + // register new clients into ConsumerManager + for (ConsumerGroupClient newClient : newClients) { consumerManager.registerClient(newClient); } - boolean restart = consumerManager.restartEventMeshConsumer(consumerGroup); - if (!restart) { + // register new clients into EventMeshConsumer + EventMeshConsumer eventMeshConsumer = consumerManager.getEventMeshConsumer(consumerGroup); + + boolean requireRestart = false; + for (ConsumerGroupClient newClient : newClients) { + if (eventMeshConsumer.registerClient(newClient)) { + requireRestart = true; + } + } + + // restart consumer group if required + if (requireRestart) { + logger.info("ConsumerGroup {} topic info changed, restart EventMesh Consumer", consumerGroup); + consumerManager.restartEventMeshConsumer(consumerGroup); + } else { logger.warn("EventMesh consumer [{}] didn't restart.", consumerGroup); } + + // send back subscribe success response + Map resp = new HashMap<>(); + resp.put("respCode", StatusCode.SUCCESS.getRetCode()); + resp.put("respMsg", "subscribe success"); + + EventMeshMessage eventMeshMessage = EventMeshMessage.newBuilder() + .setHeader(header) + .setContent(JsonUtils.serialize(resp)) + .build(); + responseObserver.onNext(eventMeshMessage); } private void sendResp(Subscription subscription, StatusCode code, StreamObserver responseObserver) { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/UnsubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/UnsubscribeProcessor.java new file mode 100644 index 0000000000..1076b2470b --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/UnsubscribeProcessor.java @@ -0,0 +1,97 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.processor; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.common.ServiceState; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +public class UnsubscribeProcessor { + + private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + public UnsubscribeProcessor(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { + + RequestHeader header = subscription.getHeader(); + + if (!ServiceUtils.validateHeader(header)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + return; + } + + if (!ServiceUtils.validateSubscription(null, subscription)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + return; + } + + ConsumerManager consumerManager = eventMeshGrpcServer.getConsumerManager(); + + String consumerGroup = subscription.getConsumerGroup(); + String url = subscription.getUrl(); + List subscriptionItems = subscription.getSubscriptionItemsList(); + + // Collect clients to remove in the unsubscribe + List removeClients = new LinkedList<>(); + for (Subscription.SubscriptionItem item : subscriptionItems) { + ConsumerGroupClient newClient = ConsumerGroupClient.builder() + .env(header.getEnv()) + .idc(header.getIdc()) + .sys(header.getSys()) + .ip(header.getIp()) + .pid(header.getPid()) + .consumerGroup(consumerGroup) + .topic(item.getTopic()) + .subscriptionMode(item.getMode()) + .url(url) + .lastUpTime(new Date()) + .build(); + removeClients.add(newClient); + consumerManager.deregisterClient(newClient); + } + + // deregister clients from ConsumerManager + for (ConsumerGroupClient client : removeClients) { + consumerManager.deregisterClient(client); + } + + // deregister clients from EventMeshConsumer + EventMeshConsumer eventMeshConsumer = consumerManager.getEventMeshConsumer(consumerGroup); + + boolean requireRestart = false; + for (ConsumerGroupClient client : removeClients) { + if (eventMeshConsumer.deregisterClient(client)) { + requireRestart = true; + } + } + + // restart consumer group if required + if (requireRestart) { + logger.info("ConsumerGroup {} topic info changed, restart EventMesh Consumer", consumerGroup); + consumerManager.restartEventMeshConsumer(consumerGroup); + } else { + logger.warn("EventMesh consumer [{}] didn't restart.", consumerGroup); + } + + ServiceUtils.sendResp(StatusCode.SUCCESS, "unsubscribe success", responseObserver); + } +} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java index 4ae4eef2ed..7a655c74f5 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java @@ -11,6 +11,7 @@ import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SubscribeProcessor; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SubscribeStreamProcessor; +import org.apache.eventmesh.runtime.core.protocol.grpc.processor.UnsubscribeProcessor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,5 +73,16 @@ public void subscribeStream(Subscription request, StreamObserver responseObserver) { + threadPoolExecutor.submit(() -> { + UnsubscribeProcessor unsubscribeProcessor = new UnsubscribeProcessor(eventMeshGrpcServer); + try { + unsubscribeProcessor.process(request, responseObserver); + } catch (Exception e) { + logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_UNSUBSCRIBE_ERR.getRetCode(), + StatusCode.EVENTMESH_UNSUBSCRIBE_ERR.getErrMsg(), e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_UNSUBSCRIBE_ERR, e.getMessage(), + responseObserver); + } + }); } } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java index 7d13dabf98..6a64e010ff 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java @@ -38,7 +38,7 @@ public void init() { } public Response subscribe(Subscription subscription) { - logger.info("Subscribe topic " + subscription.toString()); + logger.info("Create subscription: " + subscription.toString()); ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); Subscription enhancedSubscription = Subscription.newBuilder(subscription) @@ -51,7 +51,7 @@ public Response subscribe(Subscription subscription) { } public void subscribeStream(Subscription subscription) { - logger.info("Subscribe streaming topic " + subscription.toString()); + logger.info("Create streaming subscription: " + subscription.toString()); ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); Subscription enhancedSubscription = Subscription.newBuilder(subscription) @@ -65,6 +65,19 @@ public void subscribeStream(Subscription subscription) { listenerThread.start(); } + public Response unsubscribe(Subscription subscription) { + logger.info("Removing subscription: " + subscription.toString()); + ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); + Subscription enhancedSubscription = Subscription.newBuilder(subscription) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setConsumerGroup(clientConfig.getConsumerGroup()) + .build(); + + Response response = consumerClient.unsubscribe(enhancedSubscription); + logger.info("Received response " + response.toString()); + return response; + } + public void registerListener(ReceiveMsgHook listener) { if (this.listener == null) { this.listener = listener; From c622ab522a00f7823db131449919641f162649a1 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Wed, 22 Dec 2021 18:00:43 -0500 Subject: [PATCH 12/21] Grpc consumer Heartbeat API --- .../runtime/boot/EventMeshGrpcServer.java | 2 + .../grpc/consumer/ConsumerManager.java | 72 ++++++++++++++++++- .../grpc/processor/HeartbeatProcessor.java | 67 +++++++++++++++++ .../grpc/service/HeartbeatService.java | 41 +++++++++++ .../protocol/grpc/service/ServiceUtils.java | 43 ++++++++--- .../client/grpc/EventMeshGrpcConsumer.java | 69 ++++++++++++++++++ 6 files changed, 282 insertions(+), 12 deletions(-) create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java index 313800c0fe..ffaf24e8ff 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java @@ -10,6 +10,7 @@ import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.retry.GrpcRetryer; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ConsumerService; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.HeartbeatService; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ProducerService; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; @@ -71,6 +72,7 @@ public void init() throws Exception { .intercept(new MetricsInterceptor()) .addService(new ProducerService(this, sendMsgExecutor)) .addService(new ConsumerService(this, clientMgmtExecutor)) + .addService(new HeartbeatService(this, clientMgmtExecutor)) .build(); logger.info("GRPCServer[port={}] started", serverPort); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java index b0f998720d..f62fe377ba 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -3,6 +3,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.common.ServiceState; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; @@ -10,13 +11,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.awt.Event; import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; public class ConsumerManager { @@ -24,6 +30,10 @@ public class ConsumerManager { private final EventMeshGrpcServer eventMeshGrpcServer; + private static final int DEFAULT_UPDATE_TIME = 3 * 30 * 1000; + + private ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); + // key: ConsumerGroup private final Map> clientTable = new ConcurrentHashMap<>(); @@ -39,6 +49,7 @@ public void init() throws Exception { } public void start() throws Exception { + startClientCheck(); logger.info("Grpc ConsumerManager started......"); } @@ -46,6 +57,7 @@ public void shutdown() throws Exception { for (EventMeshConsumer consumer : consumerTable.values()) { consumer.shutdown(); } + scheduledExecutorService.shutdown(); logger.info("Grpc ConsumerManager shutdown......"); } @@ -95,6 +107,23 @@ public synchronized void registerClient(ConsumerGroupClient newClient) { } } + public void updateClientTime(ConsumerGroupClient client) { + String consumerGroup = client.getConsumerGroup(); + List localClients = clientTable.get(consumerGroup); + if (CollectionUtils.isEmpty(localClients)) { + return; + } + for (ConsumerGroupClient localClient : localClients) { + if (StringUtils.equals(localClient.getIp(), client.getIp()) + && StringUtils.equals(localClient.getPid(), client.getPid()) + && StringUtils.equals(localClient.getSys(), client.getSys()) + && StringUtils.equals(localClient.getTopic(), client.getTopic())) { + localClient.setLastUpTime(new Date()); + break; + } + } + } + public synchronized void deregisterClient(ConsumerGroupClient client) { String consumerGroup = client.getConsumerGroup(); List localClients = clientTable.get(consumerGroup); @@ -138,5 +167,46 @@ public synchronized void restartEventMeshConsumer(String consumerGroup) throws E eventMeshConsumer.shutdown(); } eventMeshConsumer.start(); + + if (!ServiceState.RUNNING.equals(eventMeshConsumer.getStatus())) { + consumerTable.remove(consumerGroup); + } + } + + private void startClientCheck() { + scheduledExecutorService.scheduleAtFixedRate(() -> { + logger.info("grpc client info check"); + List clientList = new LinkedList<>(); + for (List clients : clientTable.values()) { + clientList.addAll(clients); + } + if (logger.isDebugEnabled()) { + logger.debug("total number of ConsumerGroupClients: {}", clientList.size()); + } + + Set consumerGroupRestart = new HashSet<>(); + for (ConsumerGroupClient client : clientList) { + if (System.currentTimeMillis() - client.getLastUpTime().getTime() > DEFAULT_UPDATE_TIME) { + logger.warn("client {} lastUpdate time {} over three heartbeat cycles. Removing it", + JsonUtils.serialize(client), client.getLastUpTime()); + String consumerGroup = client.getConsumerGroup(); + EventMeshConsumer consumer = getEventMeshConsumer(consumerGroup); + + deregisterClient(client); + if (consumer.deregisterClient(client)) { + consumerGroupRestart.add(consumerGroup); + } + } + } + + // restart EventMeshConsumer for the group + for (String consumerGroup : consumerGroupRestart) { + try { + restartEventMeshConsumer(consumerGroup); + } catch (Exception e) { + logger.error("Error in restarting EventMeshConsumer [{}]", consumerGroup, e); + } + } + }, 10000, 10000, TimeUnit.MILLISECONDS); } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java new file mode 100644 index 0000000000..2935399127 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java @@ -0,0 +1,67 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.processor; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat; +import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.ClientType; +import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.HeartbeatItem; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.Date; + +public class HeartbeatProcessor { + private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private EventMeshGrpcServer eventMeshGrpcServer; + + public HeartbeatProcessor(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void process(Heartbeat heartbeat, StreamObserver responseObserver) throws Exception { + RequestHeader header = heartbeat.getHeader(); + + if (!ServiceUtils.validateHeader(header)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + return; + } + + if (!ServiceUtils.validateHeartBeat(heartbeat)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + return; + } + + // only handle heartbeat for consumers + ClientType clientType = heartbeat.getClientType(); + if (!ClientType.SUB.equals(clientType)) { + return; + } + + ConsumerManager consumerManager = eventMeshGrpcServer.getConsumerManager(); + + String consumerGroup = heartbeat.getConsumerGroup(); + + // update clients' timestamp in the heartbeat items + for (Heartbeat.HeartbeatItem item : heartbeat.getHeartbeatItemsList()) { + ConsumerGroupClient hbClient = ConsumerGroupClient.builder() + .env(header.getEnv()) + .idc(header.getIdc()) + .sys(header.getSys()) + .ip(header.getIp()) + .pid(header.getPid()) + .consumerGroup(consumerGroup) + .topic(item.getTopic()) + .lastUpTime(new Date()) + .build(); + consumerManager.updateClientTime(hbClient); + } + + ServiceUtils.sendResp(StatusCode.SUCCESS, "heartbeat success", responseObserver); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java new file mode 100644 index 0000000000..4a15b6a3ac --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java @@ -0,0 +1,41 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.service; + +import io.grpc.stub.StreamObserver; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat; +import org.apache.eventmesh.common.protocol.grpc.protos.HeartbeatServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.core.protocol.grpc.processor.HeartbeatProcessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.concurrent.ThreadPoolExecutor; + +public class HeartbeatService extends HeartbeatServiceGrpc.HeartbeatServiceImplBase { + + private final Logger logger = LoggerFactory.getLogger(ProducerService.class); + + private final EventMeshGrpcServer eventMeshGrpcServer; + + private final ThreadPoolExecutor threadPoolExecutor; + + public HeartbeatService(EventMeshGrpcServer eventMeshGrpcServer, + ThreadPoolExecutor threadPoolExecutor) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + this.threadPoolExecutor = threadPoolExecutor; + } + + public void heartbeat(Heartbeat request, StreamObserver responseObserver) { + threadPoolExecutor.submit(() -> { + HeartbeatProcessor heartbeatProcessor = new HeartbeatProcessor(eventMeshGrpcServer); + try { + heartbeatProcessor.process(request, responseObserver); + } catch (Exception e) { + logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_HEARTBEAT_ERR.getRetCode(), + StatusCode.EVENTMESH_HEARTBEAT_ERR.getErrMsg(), e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_HEARTBEAT_ERR, e.getMessage(), + responseObserver); + } + }); + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java index e3cd7571d3..39084f5d5e 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -5,6 +5,8 @@ import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat; +import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.ClientType; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; @@ -13,30 +15,32 @@ public class ServiceUtils { public static boolean validateHeader(RequestHeader header) { - return !StringUtils.isBlank(header.getIdc()) - && !StringUtils.isBlank(header.getPid()) + return StringUtils.isNotEmpty(header.getIdc()) + && StringUtils.isNotEmpty(header.getEnv()) + && StringUtils.isNotEmpty(header.getIp()) + && StringUtils.isNotEmpty(header.getPid()) && StringUtils.isNumeric(header.getPid()) - && !StringUtils.isBlank(header.getSys()); + && StringUtils.isNotEmpty(header.getSys()); } public static boolean validateMessage(EventMeshMessage message) { - return !StringUtils.isBlank(message.getUniqueId()) - && !StringUtils.isBlank(message.getProducerGroup()) - && !StringUtils.isBlank(message.getTopic()) - && !StringUtils.isBlank(message.getContent()) - && (!StringUtils.isBlank(message.getTtl())); + return StringUtils.isNotEmpty(message.getUniqueId()) + && StringUtils.isNotEmpty(message.getProducerGroup()) + && StringUtils.isNotEmpty(message.getTopic()) + && StringUtils.isNotEmpty(message.getContent()) + && StringUtils.isNotEmpty(message.getTtl()); } public static boolean validateSubscription(GrpcType grpcType, Subscription subscription) { - if (GrpcType.WEBHOOK.equals(grpcType) && StringUtils.isBlank(subscription.getUrl())) { + if (GrpcType.WEBHOOK.equals(grpcType) && StringUtils.isEmpty(subscription.getUrl())) { return false; } if (CollectionUtils.isEmpty(subscription.getSubscriptionItemsList()) - || StringUtils.isBlank(subscription.getConsumerGroup())) { + || StringUtils.isEmpty(subscription.getConsumerGroup())) { return false; } for (Subscription.SubscriptionItem item : subscription.getSubscriptionItemsList()) { - if (StringUtils.isBlank(item.getTopic()) + if (StringUtils.isEmpty(item.getTopic()) || item.getMode() == Subscription.SubscriptionItem.SubscriptionMode.UNRECOGNIZED || item.getType() == Subscription.SubscriptionItem.SubscriptionType.UNRECOGNIZED) { return false; @@ -45,6 +49,23 @@ public static boolean validateSubscription(GrpcType grpcType, Subscription subsc return true; } + public static boolean validateHeartBeat(Heartbeat heartbeat) { + if (ClientType.SUB.equals(heartbeat.getClientType()) + && StringUtils.isEmpty(heartbeat.getConsumerGroup())) { + return false; + } + if (ClientType.PUB.equals(heartbeat.getClientType()) + && StringUtils.isEmpty(heartbeat.getProducerGroup())) { + return false; + } + for (Heartbeat.HeartbeatItem item : heartbeat.getHeartbeatItemsList()) { + if (StringUtils.isEmpty(item.getTopic())) { + return false; + } + } + return true; + } + public static void sendResp(StatusCode code, StreamObserver responseObserver) { Response response = Response.newBuilder() .setRespCode(code.getRetCode()) diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java index 6a64e010ff..33812405f8 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java @@ -1,20 +1,32 @@ package org.apache.eventmesh.client.grpc; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; +import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.client.tcp.common.MessageUtils; import org.apache.eventmesh.common.protocol.grpc.protos.ConsumerServiceGrpc; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat; +import org.apache.eventmesh.common.protocol.grpc.protos.HeartbeatServiceGrpc; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.tcp.Package; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; public class EventMeshGrpcConsumer implements AutoCloseable { @@ -28,6 +40,12 @@ public class EventMeshGrpcConsumer implements AutoCloseable { private final List listenerThreads = new LinkedList<>(); + private final Map subscriptionMap = new ConcurrentHashMap<>(); + + private static final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor( + Runtime.getRuntime().availableProcessors(), + new ThreadFactoryBuilder().setNameFormat("GRPCClientScheduler").setDaemon(true).build()); + public EventMeshGrpcConsumer(EventMeshGrpcClientConfig clientConfig) { this.clientConfig = clientConfig; } @@ -35,10 +53,15 @@ public EventMeshGrpcConsumer(EventMeshGrpcClientConfig clientConfig) { public void init() { channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) .usePlaintext().build(); + + heartBeat(); } public Response subscribe(Subscription subscription) { logger.info("Create subscription: " + subscription.toString()); + + addSubscription(subscription); + ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); Subscription enhancedSubscription = Subscription.newBuilder(subscription) @@ -52,6 +75,9 @@ public Response subscribe(Subscription subscription) { public void subscribeStream(Subscription subscription) { logger.info("Create streaming subscription: " + subscription.toString()); + + addSubscription(subscription); + ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); Subscription enhancedSubscription = Subscription.newBuilder(subscription) @@ -65,8 +91,24 @@ public void subscribeStream(Subscription subscription) { listenerThread.start(); } + private void addSubscription(Subscription subscription) { + for (Subscription.SubscriptionItem item : subscription.getSubscriptionItemsList()) { + String url = StringUtils.isEmpty(subscription.getUrl()) ? "grpc_stream" : subscription.getUrl(); + subscriptionMap.put(item.getTopic(), url); + } + } + + private void removeSubscription(Subscription subscription) { + for (Subscription.SubscriptionItem item : subscription.getSubscriptionItemsList()) { + subscriptionMap.remove(item.getTopic()); + } + } + public Response unsubscribe(Subscription subscription) { logger.info("Removing subscription: " + subscription.toString()); + + removeSubscription(subscription); + ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); Subscription enhancedSubscription = Subscription.newBuilder(subscription) .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) @@ -84,6 +126,33 @@ public void registerListener(ReceiveMsgHook listener) { } } + private void heartBeat() { + HeartbeatServiceGrpc.HeartbeatServiceBlockingStub heartbeatClient = HeartbeatServiceGrpc.newBlockingStub(channel); + RequestHeader header = EventMeshClientUtil.buildHeader(clientConfig); + scheduler.scheduleAtFixedRate(() -> { + + Heartbeat.Builder heartbeatBuilder = Heartbeat.newBuilder() + .setHeader(header) + .setClientType(Heartbeat.ClientType.SUB); + + for (Map.Entry entry : subscriptionMap.entrySet()) { + Heartbeat.HeartbeatItem heartbeatItem = Heartbeat.HeartbeatItem + .newBuilder() + .setTopic(entry.getKey()).setUrl(entry.getValue()) + .build(); + heartbeatBuilder.addHeartbeatItems(heartbeatItem); + } + Heartbeat heartbeat = heartbeatBuilder.build(); + + Response response = heartbeatClient.heartbeat(heartbeat); + if (logger.isDebugEnabled()) { + logger.debug("Grpc Consumer Heartbeat response: {}", response); + } + }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS); + + logger.info("Grpc Consumer Heartbeat started."); + } + @Override public void close() { for (ListenerThread thread : listenerThreads) { From efea87fd11814a63a47a807bb4b56769d62f8113 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Thu, 23 Dec 2021 17:34:17 -0500 Subject: [PATCH 13/21] grpc consumer enhancement --- .../grpc/protos/ConsumerServiceGrpc.java | 5 - .../protocol/grpc/protos/EventmeshGrpc.java | 94 ++++++------- .../grpc/protos/HeartbeatServiceGrpc.java | 8 -- .../grpc/protos/PublisherServiceGrpc.java | 8 -- .../common/protocol/grpc/protos/Response.java | 127 ------------------ .../grpc/protos/ResponseOrBuilder.java | 10 -- .../eventmesh/grpc/sub/AsyncSubscribe.java | 6 +- .../src/main/proto/eventmesh-client.proto | 1 - .../grpc/consumer/ConsumerManager.java | 13 +- .../consumergroup/ConsumerGroupClient.java | 13 +- .../consumergroup/StreamTopicConfig.java | 57 +++++--- .../consumergroup/WebhookTopicConfig.java | 26 +++- .../grpc/processor/HeartbeatProcessor.java | 16 +-- .../processor/SendAsyncMessageProcessor.java | 17 +-- .../grpc/processor/SubscribeProcessor.java | 18 ++- .../processor/SubscribeStreamProcessor.java | 25 ++-- .../grpc/processor/UnsubscribeProcessor.java | 17 +-- .../protocol/grpc/push/MessageHandler.java | 8 +- .../protocol/grpc/push/StreamPushRequest.java | 37 ++--- .../grpc/push/WebhookPushRequest.java | 14 +- .../grpc/service/ConsumerService.java | 19 +-- .../protocol/grpc/service/EventEmitter.java | 39 ++++++ .../grpc/service/HeartbeatService.java | 6 +- .../grpc/service/ProducerService.java | 6 +- .../protocol/grpc/service/ServiceUtils.java | 20 +-- .../client/grpc/EventMeshGrpcConsumer.java | 75 +++++++---- .../client/grpc/EventMeshGrpcProducer.java | 22 +-- 27 files changed, 326 insertions(+), 381 deletions(-) create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/EventEmitter.java diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java index 12454c8ab5..54dc3cc0aa 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java @@ -1,18 +1,13 @@ package org.apache.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; import static io.grpc.stub.ClientCalls.asyncUnaryCall; import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; /** diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java index 2506c9bfbd..f8205e6861 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -69,53 +69,53 @@ public static void registerAllExtensions( "ntmesh.common.protocol.grpc.RequestHeade" + "r\022\025\n\rproducerGroup\030\002 \001(\t\022\r\n\005topic\030\003 \001(\t\022" + "\017\n\007content\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020\n\010uniqueI" + - "d\030\006 \001(\t\022\016\n\006seqNum\030\007 \001(\t\022\013\n\003tag\030\010 \001(\t\"O\n\010" + + "d\030\006 \001(\t\022\016\n\006seqNum\030\007 \001(\t\022\013\n\003tag\030\010 \001(\t\"?\n\010" + "Response\022\020\n\010respCode\030\001 \001(\t\022\017\n\007respMsg\030\002 " + - "\001(\t\022\020\n\010respTime\030\003 \001(\t\022\016\n\006seqNum\030\004 \001(\t\"\212\004" + - "\n\014Subscription\022=\n\006header\030\001 \001(\0132-.eventme" + - "sh.common.protocol.grpc.RequestHeader\022\025\n" + - "\rconsumerGroup\030\002 \001(\t\022X\n\021subscriptionItem" + - "s\030\003 \003(\0132=.eventmesh.common.protocol.grpc" + - ".Subscription.SubscriptionItem\022\013\n\003url\030\004 " + - "\001(\t\032\274\002\n\020SubscriptionItem\022\r\n\005topic\030\001 \001(\t\022" + - "\\\n\004mode\030\002 \001(\0162N.eventmesh.common.protoco" + - "l.grpc.Subscription.SubscriptionItem.Sub" + - "scriptionMode\022\\\n\004type\030\003 \001(\0162N.eventmesh." + - "common.protocol.grpc.Subscription.Subscr" + - "iptionItem.SubscriptionType\"4\n\020Subscript" + - "ionMode\022\016\n\nCLUSTERING\020\000\022\020\n\014BROADCASTING\020" + - "\001\"\'\n\020SubscriptionType\022\t\n\005ASYNC\020\000\022\010\n\004SYNC" + - "\020\001\"\340\002\n\tHeartbeat\022=\n\006header\030\001 \001(\0132-.event" + - "mesh.common.protocol.grpc.RequestHeader\022" + - "H\n\nclientType\030\002 \001(\01624.eventmesh.common.p" + - "rotocol.grpc.Heartbeat.ClientType\022\025\n\rpro" + - "ducerGroup\030\003 \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022" + - "O\n\016heartbeatItems\030\005 \003(\01327.eventmesh.comm" + - "on.protocol.grpc.Heartbeat.HeartbeatItem" + - "\032+\n\rHeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030" + - "\002 \001(\t\"\036\n\nClientType\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\316\002" + - "\n\020PublisherService\022e\n\007publish\0220.eventmes" + - "h.common.protocol.grpc.EventMeshMessage\032" + - "(.eventmesh.common.protocol.grpc.Respons" + - "e\022j\n\014requestReply\0220.eventmesh.common.pro" + - "tocol.grpc.EventMeshMessage\032(.eventmesh." + - "common.protocol.grpc.Response\022g\n\tbroadca" + - "st\0220.eventmesh.common.protocol.grpc.Even" + - "tMeshMessage\032(.eventmesh.common.protocol" + - ".grpc.Response2\322\002\n\017ConsumerService\022c\n\tsu" + - "bscribe\022,.eventmesh.common.protocol.grpc" + - ".Subscription\032(.eventmesh.common.protoco" + - "l.grpc.Response\022s\n\017subscribeStream\022,.eve" + - "ntmesh.common.protocol.grpc.Subscription" + - "\0320.eventmesh.common.protocol.grpc.EventM" + - "eshMessage0\001\022e\n\013unsubscribe\022,.eventmesh." + - "common.protocol.grpc.Subscription\032(.even" + - "tmesh.common.protocol.grpc.Response2t\n\020H" + - "eartbeatService\022`\n\theartbeat\022).eventmesh" + - ".common.protocol.grpc.Heartbeat\032(.eventm" + - "esh.common.protocol.grpc.ResponseBC\n0org" + - ".apache.eventmesh.common.protocol.grpc.p" + - "rotosB\rEventmeshGrpcP\001b\006proto3" + "\001(\t\022\020\n\010respTime\030\003 \001(\t\"\212\004\n\014Subscription\022=" + + "\n\006header\030\001 \001(\0132-.eventmesh.common.protoc" + + "ol.grpc.RequestHeader\022\025\n\rconsumerGroup\030\002" + + " \001(\t\022X\n\021subscriptionItems\030\003 \003(\0132=.eventm" + + "esh.common.protocol.grpc.Subscription.Su" + + "bscriptionItem\022\013\n\003url\030\004 \001(\t\032\274\002\n\020Subscrip" + + "tionItem\022\r\n\005topic\030\001 \001(\t\022\\\n\004mode\030\002 \001(\0162N." + + "eventmesh.common.protocol.grpc.Subscript" + + "ion.SubscriptionItem.SubscriptionMode\022\\\n" + + "\004type\030\003 \001(\0162N.eventmesh.common.protocol." + + "grpc.Subscription.SubscriptionItem.Subsc" + + "riptionType\"4\n\020SubscriptionMode\022\016\n\nCLUST" + + "ERING\020\000\022\020\n\014BROADCASTING\020\001\"\'\n\020Subscriptio" + + "nType\022\t\n\005ASYNC\020\000\022\010\n\004SYNC\020\001\"\340\002\n\tHeartbeat" + + "\022=\n\006header\030\001 \001(\0132-.eventmesh.common.prot" + + "ocol.grpc.RequestHeader\022H\n\nclientType\030\002 " + + "\001(\01624.eventmesh.common.protocol.grpc.Hea" + + "rtbeat.ClientType\022\025\n\rproducerGroup\030\003 \001(\t" + + "\022\025\n\rconsumerGroup\030\004 \001(\t\022O\n\016heartbeatItem" + + "s\030\005 \003(\01327.eventmesh.common.protocol.grpc" + + ".Heartbeat.HeartbeatItem\032+\n\rHeartbeatIte" + + "m\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030\002 \001(\t\"\036\n\nClientT" + + "ype\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\316\002\n\020PublisherServi" + + "ce\022e\n\007publish\0220.eventmesh.common.protoco" + + "l.grpc.EventMeshMessage\032(.eventmesh.comm" + + "on.protocol.grpc.Response\022j\n\014requestRepl" + + "y\0220.eventmesh.common.protocol.grpc.Event" + + "MeshMessage\032(.eventmesh.common.protocol." + + "grpc.Response\022g\n\tbroadcast\0220.eventmesh.c" + + "ommon.protocol.grpc.EventMeshMessage\032(.e" + + "ventmesh.common.protocol.grpc.Response2\322" + + "\002\n\017ConsumerService\022c\n\tsubscribe\022,.eventm" + + "esh.common.protocol.grpc.Subscription\032(." + + "eventmesh.common.protocol.grpc.Response\022" + + "s\n\017subscribeStream\022,.eventmesh.common.pr" + + "otocol.grpc.Subscription\0320.eventmesh.com" + + "mon.protocol.grpc.EventMeshMessage0\001\022e\n\013" + + "unsubscribe\022,.eventmesh.common.protocol." + + "grpc.Subscription\032(.eventmesh.common.pro" + + "tocol.grpc.Response2t\n\020HeartbeatService\022" + + "`\n\theartbeat\022).eventmesh.common.protocol" + + ".grpc.Heartbeat\032(.eventmesh.common.proto" + + "col.grpc.ResponseBC\n0org.apache.eventmes" + + "h.common.protocol.grpc.protosB\rEventmesh" + + "GrpcP\001b\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -146,7 +146,7 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_Response_descriptor, - new String[] { "RespCode", "RespMsg", "RespTime", "SeqNum", }); + new String[] { "RespCode", "RespMsg", "RespTime", }); internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor = getDescriptor().getMessageTypes().get(3); internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable = new diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java index 5224e01d0a..8ae133ef89 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java @@ -1,18 +1,10 @@ package org.apache.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; -import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; -import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; /** diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java index c23bb07cc2..1ab9753a97 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java @@ -1,18 +1,10 @@ package org.apache.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; -import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; import static io.grpc.stub.ClientCalls.blockingUnaryCall; import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; -import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; /** diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java index 008b0a1210..b84dbfc807 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java @@ -19,7 +19,6 @@ private Response() { respCode_ = ""; respMsg_ = ""; respTime_ = ""; - seqNum_ = ""; } @Override @@ -71,12 +70,6 @@ private Response( respTime_ = s; break; } - case 34: { - String s = input.readStringRequireUtf8(); - - seqNum_ = s; - break; - } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -203,40 +196,6 @@ public String getRespTime() { } } - public static final int SEQNUM_FIELD_NUMBER = 4; - private volatile Object seqNum_; - /** - * string seqNum = 4; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } - } - /** - * string seqNum = 4; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; @@ -258,9 +217,6 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!getRespTimeBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 3, respTime_); } - if (!getSeqNumBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, seqNum_); - } unknownFields.writeTo(output); } @@ -278,9 +234,6 @@ public int getSerializedSize() { if (!getRespTimeBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, respTime_); } - if (!getSeqNumBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, seqNum_); - } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -303,8 +256,6 @@ public boolean equals(final Object obj) { .equals(other.getRespMsg()); result = result && getRespTime() .equals(other.getRespTime()); - result = result && getSeqNum() - .equals(other.getSeqNum()); result = result && unknownFields.equals(other.unknownFields); return result; } @@ -322,8 +273,6 @@ public int hashCode() { hash = (53 * hash) + getRespMsg().hashCode(); hash = (37 * hash) + RESPTIME_FIELD_NUMBER; hash = (53 * hash) + getRespTime().hashCode(); - hash = (37 * hash) + SEQNUM_FIELD_NUMBER; - hash = (53 * hash) + getSeqNum().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -459,8 +408,6 @@ public Builder clear() { respTime_ = ""; - seqNum_ = ""; - return this; } @@ -486,7 +433,6 @@ public Response buildPartial() { result.respCode_ = respCode_; result.respMsg_ = respMsg_; result.respTime_ = respTime_; - result.seqNum_ = seqNum_; onBuilt(); return result; } @@ -540,10 +486,6 @@ public Builder mergeFrom(Response other) { respTime_ = other.respTime_; onChanged(); } - if (!other.getSeqNum().isEmpty()) { - seqNum_ = other.seqNum_; - onChanged(); - } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -777,75 +719,6 @@ public Builder setRespTimeBytes( onChanged(); return this; } - - private Object seqNum_ = ""; - /** - * string seqNum = 4; - */ - public String getSeqNum() { - Object ref = seqNum_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - seqNum_ = s; - return s; - } else { - return (String) ref; - } - } - /** - * string seqNum = 4; - */ - public com.google.protobuf.ByteString - getSeqNumBytes() { - Object ref = seqNum_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - seqNum_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string seqNum = 4; - */ - public Builder setSeqNum( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - seqNum_ = value; - onChanged(); - return this; - } - /** - * string seqNum = 4; - */ - public Builder clearSeqNum() { - - seqNum_ = getDefaultInstance().getSeqNum(); - onChanged(); - return this; - } - /** - * string seqNum = 4; - */ - public Builder setSeqNumBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - seqNum_ = value; - onChanged(); - return this; - } public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFieldsProto3(unknownFields); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java index 701507deb9..89018f7d8e 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java @@ -36,14 +36,4 @@ public interface ResponseOrBuilder extends */ com.google.protobuf.ByteString getRespTimeBytes(); - - /** - * string seqNum = 4; - */ - String getSeqNum(); - /** - * string seqNum = 4; - */ - com.google.protobuf.ByteString - getSeqNumBytes(); } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java index d958eeec63..2556a1df05 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java @@ -50,12 +50,12 @@ public static void main(String[] args) { eventMeshGrpcConsumer.subscribeStream(subscription); - try { + /* try { Thread.sleep(12000); } catch (Exception e) { - + //ignore } - eventMeshGrpcConsumer.unsubscribe(subscription); + eventMeshGrpcConsumer.unsubscribe(subscription);*/ } @Override diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto index da4c61e935..76e8b4b2ce 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto @@ -53,7 +53,6 @@ message Response { string respCode = 1; string respMsg = 2; string respTime = 3; - string seqNum = 4; } message Subscription { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java index f62fe377ba..d71759e9b1 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -32,7 +32,7 @@ public class ConsumerManager { private static final int DEFAULT_UPDATE_TIME = 3 * 30 * 1000; - private ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); + private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); // key: ConsumerGroup private final Map> clientTable = new ConcurrentHashMap<>(); @@ -91,12 +91,14 @@ public synchronized void registerClient(ConsumerGroupClient newClient) { && StringUtils.equals(localClient.getUrl(), url) && localClient.getSubscriptionMode().equals(subscriptionMode)) { isContains = true; + localClient.setUrl(newClient.getUrl()); localClient.setLastUpTime(newClient.getLastUpTime()); break; } else if (GrpcType.STREAM.equals(grpcType) && StringUtils.equals(localClient.getTopic(), topic) && StringUtils.equals(localClient.getIp(), ip) && StringUtils.equals(localClient.getPid(), pid) && localClient.getSubscriptionMode().equals(subscriptionMode)) { isContains = true; + localClient.setEventEmitter(newClient.getEventEmitter()); localClient.setLastUpTime(newClient.getLastUpTime()); break; } @@ -150,7 +152,11 @@ public synchronized void deregisterClient(ConsumerGroupClient client) { private void closeEventStream(ConsumerGroupClient client) { if (client.getEventEmitter() != null) { - client.getEventEmitter().onCompleted(); + try { + client.getEventEmitter().onCompleted(); + } catch (Exception e) { + logger.warn("GRPC client {} already closed.", client.toString()); + } } } @@ -184,6 +190,9 @@ private void startClientCheck() { logger.debug("total number of ConsumerGroupClients: {}", clientList.size()); } + if (clientList.isEmpty()) { + return; + } Set consumerGroupRestart = new HashSet<>(); for (ConsumerGroupClient client : clientList) { if (System.currentTimeMillis() - client.getLastUpTime().getTime() > DEFAULT_UPDATE_TIME) { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java index 54c4c2621c..74894d5619 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/ConsumerGroupClient.java @@ -19,12 +19,12 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; -import io.grpc.stub.StreamObserver; import lombok.Getter; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import java.util.Date; import lombok.Builder; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; @Builder @Getter @@ -40,9 +40,9 @@ public class ConsumerGroupClient { private final GrpcType grpcType; - private final String url; + private String url; - private final StreamObserver eventEmitter; + private EventEmitter eventEmitter; private final SubscriptionMode subscriptionMode; @@ -58,6 +58,13 @@ public class ConsumerGroupClient { private Date lastUpTime; + public void setUrl(String url) { + this.url = url; + } + public void setEventEmitter(EventEmitter emitter) { + this.eventEmitter = emitter; + } + public void setLastUpTime(Date lastUpTime) { this.lastUpTime = lastUpTime; } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java index 35b87f490c..0d4d8565ac 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/StreamTopicConfig.java @@ -1,8 +1,8 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup; -import io.grpc.stub.StreamObserver; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -10,19 +10,24 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; public class StreamTopicConfig extends ConsumerGroupTopicConfig { private final Logger logger = LoggerFactory.getLogger(StreamTopicConfig.class); /** - * Event streaming emitter - *
+ * Key: IDC + * Value: list of emitters with Client_IP:port + */ + private final Map>> idcEmitterMap = new ConcurrentHashMap<>(); + + /** * Key: IDC * Value: list of emitters */ - private final Map>> idcEmitters = new ConcurrentHashMap<>(); + private Map>> idcEmitters = new ConcurrentHashMap<>(); + + private List> totalEmitters = new LinkedList<>(); public StreamTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode) { super(consumerGroup, topic, subscriptionMode, GrpcType.STREAM); @@ -38,9 +43,12 @@ public synchronized void registerClient(ConsumerGroupClient client) { String idc = client.getIdc(); String clientIp = client.getIp(); String clientPid = client.getPid(); - StreamObserver emitter = client.getEventEmitter(); - Map> emitters = idcEmitters.computeIfAbsent(idc, k -> new HashMap<>()); + EventEmitter emitter = client.getEventEmitter(); + Map> emitters = idcEmitterMap.computeIfAbsent(idc, k -> new HashMap<>()); emitters.put(clientIp + ":" + clientPid, emitter); + + idcEmitters = buildIdcEmitter(); + totalEmitters = buildTotalEmitter(); } @Override @@ -49,23 +57,21 @@ public void deregisterClient(ConsumerGroupClient client) { String clientIp = client.getIp(); String clientPid = client.getPid(); - Map> emitters = idcEmitters.get(idc); + Map> emitters = idcEmitterMap.get(idc); if (emitters == null) { return; } emitters.remove(clientIp + ":" + clientPid); if (emitters.size() == 0) { - idcEmitters.remove(idc); + idcEmitterMap.remove(idc); } + idcEmitters = buildIdcEmitter(); + totalEmitters = buildTotalEmitter(); } @Override public int getSize() { - int total = 0; - for (Map> emitters : idcEmitters.values()) { - total += emitters.size(); - } - return total; + return totalEmitters.size(); } @Override @@ -91,7 +97,28 @@ public GrpcType getGrpcType() { return grpcType; } - public Map>> getIdcEmitters() { + public Map>> getIdcEmitters() { return idcEmitters; } + + public List> getTotalEmitters() { + return totalEmitters; + } + + private Map>> buildIdcEmitter() { + Map>> result = new HashMap<>(); + for (Map.Entry>> entry : idcEmitterMap.entrySet()) { + List> emitterList = new LinkedList<>(entry.getValue().values()); + result.put(entry.getKey(), emitterList); + } + return result; + } + + private List> buildTotalEmitter() { + List> emitterList = new LinkedList<>(); + for (List> emitters : idcEmitters.values()) { + emitterList.addAll(emitters); + } + return emitterList; + } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java index 3af7d98ae4..3e7b7c4993 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/consumergroup/WebhookTopicConfig.java @@ -5,10 +5,14 @@ import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import sun.awt.image.ImageWatched; +import java.util.ArrayList; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; public class WebhookTopicConfig extends ConsumerGroupTopicConfig { @@ -22,6 +26,8 @@ public class WebhookTopicConfig extends ConsumerGroupTopicConfig { */ private final Map> idcUrls = new ConcurrentHashMap<>(); + private List totalUrls = new LinkedList<>(); + public WebhookTopicConfig(String consumerGroup, String topic, SubscriptionMode subscriptionMode) { super(consumerGroup, topic, subscriptionMode, GrpcType.WEBHOOK); } @@ -39,6 +45,7 @@ public synchronized void registerClient(ConsumerGroupClient client) { if (!urls.contains(url)) { urls.add(url); } + totalUrls = buildTotalUrls(); } @Override @@ -54,15 +61,12 @@ public void deregisterClient(ConsumerGroupClient client) { if (urls.size() == 0) { idcUrls.remove(idc); } + totalUrls = buildTotalUrls(); } @Override public int getSize() { - int total = 0; - for (List urls : idcUrls.values()) { - total += urls.size(); - } - return total; + return totalUrls.size(); } @Override @@ -92,4 +96,16 @@ public GrpcType getGrpcType() { public Map> getIdcUrls() { return idcUrls; } + + private List buildTotalUrls() { + Set totalUrls = new HashSet<>(); + for (List idcUrls : idcUrls.values()) { + totalUrls.addAll(idcUrls); + } + return new ArrayList<>(totalUrls); + } + + public List getTotalUrls() { + return totalUrls; + } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java index 2935399127..428a56d560 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java @@ -1,45 +1,45 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.processor; -import io.grpc.stub.StreamObserver; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat; import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.ClientType; -import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.HeartbeatItem; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; public class HeartbeatProcessor { - private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - private EventMeshGrpcServer eventMeshGrpcServer; + private final EventMeshGrpcServer eventMeshGrpcServer; public HeartbeatProcessor(EventMeshGrpcServer eventMeshGrpcServer) { this.eventMeshGrpcServer = eventMeshGrpcServer; } - public void process(Heartbeat heartbeat, StreamObserver responseObserver) throws Exception { + public void process(Heartbeat heartbeat, EventEmitter emitter) throws Exception { RequestHeader header = heartbeat.getHeader(); if (!ServiceUtils.validateHeader(header)) { - ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, emitter); return; } if (!ServiceUtils.validateHeartBeat(heartbeat)) { - ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); return; } // only handle heartbeat for consumers ClientType clientType = heartbeat.getClientType(); if (!ClientType.SUB.equals(clientType)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); return; } @@ -62,6 +62,6 @@ public void process(Heartbeat heartbeat, StreamObserver responseObserv consumerManager.updateClientTime(hbClient); } - ServiceUtils.sendResp(StatusCode.SUCCESS, "heartbeat success", responseObserver); + ServiceUtils.sendResp(StatusCode.SUCCESS, "heartbeat success", emitter); } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java index efc3e9a1bd..037459d994 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java @@ -18,7 +18,6 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.processor; import io.cloudevents.CloudEvent; -import io.grpc.stub.StreamObserver; import org.apache.eventmesh.api.SendCallback; import org.apache.eventmesh.api.SendResult; import org.apache.eventmesh.api.exception.OnExceptionContext; @@ -34,31 +33,33 @@ import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.apache.eventmesh.runtime.util.EventMeshUtil; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SendAsyncMessageProcessor { - private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - private EventMeshGrpcServer eventMeshGrpcServer; + private final EventMeshGrpcServer eventMeshGrpcServer; public SendAsyncMessageProcessor(EventMeshGrpcServer eventMeshGrpcServer) { this.eventMeshGrpcServer = eventMeshGrpcServer; } - public void process(EventMeshMessage message, StreamObserver responseObserver) throws Exception { + public void process(EventMeshMessage message, EventEmitter emitter) throws Exception { RequestHeader requestHeader = message.getHeader(); if (!ServiceUtils.validateHeader(requestHeader)) { - ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, emitter); return; } if (!ServiceUtils.validateMessage(message)) { - ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); return; } @@ -80,7 +81,7 @@ public void process(EventMeshMessage message, StreamObserver responseO eventMeshProducer.send(sendMessageContext, new SendCallback() { @Override public void onSuccess(SendResult sendResult) { - ServiceUtils.sendResp(StatusCode.SUCCESS, sendResult.toString(), responseObserver); + ServiceUtils.sendResp(StatusCode.SUCCESS, sendResult.toString(), emitter); long endTime = System.currentTimeMillis(); logger.info("message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", endTime - startTime, topic, seqNum, uniqueId); @@ -89,7 +90,7 @@ public void onSuccess(SendResult sendResult) { @Override public void onException(OnExceptionContext context) { ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, - EventMeshUtil.stackTrace(context.getException(), 2), responseObserver); + EventMeshUtil.stackTrace(context.getException(), 2), emitter); long endTime = System.currentTimeMillis(); logger.error("message|eventMesh2mq|REQ|ASYNC|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", endTime - startTime, topic, seqNum, uniqueId, context.getException()); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java index d9826bb145..07eb5ca259 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java @@ -1,6 +1,5 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.processor; -import io.grpc.stub.StreamObserver; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; @@ -10,6 +9,7 @@ import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,31 +17,29 @@ import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Set; public class SubscribeProcessor { - private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - private EventMeshGrpcServer eventMeshGrpcServer; + private final EventMeshGrpcServer eventMeshGrpcServer; - private GrpcType grpcType = GrpcType.WEBHOOK; + private final GrpcType grpcType = GrpcType.WEBHOOK; public SubscribeProcessor(EventMeshGrpcServer eventMeshGrpcServer) { this.eventMeshGrpcServer = eventMeshGrpcServer; } - public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { - + public void process(Subscription subscription, EventEmitter emitter) throws Exception { RequestHeader header = subscription.getHeader(); if (!ServiceUtils.validateHeader(header)) { - ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, emitter); return; } if (!ServiceUtils.validateSubscription(grpcType, subscription)) { - ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); return; } @@ -93,6 +91,6 @@ public void process(Subscription subscription, StreamObserver response logger.warn("EventMesh consumer [{}] didn't restart.", consumerGroup); } - ServiceUtils.sendResp(StatusCode.SUCCESS, "subscribe success", responseObserver); + ServiceUtils.sendResp(StatusCode.SUCCESS, "subscribe success", emitter); } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java index eb317e45f7..3e0a0869f8 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java @@ -1,6 +1,5 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.processor; -import io.grpc.stub.StreamObserver; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; @@ -11,6 +10,7 @@ import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,31 +20,30 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; public class SubscribeStreamProcessor { - private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - private EventMeshGrpcServer eventMeshGrpcServer; + private final EventMeshGrpcServer eventMeshGrpcServer; - private GrpcType grpcType = GrpcType.STREAM; + private final GrpcType grpcType = GrpcType.STREAM; public SubscribeStreamProcessor(EventMeshGrpcServer eventMeshGrpcServer) { this.eventMeshGrpcServer = eventMeshGrpcServer; } - public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { + public void process(Subscription subscription, EventEmitter emitter) throws Exception { RequestHeader header = subscription.getHeader(); if (!ServiceUtils.validateHeader(header)) { - sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, emitter); return; } if (!ServiceUtils.validateSubscription(grpcType, subscription)) { - sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); return; } @@ -66,7 +65,7 @@ public void process(Subscription subscription, StreamObserver .topic(item.getTopic()) .subscriptionMode(item.getMode()) .grpcType(grpcType) - .eventEmitter(responseObserver) + .eventEmitter(emitter) .lastUpTime(new Date()) .build(); newClients.add(newClient); @@ -104,10 +103,10 @@ public void process(Subscription subscription, StreamObserver .setHeader(header) .setContent(JsonUtils.serialize(resp)) .build(); - responseObserver.onNext(eventMeshMessage); + emitter.onNext(eventMeshMessage); } - private void sendResp(Subscription subscription, StatusCode code, StreamObserver responseObserver) { + private void sendResp(Subscription subscription, StatusCode code, EventEmitter emitter) { Map resp = new HashMap<>(); resp.put("respCode", code.getRetCode()); resp.put("respMsg", code.getErrMsg()); @@ -118,7 +117,7 @@ private void sendResp(Subscription subscription, StatusCode code, StreamObserver .setContent(JsonUtils.serialize(resp)) .build(); - responseObserver.onNext(eventMeshMessage); - responseObserver.onCompleted(); + emitter.onNext(eventMeshMessage); + emitter.onCompleted(); } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/UnsubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/UnsubscribeProcessor.java index 1076b2470b..98f3d4d153 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/UnsubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/UnsubscribeProcessor.java @@ -1,16 +1,14 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.processor; -import io.grpc.stub.StreamObserver; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; -import org.apache.eventmesh.runtime.common.ServiceState; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; -import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.GrpcType; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,29 +16,28 @@ import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Set; public class UnsubscribeProcessor { - private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - private EventMeshGrpcServer eventMeshGrpcServer; + private final EventMeshGrpcServer eventMeshGrpcServer; public UnsubscribeProcessor(EventMeshGrpcServer eventMeshGrpcServer) { this.eventMeshGrpcServer = eventMeshGrpcServer; } - public void process(Subscription subscription, StreamObserver responseObserver) throws Exception { + public void process(Subscription subscription, EventEmitter emitter) throws Exception { RequestHeader header = subscription.getHeader(); if (!ServiceUtils.validateHeader(header)) { - ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, emitter); return; } if (!ServiceUtils.validateSubscription(null, subscription)) { - ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); return; } @@ -92,6 +89,6 @@ public void process(Subscription subscription, StreamObserver response logger.warn("EventMesh consumer [{}] didn't restart.", consumerGroup); } - ServiceUtils.sendResp(StatusCode.SUCCESS, "unsubscribe success", responseObserver); + ServiceUtils.sendResp(StatusCode.SUCCESS, "unsubscribe success", emitter); } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java index f50a3d7c68..2bbe9d757c 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/MessageHandler.java @@ -34,15 +34,15 @@ public class MessageHandler { - private Logger logger = LoggerFactory.getLogger(this.getClass()); + private final Logger logger = LoggerFactory.getLogger(this.getClass()); private static final ScheduledExecutorService SCHEDULER = ThreadPoolFactory.createSingleScheduledExecutor("eventMesh-pushMsgTimeout-"); - private ThreadPoolExecutor pushExecutor; + private final ThreadPoolExecutor pushExecutor; - private final Integer CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD = 10000; + private static final Integer CONSUMER_GROUP_WAITING_REQUEST_THRESHOLD = 10000; - private static Map> waitingRequests = Maps.newConcurrentMap(); + private static final Map> waitingRequests = Maps.newConcurrentMap(); public MessageHandler(String consumerGroup, ThreadPoolExecutor pushMsgExecutor) { this.pushExecutor = pushMsgExecutor; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java index 7624c0b76b..4102d18c9f 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java @@ -1,15 +1,14 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.push; -import io.grpc.stub.StreamObserver; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.StreamTopicConfig; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.LinkedList; + import java.util.List; import java.util.Map; import java.util.Set; @@ -18,9 +17,9 @@ public class StreamPushRequest extends AbstractPushRequest { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - private final Map>> idcEmitters; + private final Map>> idcEmitters; - private final List> totalEmitters; + private final List> totalEmitters; private final int startIdx; @@ -28,14 +27,14 @@ public StreamPushRequest(HandleMsgContext handleMsgContext, Map eventEmitter = selectEmitter(); + EventEmitter eventEmitter = selectEmitter(); EventMeshMessage eventMeshMessage = getEventMeshMessage(event); if (eventMeshMessage == null) { @@ -46,8 +45,8 @@ public void tryPushRequest() { finish(); } - private StreamObserver selectEmitter() { - List> emitterList = MapUtils.getObject(idcEmitters, + private EventEmitter selectEmitter() { + List> emitterList = MapUtils.getObject(idcEmitters, eventMeshGrpcConfiguration.eventMeshIDC, null); if (CollectionUtils.isNotEmpty(emitterList)) { return emitterList.get((startIdx + retryTimes) % emitterList.size()); @@ -57,22 +56,4 @@ private StreamObserver selectEmitter() { } return null; } - - private Map>> buildIdcEmitter( - Map>> idcEmitterMap) { - Map>> result = new HashMap<>(); - for (Map.Entry>> entry : idcEmitterMap.entrySet()) { - List> emitterList = new LinkedList<>(entry.getValue().values()); - result.put(entry.getKey(), emitterList); - } - return result; - } - - private List> buildTotalEmitter() { - List> emitterList = new LinkedList<>(); - for (List> emitters : this.idcEmitters.values()) { - emitterList.addAll(emitters); - } - return emitterList; - } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java index 4c7517b717..b60b0dff4e 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java @@ -77,8 +77,9 @@ public WebhookPushRequest(HandleMsgContext handleMsgContext, Map> waitingRequests) { super(handleMsgContext, waitingRequests); - this.urls = ((WebhookTopicConfig) handleMsgContext.getConsumeTopicConfig()).getIdcUrls(); - this.totalUrls = buildTotalUrls(); + WebhookTopicConfig topicConfig = (WebhookTopicConfig) handleMsgContext.getConsumeTopicConfig(); + this.urls = topicConfig.getIdcUrls(); + this.totalUrls = topicConfig.getTotalUrls(); this.startIdx = RandomUtils.nextInt(0, totalUrls.size()); } @@ -245,15 +246,6 @@ private String getUrl() { if (CollectionUtils.isNotEmpty(totalUrls)) { return totalUrls.get((startIdx + retryTimes) % totalUrls.size()); } - return null; } - - private List buildTotalUrls() { - Set totalUrls = new HashSet<>(); - for (List idcUrls : urls.values()) { - totalUrls.addAll(idcUrls); - } - return new ArrayList<>(totalUrls); - } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java index 7a655c74f5..c249836a5c 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java @@ -34,24 +34,25 @@ public ConsumerService(EventMeshGrpcServer eventMeshGrpcServer, } public void subscribe(Subscription request, StreamObserver responseObserver) { + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { SubscribeProcessor subscribeProcessor = new SubscribeProcessor(eventMeshGrpcServer); try { - subscribeProcessor.process(request, responseObserver); + subscribeProcessor.process(request, emitter); } catch (Exception e) { logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_SUBSCRIBE_ERR.getRetCode(), StatusCode.EVENTMESH_SUBSCRIBE_ERR.getErrMsg(), e); - ServiceUtils.sendResp(StatusCode.EVENTMESH_SUBSCRIBE_ERR, e.getMessage(), - responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_SUBSCRIBE_ERR, e.getMessage(), emitter); } }); } public void subscribeStream(Subscription request, StreamObserver responseObserver) { + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { SubscribeStreamProcessor streamProcessor = new SubscribeStreamProcessor(eventMeshGrpcServer); try { - streamProcessor.process(request, responseObserver); + streamProcessor.process(request, emitter); } catch (Exception e) { StatusCode code = StatusCode.EVENTMESH_SUBSCRIBE_ERR; logger.error("Error code {}, error message {}", code.getRetCode(), code.getErrMsg(), e); @@ -66,22 +67,22 @@ public void subscribeStream(Subscription request, StreamObserver responseObserver) { + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { UnsubscribeProcessor unsubscribeProcessor = new UnsubscribeProcessor(eventMeshGrpcServer); try { - unsubscribeProcessor.process(request, responseObserver); + unsubscribeProcessor.process(request, emitter); } catch (Exception e) { logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_UNSUBSCRIBE_ERR.getRetCode(), StatusCode.EVENTMESH_UNSUBSCRIBE_ERR.getErrMsg(), e); - ServiceUtils.sendResp(StatusCode.EVENTMESH_UNSUBSCRIBE_ERR, e.getMessage(), - responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_UNSUBSCRIBE_ERR, e.getMessage(), emitter); } }); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/EventEmitter.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/EventEmitter.java new file mode 100644 index 0000000000..a9999c0816 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/EventEmitter.java @@ -0,0 +1,39 @@ +package org.apache.eventmesh.runtime.core.protocol.grpc.service; + +import io.grpc.stub.StreamObserver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EventEmitter { + private final Logger logger = LoggerFactory.getLogger(EventEmitter.class); + + private final StreamObserver emitter; + + public EventEmitter(StreamObserver emitter) { + this.emitter = emitter; + } + + public void onNext(T event) { + try { + emitter.onNext(event); + } catch (Throwable t) { + logger.warn("StreamObserver Error onNext. {}", t.getMessage()); + } + } + + public void onCompleted() { + try { + emitter.onCompleted(); + } catch (Throwable t) { + logger.warn("StreamObserver Error onCompleted. {}", t.getMessage()); + } + } + + public void onError(Throwable t) { + try { + emitter.onError(t); + } catch (Throwable t1) { + logger.warn("StreamObserver Error onError. {}", t1.getMessage()); + } + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java index 4a15b6a3ac..ec54fe1fb6 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java @@ -26,15 +26,15 @@ public HeartbeatService(EventMeshGrpcServer eventMeshGrpcServer, } public void heartbeat(Heartbeat request, StreamObserver responseObserver) { + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { HeartbeatProcessor heartbeatProcessor = new HeartbeatProcessor(eventMeshGrpcServer); try { - heartbeatProcessor.process(request, responseObserver); + heartbeatProcessor.process(request, emitter); } catch (Exception e) { logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_HEARTBEAT_ERR.getRetCode(), StatusCode.EVENTMESH_HEARTBEAT_ERR.getErrMsg(), e); - ServiceUtils.sendResp(StatusCode.EVENTMESH_HEARTBEAT_ERR, e.getMessage(), - responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_HEARTBEAT_ERR, e.getMessage(), emitter); } }); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java index f3ee56967d..af35f5664e 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java @@ -27,15 +27,15 @@ public ProducerService(EventMeshGrpcServer eventMeshGrpcServer, } public void publish(EventMeshMessage request, StreamObserver responseObserver) { + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { SendAsyncMessageProcessor sendAsyncMessageProcessor = new SendAsyncMessageProcessor(eventMeshGrpcServer); try { - sendAsyncMessageProcessor.process(request, responseObserver); + sendAsyncMessageProcessor.process(request, emitter); } catch (Exception e) { logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getRetCode(), StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR.getErrMsg(), e); - ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, e.getMessage(), - responseObserver); + ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, e.getMessage(), emitter); } }); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java index 39084f5d5e..3b84ef9f99 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -66,20 +66,24 @@ public static boolean validateHeartBeat(Heartbeat heartbeat) { return true; } - public static void sendResp(StatusCode code, StreamObserver responseObserver) { + public static void sendResp(StatusCode code, EventEmitter emitter) { Response response = Response.newBuilder() .setRespCode(code.getRetCode()) - .setRespMsg(code.getErrMsg()).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); + .setRespMsg(code.getErrMsg()) + .setRespTime(String.valueOf(System.currentTimeMillis())) + .build(); + emitter.onNext(response); + emitter.onCompleted(); } - public static void sendResp(StatusCode code, String message, StreamObserver responseObserver) { + public static void sendResp(StatusCode code, String message, EventEmitter emitter) { Response response = Response.newBuilder() .setRespCode(code.getRetCode()) - .setRespMsg(code.getErrMsg() + " " + message).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); + .setRespMsg(code.getErrMsg() + " " + message) + .setRespTime(String.valueOf(System.currentTimeMillis())) + .build(); + emitter.onNext(response); + emitter.onCompleted(); } } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java index 33812405f8..7932c8d9bc 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java @@ -7,19 +7,18 @@ import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.common.MessageUtils; import org.apache.eventmesh.common.protocol.grpc.protos.ConsumerServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.ConsumerServiceGrpc.ConsumerServiceBlockingStub; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat; import org.apache.eventmesh.common.protocol.grpc.protos.HeartbeatServiceGrpc; +import org.apache.eventmesh.common.protocol.grpc.protos.HeartbeatServiceGrpc.HeartbeatServiceBlockingStub; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; -import org.apache.eventmesh.common.protocol.tcp.Package; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -36,13 +35,16 @@ public class EventMeshGrpcConsumer implements AutoCloseable { private ManagedChannel channel; + private ConsumerServiceBlockingStub consumerClient; + private HeartbeatServiceBlockingStub heartbeatClient; + private ReceiveMsgHook listener; private final List listenerThreads = new LinkedList<>(); private final Map subscriptionMap = new ConcurrentHashMap<>(); - private static final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor( + private final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor( Runtime.getRuntime().availableProcessors(), new ThreadFactoryBuilder().setNameFormat("GRPCClientScheduler").setDaemon(true).build()); @@ -54,6 +56,9 @@ public void init() { channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) .usePlaintext().build(); + consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); + heartbeatClient = HeartbeatServiceGrpc.newBlockingStub(channel); + heartBeat(); } @@ -62,15 +67,18 @@ public Response subscribe(Subscription subscription) { addSubscription(subscription); - ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); - Subscription enhancedSubscription = Subscription.newBuilder(subscription) .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) .setConsumerGroup(clientConfig.getConsumerGroup()) .build(); - Response response = consumerClient.subscribe(enhancedSubscription); - logger.info("Received response " + response.toString()); - return response; + try { + Response response = consumerClient.subscribe(enhancedSubscription); + logger.info("Received response " + response.toString()); + return response; + } catch (Exception e) { + logger.error("Error in subscribe. error {}", e.getMessage()); + return null; + } } public void subscribeStream(Subscription subscription) { @@ -78,13 +86,17 @@ public void subscribeStream(Subscription subscription) { addSubscription(subscription); - ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); - Subscription enhancedSubscription = Subscription.newBuilder(subscription) .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) .setConsumerGroup(clientConfig.getConsumerGroup()) .build(); - Iterator msgIterator = consumerClient.subscribeStream(enhancedSubscription); + Iterator msgIterator; + try { + msgIterator = consumerClient.subscribeStream(enhancedSubscription); + } catch (Exception e) { + logger.error("Error in subscribe. error {}", e.getMessage()); + return; + } ListenerThread listenerThread = new ListenerThread(msgIterator, listener); listenerThreads.add(listenerThread); @@ -109,15 +121,19 @@ public Response unsubscribe(Subscription subscription) { removeSubscription(subscription); - ConsumerServiceGrpc.ConsumerServiceBlockingStub consumerClient = ConsumerServiceGrpc.newBlockingStub(channel); Subscription enhancedSubscription = Subscription.newBuilder(subscription) .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) .setConsumerGroup(clientConfig.getConsumerGroup()) .build(); - Response response = consumerClient.unsubscribe(enhancedSubscription); - logger.info("Received response " + response.toString()); - return response; + try { + Response response = consumerClient.unsubscribe(enhancedSubscription); + logger.info("Received response " + response.toString()); + return response; + } catch (Exception e) { + logger.error("Error in unsubscribe. error {}", e.getMessage()); + return null; + } } public void registerListener(ReceiveMsgHook listener) { @@ -127,12 +143,14 @@ public void registerListener(ReceiveMsgHook listener) { } private void heartBeat() { - HeartbeatServiceGrpc.HeartbeatServiceBlockingStub heartbeatClient = HeartbeatServiceGrpc.newBlockingStub(channel); RequestHeader header = EventMeshClientUtil.buildHeader(clientConfig); scheduler.scheduleAtFixedRate(() -> { - + if (subscriptionMap.isEmpty()) { + return; + } Heartbeat.Builder heartbeatBuilder = Heartbeat.newBuilder() .setHeader(header) + .setConsumerGroup(clientConfig.getConsumerGroup()) .setClientType(Heartbeat.ClientType.SUB); for (Map.Entry entry : subscriptionMap.entrySet()) { @@ -144,9 +162,13 @@ private void heartBeat() { } Heartbeat heartbeat = heartbeatBuilder.build(); - Response response = heartbeatClient.heartbeat(heartbeat); - if (logger.isDebugEnabled()) { - logger.debug("Grpc Consumer Heartbeat response: {}", response); + try { + Response response = heartbeatClient.heartbeat(heartbeat); + if (logger.isDebugEnabled()) { + logger.debug("Grpc Consumer Heartbeat response: {}", response); + } + } catch (Exception e) { + logger.error("Error in sending out heartbeat. error {}", e.getMessage()); } }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS); @@ -159,6 +181,7 @@ public void close() { thread.stop(); } channel.shutdown(); + scheduler.shutdown(); } static class ListenerThread extends Thread { @@ -173,9 +196,13 @@ static class ListenerThread extends Thread { public void run() { logger.info("start receiving..."); - while (msgIterator.hasNext()) { - logger.info("sdk received message "); - listener.handle(msgIterator.next()); + try { + while (msgIterator.hasNext()) { + logger.info("sdk received message "); + listener.handle(msgIterator.next()); + } + } catch (Throwable t) { + logger.warn("Error in handling message. {}", t.getMessage()); } } } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java index 01203c84bb..08def1e8c1 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java @@ -1,25 +1,26 @@ package org.apache.eventmesh.client.grpc; -import io.cloudevents.SpecVersion; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; -import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc.PublisherServiceBlockingStub; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class EventMeshGrpcProducer implements AutoCloseable { - private static Logger logger = LoggerFactory.getLogger(EventMeshGrpcProducer.class); + private static final Logger logger = LoggerFactory.getLogger(EventMeshGrpcProducer.class); - private EventMeshGrpcClientConfig clientConfig; + private final EventMeshGrpcClientConfig clientConfig; private ManagedChannel channel; + private PublisherServiceBlockingStub publisherClient; + public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) { this.clientConfig = clientConfig; } @@ -27,19 +28,24 @@ public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) { public void init() { channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) .usePlaintext().build(); + publisherClient = PublisherServiceGrpc.newBlockingStub(channel); } public Response publish(EventMeshMessage message) { logger.info("Publish message " + message.toString()); - PublisherServiceGrpc.PublisherServiceBlockingStub publisherClient = PublisherServiceGrpc.newBlockingStub(channel); EventMeshMessage enhancedMessage = EventMeshMessage.newBuilder(message) .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) .setProducerGroup(clientConfig.getProducerGroup()) .build(); - Response response = publisherClient.publish(enhancedMessage); - logger.info("Received response " + response.toString()); - return response; + try { + Response response = publisherClient.publish(enhancedMessage); + logger.info("Received response " + response.toString()); + return response; + } catch (Exception e) { + logger.error("Error in publishing message {}, error {}", message, e.getMessage()); + return null; + } } public void close() { From 1f7ae90f7138845126cb281202d492f5d5f88cad Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Fri, 24 Dec 2021 12:07:54 -0500 Subject: [PATCH 14/21] enhance consumer push API --- .../EventMeshGrpcConfiguration.java | 3 + .../grpc/consumer/EventMeshConsumer.java | 4 + .../grpc/push/AbstractPushRequest.java | 25 +-- .../protocol/grpc/push/StreamPushRequest.java | 31 +++- .../grpc/push/WebhookPushRequest.java | 152 ++++++++---------- .../core/protocol/grpc/retry/GrpcRetryer.java | 45 +++--- .../protocol/grpc/service/EventEmitter.java | 4 + 7 files changed, 128 insertions(+), 136 deletions(-) diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java index 7278594eb9..8b5e95a5c7 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java @@ -21,6 +21,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.config.CommonConfiguration; import org.apache.eventmesh.common.config.ConfigurationWrapper; +import org.apache.eventmesh.common.utils.IPUtils; public class EventMeshGrpcConfiguration extends CommonConfiguration { @@ -66,6 +67,8 @@ public class EventMeshGrpcConfiguration extends CommonConfiguration { public int eventMeshBatchMsgRequestNumPerSecond = 20000; + public String eventMeshIP = IPUtils.getLocalAddress(); + public EventMeshGrpcConfiguration(ConfigurationWrapper configurationWrapper) { super(configurationWrapper); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java index e458e1be02..bb9b75958a 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/EventMeshConsumer.java @@ -240,6 +240,10 @@ private EventListener createEventListener(SubscriptionMode subscriptionMode) { // ignore exception } } + } else { + if (logger.isDebugEnabled()) { + logger.debug("no active consumer for topic={}|msg={}", topic, event); + } } eventMeshAsyncConsumeContext.commit(EventMeshAction.CommitMessage); }; diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java index 6ad5fa0e78..9c39ef91c2 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java @@ -62,10 +62,7 @@ public abstract class AbstractPushRequest extends RetryContext { protected HandleMsgContext handleMsgContext; protected CloudEvent event; - protected String topic; - protected String bizSeqNum; - protected String uniqueId; - protected int ttl; + protected EventMeshMessage eventMeshMessage; private final AtomicBoolean complete = new AtomicBoolean(Boolean.FALSE); @@ -82,21 +79,12 @@ public AbstractPushRequest(HandleMsgContext handleMsgContext, Map protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); @@ -120,7 +108,7 @@ protected void delayRetry() { delay((long) retryTimes * EventMeshConstants.DEFAULT_PUSH_RETRY_TIME_DISTANCE_IN_MILLSECONDS); grpcRetryer.pushRetry(this); } else { - complete.compareAndSet(Boolean.FALSE, Boolean.TRUE); + complete(); } } @@ -128,7 +116,7 @@ protected boolean isComplete() { return complete.get(); } - protected void finish() { + private void finish() { AbstractContext context = handleMsgContext.getContext(); CloudEvent event = handleMsgContext.getEvent(); SubscriptionMode subscriptionMode = handleMsgContext.getSubscriptionMode(); @@ -143,10 +131,11 @@ protected void finish() { protected void complete() { complete.compareAndSet(Boolean.FALSE, Boolean.TRUE); + finish(); } protected void timeout() { - if (!isComplete() && System.currentTimeMillis() - lastPushTime >= ttl) { + if (!isComplete() && System.currentTimeMillis() - lastPushTime >= Long.parseLong(eventMeshMessage.getTtl())) { delayRetry(); } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java index 4102d18c9f..f0e1acd14b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java @@ -15,7 +15,7 @@ public class StreamPushRequest extends AbstractPushRequest { - private final Logger logger = LoggerFactory.getLogger(this.getClass()); + private final Logger messageLogger = LoggerFactory.getLogger("message"); private final Map>> idcEmitters; @@ -34,15 +34,34 @@ public StreamPushRequest(HandleMsgContext handleMsgContext, Map eventEmitter = selectEmitter(); - EventMeshMessage eventMeshMessage = getEventMeshMessage(event); - if (eventMeshMessage == null) { + if (eventEmitter == null) { return; } - eventEmitter.onNext(eventMeshMessage); - complete(); - finish(); + this.lastPushTime = System.currentTimeMillis(); + + try { + long cost = System.currentTimeMillis() - lastPushTime; + eventEmitter.getEmitter().onNext(eventMeshMessage); + messageLogger.info( + "message|eventMesh2client|emitter|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", eventMeshMessage.getTopic(), + eventMeshMessage.getSeqNum(), eventMeshMessage.getUniqueId(), cost); + complete(); + } catch (Throwable t) { + long cost = System.currentTimeMillis() - lastPushTime; + messageLogger.info( + "message|eventMesh2client|exception|emitter|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", eventMeshMessage.getTopic(), + eventMeshMessage.getSeqNum(), eventMeshMessage.getUniqueId(), cost); + + delayRetry(); + } } private EventEmitter selectEmitter() { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java index b60b0dff4e..3262fdcbbf 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java @@ -24,7 +24,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; import org.apache.eventmesh.common.protocol.http.common.ClientRetCode; import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; @@ -35,7 +34,6 @@ import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.WebhookTopicConfig; import org.apache.eventmesh.runtime.util.EventMeshUtil; -import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; import org.apache.http.client.ResponseHandler; @@ -50,7 +48,6 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -71,13 +68,13 @@ public class WebhookPushRequest extends AbstractPushRequest { private final int startIdx; - private String currPushUrl; + private String selectedPushUrl; public WebhookPushRequest(HandleMsgContext handleMsgContext, Map> waitingRequests) { super(handleMsgContext, waitingRequests); - WebhookTopicConfig topicConfig = (WebhookTopicConfig) handleMsgContext.getConsumeTopicConfig(); + WebhookTopicConfig topicConfig = (WebhookTopicConfig) handleMsgContext.getConsumeTopicConfig(); this.urls = topicConfig.getIdcUrls(); this.totalUrls = topicConfig.getTotalUrls(); this.startIdx = RandomUtils.nextInt(0, totalUrls.size()); @@ -85,47 +82,37 @@ public WebhookPushRequest(HandleMsgContext handleMsgContext, @Override public void tryPushRequest() { + if (eventMeshMessage == null) { + return; + } - currPushUrl = getUrl(); - - if (StringUtils.isBlank(currPushUrl)) { + selectedPushUrl = getUrl(); + if (StringUtils.isBlank(selectedPushUrl)) { return; } - HttpPost builder = new HttpPost(currPushUrl); + HttpPost builder = new HttpPost(selectedPushUrl); String requestCode = String.valueOf(RequestCode.HTTP_PUSH_CLIENT_ASYNC.getRequestCode()); - builder.addHeader(ProtocolKey.REQUEST_CODE, requestCode); builder.addHeader(ProtocolKey.LANGUAGE, Constants.LANGUAGE_JAVA); builder.addHeader(ProtocolKey.VERSION, ProtocolVersion.V1.getVersion()); - builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHCLUSTER, - handleMsgContext.getEventMeshGrpcServer() - .getEventMeshGrpcConfiguration().eventMeshCluster); - builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIP, IPUtils.getLocalAddress()); - builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHENV, - handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration().eventMeshEnv); - builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIDC, - handleMsgContext.getEventMeshGrpcServer().getEventMeshGrpcConfiguration().eventMeshIDC); - - String content = ""; - EventMeshMessage eventMeshMessage = getEventMeshMessage(event); - if (eventMeshMessage == null) { - return; - } else { - content = eventMeshMessage.getContent(); - } + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHCLUSTER, eventMeshGrpcConfiguration.eventMeshCluster); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIP, eventMeshGrpcConfiguration.eventMeshIP); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHENV, eventMeshGrpcConfiguration.eventMeshEnv); + builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIDC, eventMeshGrpcConfiguration.eventMeshIDC); List body = new ArrayList<>(); - body.add(new BasicNameValuePair(PushMessageRequestBody.CONTENT, content)); - body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, bizSeqNum)); - body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, uniqueId)); - body.add(new BasicNameValuePair(PushMessageRequestBody.RANDOMNO, - handleMsgContext.getMsgRandomNo())); - body.add(new BasicNameValuePair(PushMessageRequestBody.TOPIC, topic)); + body.add(new BasicNameValuePair(PushMessageRequestBody.CONTENT, eventMeshMessage.getContent())); + body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, eventMeshMessage.getSeqNum())); + body.add(new BasicNameValuePair(PushMessageRequestBody.UNIQUEID, eventMeshMessage.getUniqueId())); + body.add(new BasicNameValuePair(PushMessageRequestBody.RANDOMNO, handleMsgContext.getMsgRandomNo())); + body.add(new BasicNameValuePair(PushMessageRequestBody.TOPIC, eventMeshMessage.getTopic())); body.add(new BasicNameValuePair(PushMessageRequestBody.EXTFIELDS, JsonUtils.serialize(EventMeshUtil.getEventProp(event)))); + //TODO update event time here + builder.setEntity(new UrlEncodedFormEntity(body, StandardCharsets.UTF_8)); //eventMeshHTTPServer.metrics.summaryMetrics.recordPushMsg(); @@ -135,78 +122,34 @@ public void tryPushRequest() { addToWaitingMap(this); cmdLogger.info("cmd={}|eventMesh2client|from={}|to={}", requestCode, - IPUtils.getLocalAddress(), currPushUrl); + IPUtils.getLocalAddress(), selectedPushUrl); try { - eventMeshGrpcServer.getHttpClient().execute(builder, new ResponseHandler() { - @Override - public Object handleResponse(HttpResponse response) { - removeWaitingMap(WebhookPushRequest.this); - long cost = System.currentTimeMillis() - lastPushTime; - //eventMeshHTTPServer.metrics.summaryMetrics.recordHTTPPushTimeCost(cost); - if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { - //eventMeshHTTPServer.metrics.summaryMetrics.recordHttpPushMsgFailed(); - messageLogger.info( - "message|eventMesh2client|exception|url={}|topic={}|bizSeqNo={}" - + "|uniqueId={}|cost={}", currPushUrl, topic, bizSeqNum, uniqueId, cost); - - delayRetry(); - if (isComplete()) { - finish(); - } - } else { - String res = ""; - try { - res = EntityUtils.toString(response.getEntity(), - Charset.forName(EventMeshConstants.DEFAULT_CHARSET)); - } catch (IOException e) { - finish(); - return new Object(); - } - ClientRetCode result = processResponseContent(res); - messageLogger.info( - "message|eventMesh2client|{}|url={}|topic={}|bizSeqNo={}" - + "|uniqueId={}|cost={}", - result, currPushUrl, topic, bizSeqNum, uniqueId, cost); - if (result == ClientRetCode.OK || result == ClientRetCode.FAIL) { - complete(); - finish(); - } else if (result == ClientRetCode.RETRY || result == ClientRetCode.NOLISTEN) { - delayRetry(); - if (isComplete()) { - finish(); - } - } - } - return new Object(); - } - }); + eventMeshGrpcServer.getHttpClient().execute(builder, handleResponse()); if (messageLogger.isDebugEnabled()) { - messageLogger.debug("message|eventMesh2client|url={}|topic={}|event={}", currPushUrl, - topic, event); + messageLogger.debug("message|eventMesh2client|url={}|topic={}|event={}", selectedPushUrl, + eventMeshMessage.getTopic(), event); } else { messageLogger .info("message|eventMesh2client|url={}|topic={}|bizSeqNo={}|uniqueId={}", - currPushUrl, topic, bizSeqNum, uniqueId); + selectedPushUrl, eventMeshMessage.getTopic(), eventMeshMessage.getSeqNum(), + eventMeshMessage.getUniqueId()); } } catch (IOException e) { messageLogger.error("push2client err", e); removeWaitingMap(this); delayRetry(); - if (isComplete()) { - finish(); - } } } @Override public String toString() { return "asyncPushRequest={" - + "bizSeqNo=" + bizSeqNum + + "bizSeqNo=" + eventMeshMessage.getSeqNum() + ",startIdx=" + startIdx + ",retryTimes=" + retryTimes - + ",uniqueId=" + uniqueId + + ",uniqueId=" + eventMeshMessage.getUniqueId() + ",executeTime=" + DateFormatUtils.format(executeTime, Constants.DATE_FORMAT) + ",lastPushTime=" @@ -215,6 +158,43 @@ public String toString() { + DateFormatUtils.format(createTime, Constants.DATE_FORMAT) + "}"; } + private ResponseHandler handleResponse() { + return response -> { + removeWaitingMap(WebhookPushRequest.this); + long cost = System.currentTimeMillis() - lastPushTime; + //eventMeshHTTPServer.metrics.summaryMetrics.recordHTTPPushTimeCost(cost); + if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { + //eventMeshHTTPServer.metrics.summaryMetrics.recordHttpPushMsgFailed(); + messageLogger.info( + "message|eventMesh2client|exception|url={}|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", selectedPushUrl, eventMeshMessage.getTopic(), + eventMeshMessage.getSeqNum(), eventMeshMessage.getUniqueId(), cost); + + delayRetry(); + } else { + String res = ""; + try { + res = EntityUtils.toString(response.getEntity(), + Charset.forName(EventMeshConstants.DEFAULT_CHARSET)); + } catch (IOException e) { + complete(); + return new Object(); + } + ClientRetCode result = processResponseContent(res); + messageLogger.info( + "message|eventMesh2client|{}|url={}|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", result, selectedPushUrl, eventMeshMessage.getTopic(), + eventMeshMessage.getSeqNum(), eventMeshMessage.getUniqueId(), cost); + if (result == ClientRetCode.OK || result == ClientRetCode.FAIL) { + complete(); + } else if (result == ClientRetCode.RETRY || result == ClientRetCode.NOLISTEN) { + delayRetry(); + } + } + return new Object(); + }; + } + private ClientRetCode processResponseContent(String content) { if (StringUtils.isBlank(content)) { return ClientRetCode.FAIL; @@ -230,8 +210,8 @@ private ClientRetCode processResponseContent(String content) { } return ClientRetCode.FAIL; } catch (Exception e) { - messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", currPushUrl, - bizSeqNum, uniqueId, content); + messageLogger.warn("url:{}, bizSeqno:{}, uniqueId:{}, httpResponse:{}", selectedPushUrl, + eventMeshMessage.getSeqNum(), eventMeshMessage.getUniqueId(), content); return ClientRetCode.FAIL; } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java index be9001da21..f7f13739b4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/retry/GrpcRetryer.java @@ -35,12 +35,9 @@ public class GrpcRetryer { private Logger logger = LoggerFactory.getLogger(this.getClass()); - private EventMeshGrpcServer eventMeshGrpcServer; - private EventMeshGrpcConfiguration grpcConfiguration; public GrpcRetryer(EventMeshGrpcServer eventMeshGrpcServer) { - this.eventMeshGrpcServer = eventMeshGrpcServer; this.grpcConfiguration = eventMeshGrpcServer.getEventMeshGrpcConfiguration(); } @@ -51,8 +48,7 @@ public GrpcRetryer(EventMeshGrpcServer eventMeshGrpcServer) { private Thread dispatcher; public void pushRetry(DelayRetryable delayRetryable) { - if (failed.size() >= eventMeshGrpcServer.getEventMeshGrpcConfiguration() - .eventMeshServerRetryBlockQSize) { + if (failed.size() >= grpcConfiguration.eventMeshServerRetryBlockQSize) { retryLogger.error("[RETRY-QUEUE] is full!"); return; } @@ -64,7 +60,7 @@ public void init() { grpcConfiguration.eventMeshServerRetryThreadNum, 60000, TimeUnit.MILLISECONDS, - new ArrayBlockingQueue(grpcConfiguration.eventMeshServerRetryBlockQSize), + new ArrayBlockingQueue<>(grpcConfiguration.eventMeshServerRetryBlockQSize), new ThreadFactory() { private AtomicInteger count = new AtomicInteger(); @@ -77,28 +73,25 @@ public Thread newThread(Runnable r) { } }, new ThreadPoolExecutor.AbortPolicy()); - dispatcher = new Thread(new Runnable() { - @Override - public void run() { - try { - DelayRetryable retryObj = null; - while (!Thread.currentThread().isInterrupted() - && (retryObj = failed.take()) != null) { - final DelayRetryable delayRetryable = retryObj; - pool.execute(() -> { - try { - delayRetryable.retry(); - if (retryLogger.isDebugEnabled()) { - retryLogger.debug("retryObj : {}", delayRetryable); - } - } catch (Exception e) { - retryLogger.error("grpc-retry-dispatcher error!", e); + dispatcher = new Thread(() -> { + try { + DelayRetryable retryObj = null; + while (!Thread.currentThread().isInterrupted() + && (retryObj = failed.take()) != null) { + final DelayRetryable delayRetryable = retryObj; + pool.execute(() -> { + try { + delayRetryable.retry(); + if (retryLogger.isDebugEnabled()) { + retryLogger.debug("retryObj : {}", delayRetryable); } - }); - } - } catch (Exception e) { - retryLogger.error("grpc-retry-dispatcher error!", e); + } catch (Exception e) { + retryLogger.error("grpc-retry-dispatcher error!", e); + } + }); } + } catch (Exception e) { + retryLogger.error("grpc-retry-dispatcher error!", e); } }, "grpc-retry-dispatcher"); dispatcher.setDaemon(true); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/EventEmitter.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/EventEmitter.java index a9999c0816..221aaf795a 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/EventEmitter.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/EventEmitter.java @@ -36,4 +36,8 @@ public void onError(Throwable t) { logger.warn("StreamObserver Error onError. {}", t1.getMessage()); } } + + public StreamObserver getEmitter() { + return emitter; + } } From 82c7e2ea06ba4db976881e1d271f111e8da59d27 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Fri, 24 Dec 2021 15:47:03 -0500 Subject: [PATCH 15/21] enhance consumer push API --- .../protocol/grpc/common/StatusCode.java | 3 +- .../grpc/protos/EventMeshMessage.java | 277 ++++++++++++++++++ .../protos/EventMeshMessageOrBuilder.java | 34 +++ .../protocol/grpc/protos/EventmeshGrpc.java | 112 +++---- .../src/main/proto/eventmesh-client.proto | 1 + .../grpc/GrpcMessageProtocolResolver.java | 19 +- .../runtime/boot/EventMeshGrpcServer.java | 17 +- .../EventMeshGrpcConfiguration.java | 104 ++++--- .../grpc/consumer/ConsumerManager.java | 69 ++--- .../grpc/interceptor/MetricsInterceptor.java | 24 -- .../grpc/processor/HeartbeatProcessor.java | 30 ++ .../processor/SendAsyncMessageProcessor.java | 48 ++- .../grpc/processor/SubscribeProcessor.java | 27 ++ .../processor/SubscribeStreamProcessor.java | 43 ++- .../grpc/push/AbstractPushRequest.java | 8 +- .../protocol/grpc/push/StreamPushRequest.java | 3 + .../grpc/push/WebhookPushRequest.java | 26 +- .../core/protocol/grpc/retry/GrpcRetryer.java | 4 +- .../grpc/service/ConsumerService.java | 16 + .../grpc/service/HeartbeatService.java | 5 + .../grpc/service/ProducerService.java | 13 +- .../client/grpc/EventMeshGrpcConsumer.java | 2 +- 22 files changed, 691 insertions(+), 194 deletions(-) delete mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java index 3b930e1803..3f3a850755 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java @@ -39,7 +39,8 @@ public enum StatusCode { EVENTMESH_SUBSCRIBE_ERR("17", "eventMesh subscribe err"), EVENTMESH_UNSUBSCRIBE_ERR("18", "eventMesh unsubscribe err"), EVENTMESH_HEARTBEAT_ERR("19", "eventMesh heartbeat err"), - EVENTMESH_ACL_ERR("20", "eventMesh acl err"); + EVENTMESH_ACL_ERR("20", "eventMesh acl err"), + EVENTMESH_SEND_MESSAGE_SPEED_OVER_LIMIT_ERR("21", "eventMesh send message speed over the limit err."); private String retCode; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java index c36fa52ee7..be8b1e5970 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java @@ -111,6 +111,19 @@ private EventMeshMessage( tag_ = s; break; } + case 74: { + if (!((mutable_bitField0_ & 0x00000100) == 0x00000100)) { + properties_ = com.google.protobuf.MapField.newMapField( + PropertiesDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000100; + } + com.google.protobuf.MapEntry + properties__ = input.readMessage( + PropertiesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + properties_.getMutableMap().put( + properties__.getKey(), properties__.getValue()); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -128,6 +141,17 @@ private EventMeshMessage( return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 9: + return internalGetProperties(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } protected FieldAccessorTable internalGetFieldAccessorTable() { return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable @@ -135,6 +159,7 @@ private EventMeshMessage( EventMeshMessage.class, Builder.class); } + private int bitField0_; public static final int HEADER_FIELD_NUMBER = 1; private RequestHeader header_; /** @@ -394,6 +419,82 @@ public String getTag() { } } + public static final int PROPERTIES_FIELD_NUMBER = 9; + private static final class PropertiesDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + String, String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_PropertiesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + String, String> properties_; + private com.google.protobuf.MapField + internalGetProperties() { + if (properties_ == null) { + return com.google.protobuf.MapField.emptyMapField( + PropertiesDefaultEntryHolder.defaultEntry); + } + return properties_; + } + + public int getPropertiesCount() { + return internalGetProperties().getMap().size(); + } + /** + * map<string, string> properties = 9; + */ + + public boolean containsProperties( + String key) { + if (key == null) { throw new NullPointerException(); } + return internalGetProperties().getMap().containsKey(key); + } + /** + * Use {@link #getPropertiesMap()} instead. + */ + @Deprecated + public java.util.Map getProperties() { + return getPropertiesMap(); + } + /** + * map<string, string> properties = 9; + */ + + public java.util.Map getPropertiesMap() { + return internalGetProperties().getMap(); + } + /** + * map<string, string> properties = 9; + */ + + public String getPropertiesOrDefault( + String key, + String defaultValue) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> properties = 9; + */ + + public String getPropertiesOrThrow( + String key) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; @@ -430,6 +531,12 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!getTagBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 8, tag_); } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetProperties(), + PropertiesDefaultEntryHolder.defaultEntry, + 9); unknownFields.writeTo(output); } @@ -463,6 +570,16 @@ public int getSerializedSize() { if (!getTagBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, tag_); } + for (java.util.Map.Entry entry + : internalGetProperties().getMap().entrySet()) { + com.google.protobuf.MapEntry + properties__ = PropertiesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(9, properties__); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -498,6 +615,8 @@ public boolean equals(final Object obj) { .equals(other.getSeqNum()); result = result && getTag() .equals(other.getTag()); + result = result && internalGetProperties().equals( + other.internalGetProperties()); result = result && unknownFields.equals(other.unknownFields); return result; } @@ -527,6 +646,10 @@ public int hashCode() { hash = (53 * hash) + getSeqNum().hashCode(); hash = (37 * hash) + TAG_FIELD_NUMBER; hash = (53 * hash) + getTag().hashCode(); + if (!internalGetProperties().getMap().isEmpty()) { + hash = (37 * hash) + PROPERTIES_FIELD_NUMBER; + hash = (53 * hash) + internalGetProperties().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -632,6 +755,28 @@ public static final class Builder extends return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor; } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 9: + return internalGetProperties(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 9: + return internalGetMutableProperties(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } protected FieldAccessorTable internalGetFieldAccessorTable() { return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable @@ -676,6 +821,7 @@ public Builder clear() { tag_ = ""; + internalGetMutableProperties().clear(); return this; } @@ -698,6 +844,8 @@ public EventMeshMessage build() { public EventMeshMessage buildPartial() { EventMeshMessage result = new EventMeshMessage(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; if (headerBuilder_ == null) { result.header_ = header_; } else { @@ -710,6 +858,9 @@ public EventMeshMessage buildPartial() { result.uniqueId_ = uniqueId_; result.seqNum_ = seqNum_; result.tag_ = tag_; + result.properties_ = internalGetProperties(); + result.properties_.makeImmutable(); + result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -782,6 +933,8 @@ public Builder mergeFrom(EventMeshMessage other) { tag_ = other.tag_; onChanged(); } + internalGetMutableProperties().mergeFrom( + other.internalGetProperties()); this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -808,6 +961,7 @@ public Builder mergeFrom( } return this; } + private int bitField0_; private RequestHeader header_ = null; private com.google.protobuf.SingleFieldBuilderV3< @@ -1408,6 +1562,129 @@ public Builder setTagBytes( onChanged(); return this; } + + private com.google.protobuf.MapField< + String, String> properties_; + private com.google.protobuf.MapField + internalGetProperties() { + if (properties_ == null) { + return com.google.protobuf.MapField.emptyMapField( + PropertiesDefaultEntryHolder.defaultEntry); + } + return properties_; + } + private com.google.protobuf.MapField + internalGetMutableProperties() { + onChanged();; + if (properties_ == null) { + properties_ = com.google.protobuf.MapField.newMapField( + PropertiesDefaultEntryHolder.defaultEntry); + } + if (!properties_.isMutable()) { + properties_ = properties_.copy(); + } + return properties_; + } + + public int getPropertiesCount() { + return internalGetProperties().getMap().size(); + } + /** + * map<string, string> properties = 9; + */ + + public boolean containsProperties( + String key) { + if (key == null) { throw new NullPointerException(); } + return internalGetProperties().getMap().containsKey(key); + } + /** + * Use {@link #getPropertiesMap()} instead. + */ + @Deprecated + public java.util.Map getProperties() { + return getPropertiesMap(); + } + /** + * map<string, string> properties = 9; + */ + + public java.util.Map getPropertiesMap() { + return internalGetProperties().getMap(); + } + /** + * map<string, string> properties = 9; + */ + + public String getPropertiesOrDefault( + String key, + String defaultValue) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> properties = 9; + */ + + public String getPropertiesOrThrow( + String key) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearProperties() { + internalGetMutableProperties().getMutableMap() + .clear(); + return this; + } + /** + * map<string, string> properties = 9; + */ + + public Builder removeProperties( + String key) { + if (key == null) { throw new NullPointerException(); } + internalGetMutableProperties().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @Deprecated + public java.util.Map + getMutableProperties() { + return internalGetMutableProperties().getMutableMap(); + } + /** + * map<string, string> properties = 9; + */ + public Builder putProperties( + String key, + String value) { + if (key == null) { throw new NullPointerException(); } + if (value == null) { throw new NullPointerException(); } + internalGetMutableProperties().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, string> properties = 9; + */ + + public Builder putAllProperties( + java.util.Map values) { + internalGetMutableProperties().getMutableMap() + .putAll(values); + return this; + } public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFieldsProto3(unknownFields); diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java index 505bbdd1cc..f17b510070 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java @@ -89,4 +89,38 @@ public interface EventMeshMessageOrBuilder extends */ com.google.protobuf.ByteString getTagBytes(); + + /** + * map<string, string> properties = 9; + */ + int getPropertiesCount(); + /** + * map<string, string> properties = 9; + */ + boolean containsProperties( + String key); + /** + * Use {@link #getPropertiesMap()} instead. + */ + @Deprecated + java.util.Map + getProperties(); + /** + * map<string, string> properties = 9; + */ + java.util.Map + getPropertiesMap(); + /** + * map<string, string> properties = 9; + */ + + String getPropertiesOrDefault( + String key, + String defaultValue); + /** + * map<string, string> properties = 9; + */ + + String getPropertiesOrThrow( + String key); } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java index f8205e6861..7c23f5a169 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -24,6 +24,11 @@ public static void registerAllExtensions( static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_PropertiesEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_PropertiesEntry_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_eventmesh_common_protocol_grpc_Response_descriptor; static final @@ -64,58 +69,61 @@ public static void registerAllExtensions( "ip\030\004 \001(\t\022\013\n\003pid\030\005 \001(\t\022\013\n\003sys\030\006 \001(\t\022\020\n\010us" + "ername\030\007 \001(\t\022\020\n\010password\030\010 \001(\t\022\020\n\010langua" + "ge\030\t \001(\t\022\024\n\014protocolType\030\n \001(\t\022\027\n\017protoc" + - "olVersion\030\013 \001(\t\022\024\n\014protocolDesc\030\014 \001(\t\"\304\001" + + "olVersion\030\013 \001(\t\022\024\n\014protocolDesc\030\014 \001(\t\"\315\002" + "\n\020EventMeshMessage\022=\n\006header\030\001 \001(\0132-.eve" + "ntmesh.common.protocol.grpc.RequestHeade" + "r\022\025\n\rproducerGroup\030\002 \001(\t\022\r\n\005topic\030\003 \001(\t\022" + "\017\n\007content\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020\n\010uniqueI" + - "d\030\006 \001(\t\022\016\n\006seqNum\030\007 \001(\t\022\013\n\003tag\030\010 \001(\t\"?\n\010" + - "Response\022\020\n\010respCode\030\001 \001(\t\022\017\n\007respMsg\030\002 " + - "\001(\t\022\020\n\010respTime\030\003 \001(\t\"\212\004\n\014Subscription\022=" + - "\n\006header\030\001 \001(\0132-.eventmesh.common.protoc" + - "ol.grpc.RequestHeader\022\025\n\rconsumerGroup\030\002" + - " \001(\t\022X\n\021subscriptionItems\030\003 \003(\0132=.eventm" + - "esh.common.protocol.grpc.Subscription.Su" + - "bscriptionItem\022\013\n\003url\030\004 \001(\t\032\274\002\n\020Subscrip" + - "tionItem\022\r\n\005topic\030\001 \001(\t\022\\\n\004mode\030\002 \001(\0162N." + - "eventmesh.common.protocol.grpc.Subscript" + - "ion.SubscriptionItem.SubscriptionMode\022\\\n" + - "\004type\030\003 \001(\0162N.eventmesh.common.protocol." + - "grpc.Subscription.SubscriptionItem.Subsc" + - "riptionType\"4\n\020SubscriptionMode\022\016\n\nCLUST" + - "ERING\020\000\022\020\n\014BROADCASTING\020\001\"\'\n\020Subscriptio" + - "nType\022\t\n\005ASYNC\020\000\022\010\n\004SYNC\020\001\"\340\002\n\tHeartbeat" + - "\022=\n\006header\030\001 \001(\0132-.eventmesh.common.prot" + - "ocol.grpc.RequestHeader\022H\n\nclientType\030\002 " + - "\001(\01624.eventmesh.common.protocol.grpc.Hea" + - "rtbeat.ClientType\022\025\n\rproducerGroup\030\003 \001(\t" + - "\022\025\n\rconsumerGroup\030\004 \001(\t\022O\n\016heartbeatItem" + - "s\030\005 \003(\01327.eventmesh.common.protocol.grpc" + - ".Heartbeat.HeartbeatItem\032+\n\rHeartbeatIte" + - "m\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030\002 \001(\t\"\036\n\nClientT" + - "ype\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\316\002\n\020PublisherServi" + - "ce\022e\n\007publish\0220.eventmesh.common.protoco" + - "l.grpc.EventMeshMessage\032(.eventmesh.comm" + - "on.protocol.grpc.Response\022j\n\014requestRepl" + - "y\0220.eventmesh.common.protocol.grpc.Event" + - "MeshMessage\032(.eventmesh.common.protocol." + - "grpc.Response\022g\n\tbroadcast\0220.eventmesh.c" + - "ommon.protocol.grpc.EventMeshMessage\032(.e" + - "ventmesh.common.protocol.grpc.Response2\322" + - "\002\n\017ConsumerService\022c\n\tsubscribe\022,.eventm" + - "esh.common.protocol.grpc.Subscription\032(." + - "eventmesh.common.protocol.grpc.Response\022" + - "s\n\017subscribeStream\022,.eventmesh.common.pr" + - "otocol.grpc.Subscription\0320.eventmesh.com" + - "mon.protocol.grpc.EventMeshMessage0\001\022e\n\013" + - "unsubscribe\022,.eventmesh.common.protocol." + - "grpc.Subscription\032(.eventmesh.common.pro" + - "tocol.grpc.Response2t\n\020HeartbeatService\022" + - "`\n\theartbeat\022).eventmesh.common.protocol" + - ".grpc.Heartbeat\032(.eventmesh.common.proto" + - "col.grpc.ResponseBC\n0org.apache.eventmes" + - "h.common.protocol.grpc.protosB\rEventmesh" + - "GrpcP\001b\006proto3" + "d\030\006 \001(\t\022\016\n\006seqNum\030\007 \001(\t\022\013\n\003tag\030\010 \001(\t\022T\n\n" + + "properties\030\t \003(\0132@.eventmesh.common.prot" + + "ocol.grpc.EventMeshMessage.PropertiesEnt" + + "ry\0321\n\017PropertiesEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005va" + + "lue\030\002 \001(\t:\0028\001\"?\n\010Response\022\020\n\010respCode\030\001 " + + "\001(\t\022\017\n\007respMsg\030\002 \001(\t\022\020\n\010respTime\030\003 \001(\t\"\212" + + "\004\n\014Subscription\022=\n\006header\030\001 \001(\0132-.eventm" + + "esh.common.protocol.grpc.RequestHeader\022\025" + + "\n\rconsumerGroup\030\002 \001(\t\022X\n\021subscriptionIte" + + "ms\030\003 \003(\0132=.eventmesh.common.protocol.grp" + + "c.Subscription.SubscriptionItem\022\013\n\003url\030\004" + + " \001(\t\032\274\002\n\020SubscriptionItem\022\r\n\005topic\030\001 \001(\t" + + "\022\\\n\004mode\030\002 \001(\0162N.eventmesh.common.protoc" + + "ol.grpc.Subscription.SubscriptionItem.Su" + + "bscriptionMode\022\\\n\004type\030\003 \001(\0162N.eventmesh" + + ".common.protocol.grpc.Subscription.Subsc" + + "riptionItem.SubscriptionType\"4\n\020Subscrip" + + "tionMode\022\016\n\nCLUSTERING\020\000\022\020\n\014BROADCASTING" + + "\020\001\"\'\n\020SubscriptionType\022\t\n\005ASYNC\020\000\022\010\n\004SYN" + + "C\020\001\"\340\002\n\tHeartbeat\022=\n\006header\030\001 \001(\0132-.even" + + "tmesh.common.protocol.grpc.RequestHeader" + + "\022H\n\nclientType\030\002 \001(\01624.eventmesh.common." + + "protocol.grpc.Heartbeat.ClientType\022\025\n\rpr" + + "oducerGroup\030\003 \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t" + + "\022O\n\016heartbeatItems\030\005 \003(\01327.eventmesh.com" + + "mon.protocol.grpc.Heartbeat.HeartbeatIte" + + "m\032+\n\rHeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url" + + "\030\002 \001(\t\"\036\n\nClientType\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\316" + + "\002\n\020PublisherService\022e\n\007publish\0220.eventme" + + "sh.common.protocol.grpc.EventMeshMessage" + + "\032(.eventmesh.common.protocol.grpc.Respon" + + "se\022j\n\014requestReply\0220.eventmesh.common.pr" + + "otocol.grpc.EventMeshMessage\032(.eventmesh" + + ".common.protocol.grpc.Response\022g\n\tbroadc" + + "ast\0220.eventmesh.common.protocol.grpc.Eve" + + "ntMeshMessage\032(.eventmesh.common.protoco" + + "l.grpc.Response2\322\002\n\017ConsumerService\022c\n\ts" + + "ubscribe\022,.eventmesh.common.protocol.grp" + + "c.Subscription\032(.eventmesh.common.protoc" + + "ol.grpc.Response\022s\n\017subscribeStream\022,.ev" + + "entmesh.common.protocol.grpc.Subscriptio" + + "n\0320.eventmesh.common.protocol.grpc.Event" + + "MeshMessage0\001\022e\n\013unsubscribe\022,.eventmesh" + + ".common.protocol.grpc.Subscription\032(.eve" + + "ntmesh.common.protocol.grpc.Response2t\n\020" + + "HeartbeatService\022`\n\theartbeat\022).eventmes" + + "h.common.protocol.grpc.Heartbeat\032(.event" + + "mesh.common.protocol.grpc.ResponseBC\n0or" + + "g.apache.eventmesh.common.protocol.grpc." + + "protosB\rEventmeshGrpcP\001b\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -140,7 +148,13 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor, - new String[] { "Header", "ProducerGroup", "Topic", "Content", "Ttl", "UniqueId", "SeqNum", "Tag", }); + new String[] { "Header", "ProducerGroup", "Topic", "Content", "Ttl", "UniqueId", "SeqNum", "Tag", "Properties", }); + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_PropertiesEntry_descriptor = + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor.getNestedTypes().get(0); + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_PropertiesEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_PropertiesEntry_descriptor, + new String[] { "Key", "Value", }); internal_static_eventmesh_common_protocol_grpc_Response_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable = new diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto index 76e8b4b2ce..65d3595e04 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto @@ -47,6 +47,7 @@ message EventMeshMessage { string uniqueId = 6; string seqNum = 7; string tag = 8; + map properties = 9; } message Response { diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java index 50e3f002a6..7249ba3326 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java @@ -62,6 +62,10 @@ public static CloudEvent buildEvent(EventMeshMessage message) throws ProtocolHan .withExtension(ProtocolKey.UNIQUE_ID, message.getUniqueId()) .withExtension(ProtocolKey.PRODUCERGROUP, message.getProducerGroup()) .withExtension(ProtocolKey.TTL, message.getTtl()); + + for (Map.Entry entry : message.getPropertiesMap().entrySet()) { + cloudEventBuilder.withExtension(entry.getKey(), entry.getValue()); + } if (StringUtils.isNotEmpty(message.getTag())) { cloudEventBuilder = cloudEventBuilder.withExtension(ProtocolKey.TAG, message.getTag()); } @@ -88,6 +92,10 @@ public static CloudEvent buildEvent(EventMeshMessage message) throws ProtocolHan .withExtension(ProtocolKey.UNIQUE_ID, message.getUniqueId()) .withExtension(ProtocolKey.PRODUCERGROUP, message.getProducerGroup()) .withExtension(ProtocolKey.TTL, message.getTtl()); + + for (Map.Entry entry : message.getPropertiesMap().entrySet()) { + cloudEventBuilder.withExtension(entry.getKey(), entry.getValue()); + } if (StringUtils.isNotEmpty(message.getTag())) { cloudEventBuilder = cloudEventBuilder.withExtension(ProtocolKey.TAG, message.getTag()); } @@ -128,15 +136,20 @@ public static EventMeshMessageWrapper buildEventMeshMessage(CloudEvent cloudEven .setProtocolDesc(protocolDesc).setProtocolVersion(protocolVersion) .build(); - EventMeshMessage eventMeshMessage = EventMeshMessage.newBuilder() + EventMeshMessage.Builder messageBuilder = EventMeshMessage.newBuilder() .setHeader(header) .setContent(new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8)) .setProducerGroup(producerGroup) .setSeqNum(seqNum) .setUniqueId(uniqueId) .setTopic(cloudEvent.getSubject()) - .setTtl(ttl) - .build(); + .setTtl(ttl); + + for (String key : cloudEvent.getExtensionNames()) { + messageBuilder.putProperties(key, cloudEvent.getExtension(key).toString()); + } + + EventMeshMessage eventMeshMessage = messageBuilder.build(); return new EventMeshMessageWrapper(eventMeshMessage); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java index ffaf24e8ff..8b404a0a06 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshGrpcServer.java @@ -1,12 +1,12 @@ package org.apache.eventmesh.runtime.boot; +import com.google.common.util.concurrent.RateLimiter; import io.grpc.Server; import io.grpc.ServerBuilder; import org.apache.commons.lang3.RandomUtils; import org.apache.eventmesh.common.ThreadPoolFactory; import org.apache.eventmesh.runtime.configuration.EventMeshGrpcConfiguration; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; -import org.apache.eventmesh.runtime.core.protocol.grpc.interceptor.MetricsInterceptor; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.retry.GrpcRetryer; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ConsumerService; @@ -46,6 +46,8 @@ public class EventMeshGrpcServer { private List httpClientPool; + private RateLimiter msgRateLimiter; + public EventMeshGrpcServer(EventMeshGrpcConfiguration eventMeshGrpcConfiguration) { this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; } @@ -57,6 +59,8 @@ public void init() throws Exception { initHttpClientPool(); + msgRateLimiter = RateLimiter.create(eventMeshGrpcConfiguration.eventMeshMsgReqNumPerSecond); + producerManager = new ProducerManager(this); producerManager.init(); @@ -69,7 +73,6 @@ public void init() throws Exception { int serverPort = eventMeshGrpcConfiguration.grpcServerPort; server = ServerBuilder.forPort(serverPort) - .intercept(new MetricsInterceptor()) .addService(new ProducerService(this, sendMsgExecutor)) .addService(new ConsumerService(this, clientMgmtExecutor)) .addService(new HeartbeatService(this, clientMgmtExecutor)) @@ -133,6 +136,10 @@ public ThreadPoolExecutor getPushMsgExecutor() { return pushMsgExecutor; } + public RateLimiter getMsgRateLimiter() { + return msgRateLimiter; + } + public CloseableHttpClient getHttpClient() { int size = httpClientPool.size(); return httpClientPool.get(RandomUtils.nextInt(size, 2 * size) % size); @@ -140,21 +147,21 @@ public CloseableHttpClient getHttpClient() { private void initThreadPool() { BlockingQueue sendMsgThreadPoolQueue = - new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSendMsgBlockQSize); + new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSendMsgBlockQueueSize); sendMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, eventMeshGrpcConfiguration.eventMeshServerSendMsgThreadNum, sendMsgThreadPoolQueue, "eventMesh-grpc-sendMsg-%d", true); BlockingQueue subscribeMsgThreadPoolQueue = - new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgBlockQSize); + new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgBlockQueueSize); clientMgmtExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgThreadNum, eventMeshGrpcConfiguration.eventMeshServerSubscribeMsgThreadNum, subscribeMsgThreadPoolQueue, "eventMesh-grpc-clientMgmt-%d", true); BlockingQueue pushMsgThreadPoolQueue = - new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerPushMsgBlockQSize); + new LinkedBlockingQueue(eventMeshGrpcConfiguration.eventMeshServerPushMsgBlockQueueSize); pushMsgExecutor = ThreadPoolFactory.createThreadPoolExecutor(eventMeshGrpcConfiguration.eventMeshServerPushMsgThreadNum, eventMeshGrpcConfiguration.eventMeshServerPushMsgThreadNum, pushMsgThreadPoolQueue, diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java index 8b5e95a5c7..a7430867d9 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshGrpcConfiguration.java @@ -27,6 +27,8 @@ public class EventMeshGrpcConfiguration extends CommonConfiguration { public int grpcServerPort = 10205; + public int eventMeshSessionExpiredInMills = 60000; + public boolean eventMeshServerBatchMsgBatchEnabled = Boolean.TRUE; public int eventMeshServerBatchMsgThreadNum = 10; @@ -49,15 +51,15 @@ public class EventMeshGrpcConfiguration extends CommonConfiguration { public int eventMeshServerAsyncAccumulationThreshold = 1000; - public int eventMeshServerRetryBlockQSize = 10000; + public int eventMeshServerRetryBlockQueueSize = 10000; - public int eventMeshServerBatchBlockQSize = 1000; + public int eventMeshServerBatchBlockQueueSize = 1000; - public int eventMeshServerSendMsgBlockQSize = 1000; + public int eventMeshServerSendMsgBlockQueueSize = 1000; - public int eventMeshServerPushMsgBlockQSize = 1000; + public int eventMeshServerPushMsgBlockQueueSize = 1000; - public int eventMeshServerSubscribeMsgBlockQSize = 1000; + public int eventMeshServerSubscribeMsgBlockQueueSize = 1000; public int eventMeshServerBusyCheckInterval = 1000; @@ -67,7 +69,9 @@ public class EventMeshGrpcConfiguration extends CommonConfiguration { public int eventMeshBatchMsgRequestNumPerSecond = 20000; - public String eventMeshIP = IPUtils.getLocalAddress(); + public int eventMeshMsgReqNumPerSecond = 15000; + + public String eventMeshIp = IPUtils.getLocalAddress(); public EventMeshGrpcConfiguration(ConfigurationWrapper configurationWrapper) { super(configurationWrapper); @@ -79,107 +83,123 @@ public void init() { if (configurationWrapper != null) { String httpServerPortStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_GRPC_PORT); - Preconditions.checkState(StringUtils.isNotEmpty(httpServerPortStr) && StringUtils.isNumeric(httpServerPortStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_GRPC_PORT)); - grpcServerPort = Integer.valueOf(StringUtils.deleteWhitespace(httpServerPortStr)); + Preconditions.checkState(StringUtils.isNotEmpty(httpServerPortStr) && StringUtils.isNumeric(httpServerPortStr), + String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_GRPC_PORT)); + grpcServerPort = Integer.parseInt(StringUtils.deleteWhitespace(httpServerPortStr)); String eventMeshServerBatchMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_THREAD_NUM); if (StringUtils.isNotEmpty(eventMeshServerBatchMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerBatchMsgThreadNumStr)) { - eventMeshServerBatchMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchMsgThreadNumStr)); + eventMeshServerBatchMsgThreadNum = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerBatchMsgThreadNumStr)); + } + + String eventMeshTcpSessionExpiredInMillsStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_SESSION_EXPIRED_TIME); + if (StringUtils.isNotEmpty(eventMeshTcpSessionExpiredInMillsStr) && StringUtils.isNumeric(eventMeshTcpSessionExpiredInMillsStr)) { + eventMeshSessionExpiredInMills = Integer.parseInt(eventMeshTcpSessionExpiredInMillsStr); } String eventMeshServerBatchMsgReqNumPerSecondStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_REQ_NUM_PER_SECOND); - if (StringUtils.isNotEmpty(eventMeshServerBatchMsgReqNumPerSecondStr) && StringUtils.isNumeric(eventMeshServerBatchMsgReqNumPerSecondStr)) { - eventMeshBatchMsgRequestNumPerSecond = Integer.valueOf(eventMeshServerBatchMsgReqNumPerSecondStr); + if (StringUtils.isNotEmpty(eventMeshServerBatchMsgReqNumPerSecondStr) + && StringUtils.isNumeric(eventMeshServerBatchMsgReqNumPerSecondStr)) { + eventMeshBatchMsgRequestNumPerSecond = Integer.parseInt(eventMeshServerBatchMsgReqNumPerSecondStr); } String eventMeshServerBatchMsgBatchEnableStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_BATCHMSG_BATCH_ENABLED); if (StringUtils.isNotBlank(eventMeshServerBatchMsgBatchEnableStr)) { - eventMeshServerBatchMsgBatchEnabled = Boolean.valueOf(eventMeshServerBatchMsgBatchEnableStr); + eventMeshServerBatchMsgBatchEnabled = Boolean.parseBoolean(eventMeshServerBatchMsgBatchEnableStr); } String eventMeshServerAsyncAccumulationThresholdStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ASYNC_ACCUMULATION_THRESHOLD); - if (StringUtils.isNotEmpty(eventMeshServerAsyncAccumulationThresholdStr) && StringUtils.isNumeric(eventMeshServerAsyncAccumulationThresholdStr)) { - eventMeshServerAsyncAccumulationThreshold = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAsyncAccumulationThresholdStr)); + if (StringUtils.isNotEmpty(eventMeshServerAsyncAccumulationThresholdStr) + && StringUtils.isNumeric(eventMeshServerAsyncAccumulationThresholdStr)) { + eventMeshServerAsyncAccumulationThreshold = Integer.parseInt( + StringUtils.deleteWhitespace(eventMeshServerAsyncAccumulationThresholdStr)); } String eventMeshServerSendMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SENDMSG_THREAD_NUM); if (StringUtils.isNotEmpty(eventMeshServerSendMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerSendMsgThreadNumStr)) { - eventMeshServerSendMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgThreadNumStr)); + eventMeshServerSendMsgThreadNum = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerSendMsgThreadNumStr)); } String eventMeshServerReplyMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REPLYMSG_THREAD_NUM); if (StringUtils.isNotEmpty(eventMeshServerReplyMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerReplyMsgThreadNumStr)) { - eventMeshServerReplyMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerReplyMsgThreadNumStr)); + eventMeshServerReplyMsgThreadNum = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerReplyMsgThreadNumStr)); } String eventMeshServerPushMsgThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_PUSHMSG_THREAD_NUM); if (StringUtils.isNotEmpty(eventMeshServerPushMsgThreadNumStr) && StringUtils.isNumeric(eventMeshServerPushMsgThreadNumStr)) { - eventMeshServerPushMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgThreadNumStr)); + eventMeshServerPushMsgThreadNum = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerPushMsgThreadNumStr)); } String eventMeshServerRegistryThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REGISTRY_THREAD_NUM); if (StringUtils.isNotEmpty(eventMeshServerRegistryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRegistryThreadNumStr)) { - eventMeshServerRegistryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRegistryThreadNumStr)); + eventMeshServerRegistryThreadNum = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerRegistryThreadNumStr)); } String eventMeshServerClientManageThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_CLIENTMANAGE_THREAD_NUM); if (StringUtils.isNotEmpty(eventMeshServerClientManageThreadNumStr) && StringUtils.isNumeric(eventMeshServerClientManageThreadNumStr)) { - eventMeshServerSubscribeMsgThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageThreadNumStr)); + eventMeshServerSubscribeMsgThreadNum = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerClientManageThreadNumStr)); } String eventMeshServerPullRegistryIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_PULL_REGISTRY_INTERVAL); if (StringUtils.isNotEmpty(eventMeshServerPullRegistryIntervalStr) && StringUtils.isNumeric(eventMeshServerPullRegistryIntervalStr)) { - eventMeshServerPullRegistryInterval = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPullRegistryIntervalStr)); + eventMeshServerPullRegistryInterval = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerPullRegistryIntervalStr)); } String eventMeshServerAdminThreadNumStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ADMIN_THREAD_NUM); if (StringUtils.isNotEmpty(eventMeshServerAdminThreadNumStr) && StringUtils.isNumeric(eventMeshServerAdminThreadNumStr)) { - eventMeshServerAdminThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerAdminThreadNumStr)); + eventMeshServerAdminThreadNum = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerAdminThreadNumStr)); } - String eventMeshServerRetryBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerRetryBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerRetryBlockQSizeStr)) { - eventMeshServerRetryBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryBlockQSizeStr)); + String eventMeshServerRetryBlockQueueSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerRetryBlockQueueSizeStr) && StringUtils.isNumeric(eventMeshServerRetryBlockQueueSizeStr)) { + eventMeshServerRetryBlockQueueSize = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerRetryBlockQueueSizeStr)); } - String eventMeshServerBatchBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_BATCHMSG_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerBatchBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerBatchBlockQSizeStr)) { - eventMeshServerBatchBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBatchBlockQSizeStr)); + String eventMeshServerBatchBlockQueueSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_BATCHMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerBatchBlockQueueSizeStr) && StringUtils.isNumeric(eventMeshServerBatchBlockQueueSizeStr)) { + eventMeshServerBatchBlockQueueSize = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerBatchBlockQueueSizeStr)); } - String eventMeshServerSendMsgBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_SENDMSG_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerSendMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerSendMsgBlockQSizeStr)) { - eventMeshServerSendMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerSendMsgBlockQSizeStr)); + String eventMeshServerSendMsgBlockQueueSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_SENDMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerSendMsgBlockQueueSizeStr) && StringUtils.isNumeric(eventMeshServerSendMsgBlockQueueSizeStr)) { + eventMeshServerSendMsgBlockQueueSize = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerSendMsgBlockQueueSizeStr)); } - String eventMeshServerPushMsgBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_PUSHMSG_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerPushMsgBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerPushMsgBlockQSizeStr)) { - eventMeshServerPushMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerPushMsgBlockQSizeStr)); + String eventMeshServerPushMsgBlockQueueSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_PUSHMSG_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerPushMsgBlockQueueSizeStr) && StringUtils.isNumeric(eventMeshServerPushMsgBlockQueueSizeStr)) { + eventMeshServerPushMsgBlockQueueSize = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerPushMsgBlockQueueSizeStr)); } - String eventMeshServerClientManageBlockQSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_CLIENTM_BLOCKQ_SIZE); - if (StringUtils.isNotEmpty(eventMeshServerClientManageBlockQSizeStr) && StringUtils.isNumeric(eventMeshServerClientManageBlockQSizeStr)) { - eventMeshServerSubscribeMsgBlockQSize = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerClientManageBlockQSizeStr)); + String eventMeshServerClientManageBlockQueueSizeStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_CLIENTM_BLOCKQ_SIZE); + if (StringUtils.isNotEmpty(eventMeshServerClientManageBlockQueueSizeStr) + && StringUtils.isNumeric(eventMeshServerClientManageBlockQueueSizeStr)) { + eventMeshServerSubscribeMsgBlockQueueSize = Integer.parseInt( + StringUtils.deleteWhitespace(eventMeshServerClientManageBlockQueueSizeStr)); } String eventMeshServerBusyCheckIntervalStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_BUSY_CHECK_INTERVAL); if (StringUtils.isNotEmpty(eventMeshServerBusyCheckIntervalStr) && StringUtils.isNumeric(eventMeshServerBusyCheckIntervalStr)) { - eventMeshServerBusyCheckInterval = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerBusyCheckIntervalStr)); + eventMeshServerBusyCheckInterval = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerBusyCheckIntervalStr)); } String eventMeshServerConsumerEnabledStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_CONSUMER_ENABLED); if (StringUtils.isNotEmpty(eventMeshServerConsumerEnabledStr)) { - eventMeshServerConsumerEnabled = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerConsumerEnabledStr)); + eventMeshServerConsumerEnabled = Boolean.parseBoolean(StringUtils.deleteWhitespace(eventMeshServerConsumerEnabledStr)); } String eventMeshServerRetryThreadNumStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_RETRY_THREAD_NUM); if (StringUtils.isNotEmpty(eventMeshServerRetryThreadNumStr) && StringUtils.isNumeric(eventMeshServerRetryThreadNumStr)) { - eventMeshServerRetryThreadNum = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshServerRetryThreadNumStr)); + eventMeshServerRetryThreadNum = Integer.parseInt(StringUtils.deleteWhitespace(eventMeshServerRetryThreadNumStr)); } String eventMeshServerUseTlsStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_TLS_ENABLED); if (StringUtils.isNotEmpty(eventMeshServerUseTlsStr)) { - eventMeshServerUseTls = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerUseTlsStr)); + eventMeshServerUseTls = Boolean.parseBoolean(StringUtils.deleteWhitespace(eventMeshServerUseTlsStr)); + } + + String eventMeshMsgReqNumPerSecondStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_SERVER_MSG_REQ_NUM_PER_SECOND); + if (StringUtils.isNotEmpty(eventMeshMsgReqNumPerSecondStr) && StringUtils.isNumeric(eventMeshMsgReqNumPerSecondStr)) { + eventMeshMsgReqNumPerSecond = Integer.parseInt(eventMeshMsgReqNumPerSecondStr); } } } @@ -188,6 +208,8 @@ static class ConfKeys { public static String KEYS_EVENTMESH_SERVER_GRPC_PORT = "eventMesh.server.grpc.port"; + public static String KEYS_EVENTMESH_SERVER_SESSION_EXPIRED_TIME = "eventMesh.server.session.expiredInMills"; + public static String KEYS_EVENTMESH_BATCHMSG_THREAD_NUM = "eventMesh.server.batchmsg.threads.num"; public static String KEYS_EVENTMESH_BATCHMSG_REQ_NUM_PER_SECOND = "eventMesh.server.batchmsg.reqNumPerSecond"; @@ -227,5 +249,7 @@ static class ConfKeys { public static String KEY_EVENTMESH_CONSUMER_ENABLED = "eventMesh.server.consumer.enabled"; public static String KEY_EVENTMESH_TLS_ENABLED = "eventMesh.server.useTls.enabled"; + + public static String KEY_EVENTMESH_SERVER_MSG_REQ_NUM_PER_SECOND = "eventMesh.server.http.msgReqnumPerSecond"; } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java index d71759e9b1..980d5ba4c1 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java @@ -30,8 +30,6 @@ public class ConsumerManager { private final EventMeshGrpcServer eventMeshGrpcServer; - private static final int DEFAULT_UPDATE_TIME = 3 * 30 * 1000; - private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); // key: ConsumerGroup @@ -180,42 +178,45 @@ public synchronized void restartEventMeshConsumer(String consumerGroup) throws E } private void startClientCheck() { - scheduledExecutorService.scheduleAtFixedRate(() -> { - logger.info("grpc client info check"); - List clientList = new LinkedList<>(); - for (List clients : clientTable.values()) { - clientList.addAll(clients); - } - if (logger.isDebugEnabled()) { - logger.debug("total number of ConsumerGroupClients: {}", clientList.size()); - } + int clientTimeout = eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshSessionExpiredInMills; + if (clientTimeout > 0) { + scheduledExecutorService.scheduleAtFixedRate(() -> { + logger.info("grpc client info check"); + List clientList = new LinkedList<>(); + for (List clients : clientTable.values()) { + clientList.addAll(clients); + } + if (logger.isDebugEnabled()) { + logger.debug("total number of ConsumerGroupClients: {}", clientList.size()); + } - if (clientList.isEmpty()) { - return; - } - Set consumerGroupRestart = new HashSet<>(); - for (ConsumerGroupClient client : clientList) { - if (System.currentTimeMillis() - client.getLastUpTime().getTime() > DEFAULT_UPDATE_TIME) { - logger.warn("client {} lastUpdate time {} over three heartbeat cycles. Removing it", - JsonUtils.serialize(client), client.getLastUpTime()); - String consumerGroup = client.getConsumerGroup(); - EventMeshConsumer consumer = getEventMeshConsumer(consumerGroup); - - deregisterClient(client); - if (consumer.deregisterClient(client)) { - consumerGroupRestart.add(consumerGroup); + if (clientList.isEmpty()) { + return; + } + Set consumerGroupRestart = new HashSet<>(); + for (ConsumerGroupClient client : clientList) { + if (System.currentTimeMillis() - client.getLastUpTime().getTime() > clientTimeout) { + logger.warn("client {} lastUpdate time {} over three heartbeat cycles. Removing it", + JsonUtils.serialize(client), client.getLastUpTime()); + String consumerGroup = client.getConsumerGroup(); + EventMeshConsumer consumer = getEventMeshConsumer(consumerGroup); + + deregisterClient(client); + if (consumer.deregisterClient(client)) { + consumerGroupRestart.add(consumerGroup); + } } } - } - // restart EventMeshConsumer for the group - for (String consumerGroup : consumerGroupRestart) { - try { - restartEventMeshConsumer(consumerGroup); - } catch (Exception e) { - logger.error("Error in restarting EventMeshConsumer [{}]", consumerGroup, e); + // restart EventMeshConsumer for the group + for (String consumerGroup : consumerGroupRestart) { + try { + restartEventMeshConsumer(consumerGroup); + } catch (Exception e) { + logger.error("Error in restarting EventMeshConsumer [{}]", consumerGroup, e); + } } - } - }, 10000, 10000, TimeUnit.MILLISECONDS); + }, 10000, 10000, TimeUnit.MILLISECONDS); + } } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java deleted file mode 100644 index 98706a0f51..0000000000 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/interceptor/MetricsInterceptor.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.apache.eventmesh.runtime.core.protocol.grpc.interceptor; - -import io.grpc.Grpc; -import io.grpc.Metadata; -import io.grpc.ServerCall; -import io.grpc.ServerCallHandler; -import io.grpc.ServerInterceptor; -import org.apache.eventmesh.common.utils.IPUtils; -import org.apache.eventmesh.runtime.constants.EventMeshConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MetricsInterceptor implements ServerInterceptor { - - private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - - @Override - public ServerCall.Listener interceptCall( - ServerCall call, Metadata headers, ServerCallHandler next) { - logger.info("cmd={}|{}|client2eventMesh|from={}|to={}", call.getMethodDescriptor().getFullMethodName(), - EventMeshConstants.PROTOCOL_GRPC, call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR), IPUtils.getLocalAddress()); - return next.startCall(call, headers); - } -} \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java index 428a56d560..c2b4252a04 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/HeartbeatProcessor.java @@ -1,15 +1,21 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.processor; +import org.apache.eventmesh.api.exception.AclException; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat; import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.ClientType; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.consumergroup.ConsumerGroupClient; import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.apache.eventmesh.runtime.util.RemotingHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; @@ -17,6 +23,8 @@ public class HeartbeatProcessor { private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private final Logger aclLogger = LoggerFactory.getLogger("acl"); + private final EventMeshGrpcServer eventMeshGrpcServer; public HeartbeatProcessor(EventMeshGrpcServer eventMeshGrpcServer) { @@ -36,6 +44,14 @@ public void process(Heartbeat heartbeat, EventEmitter emitter) throws return; } + try { + doAclCheck(heartbeat); + } catch (AclException e) { + aclLogger.warn("CLIENT HAS NO PERMISSION, HeartbeatProcessor failed", e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_ACL_ERR, e.getMessage(), emitter); + return; + } + // only handle heartbeat for consumers ClientType clientType = heartbeat.getClientType(); if (!ClientType.SUB.equals(clientType)) { @@ -64,4 +80,18 @@ public void process(Heartbeat heartbeat, EventEmitter emitter) throws ServiceUtils.sendResp(StatusCode.SUCCESS, "heartbeat success", emitter); } + + private void doAclCheck(Heartbeat heartbeat) throws AclException { + RequestHeader header = heartbeat.getHeader(); + if (eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshServerSecurityEnable) { + String remoteAdd = header.getIp(); + String user = header.getUsername(); + String pass = header.getPassword(); + String sys = header.getSys(); + int requestCode = Integer.valueOf(RequestCode.HEARTBEAT.getRequestCode()); + for (Heartbeat.HeartbeatItem item : heartbeat.getHeartbeatItemsList()) { + Acl.doAclCheckInHttpHeartbeat(remoteAdd, user, pass, sys, item.getTopic(), requestCode); + } + } + } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java index 037459d994..7d49c57949 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SendAsyncMessageProcessor.java @@ -20,6 +20,7 @@ import io.cloudevents.CloudEvent; import org.apache.eventmesh.api.SendCallback; import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.AclException; import org.apache.eventmesh.api.exception.OnExceptionContext; import org.apache.eventmesh.common.protocol.ProtocolTransportObject; import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; @@ -27,9 +28,16 @@ import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.http.body.message.SendMessageResponseBody; +import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.utils.IPUtils; import org.apache.eventmesh.protocol.api.ProtocolAdaptor; import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; +import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; @@ -37,13 +45,18 @@ import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.apache.eventmesh.runtime.util.RemotingHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.TimeUnit; + public class SendAsyncMessageProcessor { private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private final Logger aclLogger = LoggerFactory.getLogger("acl"); + private final EventMeshGrpcServer eventMeshGrpcServer; public SendAsyncMessageProcessor(EventMeshGrpcServer eventMeshGrpcServer) { @@ -63,15 +76,31 @@ public void process(EventMeshMessage message, EventEmitter emitter) th return; } - String protocolType = requestHeader.getProtocolType(); - ProtocolAdaptor grpcCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); - CloudEvent cloudEvent = grpcCommandProtocolAdaptor.toCloudEvent(new EventMeshMessageWrapper(message)); - String seqNum = message.getSeqNum(); String uniqueId = message.getUniqueId(); String topic = message.getTopic(); String producerGroup = message.getProducerGroup(); + try { + doAclCheck(message); + } catch (Exception e) { + aclLogger.warn("CLIENT HAS NO PERMISSION,SendAsyncMessageProcessor send failed", e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_ACL_ERR, e.getMessage(), emitter); + return; + } + + // control flow rate limit + if (!eventMeshGrpcServer.getMsgRateLimiter() + .tryAcquire(EventMeshConstants.DEFAULT_FASTFAIL_TIMEOUT_IN_MILLISECONDS, TimeUnit.MILLISECONDS)) { + logger.error("Send message speed over limit."); + ServiceUtils.sendResp(StatusCode.EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR, emitter); + return; + } + + String protocolType = requestHeader.getProtocolType(); + ProtocolAdaptor grpcCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + CloudEvent cloudEvent = grpcCommandProtocolAdaptor.toCloudEvent(new EventMeshMessageWrapper(message)); + ProducerManager producerManager = eventMeshGrpcServer.getProducerManager(); EventMeshProducer eventMeshProducer = producerManager.getEventMeshProducer(producerGroup); @@ -96,6 +125,17 @@ public void onException(OnExceptionContext context) { endTime - startTime, topic, seqNum, uniqueId, context.getException()); } }); + } + private void doAclCheck(EventMeshMessage message) throws AclException { + RequestHeader requestHeader = message.getHeader(); + if (eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshServerSecurityEnable) { + String remoteAdd = requestHeader.getIp(); + String user = requestHeader.getUsername(); + String pass = requestHeader.getPassword(); + String subsystem = requestHeader.getSys(); + String topic = message.getTopic(); + Acl.doAclCheckInHttpSend(remoteAdd, user, pass, subsystem, topic, RequestCode.MSG_SEND_ASYNC.getRequestCode()); + } } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java index 07eb5ca259..52a9d92ae9 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeProcessor.java @@ -1,9 +1,12 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.processor; +import org.apache.eventmesh.api.exception.AclException; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; @@ -22,6 +25,8 @@ public class SubscribeProcessor { private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private final Logger aclLogger = LoggerFactory.getLogger("acl"); + private final EventMeshGrpcServer eventMeshGrpcServer; private final GrpcType grpcType = GrpcType.WEBHOOK; @@ -43,6 +48,14 @@ public void process(Subscription subscription, EventEmitter emitter) t return; } + try { + doAclCheck(subscription); + } catch (AclException e) { + aclLogger.warn("CLIENT HAS NO PERMISSION to Subscribe. failed", e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_ACL_ERR, e.getMessage(), emitter); + return; + } + ConsumerManager consumerManager = eventMeshGrpcServer.getConsumerManager(); String consumerGroup = subscription.getConsumerGroup(); @@ -93,4 +106,18 @@ public void process(Subscription subscription, EventEmitter emitter) t ServiceUtils.sendResp(StatusCode.SUCCESS, "subscribe success", emitter); } + + private void doAclCheck(Subscription subscription) throws AclException { + RequestHeader header = subscription.getHeader(); + if (eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshServerSecurityEnable) { + String remoteAdd = header.getIp(); + String user = header.getUsername(); + String pass = header.getPassword(); + String subsystem = header.getSys(); + for (Subscription.SubscriptionItem item : subscription.getSubscriptionItemsList()) { + Acl.doAclCheckInHttpReceive(remoteAdd, user, pass, subsystem, item.getTopic(), + RequestCode.SUBSCRIBE.getRequestCode()); + } + } + } } \ No newline at end of file diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java index 3e0a0869f8..71f56d2799 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java @@ -1,10 +1,13 @@ package org.apache.eventmesh.runtime.core.protocol.grpc.processor; +import org.apache.eventmesh.api.exception.AclException; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.runtime.acl.Acl; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.ConsumerManager; import org.apache.eventmesh.runtime.core.protocol.grpc.consumer.EventMeshConsumer; @@ -25,6 +28,8 @@ public class SubscribeStreamProcessor { private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private final Logger aclLogger = LoggerFactory.getLogger("acl"); + private final EventMeshGrpcServer eventMeshGrpcServer; private final GrpcType grpcType = GrpcType.STREAM; @@ -47,6 +52,14 @@ public void process(Subscription subscription, EventEmitter em return; } + try { + doAclCheck(subscription); + } catch (AclException e) { + aclLogger.warn("CLIENT HAS NO PERMISSION to Subscribe. failed", e); + sendResp(subscription, StatusCode.EVENTMESH_ACL_ERR, e.getMessage(), emitter); + return; + } + ConsumerManager consumerManager = eventMeshGrpcServer.getConsumerManager(); String consumerGroup = subscription.getConsumerGroup(); @@ -94,22 +107,28 @@ public void process(Subscription subscription, EventEmitter em logger.warn("EventMesh consumer [{}] didn't restart.", consumerGroup); } - // send back subscribe success response + sendResp(subscription, StatusCode.SUCCESS, "subscribe success", emitter); + } + + private void sendResp(Subscription subscription, StatusCode code, EventEmitter emitter) { Map resp = new HashMap<>(); - resp.put("respCode", StatusCode.SUCCESS.getRetCode()); - resp.put("respMsg", "subscribe success"); + resp.put("respCode", code.getRetCode()); + resp.put("respMsg", code.getErrMsg()); + RequestHeader header = subscription.getHeader(); EventMeshMessage eventMeshMessage = EventMeshMessage.newBuilder() .setHeader(header) .setContent(JsonUtils.serialize(resp)) .build(); + emitter.onNext(eventMeshMessage); + emitter.onCompleted(); } - private void sendResp(Subscription subscription, StatusCode code, EventEmitter emitter) { + private void sendResp(Subscription subscription, StatusCode code, String message, EventEmitter emitter) { Map resp = new HashMap<>(); resp.put("respCode", code.getRetCode()); - resp.put("respMsg", code.getErrMsg()); + resp.put("respMsg", code.getErrMsg() + " " + message); RequestHeader header = subscription.getHeader(); EventMeshMessage eventMeshMessage = EventMeshMessage.newBuilder() @@ -120,4 +139,18 @@ private void sendResp(Subscription subscription, StatusCode code, EventEmitter= grpcConfiguration.eventMeshServerRetryBlockQSize) { + if (failed.size() >= grpcConfiguration.eventMeshServerRetryBlockQueueSize) { retryLogger.error("[RETRY-QUEUE] is full!"); return; } @@ -60,7 +60,7 @@ public void init() { grpcConfiguration.eventMeshServerRetryThreadNum, 60000, TimeUnit.MILLISECONDS, - new ArrayBlockingQueue<>(grpcConfiguration.eventMeshServerRetryBlockQSize), + new ArrayBlockingQueue<>(grpcConfiguration.eventMeshServerRetryBlockQueueSize), new ThreadFactory() { private AtomicInteger count = new AtomicInteger(); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java index c249836a5c..fe987aabcc 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ConsumerService.java @@ -7,11 +7,15 @@ import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.common.utils.IPUtils; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SubscribeProcessor; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SubscribeStreamProcessor; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.UnsubscribeProcessor; +import org.apache.eventmesh.runtime.util.RemotingHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +38,10 @@ public ConsumerService(EventMeshGrpcServer eventMeshGrpcServer, } public void subscribe(Subscription request, StreamObserver responseObserver) { + logger.info("cmd={}|{}|client2eventMesh|from={}|to={}", + "subscribe", EventMeshConstants.PROTOCOL_GRPC, + request.getHeader().getIp(), eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp); + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { SubscribeProcessor subscribeProcessor = new SubscribeProcessor(eventMeshGrpcServer); @@ -48,6 +56,10 @@ public void subscribe(Subscription request, StreamObserver responseObs } public void subscribeStream(Subscription request, StreamObserver responseObserver) { + logger.info("cmd={}|{}|client2eventMesh|from={}|to={}", + "subscribeStream", EventMeshConstants.PROTOCOL_GRPC, + request.getHeader().getIp(), eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp); + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { SubscribeStreamProcessor streamProcessor = new SubscribeStreamProcessor(eventMeshGrpcServer); @@ -74,6 +86,10 @@ public void subscribeStream(Subscription request, StreamObserver responseObserver) { + logger.info("cmd={}|{}|client2eventMesh|from={}|to={}", + "unsubscribe", EventMeshConstants.PROTOCOL_GRPC, + request.getHeader().getIp(), eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp); + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { UnsubscribeProcessor unsubscribeProcessor = new UnsubscribeProcessor(eventMeshGrpcServer); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java index ec54fe1fb6..4f7c83846f 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/HeartbeatService.java @@ -6,6 +6,7 @@ import org.apache.eventmesh.common.protocol.grpc.protos.HeartbeatServiceGrpc; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.HeartbeatProcessor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,6 +27,10 @@ public HeartbeatService(EventMeshGrpcServer eventMeshGrpcServer, } public void heartbeat(Heartbeat request, StreamObserver responseObserver) { + logger.info("cmd={}|{}|client2eventMesh|from={}|to={}", + "heartbeat", EventMeshConstants.PROTOCOL_GRPC, + request.getHeader().getIp(), eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp); + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { HeartbeatProcessor heartbeatProcessor = new HeartbeatProcessor(eventMeshGrpcServer); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java index af35f5664e..d6809e3d4f 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java @@ -6,6 +6,7 @@ import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SendAsyncMessageProcessor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,11 +15,13 @@ public class ProducerService extends PublisherServiceGrpc.PublisherServiceImplBase { - private Logger logger = LoggerFactory.getLogger(ProducerService.class); + private final Logger logger = LoggerFactory.getLogger(ProducerService.class); - private EventMeshGrpcServer eventMeshGrpcServer; + private final Logger cmdLogger = LoggerFactory.getLogger("cmd"); - private ThreadPoolExecutor threadPoolExecutor; + private final EventMeshGrpcServer eventMeshGrpcServer; + + private final ThreadPoolExecutor threadPoolExecutor; public ProducerService(EventMeshGrpcServer eventMeshGrpcServer, ThreadPoolExecutor threadPoolExecutor) { @@ -27,6 +30,10 @@ public ProducerService(EventMeshGrpcServer eventMeshGrpcServer, } public void publish(EventMeshMessage request, StreamObserver responseObserver) { + cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", "AsyncPublish", + EventMeshConstants.PROTOCOL_GRPC, request.getHeader().getIp(), + eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp); + EventEmitter emitter = new EventEmitter<>(responseObserver); threadPoolExecutor.submit(() -> { SendAsyncMessageProcessor sendAsyncMessageProcessor = new SendAsyncMessageProcessor(eventMeshGrpcServer); diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java index 7932c8d9bc..0af2e1229a 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java @@ -170,7 +170,7 @@ private void heartBeat() { } catch (Exception e) { logger.error("Error in sending out heartbeat. error {}", e.getMessage()); } - }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS); + }, 10000, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS); logger.info("Grpc Consumer Heartbeat started."); } From 30d485f1759a69a171867dc87d0b2ee2948ac4cc Mon Sep 17 00:00:00 2001 From: j00441484 Date: Thu, 30 Dec 2021 17:06:48 -0500 Subject: [PATCH 16/21] Fix bugs in consumer API --- .../eventmesh/grpc/sub/AsyncSubscribe.java | 8 ++------ .../grpc/processor/SubscribeStreamProcessor.java | 14 +++++++++----- .../protocol/grpc/push/AbstractPushRequest.java | 16 ++++++++++++++-- .../protocol/grpc/push/StreamPushRequest.java | 14 ++++++++------ .../protocol/grpc/push/WebhookPushRequest.java | 12 +++++++++--- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java index 2556a1df05..addc095c6a 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java @@ -50,12 +50,8 @@ public static void main(String[] args) { eventMeshGrpcConsumer.subscribeStream(subscription); - /* try { - Thread.sleep(12000); - } catch (Exception e) { - //ignore - } - eventMeshGrpcConsumer.unsubscribe(subscription);*/ + + //eventMeshGrpcConsumer.unsubscribe(subscription); } @Override diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java index 71f56d2799..35c855d336 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/SubscribeStreamProcessor.java @@ -43,12 +43,12 @@ public void process(Subscription subscription, EventEmitter em RequestHeader header = subscription.getHeader(); if (!ServiceUtils.validateHeader(header)) { - sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, emitter); + sendRespAndComplete(subscription, StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, emitter); return; } if (!ServiceUtils.validateSubscription(grpcType, subscription)) { - sendResp(subscription, StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); + sendRespAndComplete(subscription, StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); return; } @@ -56,7 +56,7 @@ public void process(Subscription subscription, EventEmitter em doAclCheck(subscription); } catch (AclException e) { aclLogger.warn("CLIENT HAS NO PERMISSION to Subscribe. failed", e); - sendResp(subscription, StatusCode.EVENTMESH_ACL_ERR, e.getMessage(), emitter); + sendRespAndComplete(subscription, StatusCode.EVENTMESH_ACL_ERR, e.getMessage(), emitter); return; } @@ -110,7 +110,7 @@ public void process(Subscription subscription, EventEmitter em sendResp(subscription, StatusCode.SUCCESS, "subscribe success", emitter); } - private void sendResp(Subscription subscription, StatusCode code, EventEmitter emitter) { + private void sendRespAndComplete(Subscription subscription, StatusCode code, EventEmitter emitter) { Map resp = new HashMap<>(); resp.put("respCode", code.getRetCode()); resp.put("respMsg", code.getErrMsg()); @@ -125,6 +125,11 @@ private void sendResp(Subscription subscription, StatusCode code, EventEmitter emitter) { + sendResp(subscription, code, message, emitter); + emitter.onCompleted(); + } + private void sendResp(Subscription subscription, StatusCode code, String message, EventEmitter emitter) { Map resp = new HashMap<>(); resp.put("respCode", code.getRetCode()); @@ -137,7 +142,6 @@ private void sendResp(Subscription subscription, StatusCode code, String message .build(); emitter.onNext(eventMeshMessage); - emitter.onCompleted(); } private void doAclCheck(Subscription subscription) throws AclException { diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java index 23bae102c5..d280280fb5 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java @@ -61,7 +61,7 @@ public abstract class AbstractPushRequest extends RetryContext { protected Map> waitingRequests; protected HandleMsgContext handleMsgContext; - protected CloudEvent event; + // protected CloudEvent event; protected EventMeshMessage eventMeshMessage; private final AtomicBoolean complete = new AtomicBoolean(Boolean.FALSE); @@ -73,7 +73,7 @@ public AbstractPushRequest(HandleMsgContext handleMsgContext, Map protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + return protocolAdaptor.toCloudEvent(new EventMeshMessageWrapper(eventMeshMessage)); + } catch (Exception e) { + logger.error("Error in getting CloudEvent from EventMeshMessage", e); + return null; + } + } + @Override public boolean retry() { tryPushRequest(); @@ -114,6 +125,7 @@ protected boolean isComplete() { private void finish() { AbstractContext context = handleMsgContext.getContext(); SubscriptionMode subscriptionMode = handleMsgContext.getSubscriptionMode(); + CloudEvent event = getCloudEvent(eventMeshMessage); if (eventMeshConsumer != null && context != null && event != null) { try { eventMeshConsumer.updateOffset(subscriptionMode, Collections.singletonList(event), context); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java index 225f4af248..c5e67f4808 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/StreamPushRequest.java @@ -46,10 +46,12 @@ public void tryPushRequest() { } this.lastPushTime = System.currentTimeMillis(); - eventMeshMessage.getPropertiesMap().put(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, - String.valueOf(lastPushTime)); + eventMeshMessage = EventMeshMessage.newBuilder(eventMeshMessage) + .putProperties(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, String.valueOf(lastPushTime)) + .build(); try { long cost = System.currentTimeMillis() - lastPushTime; + // catch the error and retry, don't use eventEmitter.onNext() to hide the error eventEmitter.getEmitter().onNext(eventMeshMessage); messageLogger.info( "message|eventMesh2client|emitter|topic={}|bizSeqNo={}" @@ -58,10 +60,10 @@ public void tryPushRequest() { complete(); } catch (Throwable t) { long cost = System.currentTimeMillis() - lastPushTime; - messageLogger.info( - "message|eventMesh2client|exception|emitter|topic={}|bizSeqNo={}" - + "|uniqueId={}|cost={}", eventMeshMessage.getTopic(), - eventMeshMessage.getSeqNum(), eventMeshMessage.getUniqueId(), cost); + messageLogger.error( + "message|eventMesh2client|exception={} |emitter|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", t.getMessage(), eventMeshMessage.getTopic(), + eventMeshMessage.getSeqNum(), eventMeshMessage.getUniqueId(), cost, t); delayRetry(); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java index 9e0d6a0c96..46d22b0fd9 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java @@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; import org.apache.eventmesh.common.protocol.http.common.ClientRetCode; import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; @@ -112,8 +113,9 @@ public void tryPushRequest() { body.add(new BasicNameValuePair(PushMessageRequestBody.EXTFIELDS, JsonUtils.serialize(eventMeshMessage.getPropertiesMap()))); - eventMeshMessage.getPropertiesMap().put(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, - String.valueOf(lastPushTime)); + eventMeshMessage = EventMeshMessage.newBuilder(eventMeshMessage) + .putProperties(EventMeshConstants.REQ_EVENTMESH2C_TIMESTAMP, String.valueOf(lastPushTime)) + .build(); builder.setEntity(new UrlEncodedFormEntity(body, StandardCharsets.UTF_8)); @@ -131,7 +133,11 @@ public void tryPushRequest() { selectedPushUrl, eventMeshMessage.getTopic(), eventMeshMessage.getSeqNum(), eventMeshMessage.getUniqueId()); } catch (IOException e) { - messageLogger.error("push2client err", e); + long cost = System.currentTimeMillis() - lastPushTime; + messageLogger.error( + "message|eventMesh2client|exception={} |emitter|topic={}|bizSeqNo={}" + + "|uniqueId={}|cost={}", e.getMessage(), eventMeshMessage.getTopic(), + eventMeshMessage.getSeqNum(), eventMeshMessage.getUniqueId(), cost, e); removeWaitingMap(this); delayRetry(); } From 0be7fd046e61bd0759064b58a8eb3e18a2b00e54 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Fri, 31 Dec 2021 15:18:05 -0500 Subject: [PATCH 17/21] GRPC RequestReply API --- .../grpc/pub/RequestReplyInstance.java | 77 ++++++++++ .../RequestReplyMessageProcessor.java | 137 ++++++++++++++++++ .../grpc/producer/EventMeshProducer.java | 9 -- .../grpc/service/ProducerService.java | 20 +++ .../protocol/grpc/service/ServiceUtils.java | 5 +- .../client/grpc/EventMeshGrpcProducer.java | 18 +++ .../config/EventMeshGrpcClientConfig.java | 10 +- 7 files changed, 261 insertions(+), 15 deletions(-) create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/RequestReplyInstance.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/RequestReplyMessageProcessor.java diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/RequestReplyInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/RequestReplyInstance.java new file mode 100644 index 0000000000..2e964527ef --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/RequestReplyInstance.java @@ -0,0 +1,77 @@ +/* + * 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.eventmesh.grpc.pub; + +import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.util.Utils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +@Slf4j +public class RequestReplyInstance { + + // This messageSize is also used in SubService.java (Subscriber) + public static int messageSize = 5; + + public static void main(String[] args) throws Exception { + + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + + final String topic = "TEST-TOPIC-GRPC-RR"; + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .producerGroup("EventMeshTest-producerGroup") + .env("env").idc("idc") + .sys("1234").build(); + + EventMeshGrpcProducer eventMeshGrpcProducer = new EventMeshGrpcProducer(eventMeshClientConfig); + + eventMeshGrpcProducer.init(); + + Map content = new HashMap<>(); + content.put("content", "testRequestReplyMessage"); + + for (int i = 0; i < messageSize; i++) { + EventMeshMessage message = EventMeshMessage.newBuilder() + .setContent(JsonUtils.serialize(content)) + .setTopic(topic) + .setUniqueId(RandomStringUtils.generateNum(30)) + .setSeqNum(RandomStringUtils.generateNum(30)) + .setTtl(String.valueOf(4 * 1000)) + .build(); + + eventMeshGrpcProducer.requestReply(message, 10000); + Thread.sleep(1000); + } + Thread.sleep(30000); + try (EventMeshGrpcProducer ignore = eventMeshGrpcProducer) { + // ignore + } + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/RequestReplyMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/RequestReplyMessageProcessor.java new file mode 100644 index 0000000000..6272f79dde --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/RequestReplyMessageProcessor.java @@ -0,0 +1,137 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.processor; + +import io.cloudevents.CloudEvent; +import org.apache.eventmesh.api.RequestReplyCallback; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.AclException; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; +import org.apache.eventmesh.runtime.acl.Acl; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.apache.eventmesh.runtime.util.EventMeshUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +public class RequestReplyMessageProcessor { + + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private final Logger aclLogger = LoggerFactory.getLogger("acl"); + + private final EventMeshGrpcServer eventMeshGrpcServer; + + public RequestReplyMessageProcessor(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void process(EventMeshMessage message, EventEmitter emitter) throws Exception { + RequestHeader requestHeader = message.getHeader(); + + if (!ServiceUtils.validateHeader(requestHeader)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, emitter); + return; + } + + if (!ServiceUtils.validateMessage(message)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); + return; + } + + String seqNum = message.getSeqNum(); + String uniqueId = message.getUniqueId(); + String topic = message.getTopic(); + String producerGroup = message.getProducerGroup(); + + int ttl = Integer.parseInt(message.getTtl()); + try { + doAclCheck(message); + } catch (Exception e) { + aclLogger.warn("CLIENT HAS NO PERMISSION,RequestReplyMessageProcessor send failed", e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_ACL_ERR, e.getMessage(), emitter); + return; + } + + // control flow rate limit + if (!eventMeshGrpcServer.getMsgRateLimiter() + .tryAcquire(EventMeshConstants.DEFAULT_FASTFAIL_TIMEOUT_IN_MILLISECONDS, TimeUnit.MILLISECONDS)) { + logger.error("Send message speed over limit."); + ServiceUtils.sendResp(StatusCode.EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR, emitter); + return; + } + + String protocolType = requestHeader.getProtocolType(); + ProtocolAdaptor grpcCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + CloudEvent cloudEvent = grpcCommandProtocolAdaptor.toCloudEvent(new EventMeshMessageWrapper(message)); + + ProducerManager producerManager = eventMeshGrpcServer.getProducerManager(); + EventMeshProducer eventMeshProducer = producerManager.getEventMeshProducer(producerGroup); + + SendMessageContext sendMessageContext = new SendMessageContext(message.getSeqNum(), cloudEvent, eventMeshProducer, eventMeshGrpcServer); + + long startTime = System.currentTimeMillis(); + eventMeshProducer.request(sendMessageContext, new RequestReplyCallback() { + @Override + public void onSuccess(CloudEvent event) { + ServiceUtils.sendResp(StatusCode.SUCCESS, event.toString(), emitter); + long endTime = System.currentTimeMillis(); + logger.info("message|eventMesh2mq|REQ|RequestReply|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", + endTime - startTime, topic, seqNum, uniqueId); + } + + @Override + public void onException(Throwable e) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_ASYNC_MSG_ERR, + EventMeshUtil.stackTrace(e, 2), emitter); + long endTime = System.currentTimeMillis(); + logger.error("message|eventMesh2mq|REQ|RequestReply|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", + endTime - startTime, topic, seqNum, uniqueId, e); + } + }, ttl); + } + + private void doAclCheck(EventMeshMessage message) throws AclException { + RequestHeader requestHeader = message.getHeader(); + if (eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshServerSecurityEnable) { + String remoteAdd = requestHeader.getIp(); + String user = requestHeader.getUsername(); + String pass = requestHeader.getPassword(); + String subsystem = requestHeader.getSys(); + String topic = message.getTopic(); + Acl.doAclCheckInHttpSend(remoteAdd, user, pass, subsystem, topic, RequestCode.MSG_SEND_ASYNC.getRequestCode()); + } + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java index c31a242e82..7c5ca07e5f 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/producer/EventMeshProducer.java @@ -35,8 +35,6 @@ public class EventMeshProducer { private ProducerGroupConf producerGroupConfig; - private EventMeshGrpcConfiguration eventMeshGrpcConfiguration; - private MQProducerWrapper mqProducerWrapper; private ServiceState serviceState; @@ -51,12 +49,6 @@ public void request(SendMessageContext sendMsgContext, RequestReplyCallback rrCa mqProducerWrapper.request(sendMsgContext.getEvent(), rrCallback, timeout); } - public boolean reply(SendMessageContext sendMsgContext, SendCallback sendCallback) - throws Exception { - mqProducerWrapper.reply(sendMsgContext.getEvent(), sendCallback); - return true; - } - public MQProducerWrapper getMqProducerWrapper() { return mqProducerWrapper; } @@ -64,7 +56,6 @@ public MQProducerWrapper getMqProducerWrapper() { public synchronized void init(EventMeshGrpcConfiguration eventMeshGrpcConfiguration, ProducerGroupConf producerGroupConfig) throws Exception { this.producerGroupConfig = producerGroupConfig; - this.eventMeshGrpcConfiguration = eventMeshGrpcConfiguration; Properties keyValue = new Properties(); keyValue.put("producerGroup", producerGroupConfig.getGroupName()); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java index d6809e3d4f..98bc04683c 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java @@ -7,12 +7,15 @@ import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.processor.RequestReplyMessageProcessor; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SendAsyncMessageProcessor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.concurrent.ThreadPoolExecutor; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + public class ProducerService extends PublisherServiceGrpc.PublisherServiceImplBase { private final Logger logger = LoggerFactory.getLogger(ProducerService.class); @@ -47,4 +50,21 @@ public void publish(EventMeshMessage request, StreamObserver responseO }); } + public void requestReply(EventMeshMessage request, StreamObserver responseObserver) { + cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", "RequestReply", + EventMeshConstants.PROTOCOL_GRPC, request.getHeader().getIp(), + eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp); + + EventEmitter emitter = new EventEmitter<>(responseObserver); + threadPoolExecutor.submit(() -> { + RequestReplyMessageProcessor requestReplyMessageProcessor = new RequestReplyMessageProcessor(eventMeshGrpcServer); + try { + requestReplyMessageProcessor.process(request, emitter); + } catch (Exception e) { + logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_SEND_SYNC_MSG_ERR.getRetCode(), + StatusCode.EVENTMESH_SEND_SYNC_MSG_ERR.getErrMsg(), e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_SEND_SYNC_MSG_ERR, e.getMessage(), emitter); + } + }); + } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java index 3b84ef9f99..753fa861a4 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -20,7 +20,10 @@ public static boolean validateHeader(RequestHeader header) { && StringUtils.isNotEmpty(header.getIp()) && StringUtils.isNotEmpty(header.getPid()) && StringUtils.isNumeric(header.getPid()) - && StringUtils.isNotEmpty(header.getSys()); + && StringUtils.isNotEmpty(header.getSys()) + && StringUtils.isNotEmpty(header.getUsername()) + && StringUtils.isNotEmpty(header.getPassword()) + && StringUtils.isNotEmpty(header.getLanguage()); } public static boolean validateMessage(EventMeshMessage message) { diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java index 08def1e8c1..3dd81115f8 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java @@ -48,6 +48,24 @@ public Response publish(EventMeshMessage message) { } } + public Response requestReply(EventMeshMessage message, int timeout) { + logger.info("RequestReply message " + message.toString()); + + EventMeshMessage enhancedMessage = EventMeshMessage.newBuilder(message) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setProducerGroup(clientConfig.getProducerGroup()) + .setTtl(String.valueOf(timeout)) + .build(); + try { + Response response = publisherClient.requestReply(enhancedMessage); + logger.info("Received response " + response.toString()); + return response; + } catch (Exception e) { + logger.error("Error in RequestReply message {}, error {}", message, e.getMessage()); + return null; + } + } + public void close() { channel.shutdown(); } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java index 3d93b9e9dc..79a67f55b4 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/config/EventMeshGrpcClientConfig.java @@ -25,13 +25,13 @@ public class EventMeshGrpcClientConfig { @Builder.Default - private String serverAddr = ""; + private String serverAddr = "127.0.0.1"; @Builder.Default private int serverPort = 10205; @Builder.Default - private String env = ""; + private String env = "env"; @Builder.Default private String consumerGroup = "DefaultConsumerGroup"; @@ -40,16 +40,16 @@ public class EventMeshGrpcClientConfig { private String producerGroup = "DefaultProducerGroup"; @Builder.Default - private String idc = ""; + private String idc = "default"; @Builder.Default private String sys = "sys123"; @Builder.Default - private String userName = ""; + private String userName = "username"; @Builder.Default - private String password = ""; + private String password = "passwd"; @Builder.Default private String language = "JAVA"; From 9d0816e807561ea0bb91feefd99656d774cfc391 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Tue, 4 Jan 2022 18:13:53 -0500 Subject: [PATCH 18/21] grpc batchpublish API --- .../grpc/common/BatchMessageWrapper.java | 34 + .../protocol/grpc/common/StatusCode.java | 2 +- .../protocol/grpc/protos/BatchMessage.java | 2556 +++++++++++++++++ .../grpc/protos/BatchMessageOrBuilder.java | 66 + .../protocol/grpc/protos/EventmeshGrpc.java | 145 +- .../grpc/protos/PublisherServiceGrpc.java | 77 +- .../grpc/pub/BatchPublishInstance.java | 77 + .../src/main/proto/eventmesh-client.proto | 19 + .../MeshMessageProtocolAdaptor.java | 9 +- .../grpc/GrpcMessageProtocolResolver.java | 97 +- .../BatchPublishMessageProcessor.java | 135 + .../grpc/service/ProducerService.java | 25 +- .../protocol/grpc/service/ServiceUtils.java | 15 + .../client/grpc/EventMeshGrpcProducer.java | 18 + 14 files changed, 3219 insertions(+), 56 deletions(-) create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/BatchMessageWrapper.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessageOrBuilder.java create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/BatchPublishInstance.java create mode 100644 eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/BatchPublishMessageProcessor.java diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/BatchMessageWrapper.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/BatchMessageWrapper.java new file mode 100644 index 0000000000..011bcb4c38 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/BatchMessageWrapper.java @@ -0,0 +1,34 @@ +/* + * 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.eventmesh.common.protocol.grpc.common; + +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; + +public class BatchMessageWrapper implements ProtocolTransportObject { + + private BatchMessage batchMessage; + + public BatchMessageWrapper(BatchMessage batchMessage) { + this.batchMessage = batchMessage; + } + + public BatchMessage getMessage() { + return batchMessage; + } +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java index 3f3a850755..a252964287 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java @@ -28,7 +28,7 @@ public enum StatusCode { EVENTMESH_PROTOCOL_BODY_ERR("7", "eventMesh protocol[body] err, "), EVENTMESH_STOP("8", "eventMesh will stop or had stopped, "), EVENTMESH_REJECT_BY_PROCESSOR_ERROR("9", "eventMesh reject by processor error, "), - EVENTMESH_BATCH_PRODUCER_STOPED_ERR("10", "eventMesh batch msg producer stopped, "), + EVENTMESH_BATCH_PUBLISH_ERR("10", "eventMesh batch publish messages error, "), EVENTMESH_SEND_BATCHLOG_MSG_ERR("17", "eventMesh send batchlog msg err, "), EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR("11", "eventMesh batch msg speed over the limit, "), EVENTMESH_PACKAGE_MSG_ERR("12", "eventMesh package msg err, "), diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java new file mode 100644 index 0000000000..c9f8570edc --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java @@ -0,0 +1,2556 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +/** + * Protobuf type {@code eventmesh.common.protocol.grpc.BatchMessage} + */ +public final class BatchMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.BatchMessage) + BatchMessageOrBuilder { +private static final long serialVersionUID = 0L; + // Use BatchMessage.newBuilder() to construct. + private BatchMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BatchMessage() { + producerGroup_ = ""; + topic_ = ""; + messageItem_ = java.util.Collections.emptyList(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BatchMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + RequestHeader.Builder subBuilder = null; + if (header_ != null) { + subBuilder = header_.toBuilder(); + } + header_ = input.readMessage(RequestHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(header_); + header_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + producerGroup_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + messageItem_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + messageItem_.add( + input.readMessage(MessageItem.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + messageItem_ = java.util.Collections.unmodifiableList(messageItem_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + BatchMessage.class, Builder.class); + } + + public interface MessageItemOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.BatchMessage.MessageItem) + com.google.protobuf.MessageOrBuilder { + + /** + * string content = 1; + */ + String getContent(); + /** + * string content = 1; + */ + com.google.protobuf.ByteString + getContentBytes(); + + /** + * string ttl = 2; + */ + String getTtl(); + /** + * string ttl = 2; + */ + com.google.protobuf.ByteString + getTtlBytes(); + + /** + * string uniqueId = 3; + */ + String getUniqueId(); + /** + * string uniqueId = 3; + */ + com.google.protobuf.ByteString + getUniqueIdBytes(); + + /** + * string seqNum = 4; + */ + String getSeqNum(); + /** + * string seqNum = 4; + */ + com.google.protobuf.ByteString + getSeqNumBytes(); + + /** + * string tag = 5; + */ + String getTag(); + /** + * string tag = 5; + */ + com.google.protobuf.ByteString + getTagBytes(); + + /** + * map<string, string> properties = 6; + */ + int getPropertiesCount(); + /** + * map<string, string> properties = 6; + */ + boolean containsProperties( + String key); + /** + * Use {@link #getPropertiesMap()} instead. + */ + @Deprecated + java.util.Map + getProperties(); + /** + * map<string, string> properties = 6; + */ + java.util.Map + getPropertiesMap(); + /** + * map<string, string> properties = 6; + */ + + String getPropertiesOrDefault( + String key, + String defaultValue); + /** + * map<string, string> properties = 6; + */ + + String getPropertiesOrThrow( + String key); + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.BatchMessage.MessageItem} + */ + public static final class MessageItem extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.BatchMessage.MessageItem) + MessageItemOrBuilder { + private static final long serialVersionUID = 0L; + // Use MessageItem.newBuilder() to construct. + private MessageItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MessageItem() { + content_ = ""; + ttl_ = ""; + uniqueId_ = ""; + seqNum_ = ""; + tag_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MessageItem( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + content_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + ttl_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + uniqueId_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + seqNum_ = s; + break; + } + case 42: { + String s = input.readStringRequireUtf8(); + + tag_ = s; + break; + } + case 50: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + properties_ = com.google.protobuf.MapField.newMapField( + PropertiesDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000020; + } + com.google.protobuf.MapEntry + properties__ = input.readMessage( + PropertiesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + properties_.getMutableMap().put( + properties__.getKey(), properties__.getValue()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 6: + return internalGetProperties(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + MessageItem.class, Builder.class); + } + + private int bitField0_; + public static final int CONTENT_FIELD_NUMBER = 1; + private volatile Object content_; + /** + * string content = 1; + */ + public String getContent() { + Object ref = content_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } + } + /** + * string content = 1; + */ + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TTL_FIELD_NUMBER = 2; + private volatile Object ttl_; + /** + * string ttl = 2; + */ + public String getTtl() { + Object ref = ttl_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ttl_ = s; + return s; + } + } + /** + * string ttl = 2; + */ + public com.google.protobuf.ByteString + getTtlBytes() { + Object ref = ttl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ttl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int UNIQUEID_FIELD_NUMBER = 3; + private volatile Object uniqueId_; + /** + * string uniqueId = 3; + */ + public String getUniqueId() { + Object ref = uniqueId_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + uniqueId_ = s; + return s; + } + } + /** + * string uniqueId = 3; + */ + public com.google.protobuf.ByteString + getUniqueIdBytes() { + Object ref = uniqueId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + uniqueId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SEQNUM_FIELD_NUMBER = 4; + private volatile Object seqNum_; + /** + * string seqNum = 4; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } + } + /** + * string seqNum = 4; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TAG_FIELD_NUMBER = 5; + private volatile Object tag_; + /** + * string tag = 5; + */ + public String getTag() { + Object ref = tag_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + tag_ = s; + return s; + } + } + /** + * string tag = 5; + */ + public com.google.protobuf.ByteString + getTagBytes() { + Object ref = tag_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + tag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROPERTIES_FIELD_NUMBER = 6; + private static final class PropertiesDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + String, String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_PropertiesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + String, String> properties_; + private com.google.protobuf.MapField + internalGetProperties() { + if (properties_ == null) { + return com.google.protobuf.MapField.emptyMapField( + PropertiesDefaultEntryHolder.defaultEntry); + } + return properties_; + } + + public int getPropertiesCount() { + return internalGetProperties().getMap().size(); + } + /** + * map<string, string> properties = 6; + */ + + public boolean containsProperties( + String key) { + if (key == null) { throw new NullPointerException(); } + return internalGetProperties().getMap().containsKey(key); + } + /** + * Use {@link #getPropertiesMap()} instead. + */ + @Deprecated + public java.util.Map getProperties() { + return getPropertiesMap(); + } + /** + * map<string, string> properties = 6; + */ + + public java.util.Map getPropertiesMap() { + return internalGetProperties().getMap(); + } + /** + * map<string, string> properties = 6; + */ + + public String getPropertiesOrDefault( + String key, + String defaultValue) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> properties = 6; + */ + + public String getPropertiesOrThrow( + String key) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getContentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, content_); + } + if (!getTtlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, ttl_); + } + if (!getUniqueIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, uniqueId_); + } + if (!getSeqNumBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, seqNum_); + } + if (!getTagBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, tag_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetProperties(), + PropertiesDefaultEntryHolder.defaultEntry, + 6); + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getContentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, content_); + } + if (!getTtlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, ttl_); + } + if (!getUniqueIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, uniqueId_); + } + if (!getSeqNumBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, seqNum_); + } + if (!getTagBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, tag_); + } + for (java.util.Map.Entry entry + : internalGetProperties().getMap().entrySet()) { + com.google.protobuf.MapEntry + properties__ = PropertiesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, properties__); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MessageItem)) { + return super.equals(obj); + } + MessageItem other = (MessageItem) obj; + + boolean result = true; + result = result && getContent() + .equals(other.getContent()); + result = result && getTtl() + .equals(other.getTtl()); + result = result && getUniqueId() + .equals(other.getUniqueId()); + result = result && getSeqNum() + .equals(other.getSeqNum()); + result = result && getTag() + .equals(other.getTag()); + result = result && internalGetProperties().equals( + other.internalGetProperties()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CONTENT_FIELD_NUMBER; + hash = (53 * hash) + getContent().hashCode(); + hash = (37 * hash) + TTL_FIELD_NUMBER; + hash = (53 * hash) + getTtl().hashCode(); + hash = (37 * hash) + UNIQUEID_FIELD_NUMBER; + hash = (53 * hash) + getUniqueId().hashCode(); + hash = (37 * hash) + SEQNUM_FIELD_NUMBER; + hash = (53 * hash) + getSeqNum().hashCode(); + hash = (37 * hash) + TAG_FIELD_NUMBER; + hash = (53 * hash) + getTag().hashCode(); + if (!internalGetProperties().getMap().isEmpty()) { + hash = (37 * hash) + PROPERTIES_FIELD_NUMBER; + hash = (53 * hash) + internalGetProperties().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static MessageItem parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static MessageItem parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static MessageItem parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static MessageItem parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static MessageItem parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static MessageItem parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static MessageItem parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static MessageItem 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 MessageItem parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static MessageItem 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 MessageItem parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static MessageItem parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(MessageItem prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.BatchMessage.MessageItem} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.BatchMessage.MessageItem) + MessageItemOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 6: + return internalGetProperties(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 6: + return internalGetMutableProperties(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_fieldAccessorTable + .ensureFieldAccessorsInitialized( + MessageItem.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage.MessageItem.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + content_ = ""; + + ttl_ = ""; + + uniqueId_ = ""; + + seqNum_ = ""; + + tag_ = ""; + + internalGetMutableProperties().clear(); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_descriptor; + } + + public MessageItem getDefaultInstanceForType() { + return MessageItem.getDefaultInstance(); + } + + public MessageItem build() { + MessageItem result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public MessageItem buildPartial() { + MessageItem result = new MessageItem(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.content_ = content_; + result.ttl_ = ttl_; + result.uniqueId_ = uniqueId_; + result.seqNum_ = seqNum_; + result.tag_ = tag_; + result.properties_ = internalGetProperties(); + result.properties_.makeImmutable(); + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof MessageItem) { + return mergeFrom((MessageItem)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(MessageItem other) { + if (other == MessageItem.getDefaultInstance()) return this; + if (!other.getContent().isEmpty()) { + content_ = other.content_; + onChanged(); + } + if (!other.getTtl().isEmpty()) { + ttl_ = other.ttl_; + onChanged(); + } + if (!other.getUniqueId().isEmpty()) { + uniqueId_ = other.uniqueId_; + onChanged(); + } + if (!other.getSeqNum().isEmpty()) { + seqNum_ = other.seqNum_; + onChanged(); + } + if (!other.getTag().isEmpty()) { + tag_ = other.tag_; + onChanged(); + } + internalGetMutableProperties().mergeFrom( + other.internalGetProperties()); + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + MessageItem parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (MessageItem) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private Object content_ = ""; + /** + * string content = 1; + */ + public String getContent() { + Object ref = content_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string content = 1; + */ + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string content = 1; + */ + public Builder setContent( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + content_ = value; + onChanged(); + return this; + } + /** + * string content = 1; + */ + public Builder clearContent() { + + content_ = getDefaultInstance().getContent(); + onChanged(); + return this; + } + /** + * string content = 1; + */ + public Builder setContentBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + content_ = value; + onChanged(); + return this; + } + + private Object ttl_ = ""; + /** + * string ttl = 2; + */ + public String getTtl() { + Object ref = ttl_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + ttl_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string ttl = 2; + */ + public com.google.protobuf.ByteString + getTtlBytes() { + Object ref = ttl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + ttl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string ttl = 2; + */ + public Builder setTtl( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + ttl_ = value; + onChanged(); + return this; + } + /** + * string ttl = 2; + */ + public Builder clearTtl() { + + ttl_ = getDefaultInstance().getTtl(); + onChanged(); + return this; + } + /** + * string ttl = 2; + */ + public Builder setTtlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + ttl_ = value; + onChanged(); + return this; + } + + private Object uniqueId_ = ""; + /** + * string uniqueId = 3; + */ + public String getUniqueId() { + Object ref = uniqueId_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + uniqueId_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string uniqueId = 3; + */ + public com.google.protobuf.ByteString + getUniqueIdBytes() { + Object ref = uniqueId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + uniqueId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string uniqueId = 3; + */ + public Builder setUniqueId( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + uniqueId_ = value; + onChanged(); + return this; + } + /** + * string uniqueId = 3; + */ + public Builder clearUniqueId() { + + uniqueId_ = getDefaultInstance().getUniqueId(); + onChanged(); + return this; + } + /** + * string uniqueId = 3; + */ + public Builder setUniqueIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + uniqueId_ = value; + onChanged(); + return this; + } + + private Object seqNum_ = ""; + /** + * string seqNum = 4; + */ + public String getSeqNum() { + Object ref = seqNum_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + seqNum_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string seqNum = 4; + */ + public com.google.protobuf.ByteString + getSeqNumBytes() { + Object ref = seqNum_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + seqNum_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string seqNum = 4; + */ + public Builder setSeqNum( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + seqNum_ = value; + onChanged(); + return this; + } + /** + * string seqNum = 4; + */ + public Builder clearSeqNum() { + + seqNum_ = getDefaultInstance().getSeqNum(); + onChanged(); + return this; + } + /** + * string seqNum = 4; + */ + public Builder setSeqNumBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + seqNum_ = value; + onChanged(); + return this; + } + + private Object tag_ = ""; + /** + * string tag = 5; + */ + public String getTag() { + Object ref = tag_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + tag_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string tag = 5; + */ + public com.google.protobuf.ByteString + getTagBytes() { + Object ref = tag_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + tag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string tag = 5; + */ + public Builder setTag( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + tag_ = value; + onChanged(); + return this; + } + /** + * string tag = 5; + */ + public Builder clearTag() { + + tag_ = getDefaultInstance().getTag(); + onChanged(); + return this; + } + /** + * string tag = 5; + */ + public Builder setTagBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + tag_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + String, String> properties_; + private com.google.protobuf.MapField + internalGetProperties() { + if (properties_ == null) { + return com.google.protobuf.MapField.emptyMapField( + PropertiesDefaultEntryHolder.defaultEntry); + } + return properties_; + } + private com.google.protobuf.MapField + internalGetMutableProperties() { + onChanged();; + if (properties_ == null) { + properties_ = com.google.protobuf.MapField.newMapField( + PropertiesDefaultEntryHolder.defaultEntry); + } + if (!properties_.isMutable()) { + properties_ = properties_.copy(); + } + return properties_; + } + + public int getPropertiesCount() { + return internalGetProperties().getMap().size(); + } + /** + * map<string, string> properties = 6; + */ + + public boolean containsProperties( + String key) { + if (key == null) { throw new NullPointerException(); } + return internalGetProperties().getMap().containsKey(key); + } + /** + * Use {@link #getPropertiesMap()} instead. + */ + @Deprecated + public java.util.Map getProperties() { + return getPropertiesMap(); + } + /** + * map<string, string> properties = 6; + */ + + public java.util.Map getPropertiesMap() { + return internalGetProperties().getMap(); + } + /** + * map<string, string> properties = 6; + */ + + public String getPropertiesOrDefault( + String key, + String defaultValue) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> properties = 6; + */ + + public String getPropertiesOrThrow( + String key) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearProperties() { + internalGetMutableProperties().getMutableMap() + .clear(); + return this; + } + /** + * map<string, string> properties = 6; + */ + + public Builder removeProperties( + String key) { + if (key == null) { throw new NullPointerException(); } + internalGetMutableProperties().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @Deprecated + public java.util.Map + getMutableProperties() { + return internalGetMutableProperties().getMutableMap(); + } + /** + * map<string, string> properties = 6; + */ + public Builder putProperties( + String key, + String value) { + if (key == null) { throw new NullPointerException(); } + if (value == null) { throw new NullPointerException(); } + internalGetMutableProperties().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, string> properties = 6; + */ + + public Builder putAllProperties( + java.util.Map values) { + internalGetMutableProperties().getMutableMap() + .putAll(values); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.BatchMessage.MessageItem) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.BatchMessage.MessageItem) + private static final MessageItem DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new MessageItem(); + } + + public static MessageItem getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public MessageItem parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MessageItem(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public MessageItem getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int HEADER_FIELD_NUMBER = 1; + private RequestHeader header_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + return getHeader(); + } + + public static final int PRODUCERGROUP_FIELD_NUMBER = 2; + private volatile Object producerGroup_; + /** + * string producerGroup = 2; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } + } + /** + * string producerGroup = 2; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TOPIC_FIELD_NUMBER = 3; + private volatile Object topic_; + /** + * string topic = 3; + */ + public String getTopic() { + Object ref = topic_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * string topic = 3; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MESSAGEITEM_FIELD_NUMBER = 4; + private java.util.List messageItem_; + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public java.util.List getMessageItemList() { + return messageItem_; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public java.util.List + getMessageItemOrBuilderList() { + return messageItem_; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public int getMessageItemCount() { + return messageItem_.size(); + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public MessageItem getMessageItem(int index) { + return messageItem_.get(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public MessageItemOrBuilder getMessageItemOrBuilder( + int index) { + return messageItem_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (header_ != null) { + output.writeMessage(1, getHeader()); + } + if (!getProducerGroupBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, producerGroup_); + } + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, topic_); + } + for (int i = 0; i < messageItem_.size(); i++) { + output.writeMessage(4, messageItem_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (header_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getHeader()); + } + if (!getProducerGroupBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, producerGroup_); + } + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, topic_); + } + for (int i = 0; i < messageItem_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, messageItem_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BatchMessage)) { + return super.equals(obj); + } + BatchMessage other = (BatchMessage) obj; + + boolean result = true; + result = result && (hasHeader() == other.hasHeader()); + if (hasHeader()) { + result = result && getHeader() + .equals(other.getHeader()); + } + result = result && getProducerGroup() + .equals(other.getProducerGroup()); + result = result && getTopic() + .equals(other.getTopic()); + result = result && getMessageItemList() + .equals(other.getMessageItemList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasHeader()) { + hash = (37 * hash) + HEADER_FIELD_NUMBER; + hash = (53 * hash) + getHeader().hashCode(); + } + hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER; + hash = (53 * hash) + getProducerGroup().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + if (getMessageItemCount() > 0) { + hash = (37 * hash) + MESSAGEITEM_FIELD_NUMBER; + hash = (53 * hash) + getMessageItemList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static BatchMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static BatchMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static BatchMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static BatchMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static BatchMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static BatchMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static BatchMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static BatchMessage 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 BatchMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static BatchMessage 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 BatchMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static BatchMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(BatchMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code eventmesh.common.protocol.grpc.BatchMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.BatchMessage) + BatchMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + BatchMessage.class, Builder.class); + } + + // Construct using org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getMessageItemFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (headerBuilder_ == null) { + header_ = null; + } else { + header_ = null; + headerBuilder_ = null; + } + producerGroup_ = ""; + + topic_ = ""; + + if (messageItemBuilder_ == null) { + messageItem_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + messageItemBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_BatchMessage_descriptor; + } + + public BatchMessage getDefaultInstanceForType() { + return BatchMessage.getDefaultInstance(); + } + + public BatchMessage build() { + BatchMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public BatchMessage buildPartial() { + BatchMessage result = new BatchMessage(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (headerBuilder_ == null) { + result.header_ = header_; + } else { + result.header_ = headerBuilder_.build(); + } + result.producerGroup_ = producerGroup_; + result.topic_ = topic_; + if (messageItemBuilder_ == null) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { + messageItem_ = java.util.Collections.unmodifiableList(messageItem_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.messageItem_ = messageItem_; + } else { + result.messageItem_ = messageItemBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof BatchMessage) { + return mergeFrom((BatchMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(BatchMessage other) { + if (other == BatchMessage.getDefaultInstance()) return this; + if (other.hasHeader()) { + mergeHeader(other.getHeader()); + } + if (!other.getProducerGroup().isEmpty()) { + producerGroup_ = other.producerGroup_; + onChanged(); + } + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (messageItemBuilder_ == null) { + if (!other.messageItem_.isEmpty()) { + if (messageItem_.isEmpty()) { + messageItem_ = other.messageItem_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureMessageItemIsMutable(); + messageItem_.addAll(other.messageItem_); + } + onChanged(); + } + } else { + if (!other.messageItem_.isEmpty()) { + if (messageItemBuilder_.isEmpty()) { + messageItemBuilder_.dispose(); + messageItemBuilder_ = null; + messageItem_ = other.messageItem_; + bitField0_ = (bitField0_ & ~0x00000008); + messageItemBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getMessageItemFieldBuilder() : null; + } else { + messageItemBuilder_.addAllMessages(other.messageItem_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + BatchMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (BatchMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private RequestHeader header_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_; + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public boolean hasHeader() { + return headerBuilder_ != null || header_ != null; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader getHeader() { + if (headerBuilder_ == null) { + return header_ == null ? RequestHeader.getDefaultInstance() : header_; + } else { + return headerBuilder_.getMessage(); + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + header_ = value; + onChanged(); + } else { + headerBuilder_.setMessage(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder setHeader( + RequestHeader.Builder builderForValue) { + if (headerBuilder_ == null) { + header_ = builderForValue.build(); + onChanged(); + } else { + headerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder mergeHeader(RequestHeader value) { + if (headerBuilder_ == null) { + if (header_ != null) { + header_ = + RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial(); + } else { + header_ = value; + } + onChanged(); + } else { + headerBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public Builder clearHeader() { + if (headerBuilder_ == null) { + header_ = null; + onChanged(); + } else { + header_ = null; + headerBuilder_ = null; + } + + return this; + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeader.Builder getHeaderBuilder() { + + onChanged(); + return getHeaderFieldBuilder().getBuilder(); + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + public RequestHeaderOrBuilder getHeaderOrBuilder() { + if (headerBuilder_ != null) { + return headerBuilder_.getMessageOrBuilder(); + } else { + return header_ == null ? + RequestHeader.getDefaultInstance() : header_; + } + } + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> + getHeaderFieldBuilder() { + if (headerBuilder_ == null) { + headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>( + getHeader(), + getParentForChildren(), + isClean()); + header_ = null; + } + return headerBuilder_; + } + + private Object producerGroup_ = ""; + /** + * string producerGroup = 2; + */ + public String getProducerGroup() { + Object ref = producerGroup_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + producerGroup_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string producerGroup = 2; + */ + public com.google.protobuf.ByteString + getProducerGroupBytes() { + Object ref = producerGroup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + producerGroup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string producerGroup = 2; + */ + public Builder setProducerGroup( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + producerGroup_ = value; + onChanged(); + return this; + } + /** + * string producerGroup = 2; + */ + public Builder clearProducerGroup() { + + producerGroup_ = getDefaultInstance().getProducerGroup(); + onChanged(); + return this; + } + /** + * string producerGroup = 2; + */ + public Builder setProducerGroupBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + producerGroup_ = value; + onChanged(); + return this; + } + + private Object topic_ = ""; + /** + * string topic = 3; + */ + public String getTopic() { + Object ref = topic_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string topic = 3; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string topic = 3; + */ + public Builder setTopic( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * string topic = 3; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * string topic = 3; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private java.util.List messageItem_ = + java.util.Collections.emptyList(); + private void ensureMessageItemIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + messageItem_ = new java.util.ArrayList(messageItem_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + MessageItem, MessageItem.Builder, MessageItemOrBuilder> messageItemBuilder_; + + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public java.util.List getMessageItemList() { + if (messageItemBuilder_ == null) { + return java.util.Collections.unmodifiableList(messageItem_); + } else { + return messageItemBuilder_.getMessageList(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public int getMessageItemCount() { + if (messageItemBuilder_ == null) { + return messageItem_.size(); + } else { + return messageItemBuilder_.getCount(); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public MessageItem getMessageItem(int index) { + if (messageItemBuilder_ == null) { + return messageItem_.get(index); + } else { + return messageItemBuilder_.getMessage(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public Builder setMessageItem( + int index, MessageItem value) { + if (messageItemBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMessageItemIsMutable(); + messageItem_.set(index, value); + onChanged(); + } else { + messageItemBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public Builder setMessageItem( + int index, MessageItem.Builder builderForValue) { + if (messageItemBuilder_ == null) { + ensureMessageItemIsMutable(); + messageItem_.set(index, builderForValue.build()); + onChanged(); + } else { + messageItemBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public Builder addMessageItem(MessageItem value) { + if (messageItemBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMessageItemIsMutable(); + messageItem_.add(value); + onChanged(); + } else { + messageItemBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public Builder addMessageItem( + int index, MessageItem value) { + if (messageItemBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMessageItemIsMutable(); + messageItem_.add(index, value); + onChanged(); + } else { + messageItemBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public Builder addMessageItem( + MessageItem.Builder builderForValue) { + if (messageItemBuilder_ == null) { + ensureMessageItemIsMutable(); + messageItem_.add(builderForValue.build()); + onChanged(); + } else { + messageItemBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public Builder addMessageItem( + int index, MessageItem.Builder builderForValue) { + if (messageItemBuilder_ == null) { + ensureMessageItemIsMutable(); + messageItem_.add(index, builderForValue.build()); + onChanged(); + } else { + messageItemBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public Builder addAllMessageItem( + Iterable values) { + if (messageItemBuilder_ == null) { + ensureMessageItemIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, messageItem_); + onChanged(); + } else { + messageItemBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public Builder clearMessageItem() { + if (messageItemBuilder_ == null) { + messageItem_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + messageItemBuilder_.clear(); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public Builder removeMessageItem(int index) { + if (messageItemBuilder_ == null) { + ensureMessageItemIsMutable(); + messageItem_.remove(index); + onChanged(); + } else { + messageItemBuilder_.remove(index); + } + return this; + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public MessageItem.Builder getMessageItemBuilder( + int index) { + return getMessageItemFieldBuilder().getBuilder(index); + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public MessageItemOrBuilder getMessageItemOrBuilder( + int index) { + if (messageItemBuilder_ == null) { + return messageItem_.get(index); } else { + return messageItemBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public java.util.List + getMessageItemOrBuilderList() { + if (messageItemBuilder_ != null) { + return messageItemBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(messageItem_); + } + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public MessageItem.Builder addMessageItemBuilder() { + return getMessageItemFieldBuilder().addBuilder( + MessageItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public MessageItem.Builder addMessageItemBuilder( + int index) { + return getMessageItemFieldBuilder().addBuilder( + index, MessageItem.getDefaultInstance()); + } + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + public java.util.List + getMessageItemBuilderList() { + return getMessageItemFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + MessageItem, MessageItem.Builder, MessageItemOrBuilder> + getMessageItemFieldBuilder() { + if (messageItemBuilder_ == null) { + messageItemBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + MessageItem, MessageItem.Builder, MessageItemOrBuilder>( + messageItem_, + ((bitField0_ & 0x00000008) == 0x00000008), + getParentForChildren(), + isClean()); + messageItem_ = null; + } + return messageItemBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.BatchMessage) + } + + // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.BatchMessage) + private static final BatchMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new BatchMessage(); + } + + public static BatchMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BatchMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BatchMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public BatchMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessageOrBuilder.java new file mode 100644 index 0000000000..734d4ee225 --- /dev/null +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessageOrBuilder.java @@ -0,0 +1,66 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: eventmesh-client.proto + +package org.apache.eventmesh.common.protocol.grpc.protos; + +public interface BatchMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.BatchMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + boolean hasHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeader getHeader(); + /** + * .eventmesh.common.protocol.grpc.RequestHeader header = 1; + */ + RequestHeaderOrBuilder getHeaderOrBuilder(); + + /** + * string producerGroup = 2; + */ + String getProducerGroup(); + /** + * string producerGroup = 2; + */ + com.google.protobuf.ByteString + getProducerGroupBytes(); + + /** + * string topic = 3; + */ + String getTopic(); + /** + * string topic = 3; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + java.util.List + getMessageItemList(); + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + BatchMessage.MessageItem getMessageItem(int index); + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + int getMessageItemCount(); + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + java.util.List + getMessageItemOrBuilderList(); + /** + * repeated .eventmesh.common.protocol.grpc.BatchMessage.MessageItem messageItem = 4; + */ + BatchMessage.MessageItemOrBuilder getMessageItemOrBuilder( + int index); +} diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java index 7c23f5a169..54a1ebdee9 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -29,6 +29,21 @@ public static void registerAllExtensions( static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_PropertiesEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_BatchMessage_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_BatchMessage_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_PropertiesEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_PropertiesEntry_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_eventmesh_common_protocol_grpc_Response_descriptor; static final @@ -78,52 +93,66 @@ public static void registerAllExtensions( "properties\030\t \003(\0132@.eventmesh.common.prot" + "ocol.grpc.EventMeshMessage.PropertiesEnt" + "ry\0321\n\017PropertiesEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005va" + - "lue\030\002 \001(\t:\0028\001\"?\n\010Response\022\020\n\010respCode\030\001 " + - "\001(\t\022\017\n\007respMsg\030\002 \001(\t\022\020\n\010respTime\030\003 \001(\t\"\212" + - "\004\n\014Subscription\022=\n\006header\030\001 \001(\0132-.eventm" + - "esh.common.protocol.grpc.RequestHeader\022\025" + - "\n\rconsumerGroup\030\002 \001(\t\022X\n\021subscriptionIte" + - "ms\030\003 \003(\0132=.eventmesh.common.protocol.grp" + - "c.Subscription.SubscriptionItem\022\013\n\003url\030\004" + - " \001(\t\032\274\002\n\020SubscriptionItem\022\r\n\005topic\030\001 \001(\t" + - "\022\\\n\004mode\030\002 \001(\0162N.eventmesh.common.protoc" + - "ol.grpc.Subscription.SubscriptionItem.Su" + - "bscriptionMode\022\\\n\004type\030\003 \001(\0162N.eventmesh" + - ".common.protocol.grpc.Subscription.Subsc" + - "riptionItem.SubscriptionType\"4\n\020Subscrip" + - "tionMode\022\016\n\nCLUSTERING\020\000\022\020\n\014BROADCASTING" + - "\020\001\"\'\n\020SubscriptionType\022\t\n\005ASYNC\020\000\022\010\n\004SYN" + - "C\020\001\"\340\002\n\tHeartbeat\022=\n\006header\030\001 \001(\0132-.even" + - "tmesh.common.protocol.grpc.RequestHeader" + - "\022H\n\nclientType\030\002 \001(\01624.eventmesh.common." + - "protocol.grpc.Heartbeat.ClientType\022\025\n\rpr" + - "oducerGroup\030\003 \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t" + - "\022O\n\016heartbeatItems\030\005 \003(\01327.eventmesh.com" + - "mon.protocol.grpc.Heartbeat.HeartbeatIte" + - "m\032+\n\rHeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url" + - "\030\002 \001(\t\"\036\n\nClientType\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\316" + - "\002\n\020PublisherService\022e\n\007publish\0220.eventme" + - "sh.common.protocol.grpc.EventMeshMessage" + - "\032(.eventmesh.common.protocol.grpc.Respon" + - "se\022j\n\014requestReply\0220.eventmesh.common.pr" + - "otocol.grpc.EventMeshMessage\032(.eventmesh" + - ".common.protocol.grpc.Response\022g\n\tbroadc" + - "ast\0220.eventmesh.common.protocol.grpc.Eve" + - "ntMeshMessage\032(.eventmesh.common.protoco" + - "l.grpc.Response2\322\002\n\017ConsumerService\022c\n\ts" + - "ubscribe\022,.eventmesh.common.protocol.grp" + - "c.Subscription\032(.eventmesh.common.protoc" + - "ol.grpc.Response\022s\n\017subscribeStream\022,.ev" + - "entmesh.common.protocol.grpc.Subscriptio" + - "n\0320.eventmesh.common.protocol.grpc.Event" + - "MeshMessage0\001\022e\n\013unsubscribe\022,.eventmesh" + - ".common.protocol.grpc.Subscription\032(.eve" + - "ntmesh.common.protocol.grpc.Response2t\n\020" + - "HeartbeatService\022`\n\theartbeat\022).eventmes" + - "h.common.protocol.grpc.Heartbeat\032(.event" + - "mesh.common.protocol.grpc.ResponseBC\n0or" + - "g.apache.eventmesh.common.protocol.grpc." + - "protosB\rEventmeshGrpcP\001b\006proto3" + "lue\030\002 \001(\t:\0028\001\"\260\003\n\014BatchMessage\022=\n\006header" + + "\030\001 \001(\0132-.eventmesh.common.protocol.grpc." + + "RequestHeader\022\025\n\rproducerGroup\030\002 \001(\t\022\r\n\005" + + "topic\030\003 \001(\t\022M\n\013messageItem\030\004 \003(\01328.event" + + "mesh.common.protocol.grpc.BatchMessage.M" + + "essageItem\032\353\001\n\013MessageItem\022\017\n\007content\030\001 " + + "\001(\t\022\013\n\003ttl\030\002 \001(\t\022\020\n\010uniqueId\030\003 \001(\t\022\016\n\006se" + + "qNum\030\004 \001(\t\022\013\n\003tag\030\005 \001(\t\022\\\n\nproperties\030\006 " + + "\003(\0132H.eventmesh.common.protocol.grpc.Bat" + + "chMessage.MessageItem.PropertiesEntry\0321\n" + + "\017PropertiesEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002" + + " \001(\t:\0028\001\"?\n\010Response\022\020\n\010respCode\030\001 \001(\t\022\017" + + "\n\007respMsg\030\002 \001(\t\022\020\n\010respTime\030\003 \001(\t\"\212\004\n\014Su" + + "bscription\022=\n\006header\030\001 \001(\0132-.eventmesh.c" + + "ommon.protocol.grpc.RequestHeader\022\025\n\rcon" + + "sumerGroup\030\002 \001(\t\022X\n\021subscriptionItems\030\003 " + + "\003(\0132=.eventmesh.common.protocol.grpc.Sub" + + "scription.SubscriptionItem\022\013\n\003url\030\004 \001(\t\032" + + "\274\002\n\020SubscriptionItem\022\r\n\005topic\030\001 \001(\t\022\\\n\004m" + + "ode\030\002 \001(\0162N.eventmesh.common.protocol.gr" + + "pc.Subscription.SubscriptionItem.Subscri" + + "ptionMode\022\\\n\004type\030\003 \001(\0162N.eventmesh.comm" + + "on.protocol.grpc.Subscription.Subscripti" + + "onItem.SubscriptionType\"4\n\020SubscriptionM" + + "ode\022\016\n\nCLUSTERING\020\000\022\020\n\014BROADCASTING\020\001\"\'\n" + + "\020SubscriptionType\022\t\n\005ASYNC\020\000\022\010\n\004SYNC\020\001\"\340" + + "\002\n\tHeartbeat\022=\n\006header\030\001 \001(\0132-.eventmesh" + + ".common.protocol.grpc.RequestHeader\022H\n\nc" + + "lientType\030\002 \001(\01624.eventmesh.common.proto" + + "col.grpc.Heartbeat.ClientType\022\025\n\rproduce" + + "rGroup\030\003 \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022O\n\016h" + + "eartbeatItems\030\005 \003(\01327.eventmesh.common.p" + + "rotocol.grpc.Heartbeat.HeartbeatItem\032+\n\r" + + "HeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030\002 \001(" + + "\t\"\036\n\nClientType\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\266\003\n\020Pu" + + "blisherService\022e\n\007publish\0220.eventmesh.co" + + "mmon.protocol.grpc.EventMeshMessage\032(.ev" + + "entmesh.common.protocol.grpc.Response\022j\n" + + "\014requestReply\0220.eventmesh.common.protoco" + + "l.grpc.EventMeshMessage\032(.eventmesh.comm" + + "on.protocol.grpc.Response\022f\n\014batchPublis" + + "h\022,.eventmesh.common.protocol.grpc.Batch" + + "Message\032(.eventmesh.common.protocol.grpc" + + ".Response\022g\n\tbroadcast\0220.eventmesh.commo" + + "n.protocol.grpc.EventMeshMessage\032(.event" + + "mesh.common.protocol.grpc.Response2\322\002\n\017C" + + "onsumerService\022c\n\tsubscribe\022,.eventmesh." + + "common.protocol.grpc.Subscription\032(.even" + + "tmesh.common.protocol.grpc.Response\022s\n\017s" + + "ubscribeStream\022,.eventmesh.common.protoc" + + "ol.grpc.Subscription\0320.eventmesh.common." + + "protocol.grpc.EventMeshMessage0\001\022e\n\013unsu" + + "bscribe\022,.eventmesh.common.protocol.grpc" + + ".Subscription\032(.eventmesh.common.protoco" + + "l.grpc.Response2t\n\020HeartbeatService\022`\n\th" + + "eartbeat\022).eventmesh.common.protocol.grp" + + "c.Heartbeat\032(.eventmesh.common.protocol." + + "grpc.ResponseBC\n0org.apache.eventmesh.co" + + "mmon.protocol.grpc.protosB\rEventmeshGrpc" + + "P\001b\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -155,14 +184,32 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_PropertiesEntry_descriptor, new String[] { "Key", "Value", }); - internal_static_eventmesh_common_protocol_grpc_Response_descriptor = + internal_static_eventmesh_common_protocol_grpc_BatchMessage_descriptor = getDescriptor().getMessageTypes().get(2); + internal_static_eventmesh_common_protocol_grpc_BatchMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_BatchMessage_descriptor, + new String[] { "Header", "ProducerGroup", "Topic", "MessageItem", }); + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_descriptor = + internal_static_eventmesh_common_protocol_grpc_BatchMessage_descriptor.getNestedTypes().get(0); + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_descriptor, + new String[] { "Content", "Ttl", "UniqueId", "SeqNum", "Tag", "Properties", }); + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_PropertiesEntry_descriptor = + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_descriptor.getNestedTypes().get(0); + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_PropertiesEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_eventmesh_common_protocol_grpc_BatchMessage_MessageItem_PropertiesEntry_descriptor, + new String[] { "Key", "Value", }); + internal_static_eventmesh_common_protocol_grpc_Response_descriptor = + getDescriptor().getMessageTypes().get(3); internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_Response_descriptor, new String[] { "RespCode", "RespMsg", "RespTime", }); internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor = - getDescriptor().getMessageTypes().get(3); + getDescriptor().getMessageTypes().get(4); internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor, @@ -174,7 +221,7 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor, new String[] { "Topic", "Mode", "Type", }); internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor = - getDescriptor().getMessageTypes().get(4); + getDescriptor().getMessageTypes().get(5); internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor, diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java index 1ab9753a97..5730d78b95 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java @@ -83,6 +83,38 @@ Response> getRequestReplyMethod() { return getRequestReplyMethod; } + private static volatile io.grpc.MethodDescriptor getBatchPublishMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "batchPublish", + requestType = org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage.class, + responseType = Response.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getBatchPublishMethod() { + io.grpc.MethodDescriptor getBatchPublishMethod; + if ((getBatchPublishMethod = PublisherServiceGrpc.getBatchPublishMethod) == null) { + synchronized (PublisherServiceGrpc.class) { + if ((getBatchPublishMethod = PublisherServiceGrpc.getBatchPublishMethod) == null) { + PublisherServiceGrpc.getBatchPublishMethod = getBatchPublishMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "eventmesh.common.protocol.grpc.PublisherService", "batchPublish")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + Response.getDefaultInstance())) + .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("batchPublish")) + .build(); + } + } + } + return getBatchPublishMethod; + } + private static volatile io.grpc.MethodDescriptor getBroadcastMethod; @@ -156,6 +188,13 @@ public void requestReply(EventMeshMessage request, asyncUnimplementedUnaryCall(getRequestReplyMethod(), responseObserver); } + /** + */ + public void batchPublish(org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getBatchPublishMethod(), responseObserver); + } + /** */ public void broadcast(EventMeshMessage request, @@ -179,6 +218,13 @@ public void broadcast(EventMeshMessage request, EventMeshMessage, Response>( this, METHODID_REQUEST_REPLY))) + .addMethod( + getBatchPublishMethod(), + asyncUnaryCall( + new MethodHandlers< + org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage, + Response>( + this, METHODID_BATCH_PUBLISH))) .addMethod( getBroadcastMethod(), asyncUnaryCall( @@ -224,6 +270,14 @@ public void requestReply(EventMeshMessage request, getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request, responseObserver); } + /** + */ + public void batchPublish(org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getBatchPublishMethod(), getCallOptions()), request, responseObserver); + } + /** */ public void broadcast(EventMeshMessage request, @@ -265,6 +319,13 @@ public Response requestReply(EventMeshMessage request) { getChannel(), getRequestReplyMethod(), getCallOptions(), request); } + /** + */ + public Response batchPublish(org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage request) { + return blockingUnaryCall( + getChannel(), getBatchPublishMethod(), getCallOptions(), request); + } + /** */ public Response broadcast(EventMeshMessage request) { @@ -307,6 +368,14 @@ public com.google.common.util.concurrent.ListenableFuture requestReply getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request); } + /** + */ + public com.google.common.util.concurrent.ListenableFuture batchPublish( + org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage request) { + return futureUnaryCall( + getChannel().newCall(getBatchPublishMethod(), getCallOptions()), request); + } + /** */ public com.google.common.util.concurrent.ListenableFuture broadcast( @@ -318,7 +387,8 @@ public com.google.common.util.concurrent.ListenableFuture broadcast( private static final int METHODID_PUBLISH = 0; private static final int METHODID_REQUEST_REPLY = 1; - private static final int METHODID_BROADCAST = 2; + private static final int METHODID_BATCH_PUBLISH = 2; + private static final int METHODID_BROADCAST = 3; private static final class MethodHandlers implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -345,6 +415,10 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv serviceImpl.requestReply((EventMeshMessage) request, (io.grpc.stub.StreamObserver) responseObserver); break; + case METHODID_BATCH_PUBLISH: + serviceImpl.batchPublish((org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; case METHODID_BROADCAST: serviceImpl.broadcast((EventMeshMessage) request, (io.grpc.stub.StreamObserver) responseObserver); @@ -412,6 +486,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { .setSchemaDescriptor(new PublisherServiceFileDescriptorSupplier()) .addMethod(getPublishMethod()) .addMethod(getRequestReplyMethod()) + .addMethod(getBatchPublishMethod()) .addMethod(getBroadcastMethod()) .build(); } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/BatchPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/BatchPublishInstance.java new file mode 100644 index 0000000000..6f9edefa92 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/BatchPublishInstance.java @@ -0,0 +1,77 @@ +/* + * 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.eventmesh.grpc.pub; + +import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.util.Utils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +@Slf4j +public class BatchPublishInstance { + + public static void main(String[] args) throws Exception { + + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + + final String topic = "TEST-TOPIC-GRPC-RR"; + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .producerGroup("EventMeshTest-producerGroup") + .env("env").idc("idc") + .sys("1234").build(); + + EventMeshGrpcProducer eventMeshGrpcProducer = new EventMeshGrpcProducer(eventMeshClientConfig); + + eventMeshGrpcProducer.init(); + + Map content = new HashMap<>(); + content.put("content", "testRequestReplyMessage"); + + BatchMessage.Builder messageBuilder = BatchMessage.newBuilder() + .setTopic(topic); + for (int i = 0; i < 5; i++) { + BatchMessage.MessageItem item = BatchMessage.MessageItem.newBuilder() + .setContent((JsonUtils.serialize(content))) + .setUniqueId(RandomStringUtils.generateNum(30)) + .setSeqNum(RandomStringUtils.generateNum(30)) + .setTtl(String.valueOf(4 * 1000)) + .build(); + + messageBuilder.addMessageItem(item); + } + + eventMeshGrpcProducer.publish(messageBuilder.build()); + Thread.sleep(10000); + try (EventMeshGrpcProducer ignore = eventMeshGrpcProducer) { + // ignore + } + } +} diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto index 65d3595e04..374ec2a288 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto @@ -50,6 +50,23 @@ message EventMeshMessage { map properties = 9; } +message BatchMessage { + RequestHeader header = 1; + string producerGroup = 2; + string topic = 3; + + message MessageItem { + string content = 1; + string ttl = 2; + string uniqueId = 3; + string seqNum = 4; + string tag = 5; + map properties = 6; + } + + repeated MessageItem messageItem = 4; +} + message Response { string respCode = 1; string respMsg = 2; @@ -104,6 +121,8 @@ service PublisherService { rpc requestReply(EventMeshMessage) returns (Response); + rpc batchPublish(BatchMessage) returns (Response); + rpc broadcast(EventMeshMessage) returns (Response); } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java index f4992ed574..34498ae063 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/MeshMessageProtocolAdaptor.java @@ -19,7 +19,9 @@ import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.BatchMessageWrapper; import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.Body; import org.apache.eventmesh.common.protocol.http.common.RequestCode; @@ -98,7 +100,12 @@ private CloudEvent deserializeHttpProtocol(String requestCode, @Override public List toBatchCloudEvent(ProtocolTransportObject protocol) throws ProtocolHandleException { - return null; + if (protocol instanceof BatchMessageWrapper) { + BatchMessage batchMessage = ((BatchMessageWrapper) protocol).getMessage(); + return GrpcMessageProtocolResolver.buildBatchEvents(batchMessage); + } else { + throw new ProtocolHandleException(String.format("protocol class: %s", protocol.getClass())); + } } @Override diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java index 7249ba3326..03a1e69b54 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-meshmessage/src/main/java/org/apache/eventmesh/protocol/meshmessage/resolver/grpc/GrpcMessageProtocolResolver.java @@ -6,14 +6,16 @@ import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; import org.apache.eventmesh.common.protocol.grpc.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage.MessageItem; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; -import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; import java.net.URI; import java.nio.charset.StandardCharsets; -import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; public class GrpcMessageProtocolResolver { @@ -107,6 +109,97 @@ public static CloudEvent buildEvent(EventMeshMessage message) throws ProtocolHan } } + public static List buildBatchEvents(BatchMessage message) { + List events = new LinkedList<>(); + RequestHeader requestHeader = message.getHeader(); + + String protocolType = requestHeader.getProtocolType(); + String protocolDesc = requestHeader.getProtocolDesc(); + String protocolVersion = requestHeader.getProtocolVersion(); + + String env = requestHeader.getEnv(); + String idc = requestHeader.getIdc(); + String ip = requestHeader.getIp(); + String pid = requestHeader.getPid(); + String sys = requestHeader.getSys(); + String username = requestHeader.getUsername(); + String passwd = requestHeader.getPassword(); + String language = requestHeader.getLanguage(); + + for (MessageItem item : message.getMessageItemList()) { + String content = item.getContent(); + + CloudEvent event = null; + CloudEventBuilder cloudEventBuilder; + + if (StringUtils.equals(SpecVersion.V1.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v1(); + + cloudEventBuilder = cloudEventBuilder.withId(item.getSeqNum()) + .withSubject(message.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.ENV, env) + .withExtension(ProtocolKey.IDC, idc) + .withExtension(ProtocolKey.IP, ip) + .withExtension(ProtocolKey.PID, pid) + .withExtension(ProtocolKey.SYS, sys) + .withExtension(ProtocolKey.USERNAME, username) + .withExtension(ProtocolKey.PASSWD, passwd) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(ProtocolKey.SEQ_NUM, item.getSeqNum()) + .withExtension(ProtocolKey.UNIQUE_ID, item.getUniqueId()) + .withExtension(ProtocolKey.PRODUCERGROUP, message.getProducerGroup()) + .withExtension(ProtocolKey.TTL, item.getTtl()); + + for (Map.Entry entry : item.getPropertiesMap().entrySet()) { + cloudEventBuilder.withExtension(entry.getKey(), entry.getValue()); + } + if (StringUtils.isNotEmpty(item.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(ProtocolKey.TAG, item.getTag()); + } + event = cloudEventBuilder.build(); + } else if (StringUtils.equals(SpecVersion.V03.toString(), protocolVersion)) { + cloudEventBuilder = CloudEventBuilder.v03(); + cloudEventBuilder = cloudEventBuilder.withId(item.getSeqNum()) + .withSubject(message.getTopic()) + .withType("eventmeshmessage") + .withSource(URI.create("/")) + .withData(content.getBytes(StandardCharsets.UTF_8)) + .withExtension(ProtocolKey.ENV, env) + .withExtension(ProtocolKey.IDC, idc) + .withExtension(ProtocolKey.IP, ip) + .withExtension(ProtocolKey.PID, pid) + .withExtension(ProtocolKey.SYS, sys) + .withExtension(ProtocolKey.USERNAME, username) + .withExtension(ProtocolKey.PASSWD, passwd) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(ProtocolKey.SEQ_NUM, item.getSeqNum()) + .withExtension(ProtocolKey.UNIQUE_ID, item.getUniqueId()) + .withExtension(ProtocolKey.PRODUCERGROUP, message.getProducerGroup()) + .withExtension(ProtocolKey.TTL, item.getTtl()); + + for (Map.Entry entry : item.getPropertiesMap().entrySet()) { + cloudEventBuilder.withExtension(entry.getKey(), entry.getValue()); + } + if (StringUtils.isNotEmpty(item.getTag())) { + cloudEventBuilder = cloudEventBuilder.withExtension(ProtocolKey.TAG, item.getTag()); + } + event = cloudEventBuilder.build(); + } + events.add(event); + } + + return events; + } + public static EventMeshMessageWrapper buildEventMeshMessage(CloudEvent cloudEvent) { String env = cloudEvent.getExtension(ProtocolKey.ENV) == null ? null : cloudEvent.getExtension(ProtocolKey.ENV).toString(); String idc = cloudEvent.getExtension(ProtocolKey.IDC) == null ? null : cloudEvent.getExtension(ProtocolKey.IDC).toString(); diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/BatchPublishMessageProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/BatchPublishMessageProcessor.java new file mode 100644 index 0000000000..2beb41b756 --- /dev/null +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/processor/BatchPublishMessageProcessor.java @@ -0,0 +1,135 @@ +/* + * 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.eventmesh.runtime.core.protocol.grpc.processor; + +import io.cloudevents.CloudEvent; +import org.apache.eventmesh.api.SendCallback; +import org.apache.eventmesh.api.SendResult; +import org.apache.eventmesh.api.exception.AclException; +import org.apache.eventmesh.api.exception.OnExceptionContext; +import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.BatchMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.http.common.RequestCode; +import org.apache.eventmesh.protocol.api.ProtocolAdaptor; +import org.apache.eventmesh.protocol.api.ProtocolPluginFactory; +import org.apache.eventmesh.runtime.acl.Acl; +import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; +import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.EventMeshProducer; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.ProducerManager; +import org.apache.eventmesh.runtime.core.protocol.grpc.producer.SendMessageContext; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.EventEmitter; +import org.apache.eventmesh.runtime.core.protocol.grpc.service.ServiceUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; +import java.util.concurrent.TimeUnit; + +public class BatchPublishMessageProcessor { + + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private final Logger aclLogger = LoggerFactory.getLogger("acl"); + + private final EventMeshGrpcServer eventMeshGrpcServer; + + public BatchPublishMessageProcessor(EventMeshGrpcServer eventMeshGrpcServer) { + this.eventMeshGrpcServer = eventMeshGrpcServer; + } + + public void process(BatchMessage message, EventEmitter emitter) throws Exception { + RequestHeader requestHeader = message.getHeader(); + + if (!ServiceUtils.validateHeader(requestHeader)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_HEADER_ERR, emitter); + return; + } + + if (!ServiceUtils.validateBatchMessage(message)) { + ServiceUtils.sendResp(StatusCode.EVENTMESH_PROTOCOL_BODY_ERR, emitter); + return; + } + + try { + doAclCheck(message); + } catch (Exception e) { + aclLogger.warn("CLIENT HAS NO PERMISSION,BatchSendMessageProcessor send failed", e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_ACL_ERR, e.getMessage(), emitter); + return; + } + + // control flow rate limit + if (!eventMeshGrpcServer.getMsgRateLimiter() + .tryAcquire(EventMeshConstants.DEFAULT_FASTFAIL_TIMEOUT_IN_MILLISECONDS, TimeUnit.MILLISECONDS)) { + logger.error("Send message speed over limit."); + ServiceUtils.sendResp(StatusCode.EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR, emitter); + return; + } + + String topic = message.getTopic(); + String producerGroup = message.getProducerGroup(); + + String protocolType = requestHeader.getProtocolType(); + ProtocolAdaptor grpcCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); + List cloudEvents = grpcCommandProtocolAdaptor.toBatchCloudEvent(new BatchMessageWrapper(message)); + + for (CloudEvent event: cloudEvents) { + String seqNum = event.getId(); + String uniqueId = event.getExtension(ProtocolKey.UNIQUE_ID).toString(); + ProducerManager producerManager = eventMeshGrpcServer.getProducerManager(); + EventMeshProducer eventMeshProducer = producerManager.getEventMeshProducer(producerGroup); + + SendMessageContext sendMessageContext = new SendMessageContext(seqNum, event, eventMeshProducer, eventMeshGrpcServer); + + long startTime = System.currentTimeMillis(); + eventMeshProducer.send(sendMessageContext, new SendCallback() { + @Override + public void onSuccess(SendResult sendResult) { + long endTime = System.currentTimeMillis(); + logger.info("message|eventMesh2mq|REQ|BatchSend|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", + endTime - startTime, topic, seqNum, uniqueId); + } + + @Override + public void onException(OnExceptionContext context) { + long endTime = System.currentTimeMillis(); + logger.error("message|eventMesh2mq|REQ|BatchSend|send2MQCost={}ms|topic={}|bizSeqNo={}|uniqueId={}", + endTime - startTime, topic, seqNum, uniqueId, context.getException()); + } + }); + } + ServiceUtils.sendResp(StatusCode.SUCCESS, "batch publish success", emitter); + } + + private void doAclCheck(BatchMessage message) throws AclException { + RequestHeader requestHeader = message.getHeader(); + if (eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshServerSecurityEnable) { + String remoteAdd = requestHeader.getIp(); + String user = requestHeader.getUsername(); + String pass = requestHeader.getPassword(); + String subsystem = requestHeader.getSys(); + String topic = message.getTopic(); + Acl.doAclCheckInHttpSend(remoteAdd, user, pass, subsystem, topic, RequestCode.MSG_SEND_ASYNC.getRequestCode()); + } + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java index 98bc04683c..6e71a6274b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ProducerService.java @@ -2,11 +2,13 @@ import io.grpc.stub.StreamObserver; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; import org.apache.eventmesh.runtime.constants.EventMeshConstants; +import org.apache.eventmesh.runtime.core.protocol.grpc.processor.BatchPublishMessageProcessor; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.RequestReplyMessageProcessor; import org.apache.eventmesh.runtime.core.protocol.grpc.processor.SendAsyncMessageProcessor; import org.slf4j.Logger; @@ -14,8 +16,6 @@ import java.util.concurrent.ThreadPoolExecutor; -import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; - public class ProducerService extends PublisherServiceGrpc.PublisherServiceImplBase { private final Logger logger = LoggerFactory.getLogger(ProducerService.class); @@ -67,4 +67,25 @@ public void requestReply(EventMeshMessage request, StreamObserver resp } }); } + + public void batchPublish(BatchMessage request, StreamObserver responseObserver) { + cmdLogger.info("cmd={}|{}|client2eventMesh|from={}|to={}", "BatchPublish", + EventMeshConstants.PROTOCOL_GRPC, request.getHeader().getIp(), + eventMeshGrpcServer.getEventMeshGrpcConfiguration().eventMeshIp); + + EventEmitter emitter = new EventEmitter<>(responseObserver); + threadPoolExecutor.submit(() -> { + BatchPublishMessageProcessor batchPublishMessageProcessor = new BatchPublishMessageProcessor(eventMeshGrpcServer); + try { + batchPublishMessageProcessor.process(request, emitter); + } catch (Exception e) { + logger.error("Error code {}, error message {}", StatusCode.EVENTMESH_BATCH_PUBLISH_ERR.getRetCode(), + StatusCode.EVENTMESH_BATCH_PUBLISH_ERR.getErrMsg(), e); + ServiceUtils.sendResp(StatusCode.EVENTMESH_BATCH_PUBLISH_ERR, e.getMessage(), emitter); + } + }); + } + + public void broadcast(EventMeshMessage request, StreamObserver responseObserver) { + } } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java index 753fa861a4..ff4b2d0382 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/service/ServiceUtils.java @@ -4,6 +4,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.common.protocol.grpc.common.StatusCode; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat; import org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.ClientType; @@ -34,6 +35,20 @@ public static boolean validateMessage(EventMeshMessage message) { && StringUtils.isNotEmpty(message.getTtl()); } + public static boolean validateBatchMessage(BatchMessage batchMessage) { + if (StringUtils.isEmpty(batchMessage.getTopic()) + || StringUtils.isEmpty(batchMessage.getProducerGroup())) { + return false; + } + for (BatchMessage.MessageItem item : batchMessage.getMessageItemList()) { + if (StringUtils.isEmpty(item.getContent()) || StringUtils.isEmpty(item.getSeqNum()) + || StringUtils.isEmpty(item.getTtl()) || StringUtils.isEmpty(item.getUniqueId())) { + return false; + } + } + return true; + } + public static boolean validateSubscription(GrpcType grpcType, Subscription subscription) { if (GrpcType.WEBHOOK.equals(grpcType) && StringUtils.isEmpty(subscription.getUrl())) { return false; diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java index 3dd81115f8..7025717a9e 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java @@ -4,6 +4,7 @@ import io.grpc.ManagedChannelBuilder; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc; import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc.PublisherServiceBlockingStub; @@ -66,6 +67,23 @@ public Response requestReply(EventMeshMessage message, int timeout) { } } + public Response publish(BatchMessage message) { + logger.info("BatchPublish message " + message.toString()); + + BatchMessage enhancedMessage = BatchMessage.newBuilder(message) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setProducerGroup(clientConfig.getProducerGroup()) + .build(); + try { + Response response = publisherClient.batchPublish(enhancedMessage); + logger.info("Received response " + response.toString()); + return response; + } catch (Exception e) { + logger.error("Error in RequestReply message {}, error {}", message, e.getMessage()); + return null; + } + } + public void close() { channel.shutdown(); } From 11ab652b8659e49e04882a79a8a7a39a242c33d3 Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Wed, 5 Jan 2022 15:21:52 -0500 Subject: [PATCH 19/21] removing broadcast API --- .../protocol/grpc/protos/EventmeshGrpc.java | 33 +++--- .../grpc/protos/PublisherServiceGrpc.java | 103 +++--------------- .../src/main/proto/eventmesh-client.proto | 2 - 3 files changed, 29 insertions(+), 109 deletions(-) diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java index 54a1ebdee9..4a93aaf22e 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -127,7 +127,7 @@ public static void registerAllExtensions( "eartbeatItems\030\005 \003(\01327.eventmesh.common.p" + "rotocol.grpc.Heartbeat.HeartbeatItem\032+\n\r" + "HeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030\002 \001(" + - "\t\"\036\n\nClientType\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\266\003\n\020Pu" + + "\t\"\036\n\nClientType\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\315\002\n\020Pu" + "blisherService\022e\n\007publish\0220.eventmesh.co" + "mmon.protocol.grpc.EventMeshMessage\032(.ev" + "entmesh.common.protocol.grpc.Response\022j\n" + @@ -136,23 +136,20 @@ public static void registerAllExtensions( "on.protocol.grpc.Response\022f\n\014batchPublis" + "h\022,.eventmesh.common.protocol.grpc.Batch" + "Message\032(.eventmesh.common.protocol.grpc" + - ".Response\022g\n\tbroadcast\0220.eventmesh.commo" + - "n.protocol.grpc.EventMeshMessage\032(.event" + - "mesh.common.protocol.grpc.Response2\322\002\n\017C" + - "onsumerService\022c\n\tsubscribe\022,.eventmesh." + - "common.protocol.grpc.Subscription\032(.even" + - "tmesh.common.protocol.grpc.Response\022s\n\017s" + - "ubscribeStream\022,.eventmesh.common.protoc" + - "ol.grpc.Subscription\0320.eventmesh.common." + - "protocol.grpc.EventMeshMessage0\001\022e\n\013unsu" + - "bscribe\022,.eventmesh.common.protocol.grpc" + - ".Subscription\032(.eventmesh.common.protoco" + - "l.grpc.Response2t\n\020HeartbeatService\022`\n\th" + - "eartbeat\022).eventmesh.common.protocol.grp" + - "c.Heartbeat\032(.eventmesh.common.protocol." + - "grpc.ResponseBC\n0org.apache.eventmesh.co" + - "mmon.protocol.grpc.protosB\rEventmeshGrpc" + - "P\001b\006proto3" + ".Response2\322\002\n\017ConsumerService\022c\n\tsubscri" + + "be\022,.eventmesh.common.protocol.grpc.Subs" + + "cription\032(.eventmesh.common.protocol.grp" + + "c.Response\022s\n\017subscribeStream\022,.eventmes" + + "h.common.protocol.grpc.Subscription\0320.ev" + + "entmesh.common.protocol.grpc.EventMeshMe" + + "ssage0\001\022e\n\013unsubscribe\022,.eventmesh.commo" + + "n.protocol.grpc.Subscription\032(.eventmesh" + + ".common.protocol.grpc.Response2t\n\020Heartb" + + "eatService\022`\n\theartbeat\022).eventmesh.comm" + + "on.protocol.grpc.Heartbeat\032(.eventmesh.c" + + "ommon.protocol.grpc.ResponseBC\n0org.apac" + + "he.eventmesh.common.protocol.grpc.protos" + + "B\rEventmeshGrpcP\001b\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java index 5730d78b95..46b48425fc 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java @@ -83,28 +83,28 @@ Response> getRequestReplyMethod() { return getRequestReplyMethod; } - private static volatile io.grpc.MethodDescriptor getBatchPublishMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "batchPublish", - requestType = org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage.class, + requestType = BatchMessage.class, responseType = Response.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getBatchPublishMethod() { - io.grpc.MethodDescriptor getBatchPublishMethod; + io.grpc.MethodDescriptor getBatchPublishMethod; if ((getBatchPublishMethod = PublisherServiceGrpc.getBatchPublishMethod) == null) { synchronized (PublisherServiceGrpc.class) { if ((getBatchPublishMethod = PublisherServiceGrpc.getBatchPublishMethod) == null) { PublisherServiceGrpc.getBatchPublishMethod = getBatchPublishMethod = - io.grpc.MethodDescriptor.newBuilder() + io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "eventmesh.common.protocol.grpc.PublisherService", "batchPublish")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage.getDefaultInstance())) + BatchMessage.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( Response.getDefaultInstance())) .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("batchPublish")) @@ -115,38 +115,6 @@ Response> getBatchPublishMethod() { return getBatchPublishMethod; } - private static volatile io.grpc.MethodDescriptor getBroadcastMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "broadcast", - requestType = EventMeshMessage.class, - responseType = Response.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor getBroadcastMethod() { - io.grpc.MethodDescriptor getBroadcastMethod; - if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { - synchronized (PublisherServiceGrpc.class) { - if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) { - PublisherServiceGrpc.getBroadcastMethod = getBroadcastMethod = - io.grpc.MethodDescriptor.newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName( - "eventmesh.common.protocol.grpc.PublisherService", "broadcast")) - .setSampledToLocalTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - EventMeshMessage.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - Response.getDefaultInstance())) - .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("broadcast")) - .build(); - } - } - } - return getBroadcastMethod; - } - /** * Creates a new async stub that supports all call types for the service */ @@ -190,18 +158,11 @@ public void requestReply(EventMeshMessage request, /** */ - public void batchPublish(org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage request, - io.grpc.stub.StreamObserver responseObserver) { + public void batchPublish(BatchMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getBatchPublishMethod(), responseObserver); } - /** - */ - public void broadcast(EventMeshMessage request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getBroadcastMethod(), responseObserver); - } - @Override public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) .addMethod( @@ -222,16 +183,9 @@ public void broadcast(EventMeshMessage request, getBatchPublishMethod(), asyncUnaryCall( new MethodHandlers< - org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage, + BatchMessage, Response>( this, METHODID_BATCH_PUBLISH))) - .addMethod( - getBroadcastMethod(), - asyncUnaryCall( - new MethodHandlers< - EventMeshMessage, - Response>( - this, METHODID_BROADCAST))) .build(); } } @@ -272,19 +226,11 @@ public void requestReply(EventMeshMessage request, /** */ - public void batchPublish(org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage request, - io.grpc.stub.StreamObserver responseObserver) { + public void batchPublish(BatchMessage request, + io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getBatchPublishMethod(), getCallOptions()), request, responseObserver); } - - /** - */ - public void broadcast(EventMeshMessage request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(getBroadcastMethod(), getCallOptions()), request, responseObserver); - } } /** @@ -321,17 +267,10 @@ public Response requestReply(EventMeshMessage request) { /** */ - public Response batchPublish(org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage request) { + public Response batchPublish(BatchMessage request) { return blockingUnaryCall( getChannel(), getBatchPublishMethod(), getCallOptions(), request); } - - /** - */ - public Response broadcast(EventMeshMessage request) { - return blockingUnaryCall( - getChannel(), getBroadcastMethod(), getCallOptions(), request); - } } /** @@ -371,24 +310,15 @@ public com.google.common.util.concurrent.ListenableFuture requestReply /** */ public com.google.common.util.concurrent.ListenableFuture batchPublish( - org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage request) { + BatchMessage request) { return futureUnaryCall( getChannel().newCall(getBatchPublishMethod(), getCallOptions()), request); } - - /** - */ - public com.google.common.util.concurrent.ListenableFuture broadcast( - EventMeshMessage request) { - return futureUnaryCall( - getChannel().newCall(getBroadcastMethod(), getCallOptions()), request); - } } private static final int METHODID_PUBLISH = 0; private static final int METHODID_REQUEST_REPLY = 1; private static final int METHODID_BATCH_PUBLISH = 2; - private static final int METHODID_BROADCAST = 3; private static final class MethodHandlers implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -416,11 +346,7 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv (io.grpc.stub.StreamObserver) responseObserver); break; case METHODID_BATCH_PUBLISH: - serviceImpl.batchPublish((org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_BROADCAST: - serviceImpl.broadcast((EventMeshMessage) request, + serviceImpl.batchPublish((BatchMessage) request, (io.grpc.stub.StreamObserver) responseObserver); break; default: @@ -487,7 +413,6 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { .addMethod(getPublishMethod()) .addMethod(getRequestReplyMethod()) .addMethod(getBatchPublishMethod()) - .addMethod(getBroadcastMethod()) .build(); } } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto index 374ec2a288..911fc11cd7 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto +++ b/eventmesh-protocol-plugin/eventmesh-protocol-grpc/src/main/proto/eventmesh-client.proto @@ -122,8 +122,6 @@ service PublisherService { rpc requestReply(EventMeshMessage) returns (Response); rpc batchPublish(BatchMessage) returns (Response); - - rpc broadcast(EventMeshMessage) returns (Response); } service ConsumerService { From 5362d646484da224f76a38b9baf3ce641469754a Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Fri, 7 Jan 2022 12:37:49 -0500 Subject: [PATCH 20/21] [Issue #417] support cloudevents in GRPC --- .../protocol/grpc/common/ProtocolKey.java | 2 + .../protocol/http/common/ProtocolKey.java | 2 + .../CloudEventsBatchPublishInstance.java | 87 +++++++++ .../CloudEventsPublishInstance.java | 85 +++++++++ .../CloudEventsRequestReplyInstance.java | 86 +++++++++ .../AsyncPublishInstance.java | 2 +- .../BatchPublishInstance.java | 2 +- .../RequestReplyInstance.java | 2 +- .../grpc/sub/CloudEventsAsyncSubscribe.java | 68 +++++++ ...ribe.java => EventmeshAsyncSubscribe.java} | 10 +- .../sub/app/controller/SubController.java | 8 +- .../grpc/sub/app/service/SubService.java | 2 +- .../build.gradle | 1 + .../CloudEventsProtocolAdaptor.java | 20 +- .../grpc/GrpcMessageProtocolResolver.java | 179 ++++++++++++++++++ .../grpc/push/WebhookPushRequest.java | 8 + .../client/grpc/EventMeshGrpcConsumer.java | 50 +++-- .../client/grpc/EventMeshGrpcProducer.java | 30 ++- .../eventmesh/client/grpc/ReceiveMsgHook.java | 7 +- .../grpc/producer/CloudEventProducer.java | 166 ++++++++++++++++ .../client/grpc/util/EventMeshClientUtil.java | 5 +- 21 files changed, 790 insertions(+), 32 deletions(-) create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsBatchPublishInstance.java create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsPublishInstance.java create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsRequestReplyInstance.java rename eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/{ => eventmeshmessage}/AsyncPublishInstance.java (98%) rename eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/{ => eventmeshmessage}/BatchPublishInstance.java (98%) rename eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/{ => eventmeshmessage}/RequestReplyInstance.java (98%) create mode 100644 eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/CloudEventsAsyncSubscribe.java rename eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/{AsyncSubscribe.java => EventmeshAsyncSubscribe.java} (86%) create mode 100644 eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/grpc/GrpcMessageProtocolResolver.java create mode 100644 eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/producer/CloudEventProducer.java diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java index 62d171bc76..0294ce1c54 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java @@ -37,4 +37,6 @@ public class ProtocolKey { public static final String TTL = "ttl"; public static final String PRODUCERGROUP = "producergroup"; public static final String TAG = "tag"; + + public static final String CONTENT_TYPE = "contenttype"; } diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java index e032f1fe9a..1af3b75154 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java @@ -29,6 +29,8 @@ public class ProtocolKey { public static final String PROTOCOL_DESC = "protocoldesc"; + public static final String CONTENT_TYPE = "contenttype"; + public static class ClientInstanceKey { ////////////////////////////////////Protocol layer requester description/////////// public static final String ENV = "env"; diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsBatchPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsBatchPublishInstance.java new file mode 100644 index 0000000000..4c3fcde8e6 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsBatchPublishInstance.java @@ -0,0 +1,87 @@ +/* + * 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.eventmesh.grpc.pub.cloudevents; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.util.Utils; + +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +@Slf4j +public class CloudEventsBatchPublishInstance { + + public static void main(String[] args) throws Exception { + + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + + final String topic = "TEST-TOPIC-GRPC-RR"; + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .producerGroup("EventMeshTest-producerGroup") + .env("env").idc("idc") + .sys("1234").build(); + + EventMeshGrpcProducer eventMeshGrpcProducer = new EventMeshGrpcProducer(eventMeshClientConfig); + + eventMeshGrpcProducer.init(); + + Map content = new HashMap<>(); + content.put("content", "testRequestReplyMessage"); + + List cloudEventList = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + CloudEvent event = CloudEventBuilder.v1() + .withId(UUID.randomUUID().toString()) + .withSubject(topic) + .withSource(URI.create("/")) + .withDataContentType("application/cloudevents+json") + .withType(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME) + .withData(JsonUtils.serialize(content).getBytes(StandardCharsets.UTF_8)) + .withExtension(Constants.EVENTMESH_MESSAGE_CONST_TTL, String.valueOf(4 * 1000)) + .build(); + + cloudEventList.add(event); + } + + eventMeshGrpcProducer.publish(cloudEventList); + Thread.sleep(10000); + try (EventMeshGrpcProducer ignore = eventMeshGrpcProducer) { + // ignore + } + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsPublishInstance.java new file mode 100644 index 0000000000..ec0dd5ed01 --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsPublishInstance.java @@ -0,0 +1,85 @@ +/* + * 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.eventmesh.grpc.pub.cloudevents; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.util.Utils; + +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +@Slf4j +public class CloudEventsPublishInstance { + + // This messageSize is also used in SubService.java (Subscriber) + public static int messageSize = 5; + + public static void main(String[] args) throws Exception { + + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + + final String topic = "TEST-TOPIC-GRPC-ASYNC"; + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .producerGroup("EventMeshTest-producerGroup") + .env("env").idc("idc") + .sys("1234").build(); + + EventMeshGrpcProducer eventMeshGrpcProducer = new EventMeshGrpcProducer(eventMeshClientConfig); + + eventMeshGrpcProducer.init(); + + Map content = new HashMap<>(); + content.put("content", "testAsyncMessage"); + + for (int i = 0; i < messageSize; i++) { + CloudEvent event = CloudEventBuilder.v1() + .withId(UUID.randomUUID().toString()) + .withSubject(topic) + .withSource(URI.create("/")) + .withDataContentType("application/cloudevents+json") + .withType(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME) + .withData(JsonUtils.serialize(content).getBytes(StandardCharsets.UTF_8)) + .withExtension(Constants.EVENTMESH_MESSAGE_CONST_TTL, String.valueOf(4 * 1000)) + .build(); + eventMeshGrpcProducer.publish(event); + Thread.sleep(1000); + } + Thread.sleep(30000); + try (EventMeshGrpcProducer ignore = eventMeshGrpcProducer) { + // ignore + } + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsRequestReplyInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsRequestReplyInstance.java new file mode 100644 index 0000000000..dd7203beaf --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/cloudevents/CloudEventsRequestReplyInstance.java @@ -0,0 +1,86 @@ +/* + * 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.eventmesh.grpc.pub.cloudevents; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.utils.JsonUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.util.Utils; + +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +@Slf4j +public class CloudEventsRequestReplyInstance { + + // This messageSize is also used in SubService.java (Subscriber) + public static int messageSize = 5; + + public static void main(String[] args) throws Exception { + + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + + final String topic = "TEST-TOPIC-GRPC-RR"; + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .producerGroup("EventMeshTest-producerGroup") + .env("env").idc("idc") + .sys("1234").build(); + + EventMeshGrpcProducer eventMeshGrpcProducer = new EventMeshGrpcProducer(eventMeshClientConfig); + + eventMeshGrpcProducer.init(); + + Map content = new HashMap<>(); + content.put("content", "testRequestReplyMessage"); + + for (int i = 0; i < messageSize; i++) { + CloudEvent event = CloudEventBuilder.v1() + .withId(UUID.randomUUID().toString()) + .withSubject(topic) + .withSource(URI.create("/")) + .withDataContentType("application/cloudevents+json") + .withType(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME) + .withData(JsonUtils.serialize(content).getBytes(StandardCharsets.UTF_8)) + .withExtension(Constants.EVENTMESH_MESSAGE_CONST_TTL, String.valueOf(4 * 1000)) + .build(); + + eventMeshGrpcProducer.requestReply(event, 10000); + Thread.sleep(1000); + } + Thread.sleep(30000); + try (EventMeshGrpcProducer ignore = eventMeshGrpcProducer) { + // ignore + } + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/eventmeshmessage/AsyncPublishInstance.java similarity index 98% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/eventmeshmessage/AsyncPublishInstance.java index 53dd34d8b4..552273b284 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/AsyncPublishInstance.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/eventmeshmessage/AsyncPublishInstance.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.grpc.pub; +package org.apache.eventmesh.grpc.pub.eventmeshmessage; import lombok.extern.slf4j.Slf4j; import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/BatchPublishInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/eventmeshmessage/BatchPublishInstance.java similarity index 98% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/BatchPublishInstance.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/eventmeshmessage/BatchPublishInstance.java index 6f9edefa92..5f4c8fb89c 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/BatchPublishInstance.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/eventmeshmessage/BatchPublishInstance.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.grpc.pub; +package org.apache.eventmesh.grpc.pub.eventmeshmessage; import lombok.extern.slf4j.Slf4j; import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/RequestReplyInstance.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/eventmeshmessage/RequestReplyInstance.java similarity index 98% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/RequestReplyInstance.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/eventmeshmessage/RequestReplyInstance.java index 2e964527ef..8273ec2d2b 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/RequestReplyInstance.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/pub/eventmeshmessage/RequestReplyInstance.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.grpc.pub; +package org.apache.eventmesh.grpc.pub.eventmeshmessage; import lombok.extern.slf4j.Slf4j; import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/CloudEventsAsyncSubscribe.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/CloudEventsAsyncSubscribe.java new file mode 100644 index 0000000000..8730be65ea --- /dev/null +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/CloudEventsAsyncSubscribe.java @@ -0,0 +1,68 @@ +package org.apache.eventmesh.grpc.sub; + +import io.cloudevents.CloudEvent; +import lombok.extern.slf4j.Slf4j; +import org.apache.eventmesh.client.grpc.EventMeshGrpcConsumer; +import org.apache.eventmesh.client.grpc.ReceiveMsgHook; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem; +import org.apache.eventmesh.util.Utils; + +import java.util.Optional; +import java.util.Properties; + +@Slf4j +public class CloudEventsAsyncSubscribe implements ReceiveMsgHook { + + public static CloudEventsAsyncSubscribe handler = new CloudEventsAsyncSubscribe(); + + public static void main(String[] args) { + Properties properties = Utils.readPropertiesFile("application.properties"); + final String eventMeshIp = properties.getProperty("eventmesh.ip"); + final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port"); + + final String topic = "TEST-TOPIC-GRPC-ASYNC"; + + EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder() + .serverAddr(eventMeshIp) + .serverPort(Integer.parseInt(eventMeshGrpcPort)) + .consumerGroup("EventMeshTest-consumerGroup") + .env("env").idc("idc") + .sys("1234").build(); + + SubscriptionItem subscriptionItem = SubscriptionItem.newBuilder() + .setTopic(topic) + .setMode(SubscriptionItem.SubscriptionMode.CLUSTERING) + .setType(SubscriptionItem.SubscriptionType.ASYNC) + .build(); + + Subscription subscription = Subscription.newBuilder() + .addSubscriptionItems(subscriptionItem) + .build(); + + + EventMeshGrpcConsumer eventMeshGrpcConsumer = new EventMeshGrpcConsumer(eventMeshClientConfig); + + eventMeshGrpcConsumer.init(); + + eventMeshGrpcConsumer.registerListener(handler); + + eventMeshGrpcConsumer.subscribeStream(subscription); + + + //eventMeshGrpcConsumer.unsubscribe(subscription); + } + + @Override + public Optional handle(CloudEvent msg) { + log.info("receive async msg====================={}", msg); + return Optional.empty(); + } + + @Override + public String getProtocolType() { + return EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME; + } +} diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/EventmeshAsyncSubscribe.java similarity index 86% rename from eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java rename to eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/EventmeshAsyncSubscribe.java index addc095c6a..939969e02c 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/AsyncSubscribe.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/EventmeshAsyncSubscribe.java @@ -4,6 +4,7 @@ import org.apache.eventmesh.client.grpc.EventMeshGrpcConsumer; import org.apache.eventmesh.client.grpc.ReceiveMsgHook; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.tcp.common.EventMeshCommon; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem; @@ -13,9 +14,9 @@ import java.util.Properties; @Slf4j -public class AsyncSubscribe implements ReceiveMsgHook { +public class EventmeshAsyncSubscribe implements ReceiveMsgHook { - public static AsyncSubscribe handler = new AsyncSubscribe(); + public static EventmeshAsyncSubscribe handler = new EventmeshAsyncSubscribe(); public static void main(String[] args) { Properties properties = Utils.readPropertiesFile("application.properties"); @@ -59,4 +60,9 @@ public Optional handle(EventMeshMessage msg) { log.info("receive async msg====================={}", msg); return Optional.empty(); } + + @Override + public String getProtocolType() { + return EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME; + } } diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/controller/SubController.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/controller/SubController.java index cb5b8489ed..002bcb19c1 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/controller/SubController.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/controller/SubController.java @@ -19,7 +19,6 @@ import io.cloudevents.CloudEvent; import io.cloudevents.core.provider.EventFormatProvider; -import io.cloudevents.jackson.JsonFormat; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.eventmesh.client.tcp.common.EventMeshCommon; @@ -47,11 +46,14 @@ public class SubController { @RequestMapping(value = "/test", method = RequestMethod.POST) public String subTest(HttpServletRequest request) { + String protocolType = request.getHeader(ProtocolKey.PROTOCOL_TYPE); String content = request.getParameter("content"); log.info("=======receive message======= {}", content); Map contentMap = JsonUtils.deserialize(content, HashMap.class); - if (StringUtils.equals(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME, contentMap.get(ProtocolKey.PROTOCOL_TYPE))) { - CloudEvent event = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) + if (StringUtils.equals(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME, protocolType)) { + String contentType = request.getHeader(ProtocolKey.CONTENT_TYPE); + + CloudEvent event = EventFormatProvider.getInstance().resolveFormat(contentType) .deserialize(content.getBytes(StandardCharsets.UTF_8)); String data = new String(event.getData().toBytes(), StandardCharsets.UTF_8); log.info("=======receive data======= {}", data); diff --git a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java index 4bc755c4d8..e19419c0da 100644 --- a/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java +++ b/eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/app/service/SubService.java @@ -26,7 +26,7 @@ import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionMode; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.SubscriptionType; import org.apache.eventmesh.common.utils.IPUtils; -import org.apache.eventmesh.grpc.pub.AsyncPublishInstance; +import org.apache.eventmesh.grpc.pub.eventmeshmessage.AsyncPublishInstance; import org.apache.eventmesh.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle index 7f77c3db21..ed6c77b92e 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/build.gradle @@ -20,6 +20,7 @@ dependencies { implementation "io.cloudevents:cloudevents-core" implementation "com.google.guava:guava" implementation "io.cloudevents:cloudevents-json-jackson" + implementation "io.grpc:grpc-protobuf:1.15.0" testImplementation "junit:junit" } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java index c54a88e7fa..86babadc31 100644 --- a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java @@ -18,7 +18,11 @@ package org.apache.eventmesh.protocol.cloudevents; import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.EventMeshMessage; import org.apache.eventmesh.common.protocol.ProtocolTransportObject; +import org.apache.eventmesh.common.protocol.grpc.common.BatchMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; import org.apache.eventmesh.common.protocol.http.HttpCommand; import org.apache.eventmesh.common.protocol.http.body.Body; import org.apache.eventmesh.common.protocol.http.common.RequestCode; @@ -26,6 +30,7 @@ import org.apache.eventmesh.common.protocol.tcp.Package; import org.apache.eventmesh.protocol.api.ProtocolAdaptor; import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException; +import org.apache.eventmesh.protocol.cloudevents.resolver.grpc.GrpcMessageProtocolResolver; import org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageBatchProtocolResolver; import org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageBatchV2ProtocolResolver; import org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageRequestProtocolResolver; @@ -69,6 +74,10 @@ public CloudEvent toCloudEvent(ProtocolTransportObject cloudEvent) throws Protoc String requestCode = ((HttpCommand) cloudEvent).getRequestCode(); return deserializeHttpProtocol(requestCode, header, body); + } else if (cloudEvent instanceof EventMeshMessageWrapper) { + org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage eventMeshMessage + = ((EventMeshMessageWrapper) cloudEvent).getMessage(); + return GrpcMessageProtocolResolver.buildEvent(eventMeshMessage); } else { throw new ProtocolHandleException(String.format("protocol class: %s", cloudEvent.getClass())); } @@ -98,8 +107,13 @@ private CloudEvent deserializeHttpProtocol(String requestCode, @Override public List toBatchCloudEvent(ProtocolTransportObject protocol) - throws ProtocolHandleException { - return null; + throws ProtocolHandleException { + if (protocol instanceof BatchMessageWrapper) { + BatchMessage batchMessage = ((BatchMessageWrapper) protocol).getMessage(); + return GrpcMessageProtocolResolver.buildBatchEvents(batchMessage); + } else { + throw new ProtocolHandleException(String.format("protocol class: %s", protocol.getClass())); + } } @Override @@ -130,6 +144,8 @@ public Map toMap() { String.format("DateContentType:%s is not supported", dataContentType)); pkg.setBody(eventFormat.serialize(cloudEvent)); return pkg; + } else if (StringUtils.equals("grpc", protocolDesc)){ + return GrpcMessageProtocolResolver.buildEventMeshMessage(cloudEvent); } else { throw new ProtocolHandleException(String.format("Unsupported protocolDesc: %s", protocolDesc)); } diff --git a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/grpc/GrpcMessageProtocolResolver.java b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/grpc/GrpcMessageProtocolResolver.java new file mode 100644 index 0000000000..3a2d3def4b --- /dev/null +++ b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/grpc/GrpcMessageProtocolResolver.java @@ -0,0 +1,179 @@ +package org.apache.eventmesh.protocol.cloudevents.resolver.grpc; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.cloudevents.core.format.EventFormat; +import io.cloudevents.core.provider.EventFormatProvider; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.common.protocol.grpc.common.EventMeshMessageWrapper; +import org.apache.eventmesh.common.protocol.grpc.common.ProtocolKey; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; + +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +public class GrpcMessageProtocolResolver { + + public static CloudEvent buildEvent(EventMeshMessage message) { + String cloudEventJson = message.getContent(); + + String contentType = message.getPropertiesOrDefault(ProtocolKey.CONTENT_TYPE, "application/cloudevents+json"); + EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(contentType); + CloudEvent event = eventFormat.deserialize(cloudEventJson.getBytes(StandardCharsets.UTF_8)); + + RequestHeader header = message.getHeader(); + String env = StringUtils.isEmpty(header.getEnv()) ? event.getExtension(ProtocolKey.ENV).toString() : header.getEnv(); + String idc = StringUtils.isEmpty(header.getIdc()) ? event.getExtension(ProtocolKey.IDC).toString() : header.getIdc(); + String ip = StringUtils.isEmpty(header.getIp()) ? event.getExtension(ProtocolKey.IP).toString() : header.getIp(); + String pid = StringUtils.isEmpty(header.getPid()) ? event.getExtension(ProtocolKey.PID).toString() : header.getPid(); + String sys = StringUtils.isEmpty(header.getSys()) ? event.getExtension(ProtocolKey.SYS).toString() : header.getSys(); + + String language = StringUtils.isEmpty(header.getLanguage()) + ? event.getExtension(ProtocolKey.LANGUAGE).toString() : header.getLanguage(); + + String protocolType = StringUtils.isEmpty(header.getProtocolType()) + ? event.getExtension(ProtocolKey.PROTOCOL_TYPE).toString() : header.getProtocolType(); + + String protocolDesc = StringUtils.isEmpty(header.getProtocolDesc()) + ? event.getExtension(ProtocolKey.PROTOCOL_DESC).toString() : header.getProtocolDesc(); + + String protocolVersion = StringUtils.isEmpty(header.getProtocolVersion()) + ? event.getExtension(ProtocolKey.PROTOCOL_VERSION).toString() : header.getProtocolVersion(); + + String uniqueId = StringUtils.isEmpty(message.getUniqueId()) + ? event.getExtension(ProtocolKey.UNIQUE_ID).toString() : message.getUniqueId(); + + String seqNum = StringUtils.isEmpty(message.getSeqNum()) + ? event.getExtension(ProtocolKey.SEQ_NUM).toString() : header.getProtocolVersion(); + + String username = StringUtils.isEmpty(header.getUsername()) ? event.getExtension(ProtocolKey.USERNAME).toString() : header.getUsername(); + String passwd = StringUtils.isEmpty(header.getPassword()) ? event.getExtension(ProtocolKey.PASSWD).toString() : header.getPassword(); + String ttl = StringUtils.isEmpty(message.getTtl()) ? event.getExtension(ProtocolKey.TTL).toString() : message.getTtl(); + + String producerGroup = StringUtils.isEmpty(message.getProducerGroup()) + ? event.getExtension(ProtocolKey.PRODUCERGROUP).toString() : message.getProducerGroup(); + + return CloudEventBuilder.from(event) + .withExtension(ProtocolKey.ENV, env) + .withExtension(ProtocolKey.IDC, idc) + .withExtension(ProtocolKey.IP, ip) + .withExtension(ProtocolKey.PID, pid) + .withExtension(ProtocolKey.SYS, sys) + .withExtension(ProtocolKey.USERNAME, username) + .withExtension(ProtocolKey.PASSWD, passwd) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .withExtension(ProtocolKey.SEQ_NUM, seqNum) + .withExtension(ProtocolKey.UNIQUE_ID, uniqueId) + .withExtension(ProtocolKey.PRODUCERGROUP, producerGroup) + .withExtension(ProtocolKey.TTL, ttl).build(); + } + + public static EventMeshMessageWrapper buildEventMeshMessage(CloudEvent cloudEvent) { + String env = cloudEvent.getExtension(ProtocolKey.ENV) == null ? null : cloudEvent.getExtension(ProtocolKey.ENV).toString(); + String idc = cloudEvent.getExtension(ProtocolKey.IDC) == null ? null : cloudEvent.getExtension(ProtocolKey.IDC).toString(); + String ip = cloudEvent.getExtension(ProtocolKey.IP) == null ? null : cloudEvent.getExtension(ProtocolKey.IP).toString(); + String pid = cloudEvent.getExtension(ProtocolKey.PID) == null ? null : cloudEvent.getExtension(ProtocolKey.PID).toString(); + String sys = cloudEvent.getExtension(ProtocolKey.SYS) == null ? null : cloudEvent.getExtension(ProtocolKey.SYS).toString(); + String userName = cloudEvent.getExtension(ProtocolKey.USERNAME) == null ? null : cloudEvent.getExtension(ProtocolKey.USERNAME).toString(); + String passwd = cloudEvent.getExtension(ProtocolKey.PASSWD) == null ? null : cloudEvent.getExtension(ProtocolKey.PASSWD).toString(); + String language = cloudEvent.getExtension(ProtocolKey.LANGUAGE) == null ? null : cloudEvent.getExtension(ProtocolKey.LANGUAGE).toString(); + String protocol = cloudEvent.getExtension(ProtocolKey.PROTOCOL_TYPE) == null ? null : + cloudEvent.getExtension(ProtocolKey.PROTOCOL_TYPE).toString(); + String protocolDesc = cloudEvent.getExtension(ProtocolKey.PROTOCOL_DESC) == null ? null : + cloudEvent.getExtension(ProtocolKey.PROTOCOL_DESC).toString(); + String protocolVersion = cloudEvent.getExtension(ProtocolKey.PROTOCOL_VERSION) == null ? null : + cloudEvent.getExtension(ProtocolKey.PROTOCOL_VERSION).toString(); + String seqNum = cloudEvent.getExtension(ProtocolKey.SEQ_NUM) == null ? null : cloudEvent.getExtension(ProtocolKey.SEQ_NUM).toString(); + String uniqueId = cloudEvent.getExtension(ProtocolKey.UNIQUE_ID) == null ? null : cloudEvent.getExtension(ProtocolKey.UNIQUE_ID).toString(); + String producerGroup = cloudEvent.getExtension(ProtocolKey.PRODUCERGROUP) == null ? null : + cloudEvent.getExtension(ProtocolKey.PRODUCERGROUP).toString(); + String ttl = cloudEvent.getExtension(ProtocolKey.TTL) == null ? null : cloudEvent.getExtension(ProtocolKey.TTL).toString(); + + RequestHeader header = RequestHeader.newBuilder() + .setEnv(env).setIdc(idc) + .setIp(ip).setPid(pid) + .setSys(sys).setUsername(userName).setPassword(passwd) + .setLanguage(language).setProtocolType(protocol) + .setProtocolDesc(protocolDesc).setProtocolVersion(protocolVersion) + .build(); + + String contentType = cloudEvent.getDataContentType(); + EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(contentType); + + EventMeshMessage.Builder messageBuilder = EventMeshMessage.newBuilder() + .setHeader(header) + .setContent(new String( eventFormat.serialize(cloudEvent), StandardCharsets.UTF_8)) + .setProducerGroup(producerGroup) + .setSeqNum(seqNum) + .setUniqueId(uniqueId) + .setTopic(cloudEvent.getSubject()) + .setTtl(ttl) + .putProperties(ProtocolKey.CONTENT_TYPE, contentType) ; + + for (String key : cloudEvent.getExtensionNames()) { + messageBuilder.putProperties(key, cloudEvent.getExtension(key).toString()); + } + + EventMeshMessage eventMeshMessage = messageBuilder.build(); + + return new EventMeshMessageWrapper(eventMeshMessage); + } + + public static List buildBatchEvents(BatchMessage batchMessage) { + List cloudEvents = new ArrayList<>(); + + RequestHeader header = batchMessage.getHeader(); + + for (BatchMessage.MessageItem item : batchMessage.getMessageItemList()) { + String cloudEventJson = item.getContent(); + + String contentType = item.getPropertiesOrDefault(ProtocolKey.CONTENT_TYPE, "application/cloudevents+json"); + EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(contentType); + CloudEvent event = eventFormat.deserialize(cloudEventJson.getBytes(StandardCharsets.UTF_8)); + + String env = StringUtils.isEmpty(header.getEnv()) ? event.getExtension(ProtocolKey.ENV).toString() : header.getEnv(); + String idc = StringUtils.isEmpty(header.getIdc()) ? event.getExtension(ProtocolKey.IDC).toString() : header.getIdc(); + String ip = StringUtils.isEmpty(header.getIp()) ? event.getExtension(ProtocolKey.IP).toString() : header.getIp(); + String pid = StringUtils.isEmpty(header.getPid()) ? event.getExtension(ProtocolKey.PID).toString() : header.getPid(); + String sys = StringUtils.isEmpty(header.getSys()) ? event.getExtension(ProtocolKey.SYS).toString() : header.getSys(); + + String language = StringUtils.isEmpty(header.getLanguage()) + ? event.getExtension(ProtocolKey.LANGUAGE).toString() : header.getLanguage(); + + String protocolType = StringUtils.isEmpty(header.getProtocolType()) + ? event.getExtension(ProtocolKey.PROTOCOL_TYPE).toString() : header.getProtocolType(); + + String protocolDesc = StringUtils.isEmpty(header.getProtocolDesc()) + ? event.getExtension(ProtocolKey.PROTOCOL_DESC).toString() : header.getProtocolDesc(); + + String protocolVersion = StringUtils.isEmpty(header.getProtocolVersion()) + ? event.getExtension(ProtocolKey.PROTOCOL_VERSION).toString() : header.getProtocolVersion(); + + String username = StringUtils.isEmpty(header.getUsername()) ? event.getExtension(ProtocolKey.USERNAME).toString() : header.getUsername(); + String passwd = StringUtils.isEmpty(header.getPassword()) ? event.getExtension(ProtocolKey.PASSWD).toString() : header.getPassword(); + + CloudEvent enhancedEvent = CloudEventBuilder.from(event) + .withExtension(ProtocolKey.ENV, env) + .withExtension(ProtocolKey.IDC, idc) + .withExtension(ProtocolKey.IP, ip) + .withExtension(ProtocolKey.PID, pid) + .withExtension(ProtocolKey.SYS, sys) + .withExtension(ProtocolKey.USERNAME, username) + .withExtension(ProtocolKey.PASSWD, passwd) + .withExtension(ProtocolKey.LANGUAGE, language) + .withExtension(ProtocolKey.PROTOCOL_TYPE, protocolType) + .withExtension(ProtocolKey.PROTOCOL_DESC, protocolDesc) + .withExtension(ProtocolKey.PROTOCOL_VERSION, protocolVersion) + .build(); + + cloudEvents.add(enhancedEvent); + } + return cloudEvents; + } +} diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java index 46d22b0fd9..8dd613b8c6 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java @@ -25,6 +25,7 @@ import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.http.body.message.PushMessageRequestBody; import org.apache.eventmesh.common.protocol.http.common.ClientRetCode; import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; @@ -104,6 +105,13 @@ public void tryPushRequest() { builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHENV, eventMeshGrpcConfiguration.eventMeshEnv); builder.addHeader(ProtocolKey.EventMeshInstanceKey.EVENTMESHIDC, eventMeshGrpcConfiguration.eventMeshIDC); + RequestHeader requestHeader = eventMeshMessage.getHeader(); + builder.addHeader(ProtocolKey.PROTOCOL_TYPE, requestHeader.getProtocolType()); + builder.addHeader(ProtocolKey.PROTOCOL_DESC, requestHeader.getProtocolDesc()); + builder.addHeader(ProtocolKey.PROTOCOL_VERSION, requestHeader.getProtocolVersion()); + builder.addHeader(ProtocolKey.CONTENT_TYPE, eventMeshMessage.getPropertiesOrDefault(ProtocolKey.CONTENT_TYPE, + "application/cloudevents+json")); + List body = new ArrayList<>(); body.add(new BasicNameValuePair(PushMessageRequestBody.CONTENT, eventMeshMessage.getContent())); body.add(new BasicNameValuePair(PushMessageRequestBody.BIZSEQNO, eventMeshMessage.getSeqNum())); diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java index 0af2e1229a..367cd23c2e 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcConsumer.java @@ -1,6 +1,9 @@ package org.apache.eventmesh.client.grpc; import com.google.common.util.concurrent.ThreadFactoryBuilder; +import io.cloudevents.CloudEvent; +import io.cloudevents.core.provider.EventFormatProvider; +import io.cloudevents.jackson.JsonFormat; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import org.apache.commons.lang3.StringUtils; @@ -16,9 +19,12 @@ import org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader; import org.apache.eventmesh.common.protocol.grpc.protos.Response; import org.apache.eventmesh.common.protocol.grpc.protos.Subscription; +import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.awt.Event; +import java.nio.charset.StandardCharsets; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -38,7 +44,7 @@ public class EventMeshGrpcConsumer implements AutoCloseable { private ConsumerServiceBlockingStub consumerClient; private HeartbeatServiceBlockingStub heartbeatClient; - private ReceiveMsgHook listener; + private ReceiveMsgHook listener; private final List listenerThreads = new LinkedList<>(); @@ -68,7 +74,7 @@ public Response subscribe(Subscription subscription) { addSubscription(subscription); Subscription enhancedSubscription = Subscription.newBuilder(subscription) - .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig, EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME)) .setConsumerGroup(clientConfig.getConsumerGroup()) .build(); try { @@ -87,7 +93,7 @@ public void subscribeStream(Subscription subscription) { addSubscription(subscription); Subscription enhancedSubscription = Subscription.newBuilder(subscription) - .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig, EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME)) .setConsumerGroup(clientConfig.getConsumerGroup()) .build(); Iterator msgIterator; @@ -98,7 +104,7 @@ public void subscribeStream(Subscription subscription) { return; } - ListenerThread listenerThread = new ListenerThread(msgIterator, listener); + ListenerThread listenerThread = new ListenerThread(msgIterator, listener, listener.getProtocolType()); listenerThreads.add(listenerThread); listenerThread.start(); } @@ -122,7 +128,7 @@ public Response unsubscribe(Subscription subscription) { removeSubscription(subscription); Subscription enhancedSubscription = Subscription.newBuilder(subscription) - .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig, EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME)) .setConsumerGroup(clientConfig.getConsumerGroup()) .build(); @@ -136,14 +142,14 @@ public Response unsubscribe(Subscription subscription) { } } - public void registerListener(ReceiveMsgHook listener) { + public void registerListener(ReceiveMsgHook listener) { if (this.listener == null) { this.listener = listener; } } private void heartBeat() { - RequestHeader header = EventMeshClientUtil.buildHeader(clientConfig); + RequestHeader header = EventMeshClientUtil.buildHeader(clientConfig, EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME); scheduler.scheduleAtFixedRate(() -> { if (subscriptionMap.isEmpty()) { return; @@ -184,14 +190,17 @@ public void close() { scheduler.shutdown(); } - static class ListenerThread extends Thread { + static class ListenerThread extends Thread { private final Iterator msgIterator; - private final ReceiveMsgHook listener; + private final ReceiveMsgHook listener; - ListenerThread(Iterator msgIterator, ReceiveMsgHook listener) { + private String protocolType; + + ListenerThread(Iterator msgIterator, ReceiveMsgHook listener, String protocolType) { this.msgIterator = msgIterator; this.listener = listener; + this.protocolType = protocolType; } public void run() { @@ -199,11 +208,30 @@ public void run() { try { while (msgIterator.hasNext()) { logger.info("sdk received message "); - listener.handle(msgIterator.next()); + + EventMeshMessage eventMeshMessage = msgIterator.next(); + T msg = buildMessage(eventMeshMessage); + if (msg != null) { + listener.handle(msg); + } } } catch (Throwable t) { logger.warn("Error in handling message. {}", t.getMessage()); } } + + private T buildMessage(EventMeshMessage eventMeshMessage) { + try { + if (EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME.equals(protocolType)) { + String contentType = eventMeshMessage.getPropertiesOrDefault(ProtocolKey.CONTENT_TYPE, JsonFormat.CONTENT_TYPE); + return (T) EventFormatProvider.getInstance().resolveFormat(contentType) + .deserialize(eventMeshMessage.getContent().getBytes(StandardCharsets.UTF_8)); + } + return (T) eventMeshMessage; + } catch (Throwable t) { + logger.warn("Error in building message. {}", t.getMessage()); + return null; + } + } } } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java index 7025717a9e..a521fb890c 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/EventMeshGrpcProducer.java @@ -1,8 +1,10 @@ package org.apache.eventmesh.client.grpc; +import io.cloudevents.CloudEvent; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.grpc.producer.CloudEventProducer; import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; @@ -12,16 +14,22 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.List; + public class EventMeshGrpcProducer implements AutoCloseable { private static final Logger logger = LoggerFactory.getLogger(EventMeshGrpcProducer.class); + private final static String PROTOCOL_TYPE = "eventmeshmessage"; + private final EventMeshGrpcClientConfig clientConfig; private ManagedChannel channel; private PublisherServiceBlockingStub publisherClient; + private CloudEventProducer cloudEventProducer; + public EventMeshGrpcProducer(EventMeshGrpcClientConfig clientConfig) { this.clientConfig = clientConfig; } @@ -30,13 +38,27 @@ public void init() { channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort()) .usePlaintext().build(); publisherClient = PublisherServiceGrpc.newBlockingStub(channel); + + cloudEventProducer = new CloudEventProducer(clientConfig, publisherClient); + } + + public Response publish(CloudEvent cloudEvent) { + return cloudEventProducer.publish(cloudEvent); + } + + public Response publish(List cloudEventList) { + return cloudEventProducer.publish(cloudEventList); + } + + public Response requestReply(CloudEvent cloudEvent, int timeout) { + return cloudEventProducer.requestReply(cloudEvent, timeout); } public Response publish(EventMeshMessage message) { logger.info("Publish message " + message.toString()); EventMeshMessage enhancedMessage = EventMeshMessage.newBuilder(message) - .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig, PROTOCOL_TYPE)) .setProducerGroup(clientConfig.getProducerGroup()) .build(); try { @@ -53,7 +75,7 @@ public Response requestReply(EventMeshMessage message, int timeout) { logger.info("RequestReply message " + message.toString()); EventMeshMessage enhancedMessage = EventMeshMessage.newBuilder(message) - .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig, PROTOCOL_TYPE)) .setProducerGroup(clientConfig.getProducerGroup()) .setTtl(String.valueOf(timeout)) .build(); @@ -71,7 +93,7 @@ public Response publish(BatchMessage message) { logger.info("BatchPublish message " + message.toString()); BatchMessage enhancedMessage = BatchMessage.newBuilder(message) - .setHeader(EventMeshClientUtil.buildHeader(clientConfig)) + .setHeader(EventMeshClientUtil.buildHeader(clientConfig, PROTOCOL_TYPE)) .setProducerGroup(clientConfig.getProducerGroup()) .build(); try { @@ -79,7 +101,7 @@ public Response publish(BatchMessage message) { logger.info("Received response " + response.toString()); return response; } catch (Exception e) { - logger.error("Error in RequestReply message {}, error {}", message, e.getMessage()); + logger.error("Error in BatchPublish message {}, error {}", message, e.getMessage()); return null; } } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/ReceiveMsgHook.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/ReceiveMsgHook.java index 86ddd278c7..507a7cb7c3 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/ReceiveMsgHook.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/ReceiveMsgHook.java @@ -19,8 +19,7 @@ import java.util.Optional; -@FunctionalInterface -public interface ReceiveMsgHook { +public interface ReceiveMsgHook { /** * Handle the received message, return the response message. @@ -28,6 +27,8 @@ public interface ReceiveMsgHook { * @param msg * @return */ - Optional handle(EventMeshMessage msg); + Optional handle(T msg); + + String getProtocolType(); } diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/producer/CloudEventProducer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/producer/CloudEventProducer.java new file mode 100644 index 0000000000..3941d94c9f --- /dev/null +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/producer/CloudEventProducer.java @@ -0,0 +1,166 @@ +package org.apache.eventmesh.client.grpc.producer; + +import io.cloudevents.CloudEvent; +import io.cloudevents.core.builder.CloudEventBuilder; +import io.cloudevents.core.provider.EventFormatProvider; +import org.apache.commons.lang3.StringUtils; +import org.apache.eventmesh.client.grpc.EventMeshGrpcProducer; +import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; +import org.apache.eventmesh.client.grpc.util.EventMeshClientUtil; +import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.BatchMessage.MessageItem; +import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage; +import org.apache.eventmesh.common.protocol.grpc.protos.PublisherServiceGrpc.PublisherServiceBlockingStub; +import org.apache.eventmesh.common.protocol.grpc.protos.Response; +import org.apache.eventmesh.common.protocol.grpc.common.ProtocolKey; +import org.apache.eventmesh.common.utils.IPUtils; +import org.apache.eventmesh.common.utils.RandomStringUtils; +import org.apache.eventmesh.common.utils.ThreadUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.stream.Collectors; + +public class CloudEventProducer { + private static final Logger logger = LoggerFactory.getLogger(EventMeshGrpcProducer.class); + + private final static String PROTOCOL_TYPE = "cloudevents"; + + private final EventMeshGrpcClientConfig clientConfig; + + private final PublisherServiceBlockingStub publisherClient; + + public CloudEventProducer(EventMeshGrpcClientConfig clientConfig, PublisherServiceBlockingStub publisherClient) { + this.clientConfig = clientConfig; + this.publisherClient = publisherClient; + } + + public Response publish(CloudEvent cloudEvent) { + logger.info("Publish message " + cloudEvent.toString()); + CloudEvent enhanceEvent = enhanceCloudEvent(cloudEvent, null); + + EventMeshMessage enhancedMessage = buildEventMeshMessage(enhanceEvent); + + try { + Response response = publisherClient.publish(enhancedMessage); + logger.info("Received response " + response.toString()); + return response; + } catch (Exception e) { + logger.error("Error in publishing message {}, error {}", cloudEvent, e.getMessage()); + return null; + } + } + + public Response requestReply(CloudEvent cloudEvent, int timeout) { + logger.info("RequestReply message " + cloudEvent.toString()); + CloudEvent enhanceEvent = enhanceCloudEvent(cloudEvent, String.valueOf(timeout)); + + EventMeshMessage enhancedMessage = buildEventMeshMessage(enhanceEvent); + try { + Response response = publisherClient.requestReply(enhancedMessage); + logger.info("Received response " + response.toString()); + return response; + } catch (Exception e) { + logger.error("Error in RequestReply message {}, error {}", cloudEvent, e.getMessage()); + return null; + } + } + + public Response publish(List events) { + logger.info("BatchPublish message, batch size=" + events.size()); + + if (events.size() == 0) { + return null; + } + List enhancedEvents = events.stream() + .map(event -> enhanceCloudEvent(event, null)) + .collect(Collectors.toList()); + + BatchMessage enhancedMessage = buildBatchMessage(enhancedEvents); + try { + Response response = publisherClient.batchPublish(enhancedMessage); + logger.info("Received response " + response.toString()); + return response; + } catch (Exception e) { + logger.error("Error in BatchPublish message {}, error {}", events, e.getMessage()); + return null; + } + } + + private CloudEvent enhanceCloudEvent(final CloudEvent cloudEvent, String timeout) { + CloudEventBuilder builder = CloudEventBuilder.from(cloudEvent) + .withExtension(ProtocolKey.ENV, clientConfig.getEnv()) + .withExtension(ProtocolKey.IDC, clientConfig.getIdc()) + .withExtension(ProtocolKey.IP, IPUtils.getLocalAddress()) + .withExtension(ProtocolKey.PID, Long.toString(ThreadUtils.getPID())) + .withExtension(ProtocolKey.SYS, clientConfig.getSys()) + .withExtension(ProtocolKey.LANGUAGE, "JAVA") + .withExtension(ProtocolKey.PROTOCOL_TYPE, PROTOCOL_TYPE) + .withExtension(ProtocolKey.PROTOCOL_DESC, cloudEvent.getSpecVersion().name()) + .withExtension(ProtocolKey.PROTOCOL_VERSION, cloudEvent.getSpecVersion().toString()) + .withExtension(ProtocolKey.UNIQUE_ID, RandomStringUtils.generateNum(30)) + .withExtension(ProtocolKey.SEQ_NUM, RandomStringUtils.generateNum(30)) + .withExtension(ProtocolKey.USERNAME, clientConfig.getUserName()) + .withExtension(ProtocolKey.PASSWD, clientConfig.getPassword()) + .withExtension(ProtocolKey.PRODUCERGROUP, clientConfig.getProducerGroup()); + + if (timeout != null) { + builder.withExtension(Constants.EVENTMESH_MESSAGE_CONST_TTL, timeout); + } + return builder.build(); + } + + private EventMeshMessage buildEventMeshMessage(CloudEvent cloudEvent) { + String contentType = StringUtils.isEmpty(cloudEvent.getDataContentType()) ? "application/cloudevents+json" + : cloudEvent.getDataContentType(); + byte[] bodyByte = EventFormatProvider.getInstance().resolveFormat(contentType) + .serialize(cloudEvent); + String content = new String(bodyByte, StandardCharsets.UTF_8); + String ttl = cloudEvent.getExtension(Constants.EVENTMESH_MESSAGE_CONST_TTL) == null ? "4000" + : cloudEvent.getExtension(Constants.EVENTMESH_MESSAGE_CONST_TTL).toString(); + + return EventMeshMessage.newBuilder() + .setHeader(EventMeshClientUtil.buildHeader(clientConfig, PROTOCOL_TYPE)) + .setProducerGroup(clientConfig.getProducerGroup()) + .setTopic(cloudEvent.getSubject()) + .setTtl(ttl) + .setSeqNum(cloudEvent.getExtension(ProtocolKey.SEQ_NUM).toString()) + .setUniqueId(cloudEvent.getExtension(ProtocolKey.UNIQUE_ID).toString()) + .setContent(content) + .putProperties(ProtocolKey.CONTENT_TYPE, contentType) + .build(); + } + + private BatchMessage buildBatchMessage(List events) { + BatchMessage.Builder messageBuilder = BatchMessage.newBuilder() + .setHeader(EventMeshClientUtil.buildHeader(clientConfig, PROTOCOL_TYPE)) + .setProducerGroup(clientConfig.getProducerGroup()) + .setTopic(events.get(0).getSubject()); + + for (CloudEvent event: events) { + String contentType = StringUtils.isEmpty(event.getDataContentType()) ? "application/cloudevents+json" + : event.getDataContentType(); + byte[] bodyByte = EventFormatProvider.getInstance().resolveFormat(contentType) + .serialize(event); + String content = new String(bodyByte, StandardCharsets.UTF_8); + + String ttl = event.getExtension(Constants.EVENTMESH_MESSAGE_CONST_TTL) == null ? "4000" + : event.getExtension(Constants.EVENTMESH_MESSAGE_CONST_TTL).toString(); + + MessageItem messageItem = MessageItem.newBuilder() + .setContent(content) + .setTtl(ttl) + .setSeqNum(event.getExtension(ProtocolKey.SEQ_NUM).toString()) + .setUniqueId(event.getExtension(ProtocolKey.UNIQUE_ID).toString()) + .putProperties(ProtocolKey.CONTENT_TYPE, contentType) + .build(); + + messageBuilder.addMessageItem(messageItem); + } + + return messageBuilder.build(); + } +} diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java index 629ff93b52..c48ed9ee72 100644 --- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java +++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshClientUtil.java @@ -8,10 +8,9 @@ public class EventMeshClientUtil { - private final static String PROTOCOL_TYPE = "eventmeshmessage"; private final static String PROTOCOL_DESC = "grpc"; - public static RequestHeader buildHeader(EventMeshGrpcClientConfig clientConfig) { + public static RequestHeader buildHeader(EventMeshGrpcClientConfig clientConfig, String protocolType) { RequestHeader header = RequestHeader.newBuilder() .setEnv(clientConfig.getEnv()) .setIdc(clientConfig.getIdc()) @@ -21,7 +20,7 @@ public static RequestHeader buildHeader(EventMeshGrpcClientConfig clientConfig) .setLanguage(clientConfig.getLanguage()) .setUsername(clientConfig.getUserName()) .setPassword(clientConfig.getPassword()) - .setProtocolType(PROTOCOL_TYPE) + .setProtocolType(protocolType) .setProtocolDesc(PROTOCOL_DESC) // default CloudEvents version is V1 .setProtocolVersion(SpecVersion.V1.toString()) From 1788752a593757a68a3315781b2e214113fab75e Mon Sep 17 00:00:00 2001 From: jinrongluo Date: Tue, 11 Jan 2022 11:33:48 -0500 Subject: [PATCH 21/21] [Issue #417] update license text and documentation for grpc --- .../eventmesh-runtime-protocol.md | 71 +++++++++++++++---- .../eventmesh-runtime-protocol.md | 71 +++++++++++++++---- .../protocol/grpc/protos/BatchMessage.java | 17 +++++ .../grpc/protos/BatchMessageOrBuilder.java | 17 +++++ .../grpc/protos/ConsumerServiceGrpc.java | 17 +++++ .../grpc/protos/EventMeshMessage.java | 17 +++++ .../protos/EventMeshMessageOrBuilder.java | 17 +++++ .../protocol/grpc/protos/EventmeshGrpc.java | 17 +++++ .../protocol/grpc/protos/Heartbeat.java | 17 +++++ .../grpc/protos/HeartbeatOrBuilder.java | 17 +++++ .../grpc/protos/HeartbeatServiceGrpc.java | 17 +++++ .../grpc/protos/PublisherServiceGrpc.java | 17 +++++ .../protocol/grpc/protos/RequestHeader.java | 17 +++++ .../grpc/protos/RequestHeaderOrBuilder.java | 17 +++++ .../common/protocol/grpc/protos/Response.java | 17 +++++ .../grpc/protos/ResponseOrBuilder.java | 17 +++++ .../protocol/grpc/protos/Subscription.java | 17 +++++ .../grpc/protos/SubscriptionOrBuilder.java | 17 +++++ 18 files changed, 384 insertions(+), 30 deletions(-) diff --git a/docs/cn/instructions/eventmesh-runtime-protocol.md b/docs/cn/instructions/eventmesh-runtime-protocol.md index 2921ee0112..378c7fc942 100644 --- a/docs/cn/instructions/eventmesh-runtime-protocol.md +++ b/docs/cn/instructions/eventmesh-runtime-protocol.md @@ -284,25 +284,45 @@ message RequestHeader { string sys = 6; string username = 7; string password = 8; - string version = 9; - string language = 10; - string seqNum = 11; + string language = 9; + string protocolType = 10; + string protocolVersion = 11; + string protocolDesc = 12; } -message Message { +message EventMeshMessage { RequestHeader header = 1; - string productionGroup = 2; + string producerGroup = 2; string topic = 3; string content = 4; string ttl = 5; string uniqueId = 6; + string seqNum = 7; + string tag = 8; + map properties = 9; +} + +message BatchMessage { + RequestHeader header = 1; + string producerGroup = 2; + string topic = 3; + + message MessageItem { + string content = 1; + string ttl = 2; + string uniqueId = 3; + string seqNum = 4; + string tag = 5; + map properties = 6; + } + + repeated MessageItem messageItem = 4; } message Response { string respCode = 1; string respMsg = 2; string respTime = 3; - string seqNum = 4; } ``` @@ -316,13 +336,23 @@ message Subscription { string consumerGroup = 2; message SubscriptionItem { + enum SubscriptionMode { + CLUSTERING = 0; + BROADCASTING = 1; + } + + enum SubscriptionType { + ASYNC = 0; + SYNC = 1; + } + string topic = 1; - string mode = 2; - string type = 3; - string url = 4; + SubscriptionMode mode = 2; + SubscriptionType type = 3; } repeated SubscriptionItem subscriptionItems = 3; + string url = 4; } ``` @@ -332,8 +362,13 @@ message Subscription { ``` message Heartbeat { + enum ClientType { + PUB = 0; + SUB = 1; + } + RequestHeader header = 1; - string clientType = 2; + ClientType clientType = 2; string producerGroup = 3; string consumerGroup = 4; @@ -351,30 +386,36 @@ message Heartbeat { - 事件生产端服务 APIs ``` +service PublisherService { # 异步事件生产 - rpc publish(Message) returns (Response); + rpc publish(EventMeshMessage) returns (Response); # 同步事件生产 - rpc requestReply(Message) returns (Response); + rpc requestReply(EventMeshMessage) returns (Response); - # 事件广播 - rpc broadcast(Message) returns (Response); + # 批量事件生产 + rpc batchPublish(BatchMessage) returns (Response); +} ``` - 事件消费端服务 APIs ``` +service ConsumerService { # 所消费事件通过 HTTP Webhook推送事件 rpc subscribe(Subscription) returns (Response); # 所消费事件通过 TCP stream推送事件 - rpc subscribeStream(Subscription) returns (stream Message); + rpc subscribeStream(Subscription) returns (stream EventMeshMessage); rpc unsubscribe(Subscription) returns (Response); +} ``` - 客户端心跳服务 API ``` +service HeartbeatService { rpc heartbeat(Heartbeat) returns (Response); +} ``` \ No newline at end of file diff --git a/docs/en/instructions/eventmesh-runtime-protocol.md b/docs/en/instructions/eventmesh-runtime-protocol.md index 2bdadb2406..9b705d3382 100644 --- a/docs/en/instructions/eventmesh-runtime-protocol.md +++ b/docs/en/instructions/eventmesh-runtime-protocol.md @@ -287,25 +287,45 @@ message RequestHeader { string sys = 6; string username = 7; string password = 8; - string version = 9; - string language = 10; - string seqNum = 11; + string language = 9; + string protocolType = 10; + string protocolVersion = 11; + string protocolDesc = 12; } -message Message { +message EventMeshMessage { RequestHeader header = 1; - string productionGroup = 2; + string producerGroup = 2; string topic = 3; string content = 4; string ttl = 5; string uniqueId = 6; + string seqNum = 7; + string tag = 8; + map properties = 9; +} + +message BatchMessage { + RequestHeader header = 1; + string producerGroup = 2; + string topic = 3; + + message MessageItem { + string content = 1; + string ttl = 2; + string uniqueId = 3; + string seqNum = 4; + string tag = 5; + map properties = 6; + } + + repeated MessageItem messageItem = 4; } message Response { string respCode = 1; string respMsg = 2; string respTime = 3; - string seqNum = 4; } ``` @@ -319,13 +339,23 @@ message Subscription { string consumerGroup = 2; message SubscriptionItem { + enum SubscriptionMode { + CLUSTERING = 0; + BROADCASTING = 1; + } + + enum SubscriptionType { + ASYNC = 0; + SYNC = 1; + } + string topic = 1; - string mode = 2; - string type = 3; - string url = 4; + SubscriptionMode mode = 2; + SubscriptionType type = 3; } repeated SubscriptionItem subscriptionItems = 3; + string url = 4; } ``` @@ -335,8 +365,13 @@ The following data model is used by `heartbeat()` API. ``` message Heartbeat { + enum ClientType { + PUB = 0; + SUB = 1; + } + RequestHeader header = 1; - string clientType = 2; + ClientType clientType = 2; string producerGroup = 3; string consumerGroup = 4; @@ -354,30 +389,36 @@ message Heartbeat { - event publisher service APIs ``` +service PublisherService { # Async event publish - rpc publish(Message) returns (Response); + rpc publish(EventMeshMessage) returns (Response); # Sync event publish - rpc requestReply(Message) returns (Response); + rpc requestReply(EventMeshMessage) returns (Response); - # event broadcast - rpc broadcast(Message) returns (Response); + # Batch event publish + rpc batchPublish(BatchMessage) returns (Response); +} ``` - event consumer service APIs ``` +service ConsumerService { # The subscribed event will be delivered by invoking the webhook url in the Subscription rpc subscribe(Subscription) returns (Response); # The subscribed event will be delivered through stream of Message - rpc subscribeStream(Subscription) returns (stream Message); + rpc subscribeStream(Subscription) returns (stream EventMeshMessage); rpc unsubscribe(Subscription) returns (Response); +} ``` - client heartbeat service API ``` +service HeartbeatService { rpc heartbeat(Heartbeat) returns (Response); +} ``` \ No newline at end of file diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java index c9f8570edc..d74a616c6a 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessageOrBuilder.java index 734d4ee225..0ab9a2fb23 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessageOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessageOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java index 54dc3cc0aa..e643a3baf2 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java @@ -1,3 +1,20 @@ +/* + * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java index be8b1e5970..8adb1191df 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java index f17b510070..5439ad1fca 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java index 4a93aaf22e..406be5d652 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java index 64e95fd3d8..814d89793f 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java index 7c900099a2..c3a39aa04f 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java index 8ae133ef89..e924b3b064 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java @@ -1,3 +1,20 @@ +/* + * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java index 46b48425fc..48dea0c797 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java @@ -1,3 +1,20 @@ +/* + * 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.eventmesh.common.protocol.grpc.protos; import static io.grpc.MethodDescriptor.generateFullMethodName; diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java index d53cbcbfef..4fe0c49c5b 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java index ab28df49f2..2041119264 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java index b84dbfc807..8fbefe2f54 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java index 89018f7d8e..d936cee595 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java index 76efe7dc6c..8f97d8bb19 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java index 2f98079eb6..7f39dbd0cc 100644 --- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java +++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java @@ -1,3 +1,20 @@ +/* + * 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. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: eventmesh-client.proto