changeset 694:273721fe69d1

NC file in progress
author Devel 2
date Mon, 27 Nov 2017 11:23:51 +0100
parents 3b6dbbe80eff
children 5a83840fa11c
files stress-tester/src/main/java/com/passus/st/source/EventSource.java stress-tester/src/main/java/com/passus/st/source/NcEventDestination.java stress-tester/src/main/java/com/passus/st/source/PcapSessionEventSource.java
diffstat 3 files changed, 31 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/source/EventSource.java	Mon Nov 27 11:23:01 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/source/EventSource.java	Mon Nov 27 11:23:51 2017 +0100
@@ -3,6 +3,7 @@
 import com.passus.commons.service.Service;
 import com.passus.config.Configurable;
 import com.passus.config.Configuration;
+import com.passus.st.client.EventHandler;
 
 /**
  *
@@ -16,6 +17,10 @@
 
     public void setName(String name);
 
+    public EventHandler getHandler();
+
+    public void setHandler(EventHandler handler);
+
     @Override
     public default void configure(Configuration config) {
 
--- a/stress-tester/src/main/java/com/passus/st/source/NcEventDestination.java	Mon Nov 27 11:23:01 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/source/NcEventDestination.java	Mon Nov 27 11:23:51 2017 +0100
@@ -12,6 +12,7 @@
 import com.passus.st.client.http.HttpSessionPayloadEvent;
 import com.passus.st.reader.nc.HttpSessionPayloadEventDataWriter;
 import com.passus.st.reader.nc.NcDataBlockWriter;
+import java.io.IOException;
 
 /**
  *
@@ -30,7 +31,9 @@
     private final HttpResponseEncoder responseEncoder = HttpResponseEncoder.getInstance();
 
     private HttpSessionPayloadEventDataWriter httpPayloadWriter = new HttpSessionPayloadEventDataWriter();
-    
+
+    private boolean encodeData;
+
     @Override
     public boolean isStarted() {
         return started;
@@ -56,11 +59,9 @@
 
     @Override
     public void stop() {
-        if (!started) {
-            return;
+        if (started) {
+            stop0();
         }
-
-        stop0();
     }
 
     private void stop0() {
@@ -85,6 +86,24 @@
 
     }
 
+    private void writeNotEncoded(HttpSessionPayloadEvent event) throws IOException {
+        if (event.getRequest() != null) {
+            ByteBuff buff = new HeapByteBuff();
+            requestEncoder.encode(event.getRequest(), buff);
+            writer.writeSessionPayload(event.getTimestamp(), event.getSessionInfo(), (byte) 1, buff);
+        }
+
+        if (event.getResponse() != null) {
+            ByteBuff buff = new HeapByteBuff();
+            responseEncoder.encode(event.getResponse(), buff);
+            writer.writeSessionPayload(event.getTimestamp(), event.getSessionInfo(), (byte) 1, buff);
+        }
+    }
+
+    private void writeEncoded(HttpSessionPayloadEvent event) throws IOException {
+        httpPayloadWriter.write(event, writer);
+    }
+
     @Override
     public void handle(Event event) {
         checkStarted();
--- a/stress-tester/src/main/java/com/passus/st/source/PcapSessionEventSource.java	Mon Nov 27 11:23:01 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/source/PcapSessionEventSource.java	Mon Nov 27 11:23:51 2017 +0100
@@ -164,10 +164,12 @@
         this.loops = loops;
     }
 
+    @Override
     public EventHandler getHandler() {
         return handler;
     }
 
+    @Override
     public void setHandler(EventHandler handler) {
         Assert.notNull(handler, "handler");
         this.handler = handler;