changeset 551:c9a1b0be46ef

improvements
author Devel 1
date Mon, 18 Sep 2017 11:11:26 +0200
parents 87e1444c7bab
children 8324c4591ad2
files stress-tester/src/main/java/com/passus/st/client/http/HttpFlowBasedClientWorker.java stress-tester/src/main/java/com/passus/st/emitter/nio/NioEmitterWorker.java
diffstat 2 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowBasedClientWorker.java	Mon Sep 18 11:09:55 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowBasedClientWorker.java	Mon Sep 18 11:11:26 2017 +0200
@@ -657,18 +657,16 @@
         }
 
         SessionInfo session = flowContext.sessionInfo();
-        int localPort = session.getSrcPort();
         if (args.length == 0) {
-            logger.log(level, message + " [{},{}]", session, localPort);
+            logger.log(level, message + " [{}]", session);
         } else {
-            Object[] logArgs = new Object[args.length + 2];
+            Object[] logArgs = new Object[args.length + 1];
             for (int i = 0; i < args.length; i++) {
                 logArgs[i] = args[i];
             }
 
-            logArgs[logArgs.length - 2] = session;
-            logArgs[logArgs.length - 1] = localPort;
-            logger.log(level, message + " [{},{}]", logArgs);
+            logArgs[logArgs.length - 1] = session;
+            logger.log(level, message + " [{}]", logArgs);
         }
     }
 }
--- a/stress-tester/src/main/java/com/passus/st/emitter/nio/NioEmitterWorker.java	Mon Sep 18 11:09:55 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/emitter/nio/NioEmitterWorker.java	Mon Sep 18 11:11:26 2017 +0200
@@ -269,7 +269,8 @@
         SocketChannel socketChannel = (SocketChannel) key.channel();
         KeyContext keyContext = (KeyContext) key.attachment();
         if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("Writing to '{}'.", keyContext.channelContext.getRemoteAddress());
+            LOGGER.debug("Writing ({} -> {}).",
+                    keyContext.channelContext.getLocalAddress(), keyContext.channelContext.getRemoteAddress());
         }
 
         Queue<ByteBuffer> queue = keyContext.channelContext.dataQueue();
@@ -300,13 +301,15 @@
         }
 
         if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("Written '" + written + "' to '" + keyContext.channelContext.getRemoteAddress() + "'.");
+            LOGGER.debug("Written {}B ({} -> {})", written,
+                    keyContext.channelContext.getLocalAddress(), keyContext.channelContext.getRemoteAddress());
         }
 
         //TODO Operacje na handlerach powinny przechodzic przez Executor
         try {
             NioChannelContext.writes.decrementAndGet();
             keyContext.handler.dataWritten(keyContext.channelContext);
+            LOGGER.debug("Write handled.");
         } catch (Exception e) {
             LOGGER.debug(e.getMessage(), e);
         }
@@ -320,7 +323,8 @@
         KeyContext keyContext = (KeyContext) key.attachment();
 
         if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("Reading from '" + keyContext.channelContext.getRemoteAddress() + "'.");
+            LOGGER.debug("Reading ({} -> {})",
+                    keyContext.channelContext.getLocalAddress(), keyContext.channelContext.getRemoteAddress());
         }
 
         ByteBuffer buffer = keyContext.buffer;
@@ -348,13 +352,17 @@
         }
 
         if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug(totalReaded + " readed from '" + keyContext.channelContext.getRemoteAddress() + "'.");
+            LOGGER.debug("Readed {}B ({} -> {})", totalReaded,
+                    keyContext.channelContext.getLocalAddress(), keyContext.channelContext.getRemoteAddress());
         }
 
-        try {
-            keyContext.handler.dataReceived(keyContext.channelContext, buff);
-        } catch (Exception e) {
-            LOGGER.debug(e.getMessage(), e);
+        if (totalReaded > 0) {
+            try {
+                keyContext.handler.dataReceived(keyContext.channelContext, buff);
+                LOGGER.debug("Read handled.");
+            } catch (Exception e) {
+                LOGGER.debug(e.getMessage(), e);
+            }
         }
 
         if (readed == -1) {