Refactor issue 4228 (#4229)

* refactor: adjusts conformance protocol layer objects

* feat: repair problems

* refactor: reafctor consistency model
This commit is contained in:
liaochuntao 2020-11-16 09:58:52 +08:00 committed by GitHub
parent c183b77db4
commit bcd62d5574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 411 additions and 3301 deletions

View File

@ -48,10 +48,10 @@ import com.alibaba.nacos.config.server.utils.LogUtil;
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 @@ import java.util.stream.Collectors;
@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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
.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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
.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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
.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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
.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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
.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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
.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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
/**
* 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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
if (submit) {
List<ModifyRequest> requests = batchUpdate.stream().map(ModifyRequest::new)
.collect(Collectors.toList());
CompletableFuture<Response> future = protocol.submitAsync(Log.newBuilder().setGroup(group())
CompletableFuture<Response> 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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
final String key =
System.currentTimeMillis() + "-" + group() + "-" + memberManager.getSelf().getAddress() + "-"
+ MD5Utils.md5Hex(sqlContext.toString(), Constants.ENCODE);
Log log = Log.newBuilder().setGroup(group()).setKey(key)
WriteRequest request = WriteRequest.newBuilder().setGroup(group()).setKey(key)
.setData(ByteString.copyFrom(serializer.serialize(sqlContext)))
.putAllExtendInfo(EmbeddedStorageContextUtils.getCurrentExtendInfo())
.setType(sqlContext.getClass().getCanonicalName()).build();
if (Objects.isNull(consumer)) {
Response response = this.protocol.submit(log);
Response response = this.protocol.submit(request);
if (response.getSuccess()) {
return true;
}
LogUtil.DEFAULT_LOG.error("execute sql modify operation failed : {}", response.getErrMsg());
return false;
} else {
this.protocol.submitAsync(log).whenComplete((BiConsumer<Response, Throwable>) (response, ex) -> {
this.protocol.submitAsync(request).whenComplete((BiConsumer<Response, Throwable>) (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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
@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 class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
}
@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");

View File

@ -30,32 +30,32 @@
</extensions>
<plugins>
<!-- Grpc coding plug-in-->
<!-- <plugin>-->
<!-- <groupId>org.xolstice.maven.plugins</groupId>-->
<!-- <artifactId>protobuf-maven-plugin</artifactId>-->
<!-- <version>0.5.0</version>-->
<!-- <configuration>-->
<!-- <protocArtifact>com.google.protobuf:protoc:${protobuf-java.version}:exe:${os.detected.classifier}</protocArtifact>-->
<!-- <pluginId>grpc-java</pluginId>-->
<!-- <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc-java.version}:exe:${os.detected.classifier}</pluginArtifact>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>compile</goal>-->
<!-- <goal>compile-custom</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <source>8</source>-->
<!-- <target>8</target>-->
<!-- </configuration>-->
<!-- </plugin>-->
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protobuf-java.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc-java.version}:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -22,7 +22,7 @@ import java.util.Set;
/**
* Consistent protocol related configuration objects.
*
* <p>{@link LogProcessor} : The consistency protocol provides services for all businesses, but each business only cares
* <p>{@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 @@ import java.util.Set;
*
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
public interface Config<L extends LogProcessor> extends Serializable {
public interface Config<L extends RequestProcessor> extends Serializable {
/**
* Set the cluster node information to initializelike [ip:port, ip:port, ip:port].

View File

@ -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 @@ import java.util.concurrent.CompletableFuture;
*
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
public interface ConsistencyProtocol<T extends Config, P extends LogProcessor> extends CommandOperations {
public interface ConsistencyProtocol<T extends Config, P extends RequestProcessor> extends CommandOperations {
/**
* Consistency protocol initialization: perform initialization operations based on the incoming.
@ -50,7 +50,7 @@ public interface ConsistencyProtocol<T extends Config, P extends LogProcessor> e
/**
* Add a log handler.
*
* @param processors {@link LogProcessor}
* @param processors {@link RequestProcessor}
*/
void addLogProcessors(Collection<P> processors);
@ -69,7 +69,7 @@ public interface ConsistencyProtocol<T extends Config, P extends LogProcessor> 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<T extends Config, P extends LogProcessor> e
* @param request request
* @return data {@link CompletableFuture}
*/
CompletableFuture<Response> aGetData(GetRequest request);
CompletableFuture<Response> 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<Response> submitAsync(Log data);
CompletableFuture<Response> submitAsync(WriteRequest request);
/**
* New member list .

View File

@ -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 <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
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();
}
}

View File

@ -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 @@ import com.alibaba.nacos.consistency.entity.Response;
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
@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.

View File

@ -25,6 +25,6 @@ import com.alibaba.nacos.consistency.ConsistencyProtocol;
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
@SuppressWarnings("all")
public interface APProtocol<C extends Config, P extends LogProcessor4AP> extends ConsistencyProtocol<C, P> {
public interface APProtocol<C extends Config, P extends RequestProcessor4AP> extends ConsistencyProtocol<C, P> {
}

View File

@ -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 @@ import com.alibaba.nacos.consistency.LogProcessor;
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
@SuppressWarnings("all")
public abstract class LogProcessor4AP extends LogProcessor {
public abstract class RequestProcessor4AP extends RequestProcessor {
}

View File

@ -25,7 +25,7 @@ import com.alibaba.nacos.consistency.ConsistencyProtocol;
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
@SuppressWarnings("all")
public interface CPProtocol<C extends Config, P extends LogProcessor4CP> extends ConsistencyProtocol<C, P> {
public interface CPProtocol<C extends Config, P extends RequestProcessor4CP> extends ConsistencyProtocol<C, P> {
/**
* Returns whether this node is a leader node

View File

@ -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 @@ import java.util.List;
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
@SuppressWarnings("all")
public abstract class LogProcessor4CP extends LogProcessor {
public abstract class RequestProcessor4CP extends RequestProcessor {
/**

View File

@ -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)
}

View File

@ -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<GetRequest> PARSER = new com.google.protobuf.AbstractParser<GetRequest>() {
@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<String, String> 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<String, String> 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<GetRequest> 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);
}
/**
* <code>string group = 1;</code>
*/
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;
}
}
/**
* <code>string group = 1;</code>
*/
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;
}
}
/**
* <code>bytes data = 2;</code>
*/
public com.google.protobuf.ByteString getData() {
return data_;
}
private com.google.protobuf.MapField<String, String> internalGetExtendInfo() {
if (extendInfo_ == null) {
return com.google.protobuf.MapField.emptyMapField(ExtendInfoDefaultEntryHolder.defaultEntry);
}
return extendInfo_;
}
public int getExtendInfoCount() {
return internalGetExtendInfo().getMap().size();
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
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<String, String> getExtendInfo() {
return getExtendInfoMap();
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
public java.util.Map<String, String> getExtendInfoMap() {
return internalGetExtendInfo().getMap();
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
public String getExtendInfoOrDefault(String key, String defaultValue) {
if (key == null) {
throw new NullPointerException();
}
java.util.Map<String, String> map = internalGetExtendInfo().getMap();
return map.containsKey(key) ? map.get(key) : defaultValue;
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
public String getExtendInfoOrThrow(String key) {
if (key == null) {
throw new NullPointerException();
}
java.util.Map<String, String> 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<String, String> entry : internalGetExtendInfo().getMap().entrySet()) {
com.google.protobuf.MapEntry<String, String> 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<GetRequest> getParserForType() {
return PARSER;
}
@Override
public GetRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
private static final class ExtendInfoDefaultEntryHolder {
static final com.google.protobuf.MapEntry<String, String> defaultEntry = com.google.protobuf.MapEntry.<String, String>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<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<String, String> 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;
}
/**
* <code>string group = 1;</code>
*/
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;
}
}
/**
* <code>string group = 1;</code>
*/
public Builder setGroup(String value) {
if (value == null) {
throw new NullPointerException();
}
group_ = value;
onChanged();
return this;
}
/**
* <code>string group = 1;</code>
*/
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;
}
}
/**
* <code>string group = 1;</code>
*/
public Builder setGroupBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
group_ = value;
onChanged();
return this;
}
/**
* <code>string group = 1;</code>
*/
public Builder clearGroup() {
group_ = getDefaultInstance().getGroup();
onChanged();
return this;
}
/**
* <code>bytes data = 2;</code>
*/
public com.google.protobuf.ByteString getData() {
return data_;
}
/**
* <code>bytes data = 2;</code>
*/
public Builder setData(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
data_ = value;
onChanged();
return this;
}
/**
* <code>bytes data = 2;</code>
*/
public Builder clearData() {
data_ = getDefaultInstance().getData();
onChanged();
return this;
}
private com.google.protobuf.MapField<String, String> internalGetExtendInfo() {
if (extendInfo_ == null) {
return com.google.protobuf.MapField.emptyMapField(ExtendInfoDefaultEntryHolder.defaultEntry);
}
return extendInfo_;
}
private com.google.protobuf.MapField<String, String> 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();
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
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<String, String> getExtendInfo() {
return getExtendInfoMap();
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
public java.util.Map<String, String> getExtendInfoMap() {
return internalGetExtendInfo().getMap();
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
public String getExtendInfoOrDefault(String key, String defaultValue) {
if (key == null) {
throw new NullPointerException();
}
java.util.Map<String, String> map = internalGetExtendInfo().getMap();
return map.containsKey(key) ? map.get(key) : defaultValue;
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
public String getExtendInfoOrThrow(String key) {
if (key == null) {
throw new NullPointerException();
}
java.util.Map<String, String> map = internalGetExtendInfo().getMap();
if (!map.containsKey(key)) {
throw new IllegalArgumentException();
}
return map.get(key);
}
public Builder clearExtendInfo() {
internalGetMutableExtendInfo().getMutableMap().clear();
return this;
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
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<String, String> getMutableExtendInfo() {
return internalGetMutableExtendInfo().getMutableMap();
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
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;
}
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
public Builder putAllExtendInfo(java.util.Map<String, String> 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)
}
}

View File

@ -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 {
/**
* <code>string group = 1;</code>
*/
String getGroup();
/**
* <code>string group = 1;</code>
*/
com.google.protobuf.ByteString getGroupBytes();
/**
* <code>bytes data = 2;</code>
*/
com.google.protobuf.ByteString getData();
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
int getExtendInfoCount();
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
boolean containsExtendInfo(String key);
/**
* Use {@link #getExtendInfoMap()} instead.
*/
@Deprecated
java.util.Map<String, String> getExtendInfo();
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
java.util.Map<String, String> getExtendInfoMap();
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
String getExtendInfoOrDefault(String key, String defaultValue);
/**
* <code>map&lt;string, string&gt; extendInfo = 3;</code>
*/
String getExtendInfoOrThrow(String key);
}

View File

@ -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 {
/**
* <code>string group = 1;</code>
*/
String getGroup();
/**
* <code>string group = 1;</code>
*/
com.google.protobuf.ByteString getGroupBytes();
/**
* <code>string key = 2;</code>
*/
String getKey();
/**
* <code>string key = 2;</code>
*/
com.google.protobuf.ByteString getKeyBytes();
/**
* <code>bytes data = 3;</code>
*/
com.google.protobuf.ByteString getData();
/**
* <code>string type = 4;</code>
*/
String getType();
/**
* <code>string type = 4;</code>
*/
com.google.protobuf.ByteString getTypeBytes();
/**
* <code>string operation = 5;</code>
*/
String getOperation();
/**
* <code>string operation = 5;</code>
*/
com.google.protobuf.ByteString getOperationBytes();
/**
* <code>map&lt;string, string&gt; extendInfo = 6;</code>
*/
int getExtendInfoCount();
/**
* <code>map&lt;string, string&gt; extendInfo = 6;</code>
*/
boolean containsExtendInfo(String key);
/**
* Use {@link #getExtendInfoMap()} instead.
*/
@Deprecated
java.util.Map<String, String> getExtendInfo();
/**
* <code>map&lt;string, string&gt; extendInfo = 6;</code>
*/
java.util.Map<String, String> getExtendInfoMap();
/**
* <code>map&lt;string, string&gt; extendInfo = 6;</code>
*/
String getExtendInfoOrDefault(String key, String defaultValue);
/**
* <code>map&lt;string, string&gt; extendInfo = 6;</code>
*/
String getExtendInfoOrThrow(String key);
}

View File

@ -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<Response> PARSER = new com.google.protobuf.AbstractParser<Response>() {
@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<Response> 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);
}
/**
* <code>bytes data = 1;</code>
*/
public com.google.protobuf.ByteString getData() {
return data_;
}
/**
* <code>string errMsg = 2;</code>
*/
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;
}
}
/**
* <code>string errMsg = 2;</code>
*/
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;
}
}
/**
* <code>bool success = 3;</code>
*/
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<Response> 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<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;
}
/**
* <code>bytes data = 1;</code>
*/
public com.google.protobuf.ByteString getData() {
return data_;
}
/**
* <code>bytes data = 1;</code>
*/
public Builder setData(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
data_ = value;
onChanged();
return this;
}
/**
* <code>bytes data = 1;</code>
*/
public Builder clearData() {
data_ = getDefaultInstance().getData();
onChanged();
return this;
}
/**
* <code>string errMsg = 2;</code>
*/
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;
}
}
/**
* <code>string errMsg = 2;</code>
*/
public Builder setErrMsg(String value) {
if (value == null) {
throw new NullPointerException();
}
errMsg_ = value;
onChanged();
return this;
}
/**
* <code>string errMsg = 2;</code>
*/
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;
}
}
/**
* <code>string errMsg = 2;</code>
*/
public Builder setErrMsgBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
errMsg_ = value;
onChanged();
return this;
}
/**
* <code>string errMsg = 2;</code>
*/
public Builder clearErrMsg() {
errMsg_ = getDefaultInstance().getErrMsg();
onChanged();
return this;
}
/**
* <code>bool success = 3;</code>
*/
public boolean getSuccess() {
return success_;
}
/**
* <code>bool success = 3;</code>
*/
public Builder setSuccess(boolean value) {
success_ = value;
onChanged();
return this;
}
/**
* <code>bool success = 3;</code>
*/
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)
}
}

View File

@ -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 {
/**
* <code>bytes data = 1;</code>
*/
com.google.protobuf.ByteString getData();
/**
* <code>string errMsg = 2;</code>
*/
String getErrMsg();
/**
* <code>string errMsg = 2;</code>
*/
com.google.protobuf.ByteString getErrMsgBytes();
/**
* <code>bool success = 3;</code>
*/
boolean getSuccess();
}

View File

@ -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<string, string> extendInfo = 6;
}
//Deprecated
message GetRequest {
string group = 1;
bytes data = 2;
map<string, string> extendInfo = 3;
}
message Response {
bytes data = 1;
string errMsg = 2;
bool success = 3;
}

View File

@ -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<string, string> extendInfo = 6;
}
message ReadRequest {
string group = 1;
bytes data = 2;
map<string, string> extendInfo = 3;
}
message Response {
bytes data = 1;
string errMsg = 2;
bool success = 3;
}

View File

@ -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());
}
}

View File

@ -18,7 +18,7 @@ package com.alibaba.nacos.core.distributed;
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 @@ import java.util.Map;
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
@SuppressWarnings("all")
public abstract class AbstractConsistencyProtocol<T extends Config, L extends LogProcessor>
public abstract class AbstractConsistencyProtocol<T extends Config, L extends RequestProcessor>
implements ConsistencyProtocol<T, L> {
protected final ProtocolMetaData metaData = new ProtocolMetaData();

View File

@ -26,11 +26,11 @@ import com.alibaba.nacos.consistency.ProtocolMetaData;
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 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
@SuppressWarnings("all")
public class JRaftProtocol extends AbstractConsistencyProtocol<RaftConfig, LogProcessor4CP>
implements CPProtocol<RaftConfig, LogProcessor4CP> {
public class JRaftProtocol extends AbstractConsistencyProtocol<RaftConfig, RequestProcessor4CP>
implements CPProtocol<RaftConfig, RequestProcessor4CP> {
private final AtomicBoolean initialized = new AtomicBoolean(false);
@ -159,31 +159,31 @@ public class JRaftProtocol extends AbstractConsistencyProtocol<RaftConfig, LogPr
}
@Override
public void addLogProcessors(Collection<LogProcessor4CP> processors) {
public void addLogProcessors(Collection<RequestProcessor4CP> processors) {
raftServer.createMultiRaftGroup(processors);
}
@Override
public Response getData(GetRequest request) throws Exception {
public Response getData(ReadRequest request) throws Exception {
CompletableFuture<Response> future = aGetData(request);
return future.get(5_000L, TimeUnit.MILLISECONDS);
}
@Override
public CompletableFuture<Response> aGetData(GetRequest request) {
public CompletableFuture<Response> aGetData(ReadRequest request) {
return raftServer.get(request);
}
@Override
public Response submit(Log data) throws Exception {
CompletableFuture<Response> future = submitAsync(data);
public Response submit(WriteRequest request) throws Exception {
CompletableFuture<Response> 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<Response> submitAsync(Log data) {
return raftServer.commit(data.getGroup(), data, new CompletableFuture<>());
public CompletableFuture<Response> submitAsync(WriteRequest request) {
return raftServer.commit(request.getGroup(), request, new CompletableFuture<>());
}
@Override

View File

@ -22,11 +22,11 @@ import com.alibaba.nacos.common.utils.ConvertUtils;
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<LogProcessor4CP> processors = Collections.synchronizedSet(new HashSet<>());
private Collection<RequestProcessor4CP> processors = Collections.synchronizedSet(new HashSet<>());
private String selfIp;
@ -226,7 +226,7 @@ public class JRaftServer {
}
}
synchronized void createMultiRaftGroup(Collection<LogProcessor4CP> processors) {
synchronized void createMultiRaftGroup(Collection<RequestProcessor4CP> 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 @@ public class JRaftServer {
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 @@ public class JRaftServer {
}
}
CompletableFuture<Response> get(final GetRequest request) {
CompletableFuture<Response> get(final ReadRequest request) {
final String group = request.getGroup();
CompletableFuture<Response> future = new CompletableFuture<>();
final RaftGroupTuple tuple = findTupleByGroup(group);
@ -289,7 +289,7 @@ public class JRaftServer {
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 class JRaftServer {
}
}
public void readFromLeader(final GetRequest request, final CompletableFuture<Response> future) {
public void readFromLeader(final ReadRequest request, final CompletableFuture<Response> future) {
commit(request.getGroup(), request, future).whenComplete(new BiConsumer<Response, Throwable>() {
@Override
public void accept(Response response, Throwable throwable) {
@ -540,7 +540,7 @@ public class JRaftServer {
public static class RaftGroupTuple {
private LogProcessor processor;
private RequestProcessor processor;
private Node node;
@ -552,7 +552,7 @@ public class JRaftServer {
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 class JRaftServer {
return node;
}
public LogProcessor getProcessor() {
public RequestProcessor getProcessor() {
return processor;
}

View File

@ -20,11 +20,12 @@ import com.alibaba.nacos.common.notify.NotifyCenter;
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 @@ class NacosStateMachine extends StateMachineAdapter {
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 @@ class NacosStateMachine extends StateMachineAdapter {
}
}
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;
}

View File

@ -18,7 +18,7 @@ package com.alibaba.nacos.core.distributed.raft;
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 @@ import java.util.Set;
*/
@Component
@ConfigurationProperties(prefix = "nacos.core.protocol.raft")
public class RaftConfig implements Config<LogProcessor4CP> {
public class RaftConfig implements Config<RequestProcessor4CP> {
private static final long serialVersionUID = 9174789390266064002L;

View File

@ -40,7 +40,7 @@ public abstract class AbstractProcessor {
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 @@ public abstract class AbstractProcessor {
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 @@ public abstract class AbstractProcessor {
}
}
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 abstract class AbstractProcessor {
}
};
server.applyOperation(tuple.getNode(), log, closure);
server.applyOperation(tuple.getNode(), message, closure);
}
}

View File

@ -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 class NacosGetRequestProcessor extends AbstractProcessor implements RpcPr
@Override
public void handleRequest(final RpcContext rpcCtx, GetRequest request) {
handleRequest(server, request.getGroup(), rpcCtx, request);
handleRequest(server, request.getGroup(), rpcCtx, ProtoMessageUtil.convertToReadRequest(request));
}
@Override

View File

@ -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 class NacosLogProcessor extends AbstractProcessor implements RpcProcessor
@Override
public void handleRequest(final RpcContext rpcCtx, Log log) {
handleRequest(server, log.getGroup(), rpcCtx, log);
handleRequest(server, log.getGroup(), rpcCtx, ProtoMessageUtil.convertToWriteRequest(log));
}
@Override

View File

@ -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 <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
public class NacosReadRequestProcessor extends AbstractProcessor implements RpcProcessor<ReadRequest> {
public NacosReadRequestProcessor(Serializer serializer) {
super(serializer);
}
@Override
public void handleRequest(RpcContext rpcCtx, ReadRequest request) {
}
@Override
public String interest() {
return null;
}
}

View File

@ -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 <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
public class NacosWriteRequestProcessor extends AbstractProcessor implements RpcProcessor<WriteRequest> {
public NacosWriteRequestProcessor(Serializer serializer) {
super(serializer);
}
@Override
public void handleRequest(RpcContext rpcCtx, WriteRequest request) {
}
@Override
public String interest() {
return null;
}
}

View File

@ -20,7 +20,9 @@ import com.alibaba.nacos.common.utils.ThreadUtils;
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 class JRaftUtils {
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 class JRaftUtils {
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<String> toStrings(List<PeerId> peerIds) {
return peerIds.stream().map(peerId -> peerId.getEndpoint().toString()).collect(Collectors.toList());
}

View File

@ -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 class AbstractProcessorTest {
}
};
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);

View File

@ -25,11 +25,11 @@ import com.alibaba.nacos.consistency.DataOperation;
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 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
*/
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
@Service
public class PersistentServiceProcessor extends LogProcessor4CP implements PersistentConsistencyService {
public class PersistentServiceProcessor extends RequestProcessor4CP implements PersistentConsistencyService {
enum Op {
/**
@ -176,7 +176,7 @@ public class PersistentServiceProcessor extends LogProcessor4CP implements Persi
}
@Override
public Response onRequest(GetRequest request) {
public Response onRequest(ReadRequest request) {
final List<byte[]> keys = serializer
.deserialize(request.getData().toByteArray(), TypeUtils.parameterize(List.class, byte[].class));
final Lock lock = readLock;
@ -195,24 +195,24 @@ public class PersistentServiceProcessor extends LogProcessor4CP implements Persi
}
@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 class PersistentServiceProcessor extends LogProcessor4CP implements Persi
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 class PersistentServiceProcessor extends LogProcessor4CP implements Persi
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 class PersistentServiceProcessor extends LogProcessor4CP implements Persi
public Datum get(String key) throws NacosException {
final List<byte[]> 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);

View File

@ -303,7 +303,7 @@
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<excludes>**/istio/model/**,**/nacos/test/**</excludes>
<excludes>**/istio/model/**,**/consistency/entity/**,**/nacos/test/**</excludes>
</configuration>
<executions>
<execution>