changeset 574:f7c2e8285d7c

ST-86
author Devel 2
date Wed, 27 Sep 2017 16:33:50 +0200
parents 1fb90938c654
children 5076b7ad9328
files stress-tester/src/main/java/com/passus/st/client/http/HttpFlowBasedClientWorker.java stress-tester/src/main/java/com/passus/st/client/http/HttpSynchClientWorker.java
diffstat 2 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowBasedClientWorker.java	Wed Sep 27 15:47:49 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowBasedClientWorker.java	Wed Sep 27 16:33:50 2017 +0200
@@ -25,7 +25,9 @@
 import com.passus.st.metric.MetricsContainer;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import org.apache.logging.log4j.Level;
 
@@ -51,6 +53,8 @@
 
     protected final Map<SessionInfo, HttpFlowContext> sessions = new ConcurrentHashMap<>();
 
+    private final Set<SessionInfo> blockedSessions = new HashSet<>();
+
     private final Map<Integer, Long> timeouts = new HashMap<>();
 
     private final HttpRequestEncoder reqEncoder = new HttpRequestEncoder();
@@ -107,6 +111,14 @@
         this.timeGenerator = timeGenerator;
     }
 
+    protected final void addBlockedSession(SessionInfo session) {
+        blockedSessions.add(session);
+    }
+
+    protected final boolean isBlockedSession(SessionInfo session) {
+        return !blockedSessions.isEmpty() && blockedSessions.contains(session);
+    }
+
     public float getSleepFactor() {
         return sleepFactor;
     }
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpSynchClientWorker.java	Wed Sep 27 15:47:49 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpSynchClientWorker.java	Wed Sep 27 16:33:50 2017 +0200
@@ -61,6 +61,9 @@
             if (flowContext != null) {
                 changeFlowState(flowContext, HttpFlowContext.STATE_DISCONNECTING);
             }
+
+            addBlockedSession(session);
+            lock.notifyAll();
         }
     }
 
@@ -138,8 +141,13 @@
             }
 
             if (event instanceof SessionEvent) {
+                SessionEvent sessEvent = (SessionEvent) event;
+                if (isBlockedSession(sessEvent.getSessionInfo())) {
+                    return true;
+                }
+
                 if (event.getType() == SessionStatusEvent.TYPE) {
-                    SessionStatusEvent statusEvent = (SessionStatusEvent) event;
+                    SessionStatusEvent statusEvent = (SessionStatusEvent) sessEvent;
                     if (statusEvent.getStatus() == SessionStatusEvent.STATUS_ESTABLISHED) {
                         try {
                             currFlowContext = connect(statusEvent);
@@ -159,7 +167,6 @@
 
                     return true;
                 } else if (event.getType() == HttpSessionPayloadEvent.TYPE) {
-                    SessionEvent sessEvent = (SessionEvent) event;
                     HttpFlowContext flowContext = flowContext(sessEvent);
                     if (flowContext != null) {
                         switch (flowContext.state) {