From ab65cd250c9e30942bfad1336fedb7d30fb0fce0 Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Tue, 4 Sep 2012 10:15:17 +0200 Subject: [PATCH] Minor change on server statistics --- .../java/org/dna/mqtt/moquette/server/Server.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/parser/src/main/java/org/dna/mqtt/moquette/server/Server.java b/parser/src/main/java/org/dna/mqtt/moquette/server/Server.java index ea2563dc..81184f64 100644 --- a/parser/src/main/java/org/dna/mqtt/moquette/server/Server.java +++ b/parser/src/main/java/org/dna/mqtt/moquette/server/Server.java @@ -80,6 +80,8 @@ public class Server { ((NioSocketAcceptor)m_acceptor).getSessionConfig().setReuseAddress(true); m_acceptor.getSessionConfig().setReadBufferSize( 2048 ); m_acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, DEFAULT_CONNECT_TIMEOUT ); + m_acceptor.getStatistics().setThroughputCalculationInterval(10); + m_acceptor.getStatistics().updateThroughput(System.currentTimeMillis()); m_acceptor.bind( new InetSocketAddress(PORT) ); LOG.info("Server binded"); @@ -107,19 +109,18 @@ public class Server { /*m_notifierPool.shutdown();*/ + //log statistics + IoServiceStatistics statistics = m_acceptor.getStatistics(); + statistics.updateThroughput(System.currentTimeMillis()); + System.out.println(String.format("Total read bytes: %d, read throughtput: %f (b/s)", statistics.getReadBytes(), statistics.getReadBytesThroughput())); + System.out.println(String.format("Total read msgs: %d, read msg throughtput: %f (msg/s)", statistics.getReadMessages(), statistics.getReadMessagesThroughput())); + for(IoSession session: m_acceptor.getManagedSessions().values()) { if(session.isConnected() && !session.isClosing()){ session.close(false); } } - //log statistics - IoServiceStatistics statistics = m_acceptor.getStatistics(); - statistics.updateThroughput(System.currentTimeMillis()); - /*System.out.println(String.format("Total read bytes: %d, read throughtput: %f (b//s)", statistics.getReadBytes(), statistics.getReadBytesThroughput())); - System.out.println(String.format("Total read msgs: %d, read msg throughtput: %f (msg//s)", statistics.getReadMessages(), statistics.getReadMessagesThroughput()));*/ - - m_acceptor.unbind(); m_acceptor.dispose(); LOG.info("Server stopped");