Skip to content

Commit

Permalink
define codes directly
Browse files Browse the repository at this point in the history
  • Loading branch information
yuz10 committed Jul 4, 2023
1 parent c972399 commit 10c0e21
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private RemotingCommand processRequest(final Channel channel, RemotingCommand re
BatchAckMessageRequestBody reqBody = null;
final RemotingCommand response = RemotingCommand.createResponseCommand(ResponseCode.SUCCESS, null);
response.setOpaque(request.getOpaque());
if (request.getCode() == RequestCode.ACK_MESSAGE) {
if (request.getCode() == RequestCode.ACK_MESSAGE || request.getCode() == RequestCode._ACK_MESSAGE) {
requestHeader = (AckMessageRequestHeader) request.decodeCommandCustomHeader(AckMessageRequestHeader.class);

TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
Expand Down Expand Up @@ -144,7 +144,7 @@ private RemotingCommand processRequest(final Channel channel, RemotingCommand re
}

appendAck(requestHeader, null, response, channel, null);
} else if (request.getCode() == RequestCode.BATCH_ACK_MESSAGE) {
} else if (request.getCode() == RequestCode.BATCH_ACK_MESSAGE || request.getCode() == RequestCode._BATCH_ACK_MESSAGE) {
if (request.getBody() != null) {
reqBody = BatchAckMessageRequestBody.decode(request.getBody(), BatchAckMessageRequestBody.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,19 @@ public class RequestCode {
public static final int GET_TIMER_METRICS = 61;

public static final int POP_MESSAGE = 200050;
public static final int _POP_MESSAGE = (short) POP_MESSAGE;
public static final int ACK_MESSAGE = 200051;
public static final int _ACK_MESSAGE = (short) ACK_MESSAGE;
public static final int BATCH_ACK_MESSAGE = 200151;
public static final int _BATCH_ACK_MESSAGE = (short) BATCH_ACK_MESSAGE;
public static final int PEEK_MESSAGE = 200052;
public static final int _PEEK_MESSAGE = (short) PEEK_MESSAGE;
public static final int CHANGE_MESSAGE_INVISIBLETIME = 200053;
public static final int _CHANGE_MESSAGE_INVISIBLETIME = (short) CHANGE_MESSAGE_INVISIBLETIME;
public static final int NOTIFICATION = 200054;
public static final int _NOTIFICATION = (short) NOTIFICATION;
public static final int POLLING_INFO = 200055;
public static final int _POLLING_INFO = (short) POLLING_INFO;

public static final int PUT_KV_CONFIG = 100;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,15 @@ public void testRequestCodeShouldBeShort() throws IllegalAccessException {
ignored.add("NOTIFICATION");
ignored.add("POLLING_INFO");

Set<Integer> forbidden = new HashSet<>();
Class clazz = RequestCode.class;
Field[] fields = clazz.getFields();
for (Field field : fields) {
if (ignored.contains(field.getName())) {
forbidden.add((int) (short) field.getInt(clazz));
continue;
}
if (field.getInt(clazz) > Short.MAX_VALUE) {
Assert.fail(field.getName() + "=" + field.getInt(clazz) + " should be short, to support serializeTypeCurrentRPC=ROCKETMQ");
}
}
for (Field field : fields) {
if (forbidden.contains(field.getInt(clazz))) {
Assert.fail(field.getName() + "=" + field.getInt(clazz) + " is occupied.");
}
}
}
}

0 comments on commit 10c0e21

Please sign in to comment.