mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 04:22:01 -08:00
fixed issues with ConnectionLoadTest
This commit is contained in:
parent
13d267f5a1
commit
3ba67ace1c
4 changed files with 15 additions and 12 deletions
|
|
@ -61,10 +61,11 @@ public class Client {
|
|||
|
||||
private SslContext sslCtx;
|
||||
private Channel channel;
|
||||
private EventLoopGroup group;
|
||||
private String username;
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
private static final EventLoopGroup group = new NioEventLoopGroup();
|
||||
|
||||
public Client(MageClient client) {
|
||||
this.client = client;
|
||||
|
|
@ -81,7 +82,6 @@ public class Client {
|
|||
this.host = connection.getHost();
|
||||
this.port = connection.getPort();
|
||||
|
||||
group = new NioEventLoopGroup();
|
||||
try {
|
||||
if (connection.isSSL()) {
|
||||
sslCtx = SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE);
|
||||
|
|
@ -112,7 +112,7 @@ public class Client {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private class ClientInitializer extends ChannelInitializer<SocketChannel> {
|
||||
|
||||
@Override
|
||||
|
|
@ -141,11 +141,13 @@ public class Client {
|
|||
try {
|
||||
channel.disconnect().sync();
|
||||
client.disconnected(error);
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
logger.fatal("Error disconnecting", ex);
|
||||
} finally {
|
||||
group.shutdownGracefully();
|
||||
}
|
||||
}
|
||||
// finally {
|
||||
// group.shutdownGracefully();
|
||||
// }
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class HeartbeatHandler extends ChannelHandlerAdapter {
|
|||
logger.info("Disconnected due to extended idle");
|
||||
} else if (e.state() == IdleState.WRITER_IDLE) {
|
||||
ctx.writeAndFlush(ping).addListener(WriteListener.getInstance());
|
||||
logger.info("Sending ping");
|
||||
logger.debug("Sending ping");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,13 +42,14 @@ public class HeartbeatHandler extends ChannelHandlerAdapter {
|
|||
if (evt instanceof IdleStateEvent) {
|
||||
IdleStateEvent e = (IdleStateEvent) evt;
|
||||
if (e.state() == IdleState.READER_IDLE) {
|
||||
server.disconnect(getSessionId(ctx), DisconnectReason.LostConnection);
|
||||
String sessionId = getSessionId(ctx);
|
||||
server.disconnect(sessionId, DisconnectReason.LostConnection);
|
||||
ctx.disconnect();
|
||||
logger.info("Disconnected due to extended idle");
|
||||
logger.info(sessionId + " disconnected due to extended idle");
|
||||
} else if (e.state() == IdleState.WRITER_IDLE) {
|
||||
startTime = System.nanoTime();
|
||||
ctx.writeAndFlush(ping).addListener(WriteListener.getInstance());
|
||||
logger.info("Sending ping");
|
||||
logger.debug("Sending ping");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import org.junit.Test;
|
|||
*/
|
||||
public class ConnectionLoadTest extends BaseLoadTest {
|
||||
|
||||
private static final Integer USER_COUNT = 400;
|
||||
private static final Integer USER_COUNT = 1000;
|
||||
|
||||
@Test
|
||||
public void connectTest() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue