Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RATIS-1524. Optional DataStreamManagement#startTransaction configuration #601

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ StreamInfo remove(ClientInvocationId key) {
private final Executor requestExecutor;
private final Executor writeExecutor;

private final boolean startTransactionEnable;

DataStreamManagement(RaftServer server) {
this.server = server;
this.name = server.getId() + "-" + JavaUtils.getClassSimpleName(getClass());
Expand All @@ -225,6 +227,7 @@ StreamInfo remove(ClientInvocationId key) {
this.writeExecutor = ConcurrentUtils.newThreadPoolWithMax(useCachedThreadPool,
RaftServerConfigKeys.DataStream.asyncWriteThreadPoolSize(properties),
name + "-write-");
this.startTransactionEnable = RaftServerConfigKeys.DataStream.raftLogNeed(properties);
}

private CompletableFuture<DataStream> computeDataStreamIfAbsent(RaftClientRequest request) throws IOException {
Expand Down Expand Up @@ -327,6 +330,12 @@ static void sendReply(List<CompletableFuture<DataStreamReply>> remoteWrites,
private CompletableFuture<RaftClientReply> startTransaction(StreamInfo info, DataStreamRequestByteBuf request,
long bytesWritten, ChannelHandlerContext ctx) {
try {
if (!startTransactionEnable) {
RaftClientReply reply = RaftClientReply.newBuilder().setSuccess(true).build();
ctx.writeAndFlush(newDataStreamReplyByteBuffer(request, reply, bytesWritten, info.getCommitInfos()));
return null;
}

AsyncRpcApi asyncRpcApi = (AsyncRpcApi) (server.getDivision(info.getRequest()
.getRaftGroupId())
.getRaftClient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,18 @@ static void setAsyncWriteThreadPoolSize(RaftProperties properties, int port) {
setInt(properties::setInt, ASYNC_WRITE_THREAD_POOL_SIZE_KEY, port);
}

String RAFT_LOG_NEED_KEY = PREFIX + ".raft-log.need";
boolean RAFT_LOG_NEED_DEFAULT = true;

static boolean raftLogNeed(RaftProperties properties) {
return getBoolean(properties::getBoolean, RAFT_LOG_NEED_KEY,
RAFT_LOG_NEED_DEFAULT, getDefaultLog());
}

static void setRaftLogNeed(RaftProperties properties, boolean enable) {
setBoolean(properties::setBoolean, RAFT_LOG_NEED_KEY, enable);
}

String CLIENT_POOL_SIZE_KEY = PREFIX + ".client.pool.size";
int CLIENT_POOL_SIZE_DEFAULT = 10;

Expand Down