changeset 800:06bb0c4c4a5d

HttpSynchClientWorker connection sequence changed
author Devel 2
date Wed, 03 Jan 2018 12:49:59 +0100
parents 4af45fd9b562
children f07a59880d45
files stress-tester/src/main/java/com/passus/st/client/http/HttpSynchClientWorker.java stress-tester/src/test/java/com/passus/st/client/http/HttpSynchClientWorkerTest.java
diffstat 2 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpSynchClientWorker.java	Wed Jan 03 12:24:09 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpSynchClientWorker.java	Wed Jan 03 12:49:59 2018 +0100
@@ -10,6 +10,7 @@
 import com.passus.st.emitter.Emitter;
 import com.passus.st.emitter.SessionInfo;
 import com.passus.st.plugin.PluginConstants;
+import java.io.IOException;
 import java.util.concurrent.LinkedBlockingDeque;
 
 /**
@@ -152,8 +153,9 @@
                     SessionStatusEvent statusEvent = (SessionStatusEvent) sessEvent;
                     if (statusEvent.getStatus() == SessionStatusEvent.STATUS_ESTABLISHED) {
                         try {
-                            currFlowContext = connect(statusEvent);
+                            currFlowContext = register(statusEvent);
                             if (currFlowContext != null) {
+                                emitter.connect(statusEvent.getSessionInfo(), this, index);
                                 currFlowContext.setParameters(currentFlowParameters);
                             }
                         } catch (Exception e) {
@@ -188,10 +190,17 @@
                             case HttpFlowContext.STATE_DISCONNECTING:
                             case HttpFlowContext.STATE_DISCONNECTED:
                                 if (connectPartialSession) {
-                                    currFlowContext = connect(sessEvent);
+                                    currFlowContext = register(sessEvent);
                                     if (currFlowContext != null) {
-                                        currFlowContext.setParameters(currentFlowParameters);
+                                        try {
+                                            emitter.connect(sessEvent.getSessionInfo(), this, index);
+                                            currFlowContext.setParameters(currentFlowParameters);
+                                        } catch (IOException e) {
+                                            logger.error(e.getMessage(), e);
+                                            currFlowContext = null;
+                                        }
                                     }
+
                                     return false;
                                 } else {
                                     return true;
@@ -200,10 +209,17 @@
                                 return false;
                         }
                     } else if (connectPartialSession) {
-                        currFlowContext = connect(sessEvent);
+                        currFlowContext = register(sessEvent);
                         if (currFlowContext != null) {
-                            currFlowContext.setParameters(currentFlowParameters);
-                            eventsQueue.addFirst(sessEvent);
+                            try {
+                                emitter.connect(sessEvent.getSessionInfo(), this, index);
+                                currFlowContext.setParameters(currentFlowParameters);
+                                eventsQueue.addFirst(sessEvent);
+                            } catch (IOException e) {
+                                logger.error(e.getMessage(), e);
+                                currFlowContext = null;
+                            }
+
                             return false;
                         } else {
                             return true;
--- a/stress-tester/src/test/java/com/passus/st/client/http/HttpSynchClientWorkerTest.java	Wed Jan 03 12:24:09 2018 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/HttpSynchClientWorkerTest.java	Wed Jan 03 12:49:59 2018 +0100
@@ -147,7 +147,7 @@
         LocalEmitter emitter = new LocalEmitter();
         HttpSynchClientWorker worker = new HttpSynchClientWorker(emitter, "test", 0);
         worker.setListeners(Arrays.asList(listner));
-        worker.setConnectPartialSession(true);
+        //worker.setConnectPartialSession(true);
 
         worker.start();
         SessionEvent sessionEvent = (SessionEvent) events.get(0);