Skip to content

Commit

Permalink
增加压测代码,测试模块优化
Browse files Browse the repository at this point in the history
  • Loading branch information
夜色 committed Dec 8, 2016
1 parent a6c7a90 commit 208c91a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Expand Up @@ -28,7 +28,6 @@
import com.mpush.api.protocol.Packet;
import com.mpush.cache.redis.RedisKey;
import com.mpush.cache.redis.manager.RedisManager;
import com.mpush.common.ErrorCode;
import com.mpush.common.message.*;
import com.mpush.common.security.AesCipher;
import com.mpush.common.security.CipherBox;
Expand All @@ -41,7 +40,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

Expand All @@ -58,10 +56,10 @@ public final class ConnClientChannelHandler extends ChannelInboundHandlerAdapter

private final Connection connection = new NettyConnection();
private ClientConfig clientConfig;
private boolean stressingTest;
private boolean perfTest;

public ConnClientChannelHandler() {
stressingTest = true;
perfTest = true;
}

public ConnClientChannelHandler(ClientConfig clientConfig) {
Expand All @@ -87,7 +85,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
startHeartBeat(message.heartbeat);
LOGGER.info(">>> handshake success, clientConfig={}, connectedNum={}", clientConfig, connectedNum);
bindUser(clientConfig);
if (!stressingTest) {
if (!perfTest) {
saveToRedisForFastConnection(clientConfig, message.sessionId, message.expireTime, sessionKey);
}
} else if (command == Command.FAST_CONNECT) {
Expand Down Expand Up @@ -156,7 +154,7 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception {
clientConfig = ctx.channel().attr(CONFIG_KEY).getAndRemove();
}
connection.init(ctx.channel(), true);
if (stressingTest) {
if (perfTest) {
handshake();
} else {
tryFastConnect();
Expand Down
Expand Up @@ -44,6 +44,7 @@

import java.net.InetSocketAddress;
import java.util.List;
import java.util.concurrent.TimeUnit;

public final class ConnClientBoot extends BaseService {
private static final Logger LOGGER = LoggerFactory.getLogger(ConnClientBoot.class);
Expand Down Expand Up @@ -76,7 +77,7 @@ public void onFailure(Throwable cause) {
.option(ChannelOption.SO_REUSEADDR, true)//
.option(ChannelOption.SO_KEEPALIVE, true)//
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)//
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 4000)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 60 * 1000)
.channel(NioSocketChannel.class);

bootstrap.handler(new ChannelInitializer<SocketChannel>() { // (4)
Expand Down

0 comments on commit 208c91a

Please sign in to comment.