Skip to content

Commit

Permalink
Polish remoting module's UT
Browse files Browse the repository at this point in the history
  • Loading branch information
vongosling committed Jan 20, 2017
1 parent 63de56c commit b997c97
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 360 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public Thread newThread(Runnable r) {

@Override
public void start() {
this.defaultEventExecutorGroup = new DefaultEventExecutorGroup(//
nettyServerConfig.getServerWorkerThreads(), //
this.defaultEventExecutorGroup = new DefaultEventExecutorGroup(
nettyServerConfig.getServerWorkerThreads(),
new ThreadFactory() {

private AtomicInteger threadIndex = new AtomicInteger(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ public class RemotingCommand {
}
}

/**
*/
private int code;
private LanguageCode language = LanguageCode.JAVA;
private int version = 0;
Expand All @@ -80,13 +77,9 @@ public class RemotingCommand {
private String remark;
private HashMap<String, String> extFields;
private transient CommandCustomHeader customHeader;
/**

*/
private SerializeType serializeTypeCurrentRPC = serializeTypeConfigInThisServer;
/**

*/
private transient byte[] body;

protected RemotingCommand() {
Expand Down Expand Up @@ -117,9 +110,6 @@ public static RemotingCommand createResponseCommand(Class<? extends CommandCusto
return createResponseCommand(RemotingSysResponseCode.SYSTEM_ERROR, "not set any response code", classHeader);
}

/**
*/
public static RemotingCommand createResponseCommand(int code, String remark, Class<? extends CommandCustomHeader> classHeader) {
RemotingCommand cmd = new RemotingCommand();
cmd.markResponseType();
Expand Down Expand Up @@ -411,9 +401,7 @@ public ByteBuffer encodeHeader() {
return encodeHeader(this.body != null ? this.body.length : 0);
}

/**

*/
public ByteBuffer encodeHeader(final int bodyLength) {
// 1> header length size
int length = 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ public static byte[] rocketMQProtocolEncode(RemotingCommand cmd) {
extLen = extFieldsBytes.length;
}

// ################### cal total length
int totalLen = calTotalLen(remarkLen, extLen);

// ################### content
ByteBuffer headerBuffer = ByteBuffer.allocate(totalLen);
// int code(~32767)
headerBuffer.putShort((short) cmd.getCode());
Expand Down Expand Up @@ -76,7 +74,6 @@ public static byte[] rocketMQProtocolEncode(RemotingCommand cmd) {
}

public static byte[] mapSerialize(HashMap<String, String> map) {
// keySize+key+valSize+val
// keySize+key+valSize+val
if (null == map || map.isEmpty())
return null;
Expand Down Expand Up @@ -174,10 +171,10 @@ public static HashMap<String, String> mapDeserialize(byte[] bytes) {
HashMap<String, String> map = new HashMap<String, String>();
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);

short keySize = 0;
byte[] keyContent = null;
int valSize = 0;
byte[] valContent = null;
short keySize;
byte[] keyContent;
int valSize;
byte[] valContent;
while (byteBuffer.hasRemaining()) {
keySize = byteBuffer.getShort();
keyContent = new byte[keySize];
Expand Down

This file was deleted.

This file was deleted.

30 changes: 0 additions & 30 deletions remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java

This file was deleted.

233 changes: 0 additions & 233 deletions remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java

This file was deleted.

Loading

0 comments on commit b997c97

Please sign in to comment.