diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/DistributedDatabaseOperateImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/DistributedDatabaseOperateImpl.java index cfd0a7b19c1..7eca60e85f2 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/DistributedDatabaseOperateImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/DistributedDatabaseOperateImpl.java @@ -48,10 +48,10 @@ import com.alibaba.nacos.consistency.SerializeFactory; import com.alibaba.nacos.consistency.Serializer; import com.alibaba.nacos.consistency.cp.CPProtocol; -import com.alibaba.nacos.consistency.cp.LogProcessor4CP; -import com.alibaba.nacos.consistency.entity.GetRequest; -import com.alibaba.nacos.consistency.entity.Log; +import com.alibaba.nacos.consistency.cp.RequestProcessor4CP; +import com.alibaba.nacos.consistency.entity.ReadRequest; import com.alibaba.nacos.consistency.entity.Response; +import com.alibaba.nacos.consistency.entity.WriteRequest; import com.alibaba.nacos.consistency.exception.ConsistencyException; import com.alibaba.nacos.consistency.snapshot.SnapshotOperation; import com.alibaba.nacos.core.cluster.ServerMemberManager; @@ -142,7 +142,7 @@ @Conditional(ConditionDistributedEmbedStorage.class) @Component @SuppressWarnings({"unchecked"}) -public class DistributedDatabaseOperateImpl extends LogProcessor4CP implements BaseDatabaseOperate { +public class DistributedDatabaseOperateImpl extends RequestProcessor4CP implements BaseDatabaseOperate { /** * The data import operation is dedicated key, which ACTS as an identifier. @@ -227,7 +227,7 @@ public R queryOne(String sql, Class cls) { .containsExtendInfo(Constants.EXTEND_NEED_READ_UNTIL_HAVE_DATA); Response response = innerRead( - GetRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); + ReadRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); if (response.getSuccess()) { return serializer.deserialize(response.getData().toByteArray(), cls); } @@ -251,7 +251,7 @@ public R queryOne(String sql, Object[] args, Class cls) { .containsExtendInfo(Constants.EXTEND_NEED_READ_UNTIL_HAVE_DATA); Response response = innerRead( - GetRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); + ReadRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); if (response.getSuccess()) { return serializer.deserialize(response.getData().toByteArray(), cls); } @@ -275,7 +275,7 @@ public R queryOne(String sql, Object[] args, RowMapper mapper) { .containsExtendInfo(Constants.EXTEND_NEED_READ_UNTIL_HAVE_DATA); Response response = innerRead( - GetRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); + ReadRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); if (response.getSuccess()) { return serializer.deserialize(response.getData().toByteArray(), ClassUtils.resolveGenericTypeByInterface(mapper.getClass())); @@ -300,7 +300,7 @@ public List queryMany(String sql, Object[] args, RowMapper mapper) { .containsExtendInfo(Constants.EXTEND_NEED_READ_UNTIL_HAVE_DATA); Response response = innerRead( - GetRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); + ReadRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); if (response.getSuccess()) { return serializer.deserialize(response.getData().toByteArray(), List.class); } @@ -324,7 +324,7 @@ public List queryMany(String sql, Object[] args, Class rClass) { .containsExtendInfo(Constants.EXTEND_NEED_READ_UNTIL_HAVE_DATA); Response response = innerRead( - GetRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); + ReadRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); if (response.getSuccess()) { return serializer.deserialize(response.getData().toByteArray(), List.class); } @@ -348,7 +348,7 @@ public List> queryMany(String sql, Object[] args) { .containsExtendInfo(Constants.EXTEND_NEED_READ_UNTIL_HAVE_DATA); Response response = innerRead( - GetRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); + ReadRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead); if (response.getSuccess()) { return serializer.deserialize(response.getData().toByteArray(), List.class); } @@ -362,12 +362,12 @@ public List> queryMany(String sql, Object[] args) { /** * In some business situations, you need to avoid the timeout issue, so blockRead is used to determine this. * - * @param request {@link GetRequest} + * @param request {@link ReadRequest} * @param blockRead is async read operation * @return {@link Response} * @throws Exception Exception */ - private Response innerRead(GetRequest request, boolean blockRead) throws Exception { + private Response innerRead(ReadRequest request, boolean blockRead) throws Exception { if (blockRead) { return (Response) protocol.aGetData(request).join(); } @@ -390,7 +390,7 @@ public CompletableFuture> dataImport(File file) { if (submit) { List requests = batchUpdate.stream().map(ModifyRequest::new) .collect(Collectors.toList()); - CompletableFuture future = protocol.submitAsync(Log.newBuilder().setGroup(group()) + CompletableFuture future = protocol.submitAsync(WriteRequest.newBuilder().setGroup(group()) .setData(ByteString.copyFrom(serializer.serialize(requests))) .putExtendInfo(DATA_IMPORT_KEY, Boolean.TRUE.toString()).build()); futures.add(future); @@ -427,19 +427,19 @@ public Boolean update(List sqlContext, BiConsumer) (response, ex) -> { + this.protocol.submitAsync(request).whenComplete((BiConsumer) (response, ex) -> { String errMsg = Objects.isNull(ex) ? response.getErrMsg() : ExceptionUtil.getCause(ex).getMessage(); consumer.accept(response.getSuccess(), StringUtils.isBlank(errMsg) ? null : new NJdbcException(errMsg)); @@ -462,7 +462,7 @@ public List loadSnapshotOperate() { @SuppressWarnings("all") @Override - public Response onRequest(final GetRequest request) { + public Response onRequest(final ReadRequest request) { final SelectRequest selectRequest = serializer .deserialize(request.getData().toByteArray(), SelectRequest.class); @@ -511,7 +511,7 @@ public Response onRequest(final GetRequest request) { } @Override - public Response onApply(Log log) { + public Response onApply(WriteRequest log) { LoggerUtils.printIfDebugEnabled(LogUtil.DEFAULT_LOG, "onApply info : log : {}", log); final ByteString byteString = log.getData(); Preconditions.checkArgument(byteString != null, "Log.getData() must not null"); diff --git a/consistency/pom.xml b/consistency/pom.xml index bb3f9b2931f..94255b8b381 100644 --- a/consistency/pom.xml +++ b/consistency/pom.xml @@ -30,32 +30,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.5.0 + + com.google.protobuf:protoc:${protobuf-java.version}:exe:${os.detected.classifier} + grpc-java + io.grpc:protoc-gen-grpc-java:${grpc-java.version}:exe:${os.detected.classifier} + + + + + compile + compile-custom + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/Config.java b/consistency/src/main/java/com/alibaba/nacos/consistency/Config.java index fd47c56335f..a523f39031f 100644 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/Config.java +++ b/consistency/src/main/java/com/alibaba/nacos/consistency/Config.java @@ -22,7 +22,7 @@ /** * Consistent protocol related configuration objects. * - *

{@link LogProcessor} : The consistency protocol provides services for all businesses, but each business only cares + *

{@link RequestProcessor} : The consistency protocol provides services for all businesses, but each business only cares * about the transaction information belonging to that business, and the transaction processing between the various * services should not block each other. Therefore, the LogProcessor is abstracted to implement the parallel processing * of transactions of different services. Corresponding LogProcessor sub-interface: LogProcessor4AP or LogProcessor4CP, @@ -30,7 +30,7 @@ * * @author liaochuntao */ -public interface Config extends Serializable { +public interface Config extends Serializable { /** * Set the cluster node information to initialize,like [ip:port, ip:port, ip:port]. diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/ConsistencyProtocol.java b/consistency/src/main/java/com/alibaba/nacos/consistency/ConsistencyProtocol.java index e03134b6e59..534423809fe 100644 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/ConsistencyProtocol.java +++ b/consistency/src/main/java/com/alibaba/nacos/consistency/ConsistencyProtocol.java @@ -16,9 +16,9 @@ package com.alibaba.nacos.consistency; -import com.alibaba.nacos.consistency.entity.GetRequest; -import com.alibaba.nacos.consistency.entity.Log; +import com.alibaba.nacos.consistency.entity.ReadRequest; import com.alibaba.nacos.consistency.entity.Response; +import com.alibaba.nacos.consistency.entity.WriteRequest; import java.util.Collection; import java.util.Set; @@ -37,7 +37,7 @@ * * @author liaochuntao */ -public interface ConsistencyProtocol extends CommandOperations { +public interface ConsistencyProtocol extends CommandOperations { /** * Consistency protocol initialization: perform initialization operations based on the incoming. @@ -50,7 +50,7 @@ public interface ConsistencyProtocol e /** * Add a log handler. * - * @param processors {@link LogProcessor} + * @param processors {@link RequestProcessor} */ void addLogProcessors(Collection

processors); @@ -69,7 +69,7 @@ public interface ConsistencyProtocol e * @return data {@link Response} * @throws Exception {@link Exception} */ - Response getData(GetRequest request) throws Exception; + Response getData(ReadRequest request) throws Exception; /** * Get data asynchronously. @@ -77,27 +77,27 @@ public interface ConsistencyProtocol e * @param request request * @return data {@link CompletableFuture} */ - CompletableFuture aGetData(GetRequest request); + CompletableFuture aGetData(ReadRequest request); /** * Data operation, returning submission results synchronously. * 同步数据提交,在 Datum 中已携带相应的数据操作信息 * - * @param data {@link Log} + * @param request {@link com.alibaba.nacos.consistency.entity.WriteRequest} * @return submit operation result {@link Response} * @throws Exception {@link Exception} */ - Response submit(Log data) throws Exception; + Response submit(WriteRequest request) throws Exception; /** * Data submission operation, returning submission results asynchronously. * 异步数据提交,在 Datum中已携带相应的数据操作信息,返回一个Future,自行操作,提交发生的异常会在CompleteFuture中 * - * @param data {@link Log} + * @param request {@link com.alibaba.nacos.consistency.entity.WriteRequest} * @return {@link CompletableFuture} submit result * @throws Exception when submit throw Exception */ - CompletableFuture submitAsync(Log data); + CompletableFuture submitAsync(WriteRequest request); /** * New member list . diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/ProtoMessageUtil.java b/consistency/src/main/java/com/alibaba/nacos/consistency/ProtoMessageUtil.java new file mode 100644 index 00000000000..9bcc0c66b4b --- /dev/null +++ b/consistency/src/main/java/com/alibaba/nacos/consistency/ProtoMessageUtil.java @@ -0,0 +1,97 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.nacos.consistency; + +import com.alibaba.nacos.consistency.entity.GetRequest; +import com.alibaba.nacos.consistency.entity.Log; +import com.alibaba.nacos.consistency.entity.ReadRequest; +import com.alibaba.nacos.consistency.entity.WriteRequest; +import com.alibaba.nacos.consistency.exception.ConsistencyException; +import com.google.protobuf.Message; + +/** + * protobuf message utils. + * + * @author liaochuntao + */ +public class ProtoMessageUtil { + + /** + * Converts the byte array to a specific Protobuf object. + * Internally, the protobuf new and old objects are compatible. + * + * @param bytes An array of bytes + * @return Message + */ + public static Message parse(byte[] bytes) { + Message result; + try { + result = WriteRequest.parseFrom(bytes); + return result; + } catch (Throwable ignore) { + } + try { + result = ReadRequest.parseFrom(bytes); + return result; + } catch (Throwable ignore) { + } + + // old consistency entity, will be @Deprecated in future + try { + Log log = Log.parseFrom(bytes); + return convertToWriteRequest(log); + } catch (Throwable ignore) { + } + + try { + GetRequest request = GetRequest.parseFrom(bytes); + return convertToReadRequest(request); + } catch (Throwable ignore) { + } + + throw new ConsistencyException("The current array cannot be serialized to the corresponding object"); + } + + /** + * convert Log to WriteRequest. + * + * @param log log + * @return {@link WriteRequest} + */ + public static WriteRequest convertToWriteRequest(Log log) { + return WriteRequest.newBuilder().setKey(log.getKey()).setGroup(log.getGroup()) + .setData(log.getData()) + .setType(log.getType()) + .setOperation(log.getOperation()) + .putAllExtendInfo(log.getExtendInfoMap()) + .build(); + } + + /** + * convert Log to ReadRequest. + * + * @param request request + * @return {@link ReadRequest} + */ + public static ReadRequest convertToReadRequest(GetRequest request) { + return ReadRequest.newBuilder() + .setGroup(request.getGroup()) + .setData(request.getData()) + .putAllExtendInfo(request.getExtendInfoMap()) + .build(); + } +} diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/LogProcessor.java b/consistency/src/main/java/com/alibaba/nacos/consistency/RequestProcessor.java similarity index 81% rename from consistency/src/main/java/com/alibaba/nacos/consistency/LogProcessor.java rename to consistency/src/main/java/com/alibaba/nacos/consistency/RequestProcessor.java index 8cf8b5e6b3e..c575ac64631 100644 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/LogProcessor.java +++ b/consistency/src/main/java/com/alibaba/nacos/consistency/RequestProcessor.java @@ -16,9 +16,9 @@ package com.alibaba.nacos.consistency; -import com.alibaba.nacos.consistency.entity.GetRequest; -import com.alibaba.nacos.consistency.entity.Log; +import com.alibaba.nacos.consistency.entity.ReadRequest; import com.alibaba.nacos.consistency.entity.Response; +import com.alibaba.nacos.consistency.entity.WriteRequest; /** * Can be discovered through SPI or Spring, This interface is just a function definition interface. Different @@ -27,23 +27,23 @@ * @author liaochuntao */ @SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule") -public abstract class LogProcessor { +public abstract class RequestProcessor { /** * get data by key. * - * @param request request {@link GetRequest} + * @param request request {@link com.alibaba.nacos.consistency.entity.ReadRequest} * @return target type data */ - public abstract Response onRequest(GetRequest request); + public abstract Response onRequest(ReadRequest request); /** * Process Submitted Log. * - * @param log {@link Log} + * @param log {@link WriteRequest} * @return {@link boolean} */ - public abstract Response onApply(Log log); + public abstract Response onApply(WriteRequest log); /** * Irremediable errors that need to trigger business price cuts. diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/ap/APProtocol.java b/consistency/src/main/java/com/alibaba/nacos/consistency/ap/APProtocol.java index 9197e53f806..f7f3cabacc9 100644 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/ap/APProtocol.java +++ b/consistency/src/main/java/com/alibaba/nacos/consistency/ap/APProtocol.java @@ -25,6 +25,6 @@ * @author liaochuntao */ @SuppressWarnings("all") -public interface APProtocol extends ConsistencyProtocol { +public interface APProtocol extends ConsistencyProtocol { } diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/ap/LogProcessor4AP.java b/consistency/src/main/java/com/alibaba/nacos/consistency/ap/RequestProcessor4AP.java similarity index 86% rename from consistency/src/main/java/com/alibaba/nacos/consistency/ap/LogProcessor4AP.java rename to consistency/src/main/java/com/alibaba/nacos/consistency/ap/RequestProcessor4AP.java index 397a0d17583..e56cd3618eb 100644 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/ap/LogProcessor4AP.java +++ b/consistency/src/main/java/com/alibaba/nacos/consistency/ap/RequestProcessor4AP.java @@ -16,7 +16,7 @@ package com.alibaba.nacos.consistency.ap; -import com.alibaba.nacos.consistency.LogProcessor; +import com.alibaba.nacos.consistency.RequestProcessor; /** * log processor for ap. @@ -24,6 +24,6 @@ * @author liaochuntao */ @SuppressWarnings("all") -public abstract class LogProcessor4AP extends LogProcessor { +public abstract class RequestProcessor4AP extends RequestProcessor { } diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/cp/CPProtocol.java b/consistency/src/main/java/com/alibaba/nacos/consistency/cp/CPProtocol.java index 6fc0d2468de..93d418e046e 100644 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/cp/CPProtocol.java +++ b/consistency/src/main/java/com/alibaba/nacos/consistency/cp/CPProtocol.java @@ -25,7 +25,7 @@ * @author liaochuntao */ @SuppressWarnings("all") -public interface CPProtocol extends ConsistencyProtocol { +public interface CPProtocol extends ConsistencyProtocol { /** * Returns whether this node is a leader node diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/cp/LogProcessor4CP.java b/consistency/src/main/java/com/alibaba/nacos/consistency/cp/RequestProcessor4CP.java similarity index 90% rename from consistency/src/main/java/com/alibaba/nacos/consistency/cp/LogProcessor4CP.java rename to consistency/src/main/java/com/alibaba/nacos/consistency/cp/RequestProcessor4CP.java index 49ef8cd31fc..f86cdd613ac 100644 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/cp/LogProcessor4CP.java +++ b/consistency/src/main/java/com/alibaba/nacos/consistency/cp/RequestProcessor4CP.java @@ -16,7 +16,7 @@ package com.alibaba.nacos.consistency.cp; -import com.alibaba.nacos.consistency.LogProcessor; +import com.alibaba.nacos.consistency.RequestProcessor; import com.alibaba.nacos.consistency.snapshot.SnapshotOperation; import java.util.Collections; @@ -28,7 +28,7 @@ * @author liaochuntao */ @SuppressWarnings("all") -public abstract class LogProcessor4CP extends LogProcessor { +public abstract class RequestProcessor4CP extends RequestProcessor { /** diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/Data.java b/consistency/src/main/java/com/alibaba/nacos/consistency/entity/Data.java deleted file mode 100644 index f1701104d6c..00000000000 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/Data.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Data.proto - -package com.alibaba.nacos.consistency.entity; - -@SuppressWarnings("all") -public final class Data { - - static final com.google.protobuf.Descriptors.Descriptor internal_static_Log_descriptor; - - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_Log_fieldAccessorTable; - - static final com.google.protobuf.Descriptors.Descriptor internal_static_Log_ExtendInfoEntry_descriptor; - - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_Log_ExtendInfoEntry_fieldAccessorTable; - - static final com.google.protobuf.Descriptors.Descriptor internal_static_GetRequest_descriptor; - - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_GetRequest_fieldAccessorTable; - - static final com.google.protobuf.Descriptors.Descriptor internal_static_GetRequest_ExtendInfoEntry_descriptor; - - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_GetRequest_ExtendInfoEntry_fieldAccessorTable; - - static final com.google.protobuf.Descriptors.Descriptor internal_static_Response_descriptor; - - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_Response_fieldAccessorTable; - - private static com.google.protobuf.Descriptors.FileDescriptor descriptor; - - static { - String[] descriptorData = {"\n\nData.proto\"\255\001\n\003Log\022\r\n\005group\030\001 \001(\t\022\013\n\003k" - + "ey\030\002 \001(\t\022\014\n\004data\030\003 \001(\014\022\014\n\004type\030\004 \001(\t\022\021\n\t" - + "operation\030\005 \001(\t\022(\n\nextendInfo\030\006 \003(\0132\024.Lo" - + "g.ExtendInfoEntry\0321\n\017ExtendInfoEntry\022\013\n\003" - + "key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\215\001\n\nGetRequ" - + "est\022\r\n\005group\030\001 \001(\t\022\014\n\004data\030\002 \001(\014\022/\n\nexte" - + "ndInfo\030\003 \003(\0132\033.GetRequest.ExtendInfoEntr" - + "y\0321\n\017ExtendInfoEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005val" - + "ue\030\002 \001(\t:\0028\001\"9\n\010Response\022\014\n\004data\030\001 \001(\014\022\016" - + "\n\006errMsg\030\002 \001(\t\022\017\n\007success\030\003 \001(\010B(\n$com.a" - + "libaba.nacos.consistency.entityP\001b\006proto" + "3"}; - descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] {}); - internal_static_Log_descriptor = getDescriptor().getMessageTypes().get(0); - internal_static_Log_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_Log_descriptor, - new String[] {"Group", "Key", "Data", "Type", "Operation", "ExtendInfo",}); - internal_static_Log_ExtendInfoEntry_descriptor = internal_static_Log_descriptor.getNestedTypes().get(0); - internal_static_Log_ExtendInfoEntry_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_Log_ExtendInfoEntry_descriptor, new String[] {"Key", "Value",}); - internal_static_GetRequest_descriptor = getDescriptor().getMessageTypes().get(1); - internal_static_GetRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_GetRequest_descriptor, new String[] {"Group", "Data", "ExtendInfo",}); - internal_static_GetRequest_ExtendInfoEntry_descriptor = internal_static_GetRequest_descriptor.getNestedTypes() - .get(0); - internal_static_GetRequest_ExtendInfoEntry_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_GetRequest_ExtendInfoEntry_descriptor, new String[] {"Key", "Value",}); - internal_static_Response_descriptor = getDescriptor().getMessageTypes().get(2); - internal_static_Response_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_Response_descriptor, new String[] {"Data", "ErrMsg", "Success",}); - } - - private Data() { - } - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); - } - - public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { - return descriptor; - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/GetRequest.java b/consistency/src/main/java/com/alibaba/nacos/consistency/entity/GetRequest.java deleted file mode 100644 index e11c5c33c7c..00000000000 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/GetRequest.java +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Data.proto - -package com.alibaba.nacos.consistency.entity; - -/** - * Protobuf type {@code GetRequest}. - */ -@SuppressWarnings("all") -public final class GetRequest extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:GetRequest) - GetRequestOrBuilder { - - public static final int GROUP_FIELD_NUMBER = 1; - - public static final int DATA_FIELD_NUMBER = 2; - - public static final int EXTENDINFO_FIELD_NUMBER = 3; - - private static final long serialVersionUID = 0L; - - // @@protoc_insertion_point(class_scope:GetRequest) - private static final GetRequest DEFAULT_INSTANCE; - - private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { - @Override - public GetRequest parsePartialFrom(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new GetRequest(input, extensionRegistry); - } - }; - - static { - DEFAULT_INSTANCE = new GetRequest(); - } - - private volatile Object group_; - - private com.google.protobuf.ByteString data_; - - private com.google.protobuf.MapField extendInfo_; - - private byte memoizedIsInitialized = -1; - - // Use GetRequest.newBuilder() to construct. - private GetRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private GetRequest() { - group_ = ""; - data_ = com.google.protobuf.ByteString.EMPTY; - } - - private GetRequest(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; - case 10: { - String s = input.readStringRequireUtf8(); - - group_ = s; - break; - } - case 18: { - - data_ = input.readBytes(); - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000001) != 0)) { - extendInfo_ = com.google.protobuf.MapField - .newMapField(ExtendInfoDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000001; - } - com.google.protobuf.MapEntry extendInfo__ = input - .readMessage(ExtendInfoDefaultEntryHolder.defaultEntry.getParserForType(), - extensionRegistry); - extendInfo_.getMutableMap().put(extendInfo__.getKey(), extendInfo__.getValue()); - break; - } - default: { - if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { - done = true; - } - 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 Data.internal_static_GetRequest_descriptor; - } - - public static GetRequest parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static GetRequest parseFrom(java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static GetRequest parseFrom(com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static GetRequest parseFrom(com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static GetRequest parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static GetRequest parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static GetRequest parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static GetRequest 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 GetRequest parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static GetRequest 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 GetRequest parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static GetRequest 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 static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(GetRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public static GetRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - @SuppressWarnings({"unused"}) - protected Object newInstance(UnusedPrivateParameter unused) { - return new GetRequest(); - } - - @Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - @SuppressWarnings({"rawtypes"}) - @Override - protected com.google.protobuf.MapField internalGetMapField(int number) { - switch (number) { - case 3: - return internalGetExtendInfo(); - default: - throw new RuntimeException("Invalid map field number: " + number); - } - } - - @Override - protected FieldAccessorTable internalGetFieldAccessorTable() { - return Data.internal_static_GetRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized(GetRequest.class, GetRequest.Builder.class); - } - - /** - * string group = 1; - */ - public String getGroup() { - Object ref = group_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - group_ = s; - return s; - } - } - - /** - * string group = 1; - */ - public com.google.protobuf.ByteString getGroupBytes() { - Object ref = group_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - group_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * bytes data = 2; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - private com.google.protobuf.MapField internalGetExtendInfo() { - if (extendInfo_ == null) { - return com.google.protobuf.MapField.emptyMapField(ExtendInfoDefaultEntryHolder.defaultEntry); - } - return extendInfo_; - } - - public int getExtendInfoCount() { - return internalGetExtendInfo().getMap().size(); - } - - /** - * map<string, string> extendInfo = 3; - */ - - public boolean containsExtendInfo(String key) { - if (key == null) { - throw new NullPointerException(); - } - return internalGetExtendInfo().getMap().containsKey(key); - } - - /** - * Use {@link #getExtendInfoMap()} instead. - */ - @Deprecated - public java.util.Map getExtendInfo() { - return getExtendInfoMap(); - } - - /** - * map<string, string> extendInfo = 3; - */ - - public java.util.Map getExtendInfoMap() { - return internalGetExtendInfo().getMap(); - } - - /** - * map<string, string> extendInfo = 3; - */ - - public String getExtendInfoOrDefault(String key, String defaultValue) { - if (key == null) { - throw new NullPointerException(); - } - java.util.Map map = internalGetExtendInfo().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - - /** - * map<string, string> extendInfo = 3; - */ - - public String getExtendInfoOrThrow(String key) { - if (key == null) { - throw new NullPointerException(); - } - java.util.Map map = internalGetExtendInfo().getMap(); - if (!map.containsKey(key)) { - throw new IllegalArgumentException(); - } - return map.get(key); - } - - @Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; - } - - @Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!getGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, group_); - } - if (!data_.isEmpty()) { - output.writeBytes(2, data_); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo(output, internalGetExtendInfo(), ExtendInfoDefaultEntryHolder.defaultEntry, 3); - unknownFields.writeTo(output); - } - - @Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, group_); - } - if (!data_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, data_); - } - for (java.util.Map.Entry entry : internalGetExtendInfo().getMap().entrySet()) { - com.google.protobuf.MapEntry extendInfo__ = ExtendInfoDefaultEntryHolder.defaultEntry - .newBuilderForType().setKey(entry.getKey()).setValue(entry.getValue()).build(); - size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, extendInfo__); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof GetRequest)) { - return super.equals(obj); - } - GetRequest other = (GetRequest) obj; - - if (!getGroup().equals(other.getGroup())) { - return false; - } - if (!getData().equals(other.getData())) { - return false; - } - if (!internalGetExtendInfo().equals(other.internalGetExtendInfo())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + GROUP_FIELD_NUMBER; - hash = (53 * hash) + getGroup().hashCode(); - hash = (37 * hash) + DATA_FIELD_NUMBER; - hash = (53 * hash) + getData().hashCode(); - if (!internalGetExtendInfo().getMap().isEmpty()) { - hash = (37 * hash) + EXTENDINFO_FIELD_NUMBER; - hash = (53 * hash) + internalGetExtendInfo().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - @Override - public Builder newBuilderForType() { - return newBuilder(); - } - - @Override - 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; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @Override - public GetRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - private static final class ExtendInfoDefaultEntryHolder { - - static final com.google.protobuf.MapEntry defaultEntry = com.google.protobuf.MapEntry.newDefaultInstance( - Data.internal_static_GetRequest_ExtendInfoEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, "", com.google.protobuf.WireFormat.FieldType.STRING, - ""); - } - - /** - * Protobuf type {@code GetRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:GetRequest) - GetRequestOrBuilder { - - private int bitField0_; - - private Object group_ = ""; - - private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; - - private com.google.protobuf.MapField extendInfo_; - - // Construct using com.alibaba.nacos.consistency.entity.GetRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder(BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return Data.internal_static_GetRequest_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField(int number) { - switch (number) { - case 3: - return internalGetExtendInfo(); - default: - throw new RuntimeException("Invalid map field number: " + number); - } - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField(int number) { - switch (number) { - case 3: - return internalGetMutableExtendInfo(); - default: - throw new RuntimeException("Invalid map field number: " + number); - } - } - - @Override - protected FieldAccessorTable internalGetFieldAccessorTable() { - return Data.internal_static_GetRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized(GetRequest.class, GetRequest.Builder.class); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { - } - } - - @Override - public Builder clear() { - super.clear(); - group_ = ""; - - data_ = com.google.protobuf.ByteString.EMPTY; - - internalGetMutableExtendInfo().clear(); - return this; - } - - @Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return Data.internal_static_GetRequest_descriptor; - } - - @Override - public GetRequest getDefaultInstanceForType() { - return GetRequest.getDefaultInstance(); - } - - @Override - public GetRequest build() { - GetRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @Override - public GetRequest buildPartial() { - GetRequest result = new GetRequest(this); - int from_bitField0_ = bitField0_; - result.group_ = group_; - result.data_ = data_; - result.extendInfo_ = internalGetExtendInfo(); - result.extendInfo_.makeImmutable(); - onBuilt(); - return result; - } - - @Override - public Builder clone() { - return super.clone(); - } - - @Override - public Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return super.setField(field, value); - } - - @Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @Override - public Builder setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index, - Object value) { - return super.setRepeatedField(field, index, value); - } - - @Override - public Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return super.addRepeatedField(field, value); - } - - @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof GetRequest) { - return mergeFrom((GetRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(GetRequest other) { - if (other == GetRequest.getDefaultInstance()) { - return this; - } - if (!other.getGroup().isEmpty()) { - group_ = other.group_; - onChanged(); - } - if (other.getData() != com.google.protobuf.ByteString.EMPTY) { - setData(other.getData()); - } - internalGetMutableExtendInfo().mergeFrom(other.internalGetExtendInfo()); - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @Override - public final boolean isInitialized() { - return true; - } - - @Override - public Builder mergeFrom(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - GetRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (GetRequest) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - /** - * string group = 1; - */ - public String getGroup() { - Object ref = group_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - group_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string group = 1; - */ - public Builder setGroup(String value) { - if (value == null) { - throw new NullPointerException(); - } - - group_ = value; - onChanged(); - return this; - } - - /** - * string group = 1; - */ - public com.google.protobuf.ByteString getGroupBytes() { - Object ref = group_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - group_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string group = 1; - */ - public Builder setGroupBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - group_ = value; - onChanged(); - return this; - } - - /** - * string group = 1; - */ - public Builder clearGroup() { - - group_ = getDefaultInstance().getGroup(); - onChanged(); - return this; - } - - /** - * bytes data = 2; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - /** - * bytes data = 2; - */ - public Builder setData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - data_ = value; - onChanged(); - return this; - } - - /** - * bytes data = 2; - */ - public Builder clearData() { - - data_ = getDefaultInstance().getData(); - onChanged(); - return this; - } - - private com.google.protobuf.MapField internalGetExtendInfo() { - if (extendInfo_ == null) { - return com.google.protobuf.MapField.emptyMapField(ExtendInfoDefaultEntryHolder.defaultEntry); - } - return extendInfo_; - } - - private com.google.protobuf.MapField internalGetMutableExtendInfo() { - onChanged(); - ; - if (extendInfo_ == null) { - extendInfo_ = com.google.protobuf.MapField.newMapField(ExtendInfoDefaultEntryHolder.defaultEntry); - } - if (!extendInfo_.isMutable()) { - extendInfo_ = extendInfo_.copy(); - } - return extendInfo_; - } - - public int getExtendInfoCount() { - return internalGetExtendInfo().getMap().size(); - } - - /** - * map<string, string> extendInfo = 3; - */ - - public boolean containsExtendInfo(String key) { - if (key == null) { - throw new NullPointerException(); - } - return internalGetExtendInfo().getMap().containsKey(key); - } - - /** - * Use {@link #getExtendInfoMap()} instead. - */ - @Deprecated - public java.util.Map getExtendInfo() { - return getExtendInfoMap(); - } - - /** - * map<string, string> extendInfo = 3; - */ - - public java.util.Map getExtendInfoMap() { - return internalGetExtendInfo().getMap(); - } - - /** - * map<string, string> extendInfo = 3; - */ - - public String getExtendInfoOrDefault(String key, String defaultValue) { - if (key == null) { - throw new NullPointerException(); - } - java.util.Map map = internalGetExtendInfo().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - - /** - * map<string, string> extendInfo = 3; - */ - - public String getExtendInfoOrThrow(String key) { - if (key == null) { - throw new NullPointerException(); - } - java.util.Map map = internalGetExtendInfo().getMap(); - if (!map.containsKey(key)) { - throw new IllegalArgumentException(); - } - return map.get(key); - } - - public Builder clearExtendInfo() { - internalGetMutableExtendInfo().getMutableMap().clear(); - return this; - } - - /** - * map<string, string> extendInfo = 3; - */ - - public Builder removeExtendInfo(String key) { - if (key == null) { - throw new NullPointerException(); - } - internalGetMutableExtendInfo().getMutableMap().remove(key); - return this; - } - - /** - * Use alternate mutation accessors instead. - */ - @Deprecated - public java.util.Map getMutableExtendInfo() { - return internalGetMutableExtendInfo().getMutableMap(); - } - - /** - * map<string, string> extendInfo = 3; - */ - public Builder putExtendInfo(String key, String value) { - if (key == null) { - throw new NullPointerException(); - } - if (value == null) { - throw new NullPointerException(); - } - internalGetMutableExtendInfo().getMutableMap().put(key, value); - return this; - } - - /** - * map<string, string> extendInfo = 3; - */ - - public Builder putAllExtendInfo(java.util.Map values) { - internalGetMutableExtendInfo().getMutableMap().putAll(values); - return this; - } - - @Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @Override - public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:GetRequest) - } - -} - diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/GetRequestOrBuilder.java b/consistency/src/main/java/com/alibaba/nacos/consistency/entity/GetRequestOrBuilder.java deleted file mode 100644 index 8e7886df32c..00000000000 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/GetRequestOrBuilder.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Data.proto - -package com.alibaba.nacos.consistency.entity; - -@SuppressWarnings("all") -public interface GetRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:GetRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * string group = 1; - */ - String getGroup(); - - /** - * string group = 1; - */ - com.google.protobuf.ByteString getGroupBytes(); - - /** - * bytes data = 2; - */ - com.google.protobuf.ByteString getData(); - - /** - * map<string, string> extendInfo = 3; - */ - int getExtendInfoCount(); - - /** - * map<string, string> extendInfo = 3; - */ - boolean containsExtendInfo(String key); - - /** - * Use {@link #getExtendInfoMap()} instead. - */ - @Deprecated - java.util.Map getExtendInfo(); - - /** - * map<string, string> extendInfo = 3; - */ - java.util.Map getExtendInfoMap(); - - /** - * map<string, string> extendInfo = 3; - */ - - String getExtendInfoOrDefault(String key, String defaultValue); - - /** - * map<string, string> extendInfo = 3; - */ - - String getExtendInfoOrThrow(String key); -} diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/Log.java b/consistency/src/main/java/com/alibaba/nacos/consistency/entity/Log.java deleted file mode 100644 index 452e7374401..00000000000 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/Log.java +++ /dev/null @@ -1,1258 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Data.proto - -package com.alibaba.nacos.consistency.entity; - -/** - * Protobuf type {@code Log}. - */ -@SuppressWarnings("all") -public final class Log extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:Log) - LogOrBuilder { - - public static final int GROUP_FIELD_NUMBER = 1; - - public static final int KEY_FIELD_NUMBER = 2; - - public static final int DATA_FIELD_NUMBER = 3; - - public static final int TYPE_FIELD_NUMBER = 4; - - public static final int OPERATION_FIELD_NUMBER = 5; - - public static final int EXTENDINFO_FIELD_NUMBER = 6; - - private static final long serialVersionUID = 0L; - - // @@protoc_insertion_point(class_scope:Log) - private static final Log DEFAULT_INSTANCE; - - private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { - @Override - public Log parsePartialFrom(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Log(input, extensionRegistry); - } - }; - - static { - DEFAULT_INSTANCE = new Log(); - } - - private volatile Object group_; - - private volatile Object key_; - - private com.google.protobuf.ByteString data_; - - private volatile Object type_; - - private volatile Object operation_; - - private com.google.protobuf.MapField extendInfo_; - - private byte memoizedIsInitialized = -1; - - // Use Log.newBuilder() to construct. - private Log(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Log() { - group_ = ""; - key_ = ""; - data_ = com.google.protobuf.ByteString.EMPTY; - type_ = ""; - operation_ = ""; - } - - private Log(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; - case 10: { - String s = input.readStringRequireUtf8(); - - group_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - key_ = s; - break; - } - case 26: { - - data_ = input.readBytes(); - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - type_ = s; - break; - } - case 42: { - String s = input.readStringRequireUtf8(); - - operation_ = s; - break; - } - case 50: { - if (!((mutable_bitField0_ & 0x00000001) != 0)) { - extendInfo_ = com.google.protobuf.MapField - .newMapField(ExtendInfoDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000001; - } - com.google.protobuf.MapEntry extendInfo__ = input - .readMessage(ExtendInfoDefaultEntryHolder.defaultEntry.getParserForType(), - extensionRegistry); - extendInfo_.getMutableMap().put(extendInfo__.getKey(), extendInfo__.getValue()); - break; - } - default: { - if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { - done = true; - } - 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 Data.internal_static_Log_descriptor; - } - - public static Log parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Log parseFrom(java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Log parseFrom(com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Log parseFrom(com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Log parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Log parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Log parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static Log 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 Log parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static Log 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 Log parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static Log 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 static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Log prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public static Log getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - @SuppressWarnings({"unused"}) - protected Object newInstance(UnusedPrivateParameter unused) { - return new Log(); - } - - @Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - @SuppressWarnings({"rawtypes"}) - @Override - protected com.google.protobuf.MapField internalGetMapField(int number) { - switch (number) { - case 6: - return internalGetExtendInfo(); - default: - throw new RuntimeException("Invalid map field number: " + number); - } - } - - @Override - protected FieldAccessorTable internalGetFieldAccessorTable() { - return Data.internal_static_Log_fieldAccessorTable - .ensureFieldAccessorsInitialized(Log.class, Log.Builder.class); - } - - /** - * string group = 1; - */ - public String getGroup() { - Object ref = group_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - group_ = s; - return s; - } - } - - /** - * string group = 1; - */ - public com.google.protobuf.ByteString getGroupBytes() { - Object ref = group_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - group_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string key = 2; - */ - public String getKey() { - Object ref = key_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - key_ = s; - return s; - } - } - - /** - * string key = 2; - */ - public com.google.protobuf.ByteString getKeyBytes() { - Object ref = key_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * bytes data = 3; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - /** - * string type = 4; - */ - 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 = 4; - */ - 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 operation = 5; - */ - public String getOperation() { - Object ref = operation_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - operation_ = s; - return s; - } - } - - /** - * string operation = 5; - */ - public com.google.protobuf.ByteString getOperationBytes() { - Object ref = operation_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - operation_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private com.google.protobuf.MapField internalGetExtendInfo() { - if (extendInfo_ == null) { - return com.google.protobuf.MapField.emptyMapField(ExtendInfoDefaultEntryHolder.defaultEntry); - } - return extendInfo_; - } - - public int getExtendInfoCount() { - return internalGetExtendInfo().getMap().size(); - } - - /** - * map<string, string> extendInfo = 6; - */ - - public boolean containsExtendInfo(String key) { - if (key == null) { - throw new NullPointerException(); - } - return internalGetExtendInfo().getMap().containsKey(key); - } - - /** - * Use {@link #getExtendInfoMap()} instead. - */ - @Deprecated - public java.util.Map getExtendInfo() { - return getExtendInfoMap(); - } - - /** - * map<string, string> extendInfo = 6; - */ - - public java.util.Map getExtendInfoMap() { - return internalGetExtendInfo().getMap(); - } - - /** - * map<string, string> extendInfo = 6; - */ - - public String getExtendInfoOrDefault(String key, String defaultValue) { - if (key == null) { - throw new NullPointerException(); - } - java.util.Map map = internalGetExtendInfo().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - - /** - * map<string, string> extendInfo = 6; - */ - - public String getExtendInfoOrThrow(String key) { - if (key == null) { - throw new NullPointerException(); - } - java.util.Map map = internalGetExtendInfo().getMap(); - if (!map.containsKey(key)) { - throw new IllegalArgumentException(); - } - return map.get(key); - } - - @Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; - } - - @Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!getGroupBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, group_); - } - if (!getKeyBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, key_); - } - if (!data_.isEmpty()) { - output.writeBytes(3, data_); - } - if (!getTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, type_); - } - if (!getOperationBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, operation_); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo(output, internalGetExtendInfo(), ExtendInfoDefaultEntryHolder.defaultEntry, 6); - unknownFields.writeTo(output); - } - - @Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!getGroupBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, group_); - } - if (!getKeyBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, key_); - } - if (!data_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, data_); - } - if (!getTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, type_); - } - if (!getOperationBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, operation_); - } - for (java.util.Map.Entry entry : internalGetExtendInfo().getMap().entrySet()) { - com.google.protobuf.MapEntry extendInfo__ = ExtendInfoDefaultEntryHolder.defaultEntry - .newBuilderForType().setKey(entry.getKey()).setValue(entry.getValue()).build(); - size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, extendInfo__); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Log)) { - return super.equals(obj); - } - Log other = (Log) obj; - - if (!getGroup().equals(other.getGroup())) { - return false; - } - if (!getKey().equals(other.getKey())) { - return false; - } - if (!getData().equals(other.getData())) { - return false; - } - if (!getType().equals(other.getType())) { - return false; - } - if (!getOperation().equals(other.getOperation())) { - return false; - } - if (!internalGetExtendInfo().equals(other.internalGetExtendInfo())) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + GROUP_FIELD_NUMBER; - hash = (53 * hash) + getGroup().hashCode(); - hash = (37 * hash) + KEY_FIELD_NUMBER; - hash = (53 * hash) + getKey().hashCode(); - hash = (37 * hash) + DATA_FIELD_NUMBER; - hash = (53 * hash) + getData().hashCode(); - hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + getType().hashCode(); - hash = (37 * hash) + OPERATION_FIELD_NUMBER; - hash = (53 * hash) + getOperation().hashCode(); - if (!internalGetExtendInfo().getMap().isEmpty()) { - hash = (37 * hash) + EXTENDINFO_FIELD_NUMBER; - hash = (53 * hash) + internalGetExtendInfo().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - @Override - public Builder newBuilderForType() { - return newBuilder(); - } - - @Override - 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; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @Override - public Log getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - private static final class ExtendInfoDefaultEntryHolder { - - static final com.google.protobuf.MapEntry defaultEntry = com.google.protobuf.MapEntry.newDefaultInstance( - Data.internal_static_Log_ExtendInfoEntry_descriptor, com.google.protobuf.WireFormat.FieldType.STRING, - "", com.google.protobuf.WireFormat.FieldType.STRING, ""); - } - - /** - * Protobuf type {@code Log} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:Log) - LogOrBuilder { - - private int bitField0_; - - private Object group_ = ""; - - private Object key_ = ""; - - private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; - - private Object type_ = ""; - - private Object operation_ = ""; - - private com.google.protobuf.MapField extendInfo_; - - // Construct using com.alibaba.nacos.consistency.entity.Log.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder(BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return Data.internal_static_Log_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField(int number) { - switch (number) { - case 6: - return internalGetExtendInfo(); - default: - throw new RuntimeException("Invalid map field number: " + number); - } - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField(int number) { - switch (number) { - case 6: - return internalGetMutableExtendInfo(); - default: - throw new RuntimeException("Invalid map field number: " + number); - } - } - - @Override - protected FieldAccessorTable internalGetFieldAccessorTable() { - return Data.internal_static_Log_fieldAccessorTable - .ensureFieldAccessorsInitialized(Log.class, Log.Builder.class); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { - } - } - - @Override - public Builder clear() { - super.clear(); - group_ = ""; - - key_ = ""; - - data_ = com.google.protobuf.ByteString.EMPTY; - - type_ = ""; - - operation_ = ""; - - internalGetMutableExtendInfo().clear(); - return this; - } - - @Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return Data.internal_static_Log_descriptor; - } - - @Override - public Log getDefaultInstanceForType() { - return Log.getDefaultInstance(); - } - - @Override - public Log build() { - Log result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @Override - public Log buildPartial() { - Log result = new Log(this); - int from_bitField0_ = bitField0_; - result.group_ = group_; - result.key_ = key_; - result.data_ = data_; - result.type_ = type_; - result.operation_ = operation_; - result.extendInfo_ = internalGetExtendInfo(); - result.extendInfo_.makeImmutable(); - onBuilt(); - return result; - } - - @Override - public Builder clone() { - return super.clone(); - } - - @Override - public Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return super.setField(field, value); - } - - @Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @Override - public Builder setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index, - Object value) { - return super.setRepeatedField(field, index, value); - } - - @Override - public Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return super.addRepeatedField(field, value); - } - - @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Log) { - return mergeFrom((Log) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Log other) { - if (other == Log.getDefaultInstance()) { - return this; - } - if (!other.getGroup().isEmpty()) { - group_ = other.group_; - onChanged(); - } - if (!other.getKey().isEmpty()) { - key_ = other.key_; - onChanged(); - } - if (other.getData() != com.google.protobuf.ByteString.EMPTY) { - setData(other.getData()); - } - if (!other.getType().isEmpty()) { - type_ = other.type_; - onChanged(); - } - if (!other.getOperation().isEmpty()) { - operation_ = other.operation_; - onChanged(); - } - internalGetMutableExtendInfo().mergeFrom(other.internalGetExtendInfo()); - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @Override - public final boolean isInitialized() { - return true; - } - - @Override - public Builder mergeFrom(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - Log parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Log) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - /** - * string group = 1; - */ - public String getGroup() { - Object ref = group_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - group_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string group = 1; - */ - public Builder setGroup(String value) { - if (value == null) { - throw new NullPointerException(); - } - - group_ = value; - onChanged(); - return this; - } - - /** - * string group = 1; - */ - public com.google.protobuf.ByteString getGroupBytes() { - Object ref = group_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - group_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string group = 1; - */ - public Builder setGroupBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - group_ = value; - onChanged(); - return this; - } - - /** - * string group = 1; - */ - public Builder clearGroup() { - - group_ = getDefaultInstance().getGroup(); - onChanged(); - return this; - } - - /** - * string key = 2; - */ - public String getKey() { - Object ref = key_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - key_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string key = 2; - */ - public Builder setKey(String value) { - if (value == null) { - throw new NullPointerException(); - } - - key_ = value; - onChanged(); - return this; - } - - /** - * string key = 2; - */ - public com.google.protobuf.ByteString getKeyBytes() { - Object ref = key_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string key = 2; - */ - public Builder setKeyBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - key_ = value; - onChanged(); - return this; - } - - /** - * string key = 2; - */ - public Builder clearKey() { - - key_ = getDefaultInstance().getKey(); - onChanged(); - return this; - } - - /** - * bytes data = 3; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - /** - * bytes data = 3; - */ - public Builder setData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - data_ = value; - onChanged(); - return this; - } - - /** - * bytes data = 3; - */ - public Builder clearData() { - - data_ = getDefaultInstance().getData(); - onChanged(); - return this; - } - - /** - * string type = 4; - */ - 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 = 4; - */ - public Builder setType(String value) { - if (value == null) { - throw new NullPointerException(); - } - - type_ = value; - onChanged(); - return this; - } - - /** - * string type = 4; - */ - 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 = 4; - */ - public Builder setTypeBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - type_ = value; - onChanged(); - return this; - } - - /** - * string type = 4; - */ - public Builder clearType() { - - type_ = getDefaultInstance().getType(); - onChanged(); - return this; - } - - /** - * string operation = 5; - */ - public String getOperation() { - Object ref = operation_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - operation_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string operation = 5; - */ - public Builder setOperation(String value) { - if (value == null) { - throw new NullPointerException(); - } - - operation_ = value; - onChanged(); - return this; - } - - /** - * string operation = 5; - */ - public com.google.protobuf.ByteString getOperationBytes() { - Object ref = operation_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - operation_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string operation = 5; - */ - public Builder setOperationBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - operation_ = value; - onChanged(); - return this; - } - - /** - * string operation = 5; - */ - public Builder clearOperation() { - - operation_ = getDefaultInstance().getOperation(); - onChanged(); - return this; - } - - private com.google.protobuf.MapField internalGetExtendInfo() { - if (extendInfo_ == null) { - return com.google.protobuf.MapField.emptyMapField(ExtendInfoDefaultEntryHolder.defaultEntry); - } - return extendInfo_; - } - - private com.google.protobuf.MapField internalGetMutableExtendInfo() { - onChanged(); - ; - if (extendInfo_ == null) { - extendInfo_ = com.google.protobuf.MapField.newMapField(ExtendInfoDefaultEntryHolder.defaultEntry); - } - if (!extendInfo_.isMutable()) { - extendInfo_ = extendInfo_.copy(); - } - return extendInfo_; - } - - public int getExtendInfoCount() { - return internalGetExtendInfo().getMap().size(); - } - - /** - * map<string, string> extendInfo = 6; - */ - - public boolean containsExtendInfo(String key) { - if (key == null) { - throw new NullPointerException(); - } - return internalGetExtendInfo().getMap().containsKey(key); - } - - /** - * Use {@link #getExtendInfoMap()} instead. - */ - @Deprecated - public java.util.Map getExtendInfo() { - return getExtendInfoMap(); - } - - /** - * map<string, string> extendInfo = 6; - */ - - public java.util.Map getExtendInfoMap() { - return internalGetExtendInfo().getMap(); - } - - /** - * map<string, string> extendInfo = 6; - */ - - public String getExtendInfoOrDefault(String key, String defaultValue) { - if (key == null) { - throw new NullPointerException(); - } - java.util.Map map = internalGetExtendInfo().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - - /** - * map<string, string> extendInfo = 6; - */ - - public String getExtendInfoOrThrow(String key) { - if (key == null) { - throw new NullPointerException(); - } - java.util.Map map = internalGetExtendInfo().getMap(); - if (!map.containsKey(key)) { - throw new IllegalArgumentException(); - } - return map.get(key); - } - - public Builder clearExtendInfo() { - internalGetMutableExtendInfo().getMutableMap().clear(); - return this; - } - - /** - * map<string, string> extendInfo = 6; - */ - - public Builder removeExtendInfo(String key) { - if (key == null) { - throw new NullPointerException(); - } - internalGetMutableExtendInfo().getMutableMap().remove(key); - return this; - } - - /** - * Use alternate mutation accessors instead. - */ - @Deprecated - public java.util.Map getMutableExtendInfo() { - return internalGetMutableExtendInfo().getMutableMap(); - } - - /** - * map<string, string> extendInfo = 6; - */ - public Builder putExtendInfo(String key, String value) { - if (key == null) { - throw new NullPointerException(); - } - if (value == null) { - throw new NullPointerException(); - } - internalGetMutableExtendInfo().getMutableMap().put(key, value); - return this; - } - - /** - * map<string, string> extendInfo = 6; - */ - - public Builder putAllExtendInfo(java.util.Map values) { - internalGetMutableExtendInfo().getMutableMap().putAll(values); - return this; - } - - @Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @Override - public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:Log) - } - -} - diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/LogOrBuilder.java b/consistency/src/main/java/com/alibaba/nacos/consistency/entity/LogOrBuilder.java deleted file mode 100644 index d1bfb48b641..00000000000 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/LogOrBuilder.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Data.proto - -package com.alibaba.nacos.consistency.entity; - -@SuppressWarnings("all") -public interface LogOrBuilder extends - // @@protoc_insertion_point(interface_extends:Log) - com.google.protobuf.MessageOrBuilder { - - /** - * string group = 1; - */ - String getGroup(); - - /** - * string group = 1; - */ - com.google.protobuf.ByteString getGroupBytes(); - - /** - * string key = 2; - */ - String getKey(); - - /** - * string key = 2; - */ - com.google.protobuf.ByteString getKeyBytes(); - - /** - * bytes data = 3; - */ - com.google.protobuf.ByteString getData(); - - /** - * string type = 4; - */ - String getType(); - - /** - * string type = 4; - */ - com.google.protobuf.ByteString getTypeBytes(); - - /** - * string operation = 5; - */ - String getOperation(); - - /** - * string operation = 5; - */ - com.google.protobuf.ByteString getOperationBytes(); - - /** - * map<string, string> extendInfo = 6; - */ - int getExtendInfoCount(); - - /** - * map<string, string> extendInfo = 6; - */ - boolean containsExtendInfo(String key); - - /** - * Use {@link #getExtendInfoMap()} instead. - */ - @Deprecated - java.util.Map getExtendInfo(); - - /** - * map<string, string> extendInfo = 6; - */ - java.util.Map getExtendInfoMap(); - - /** - * map<string, string> extendInfo = 6; - */ - - String getExtendInfoOrDefault(String key, String defaultValue); - - /** - * map<string, string> extendInfo = 6; - */ - - String getExtendInfoOrThrow(String key); -} diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/Response.java b/consistency/src/main/java/com/alibaba/nacos/consistency/entity/Response.java deleted file mode 100644 index e5784f55ca6..00000000000 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/Response.java +++ /dev/null @@ -1,677 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Data.proto - -package com.alibaba.nacos.consistency.entity; - -/** - * Protobuf type {@code Response}. - */ -@SuppressWarnings("all") -public final class Response extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:Response) - ResponseOrBuilder { - - public static final int DATA_FIELD_NUMBER = 1; - - public static final int ERRMSG_FIELD_NUMBER = 2; - - public static final int SUCCESS_FIELD_NUMBER = 3; - - private static final long serialVersionUID = 0L; - - // @@protoc_insertion_point(class_scope:Response) - private static final Response DEFAULT_INSTANCE; - - private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { - @Override - public Response parsePartialFrom(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Response(input, extensionRegistry); - } - }; - - static { - DEFAULT_INSTANCE = new Response(); - } - - private com.google.protobuf.ByteString data_; - - private volatile Object errMsg_; - - private boolean success_; - - private byte memoizedIsInitialized = -1; - - // Use Response.newBuilder() to construct. - private Response(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Response() { - data_ = com.google.protobuf.ByteString.EMPTY; - errMsg_ = ""; - } - - private Response(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new NullPointerException(); - } - 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; - case 10: { - - data_ = input.readBytes(); - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - errMsg_ = s; - break; - } - case 24: { - - success_ = input.readBool(); - break; - } - default: { - if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { - done = true; - } - 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 Data.internal_static_Response_descriptor; - } - - 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 static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Response prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public static Response getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - @SuppressWarnings({"unused"}) - protected Object newInstance(UnusedPrivateParameter unused) { - return new Response(); - } - - @Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - @Override - protected FieldAccessorTable internalGetFieldAccessorTable() { - return Data.internal_static_Response_fieldAccessorTable - .ensureFieldAccessorsInitialized(Response.class, Response.Builder.class); - } - - /** - * bytes data = 1; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - /** - * string errMsg = 2; - */ - public String getErrMsg() { - Object ref = errMsg_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - errMsg_ = s; - return s; - } - } - - /** - * string errMsg = 2; - */ - public com.google.protobuf.ByteString getErrMsgBytes() { - Object ref = errMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - errMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * bool success = 3; - */ - public boolean getSuccess() { - return success_; - } - - @Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - - memoizedIsInitialized = 1; - return true; - } - - @Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!data_.isEmpty()) { - output.writeBytes(1, data_); - } - if (!getErrMsgBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, errMsg_); - } - if (success_ != false) { - output.writeBool(3, success_); - } - unknownFields.writeTo(output); - } - - @Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (!data_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, data_); - } - if (!getErrMsgBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, errMsg_); - } - if (success_ != false) { - size += com.google.protobuf.CodedOutputStream.computeBoolSize(3, success_); - } - 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; - - if (!getData().equals(other.getData())) { - return false; - } - if (!getErrMsg().equals(other.getErrMsg())) { - return false; - } - if (getSuccess() != other.getSuccess()) { - return false; - } - if (!unknownFields.equals(other.unknownFields)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + DATA_FIELD_NUMBER; - hash = (53 * hash) + getData().hashCode(); - hash = (37 * hash) + ERRMSG_FIELD_NUMBER; - hash = (53 * hash) + getErrMsg().hashCode(); - hash = (37 * hash) + SUCCESS_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getSuccess()); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - @Override - public Builder newBuilderForType() { - return newBuilder(); - } - - @Override - 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; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @Override - public Response getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - /** - * Protobuf type {@code Response} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:Response) - ResponseOrBuilder { - - private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; - - private Object errMsg_ = ""; - - private boolean success_; - - // Construct using com.alibaba.nacos.consistency.entity.Response.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder(BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return Data.internal_static_Response_descriptor; - } - - @Override - protected FieldAccessorTable internalGetFieldAccessorTable() { - return Data.internal_static_Response_fieldAccessorTable - .ensureFieldAccessorsInitialized(Response.class, Response.Builder.class); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { - } - } - - @Override - public Builder clear() { - super.clear(); - data_ = com.google.protobuf.ByteString.EMPTY; - - errMsg_ = ""; - - success_ = false; - - return this; - } - - @Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return Data.internal_static_Response_descriptor; - } - - @Override - public Response getDefaultInstanceForType() { - return Response.getDefaultInstance(); - } - - @Override - public Response build() { - Response result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @Override - public Response buildPartial() { - Response result = new Response(this); - result.data_ = data_; - result.errMsg_ = errMsg_; - result.success_ = success_; - onBuilt(); - return result; - } - - @Override - public Builder clone() { - return super.clone(); - } - - @Override - public Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return super.setField(field, value); - } - - @Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @Override - public Builder setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index, - Object value) { - return super.setRepeatedField(field, index, value); - } - - @Override - public Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return super.addRepeatedField(field, value); - } - - @Override - 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.getData() != com.google.protobuf.ByteString.EMPTY) { - setData(other.getData()); - } - if (!other.getErrMsg().isEmpty()) { - errMsg_ = other.errMsg_; - onChanged(); - } - if (other.getSuccess() != false) { - setSuccess(other.getSuccess()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @Override - public final boolean isInitialized() { - return true; - } - - @Override - 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; - } - - /** - * bytes data = 1; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - /** - * bytes data = 1; - */ - public Builder setData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - data_ = value; - onChanged(); - return this; - } - - /** - * bytes data = 1; - */ - public Builder clearData() { - - data_ = getDefaultInstance().getData(); - onChanged(); - return this; - } - - /** - * string errMsg = 2; - */ - public String getErrMsg() { - Object ref = errMsg_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - errMsg_ = s; - return s; - } else { - return (String) ref; - } - } - - /** - * string errMsg = 2; - */ - public Builder setErrMsg(String value) { - if (value == null) { - throw new NullPointerException(); - } - - errMsg_ = value; - onChanged(); - return this; - } - - /** - * string errMsg = 2; - */ - public com.google.protobuf.ByteString getErrMsgBytes() { - Object ref = errMsg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - errMsg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string errMsg = 2; - */ - public Builder setErrMsgBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - errMsg_ = value; - onChanged(); - return this; - } - - /** - * string errMsg = 2; - */ - public Builder clearErrMsg() { - - errMsg_ = getDefaultInstance().getErrMsg(); - onChanged(); - return this; - } - - /** - * bool success = 3; - */ - public boolean getSuccess() { - return success_; - } - - /** - * bool success = 3; - */ - public Builder setSuccess(boolean value) { - - success_ = value; - onChanged(); - return this; - } - - /** - * bool success = 3; - */ - public Builder clearSuccess() { - - success_ = false; - onChanged(); - return this; - } - - @Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @Override - public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:Response) - } - -} - diff --git a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/ResponseOrBuilder.java b/consistency/src/main/java/com/alibaba/nacos/consistency/entity/ResponseOrBuilder.java deleted file mode 100644 index c0050499747..00000000000 --- a/consistency/src/main/java/com/alibaba/nacos/consistency/entity/ResponseOrBuilder.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Data.proto - -package com.alibaba.nacos.consistency.entity; - -@SuppressWarnings("all") -public interface ResponseOrBuilder extends - // @@protoc_insertion_point(interface_extends:Response) - com.google.protobuf.MessageOrBuilder { - - /** - * bytes data = 1; - */ - com.google.protobuf.ByteString getData(); - - /** - * string errMsg = 2; - */ - String getErrMsg(); - - /** - * string errMsg = 2; - */ - com.google.protobuf.ByteString getErrMsgBytes(); - - /** - * bool success = 3; - */ - boolean getSuccess(); -} diff --git a/consistency/src/main/proto/Data.proto b/consistency/src/main/proto/Data.proto index 32f19af052d..8690a490186 100644 --- a/consistency/src/main/proto/Data.proto +++ b/consistency/src/main/proto/Data.proto @@ -19,6 +19,7 @@ syntax = "proto3"; option java_multiple_files = true; option java_package = "com.alibaba.nacos.consistency.entity"; +//Deprecated message Log { string group = 1; string key = 2; @@ -28,15 +29,10 @@ message Log { map extendInfo = 6; } +//Deprecated message GetRequest { string group = 1; bytes data = 2; map extendInfo = 3; } -message Response { - bytes data = 1; - string errMsg = 2; - bool success = 3; -} - diff --git a/consistency/src/main/proto/consistency.proto b/consistency/src/main/proto/consistency.proto new file mode 100644 index 00000000000..0dba9d83aaf --- /dev/null +++ b/consistency/src/main/proto/consistency.proto @@ -0,0 +1,42 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "com.alibaba.nacos.consistency.entity"; + +message WriteRequest { + string group = 1; + string key = 2; + bytes data = 3; + string type = 4; + string operation = 5; + map extendInfo = 6; +} + +message ReadRequest { + string group = 1; + bytes data = 2; + map extendInfo = 3; +} + +message Response { + bytes data = 1; + string errMsg = 2; + bool success = 3; +} + diff --git a/consistency/src/test/java/com/alibaba/nacos/consistency/ProtoMessageUtilTest.java b/consistency/src/test/java/com/alibaba/nacos/consistency/ProtoMessageUtilTest.java new file mode 100644 index 00000000000..2cf1cc18c7e --- /dev/null +++ b/consistency/src/test/java/com/alibaba/nacos/consistency/ProtoMessageUtilTest.java @@ -0,0 +1,37 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.nacos.consistency; + +import com.alibaba.nacos.consistency.entity.Log; +import com.alibaba.nacos.consistency.entity.WriteRequest; +import org.junit.Assert; +import org.junit.Test; + +public class ProtoMessageUtilTest { + + @Test + public void testProto() throws Exception { + WriteRequest request = WriteRequest.newBuilder() + .setKey("test-proto-new") + .build(); + + byte[] bytes = request.toByteArray(); + Log log = Log.parseFrom(bytes); + Assert.assertEquals(request.getKey(), log.getKey()); + } + +} \ No newline at end of file diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/AbstractConsistencyProtocol.java b/core/src/main/java/com/alibaba/nacos/core/distributed/AbstractConsistencyProtocol.java index 8cf1183343e..250c12c7833 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/AbstractConsistencyProtocol.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/AbstractConsistencyProtocol.java @@ -18,7 +18,7 @@ import com.alibaba.nacos.consistency.Config; import com.alibaba.nacos.consistency.ConsistencyProtocol; -import com.alibaba.nacos.consistency.LogProcessor; +import com.alibaba.nacos.consistency.RequestProcessor; import com.alibaba.nacos.consistency.ProtocolMetaData; import java.util.Collections; @@ -32,7 +32,7 @@ * @author liaochuntao */ @SuppressWarnings("all") -public abstract class AbstractConsistencyProtocol +public abstract class AbstractConsistencyProtocol implements ConsistencyProtocol { protected final ProtocolMetaData metaData = new ProtocolMetaData(); diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftProtocol.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftProtocol.java index 261bce4578b..f53ad71d714 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftProtocol.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftProtocol.java @@ -26,11 +26,11 @@ import com.alibaba.nacos.consistency.SerializeFactory; import com.alibaba.nacos.consistency.Serializer; import com.alibaba.nacos.consistency.cp.CPProtocol; -import com.alibaba.nacos.consistency.cp.LogProcessor4CP; +import com.alibaba.nacos.consistency.cp.RequestProcessor4CP; import com.alibaba.nacos.consistency.cp.MetadataKey; -import com.alibaba.nacos.consistency.entity.GetRequest; -import com.alibaba.nacos.consistency.entity.Log; +import com.alibaba.nacos.consistency.entity.ReadRequest; import com.alibaba.nacos.consistency.entity.Response; +import com.alibaba.nacos.consistency.entity.WriteRequest; import com.alibaba.nacos.core.cluster.Member; import com.alibaba.nacos.core.cluster.ServerMemberManager; import com.alibaba.nacos.core.distributed.AbstractConsistencyProtocol; @@ -90,8 +90,8 @@ * @author liaochuntao */ @SuppressWarnings("all") -public class JRaftProtocol extends AbstractConsistencyProtocol - implements CPProtocol { +public class JRaftProtocol extends AbstractConsistencyProtocol + implements CPProtocol { private final AtomicBoolean initialized = new AtomicBoolean(false); @@ -159,31 +159,31 @@ public Class subscribeType() { } @Override - public void addLogProcessors(Collection processors) { + public void addLogProcessors(Collection processors) { raftServer.createMultiRaftGroup(processors); } @Override - public Response getData(GetRequest request) throws Exception { + public Response getData(ReadRequest request) throws Exception { CompletableFuture future = aGetData(request); return future.get(5_000L, TimeUnit.MILLISECONDS); } @Override - public CompletableFuture aGetData(GetRequest request) { + public CompletableFuture aGetData(ReadRequest request) { return raftServer.get(request); } @Override - public Response submit(Log data) throws Exception { - CompletableFuture future = submitAsync(data); + public Response submit(WriteRequest request) throws Exception { + CompletableFuture future = submitAsync(request); // Here you wait for 10 seconds, as long as possible, for the request to complete return future.get(10_000L, TimeUnit.MILLISECONDS); } @Override - public CompletableFuture submitAsync(Log data) { - return raftServer.commit(data.getGroup(), data, new CompletableFuture<>()); + public CompletableFuture submitAsync(WriteRequest request) { + return raftServer.commit(request.getGroup(), request, new CompletableFuture<>()); } @Override diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftServer.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftServer.java index 567dc0503f4..a4ee8f98174 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftServer.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/JRaftServer.java @@ -22,11 +22,11 @@ import com.alibaba.nacos.common.utils.IPUtil; import com.alibaba.nacos.common.utils.LoggerUtils; import com.alibaba.nacos.common.utils.ThreadUtils; -import com.alibaba.nacos.consistency.LogProcessor; +import com.alibaba.nacos.consistency.RequestProcessor; import com.alibaba.nacos.consistency.SerializeFactory; import com.alibaba.nacos.consistency.Serializer; -import com.alibaba.nacos.consistency.cp.LogProcessor4CP; -import com.alibaba.nacos.consistency.entity.GetRequest; +import com.alibaba.nacos.consistency.cp.RequestProcessor4CP; +import com.alibaba.nacos.consistency.entity.ReadRequest; import com.alibaba.nacos.consistency.entity.Response; import com.alibaba.nacos.consistency.exception.ConsistencyException; import com.alibaba.nacos.core.distributed.raft.exception.DuplicateRaftGroupException; @@ -135,7 +135,7 @@ public class JRaftServer { private Serializer serializer; - private Collection processors = Collections.synchronizedSet(new HashSet<>()); + private Collection processors = Collections.synchronizedSet(new HashSet<>()); private String selfIp; @@ -226,7 +226,7 @@ synchronized void start() { } } - synchronized void createMultiRaftGroup(Collection processors) { + synchronized void createMultiRaftGroup(Collection processors) { // There is no reason why the LogProcessor cannot be processed because of the synchronization if (!this.isStarted) { this.processors.addAll(processors); @@ -235,7 +235,7 @@ synchronized void createMultiRaftGroup(Collection processors) { final String parentPath = Paths.get(ApplicationUtils.getNacosHome(), "data/protocol/raft").toString(); - for (LogProcessor4CP processor : processors) { + for (RequestProcessor4CP processor : processors) { final String groupName = processor.group(); if (multiRaftGroup.containsKey(groupName)) { throw new DuplicateRaftGroupException(groupName); @@ -280,7 +280,7 @@ synchronized void createMultiRaftGroup(Collection processors) { } } - CompletableFuture get(final GetRequest request) { + CompletableFuture get(final ReadRequest request) { final String group = request.getGroup(); CompletableFuture future = new CompletableFuture<>(); final RaftGroupTuple tuple = findTupleByGroup(group); @@ -289,7 +289,7 @@ CompletableFuture get(final GetRequest request) { return future; } final Node node = tuple.node; - final LogProcessor processor = tuple.processor; + final RequestProcessor processor = tuple.processor; try { node.readIndex(BytesUtil.EMPTY_BYTES, new ReadIndexClosure() { @Override @@ -322,7 +322,7 @@ public void run(Status status, long index, byte[] reqCtx) { } } - public void readFromLeader(final GetRequest request, final CompletableFuture future) { + public void readFromLeader(final ReadRequest request, final CompletableFuture future) { commit(request.getGroup(), request, future).whenComplete(new BiConsumer() { @Override public void accept(Response response, Throwable throwable) { @@ -540,7 +540,7 @@ CliService getCliService() { public static class RaftGroupTuple { - private LogProcessor processor; + private RequestProcessor processor; private Node node; @@ -552,7 +552,7 @@ public static class RaftGroupTuple { public RaftGroupTuple() { } - public RaftGroupTuple(Node node, LogProcessor processor, RaftGroupService raftGroupService, + public RaftGroupTuple(Node node, RequestProcessor processor, RaftGroupService raftGroupService, NacosStateMachine machine) { this.node = node; this.processor = processor; @@ -564,7 +564,7 @@ public Node getNode() { return node; } - public LogProcessor getProcessor() { + public RequestProcessor getProcessor() { return processor; } diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/NacosStateMachine.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/NacosStateMachine.java index bacc39b34a5..bb7e8e903bb 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/NacosStateMachine.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/NacosStateMachine.java @@ -20,11 +20,12 @@ import com.alibaba.nacos.common.utils.ExceptionUtil; import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.common.utils.LoggerUtils; -import com.alibaba.nacos.consistency.LogProcessor; -import com.alibaba.nacos.consistency.cp.LogProcessor4CP; -import com.alibaba.nacos.consistency.entity.GetRequest; -import com.alibaba.nacos.consistency.entity.Log; +import com.alibaba.nacos.consistency.RequestProcessor; +import com.alibaba.nacos.consistency.ProtoMessageUtil; +import com.alibaba.nacos.consistency.cp.RequestProcessor4CP; +import com.alibaba.nacos.consistency.entity.ReadRequest; import com.alibaba.nacos.consistency.entity.Response; +import com.alibaba.nacos.consistency.entity.WriteRequest; import com.alibaba.nacos.consistency.exception.ConsistencyException; import com.alibaba.nacos.consistency.snapshot.LocalFileMeta; import com.alibaba.nacos.consistency.snapshot.Reader; @@ -69,7 +70,7 @@ class NacosStateMachine extends StateMachineAdapter { protected final JRaftServer server; - protected final LogProcessor processor; + protected final RequestProcessor processor; private final AtomicBoolean isLeader = new AtomicBoolean(false); @@ -83,7 +84,7 @@ class NacosStateMachine extends StateMachineAdapter { private volatile String leaderIp = "unknown"; - NacosStateMachine(JRaftServer server, LogProcessor4CP processor) { + NacosStateMachine(JRaftServer server, RequestProcessor4CP processor) { this.server = server; this.processor = processor; this.groupId = processor.group(); @@ -105,18 +106,18 @@ public void onApply(Iterator iter) { message = closure.getMessage(); } else { final ByteBuffer data = iter.getData(); - message = parse(data.array()); + message = ProtoMessageUtil.parse(data.array()); } LoggerUtils.printIfDebugEnabled(Loggers.RAFT, "receive log : {}", message); - if (message instanceof Log) { - Response response = processor.onApply((Log) message); + if (message instanceof WriteRequest) { + Response response = processor.onApply((WriteRequest) message); postProcessor(response, closure); } - if (message instanceof GetRequest) { - Response response = processor.onRequest((GetRequest) message); + if (message instanceof ReadRequest) { + Response response = processor.onRequest((ReadRequest) message); postProcessor(response, closure); } } catch (Throwable e) { @@ -140,23 +141,6 @@ public void onApply(Iterator iter) { } } - private Message parse(byte[] bytes) { - Message result; - try { - result = Log.parseFrom(bytes); - return result; - } catch (Throwable ignore) { - } - - try { - result = GetRequest.parseFrom(bytes); - return result; - } catch (Throwable ignore) { - } - - throw new ConsistencyException("The current array cannot be serialized to the corresponding object"); - } - public void setNode(Node node) { this.node = node; } diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftConfig.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftConfig.java index a605f497833..123f4233cc5 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftConfig.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/RaftConfig.java @@ -18,7 +18,7 @@ import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.consistency.Config; -import com.alibaba.nacos.consistency.cp.LogProcessor4CP; +import com.alibaba.nacos.consistency.cp.RequestProcessor4CP; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @@ -35,7 +35,7 @@ */ @Component @ConfigurationProperties(prefix = "nacos.core.protocol.raft") -public class RaftConfig implements Config { +public class RaftConfig implements Config { private static final long serialVersionUID = 9174789390266064002L; diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/AbstractProcessor.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/AbstractProcessor.java index 51800655e29..17f066bfbce 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/AbstractProcessor.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/AbstractProcessor.java @@ -40,7 +40,7 @@ public AbstractProcessor(Serializer serializer) { this.serializer = serializer; } - protected void handleRequest(final JRaftServer server, final String group, final RpcContext rpcCtx, Message log) { + protected void handleRequest(final JRaftServer server, final String group, final RpcContext rpcCtx, Message message) { try { final JRaftServer.RaftGroupTuple tuple = server.findTupleByGroup(group); if (Objects.isNull(tuple)) { @@ -49,7 +49,7 @@ protected void handleRequest(final JRaftServer server, final String group, final return; } if (tuple.getNode().isLeader()) { - execute(server, rpcCtx, log, tuple); + execute(server, rpcCtx, message, tuple); } else { rpcCtx.sendResponse( Response.newBuilder().setSuccess(false).setErrMsg("Could not find leader : " + group).build()); @@ -60,7 +60,7 @@ protected void handleRequest(final JRaftServer server, final String group, final } } - protected void execute(JRaftServer server, final RpcContext asyncCtx, final Message log, + protected void execute(JRaftServer server, final RpcContext asyncCtx, final Message message, final JRaftServer.RaftGroupTuple tuple) { FailoverClosure closure = new FailoverClosure() { @@ -89,7 +89,7 @@ public void run(Status status) { } }; - server.applyOperation(tuple.getNode(), log, closure); + server.applyOperation(tuple.getNode(), message, closure); } } diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosGetRequestProcessor.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosGetRequestProcessor.java index 8097908fe14..f87578083bc 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosGetRequestProcessor.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosGetRequestProcessor.java @@ -16,6 +16,7 @@ package com.alibaba.nacos.core.distributed.raft.processor; +import com.alibaba.nacos.consistency.ProtoMessageUtil; import com.alibaba.nacos.consistency.Serializer; import com.alibaba.nacos.consistency.entity.GetRequest; import com.alibaba.nacos.core.distributed.raft.JRaftServer; @@ -40,7 +41,7 @@ public NacosGetRequestProcessor(JRaftServer server, Serializer serializer) { @Override public void handleRequest(final RpcContext rpcCtx, GetRequest request) { - handleRequest(server, request.getGroup(), rpcCtx, request); + handleRequest(server, request.getGroup(), rpcCtx, ProtoMessageUtil.convertToReadRequest(request)); } @Override diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosLogProcessor.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosLogProcessor.java index acbc66bd9b4..0511db1e5b4 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosLogProcessor.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosLogProcessor.java @@ -16,6 +16,7 @@ package com.alibaba.nacos.core.distributed.raft.processor; +import com.alibaba.nacos.consistency.ProtoMessageUtil; import com.alibaba.nacos.consistency.Serializer; import com.alibaba.nacos.consistency.entity.Log; import com.alibaba.nacos.core.distributed.raft.JRaftServer; @@ -40,7 +41,7 @@ public NacosLogProcessor(JRaftServer server, Serializer serializer) { @Override public void handleRequest(final RpcContext rpcCtx, Log log) { - handleRequest(server, log.getGroup(), rpcCtx, log); + handleRequest(server, log.getGroup(), rpcCtx, ProtoMessageUtil.convertToWriteRequest(log)); } @Override diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosReadRequestProcessor.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosReadRequestProcessor.java new file mode 100644 index 00000000000..05f2d32d3c1 --- /dev/null +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosReadRequestProcessor.java @@ -0,0 +1,44 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.nacos.core.distributed.raft.processor; + +import com.alibaba.nacos.consistency.Serializer; +import com.alibaba.nacos.consistency.entity.ReadRequest; +import com.alipay.sofa.jraft.rpc.RpcContext; +import com.alipay.sofa.jraft.rpc.RpcProcessor; + +/** + * nacos request processor for {@link com.alibaba.nacos.consistency.entity.ReadRequest}. + * + * @author liaochuntao + */ +public class NacosReadRequestProcessor extends AbstractProcessor implements RpcProcessor { + + public NacosReadRequestProcessor(Serializer serializer) { + super(serializer); + } + + @Override + public void handleRequest(RpcContext rpcCtx, ReadRequest request) { + + } + + @Override + public String interest() { + return null; + } +} diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosWriteRequestProcessor.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosWriteRequestProcessor.java new file mode 100644 index 00000000000..e684ef0a694 --- /dev/null +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/processor/NacosWriteRequestProcessor.java @@ -0,0 +1,44 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.nacos.core.distributed.raft.processor; + +import com.alibaba.nacos.consistency.Serializer; +import com.alibaba.nacos.consistency.entity.WriteRequest; +import com.alipay.sofa.jraft.rpc.RpcContext; +import com.alipay.sofa.jraft.rpc.RpcProcessor; + +/** + * nacos request processor for {@link WriteRequest}. + * + * @author liaochuntao + */ +public class NacosWriteRequestProcessor extends AbstractProcessor implements RpcProcessor { + + public NacosWriteRequestProcessor(Serializer serializer) { + super(serializer); + } + + @Override + public void handleRequest(RpcContext rpcCtx, WriteRequest request) { + + } + + @Override + public String interest() { + return null; + } +} diff --git a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/utils/JRaftUtils.java b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/utils/JRaftUtils.java index 02fb26bbf21..af5c6bc94e7 100644 --- a/core/src/main/java/com/alibaba/nacos/core/distributed/raft/utils/JRaftUtils.java +++ b/core/src/main/java/com/alibaba/nacos/core/distributed/raft/utils/JRaftUtils.java @@ -20,7 +20,9 @@ import com.alibaba.nacos.consistency.SerializeFactory; import com.alibaba.nacos.consistency.entity.GetRequest; import com.alibaba.nacos.consistency.entity.Log; +import com.alibaba.nacos.consistency.entity.ReadRequest; import com.alibaba.nacos.consistency.entity.Response; +import com.alibaba.nacos.consistency.entity.WriteRequest; import com.alibaba.nacos.core.cluster.ServerMemberManager; import com.alibaba.nacos.core.distributed.raft.JRaftServer; import com.alibaba.nacos.core.distributed.raft.processor.NacosGetRequestProcessor; @@ -62,11 +64,16 @@ public static RpcServer initRpcServer(JRaftServer server, PeerId peerId) { GrpcRaftRpcFactory raftRpcFactory = (GrpcRaftRpcFactory) RpcFactoryHelper.rpcFactory(); raftRpcFactory.registerProtobufSerializer(Log.class.getName(), Log.getDefaultInstance()); raftRpcFactory.registerProtobufSerializer(GetRequest.class.getName(), GetRequest.getDefaultInstance()); + raftRpcFactory.registerProtobufSerializer(WriteRequest.class.getName(), WriteRequest.getDefaultInstance()); + raftRpcFactory.registerProtobufSerializer(ReadRequest.class.getName(), ReadRequest.getDefaultInstance()); raftRpcFactory.registerProtobufSerializer(Response.class.getName(), Response.getDefaultInstance()); MarshallerRegistry registry = raftRpcFactory.getMarshallerRegistry(); registry.registerResponseInstance(Log.class.getName(), Response.getDefaultInstance()); registry.registerResponseInstance(GetRequest.class.getName(), Response.getDefaultInstance()); + + registry.registerResponseInstance(WriteRequest.class.getName(), WriteRequest.getDefaultInstance()); + registry.registerResponseInstance(ReadRequest.class.getName(), ReadRequest.getDefaultInstance()); final RpcServer rpcServer = raftRpcFactory.createRpcServer(new Endpoint(peerId.getIp(), peerId.getPort())); RaftRpcServerFactory.addRaftRequestProcessors(rpcServer, RaftExecutor.getRaftCoreExecutor(), @@ -97,12 +104,7 @@ public static final void initDirectory(String parentPath, String groupName, Node copy.setRaftMetaUri(metaDataUri); copy.setSnapshotUri(snapshotUri); } - - public static final Log injectExtendInfo(Log log, final String operate) { - Log gLog = Log.newBuilder(log).putExtendInfo(JRaftConstants.JRAFT_EXTEND_INFO_KEY, operate).build(); - return gLog; - } - + public static List toStrings(List peerIds) { return peerIds.stream().map(peerId -> peerId.getEndpoint().toString()).collect(Collectors.toList()); } diff --git a/core/src/test/java/com/alibaba/nacos/core/distributed/raft/processor/AbstractProcessorTest.java b/core/src/test/java/com/alibaba/nacos/core/distributed/raft/processor/AbstractProcessorTest.java index bc370daad7d..8cde8e4a026 100644 --- a/core/src/test/java/com/alibaba/nacos/core/distributed/raft/processor/AbstractProcessorTest.java +++ b/core/src/test/java/com/alibaba/nacos/core/distributed/raft/processor/AbstractProcessorTest.java @@ -17,8 +17,8 @@ package com.alibaba.nacos.core.distributed.raft.processor; import com.alibaba.nacos.consistency.SerializeFactory; -import com.alibaba.nacos.consistency.entity.Log; import com.alibaba.nacos.consistency.entity.Response; +import com.alibaba.nacos.consistency.entity.WriteRequest; import com.alibaba.nacos.core.distributed.raft.JRaftServer; import com.alibaba.nacos.core.distributed.raft.utils.FailoverClosure; import com.alipay.sofa.jraft.Node; @@ -64,7 +64,7 @@ public String getRemoteAddress() { } }; AbstractProcessor processor = new NacosLogProcessor(server, SerializeFactory.getDefault()); - processor.execute(server, context, Log.newBuilder().build(), new JRaftServer.RaftGroupTuple()); + processor.execute(server, context, WriteRequest.newBuilder().build(), new JRaftServer.RaftGroupTuple()); Response response = reference.get(); Assert.assertNotNull(response); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/impl/PersistentServiceProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/impl/PersistentServiceProcessor.java index 1d807dcfd02..e90211c6ed5 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/impl/PersistentServiceProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/consistency/persistent/impl/PersistentServiceProcessor.java @@ -25,11 +25,11 @@ import com.alibaba.nacos.consistency.SerializeFactory; import com.alibaba.nacos.consistency.Serializer; import com.alibaba.nacos.consistency.cp.CPProtocol; -import com.alibaba.nacos.consistency.cp.LogProcessor4CP; +import com.alibaba.nacos.consistency.cp.RequestProcessor4CP; import com.alibaba.nacos.consistency.cp.MetadataKey; -import com.alibaba.nacos.consistency.entity.GetRequest; -import com.alibaba.nacos.consistency.entity.Log; +import com.alibaba.nacos.consistency.entity.ReadRequest; import com.alibaba.nacos.consistency.entity.Response; +import com.alibaba.nacos.consistency.entity.WriteRequest; import com.alibaba.nacos.consistency.snapshot.SnapshotOperation; import com.alibaba.nacos.core.distributed.ProtocolManager; import com.alibaba.nacos.core.exception.ErrorCode; @@ -68,7 +68,7 @@ */ @SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule") @Service -public class PersistentServiceProcessor extends LogProcessor4CP implements PersistentConsistencyService { +public class PersistentServiceProcessor extends RequestProcessor4CP implements PersistentConsistencyService { enum Op { /** @@ -176,7 +176,7 @@ private void waitLeader() { } @Override - public Response onRequest(GetRequest request) { + public Response onRequest(ReadRequest request) { final List keys = serializer .deserialize(request.getData().toByteArray(), TypeUtils.parameterize(List.class, byte[].class)); final Lock lock = readLock; @@ -195,24 +195,24 @@ public Response onRequest(GetRequest request) { } @Override - public Response onApply(Log log) { - final byte[] data = log.getData().toByteArray(); - final BatchWriteRequest request = serializer.deserialize(data, BatchWriteRequest.class); - final Op op = Op.valueOf(log.getOperation()); + public Response onApply(WriteRequest request) { + final byte[] data = request.getData().toByteArray(); + final BatchWriteRequest bwRequest = serializer.deserialize(data, BatchWriteRequest.class); + final Op op = Op.valueOf(request.getOperation()); final Lock lock = readLock; lock.lock(); try { switch (op) { case Write: - kvStorage.batchPut(request.getKeys(), request.getValues()); + kvStorage.batchPut(bwRequest.getKeys(), bwRequest.getValues()); break; case Delete: - kvStorage.batchDelete(request.getKeys()); + kvStorage.batchDelete(bwRequest.getKeys()); break; default: return Response.newBuilder().setSuccess(false).setErrMsg("unsupport operation : " + op).build(); } - publishValueChangeEvent(op, request); + publishValueChangeEvent(op, bwRequest); return Response.newBuilder().setSuccess(true).build(); } catch (KvStorageException e) { return Response.newBuilder().setSuccess(false).setErrMsg(e.getErrMsg()).build(); @@ -249,10 +249,10 @@ public void put(String key, Record value) throws NacosException { final BatchWriteRequest req = new BatchWriteRequest(); Datum datum = Datum.createDatum(key, value); req.append(ByteUtils.toBytes(key), serializer.serialize(datum)); - final Log log = Log.newBuilder().setData(ByteString.copyFrom(serializer.serialize(req))) + final WriteRequest request = WriteRequest.newBuilder().setData(ByteString.copyFrom(serializer.serialize(req))) .setGroup(Constants.NAMING_PERSISTENT_SERVICE_GROUP).setOperation(Op.Write.desc).build(); try { - protocol.submit(log); + protocol.submit(request); } catch (Exception e) { throw new NacosException(ErrorCode.ProtoSubmitError.getCode(), e.getMessage()); } @@ -262,10 +262,10 @@ public void put(String key, Record value) throws NacosException { public void remove(String key) throws NacosException { final BatchWriteRequest req = new BatchWriteRequest(); req.append(ByteUtils.toBytes(key), ByteUtils.EMPTY); - final Log log = Log.newBuilder().setData(ByteString.copyFrom(serializer.serialize(req))) + final WriteRequest request = WriteRequest.newBuilder().setData(ByteString.copyFrom(serializer.serialize(req))) .setGroup(Constants.NAMING_PERSISTENT_SERVICE_GROUP).setOperation(Op.Delete.desc).build(); try { - protocol.submit(log); + protocol.submit(request); } catch (Exception e) { throw new NacosException(ErrorCode.ProtoSubmitError.getCode(), e.getMessage()); } @@ -275,7 +275,7 @@ public void remove(String key) throws NacosException { public Datum get(String key) throws NacosException { final List keys = new ArrayList<>(1); keys.add(ByteUtils.toBytes(key)); - final GetRequest req = GetRequest.newBuilder().setGroup(Constants.NAMING_PERSISTENT_SERVICE_GROUP) + final ReadRequest req = ReadRequest.newBuilder().setGroup(Constants.NAMING_PERSISTENT_SERVICE_GROUP) .setData(ByteString.copyFrom(serializer.serialize(keys))).build(); try { Response resp = protocol.getData(req); diff --git a/pom.xml b/pom.xml index f1e552a17eb..47ec44a352c 100644 --- a/pom.xml +++ b/pom.xml @@ -303,7 +303,7 @@ UTF-8 true true - **/istio/model/**,**/nacos/test/** + **/istio/model/**,**/consistency/entity/**,**/nacos/test/**