Skip to content

Commit

Permalink
Reduce unnecessary switches
Browse files Browse the repository at this point in the history
  • Loading branch information
LetLetMe committed Oct 23, 2024
1 parent 127b684 commit 0984cf6
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
Expand Down Expand Up @@ -473,14 +472,10 @@ private RemotingCommand updateAndGetGroupForbidden(ChannelHandlerContext ctx, Re
return response;
}



/**
* diffResult: string
* checkStatus: int 0->ready, 1->notReady, 2->async doing, 3->error
*/
private RemotingCommand checkRocksdbCqWriteProgress(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
CheckRocksdbCqWriteProgressRequestHeader requestHeader = request.decodeCommandCustomHeader(CheckRocksdbCqWriteProgressRequestHeader.class);
CheckRocksdbCqWriteResult result = new CheckRocksdbCqWriteResult();
result.setCheckStatus(CheckRocksdbCqWriteResult.CheckStatus.CHECK_IN_PROGRESS.getValue());
if (requestHeader.isAsync()) {
Runnable runnable = () -> {
try {
Expand All @@ -491,17 +486,13 @@ private RemotingCommand checkRocksdbCqWriteProgress(ChannelHandlerContext ctx, R
}
};
asyncExecuteWorker.submit(runnable);
RemotingCommand response = RemotingCommand.createResponseCommand(null);
response.setCode(ResponseCode.SUCCESS);
response.setBody(JSON.toJSONBytes(ImmutableMap.of("checkStatus", "2")));
return response;
} else {
CheckRocksdbCqWriteResult result = doCheckRocksdbCqWriteProgress(ctx, request);
RemotingCommand response = RemotingCommand.createResponseCommand(null);
response.setCode(ResponseCode.SUCCESS);
response.setBody(JSON.toJSONBytes(result));
return response;
result = doCheckRocksdbCqWriteProgress(ctx, request);
}
RemotingCommand response = RemotingCommand.createResponseCommand(null);
response.setCode(ResponseCode.SUCCESS);
response.setBody(JSON.toJSONBytes(result));
return response;
}
@Override
public boolean rejectRequest() {
Expand Down

0 comments on commit 0984cf6

Please sign in to comment.