changeset 643:32c92600da57

reporter - loopInfo
author Devel 1
date Wed, 08 Nov 2017 09:25:54 +0100
parents af2640f52b66
children 68dea2ebc0bd
files stress-tester-reporter/src/main/java/com/passus/st/reporter/ReporterImpl.java stress-tester/src/main/java/com/passus/st/client/http/HttpFlowContext.java stress-tester/src/main/java/com/passus/st/client/http/HttpRequestResponseMetric.java stress-tester/src/main/java/com/passus/st/client/http/ReporterDestination.java stress-tester/src/main/java/com/passus/st/client/http/ReporterFileDestination.java stress-tester/src/main/java/com/passus/st/client/http/ReporterRemoteDestination.java
diffstat 6 files changed, 117 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester-reporter/src/main/java/com/passus/st/reporter/ReporterImpl.java	Tue Nov 07 16:24:51 2017 +0100
+++ b/stress-tester-reporter/src/main/java/com/passus/st/reporter/ReporterImpl.java	Wed Nov 08 09:25:54 2017 +0100
@@ -100,6 +100,7 @@
             Map<CharSequence, CharSequence> misc = (Map<CharSequence, CharSequence>) fields.get(new Utf8("misc"));
             addValue(builder, getValue(misc, "sessionId"));
             addValue(builder, getValue(misc, "username"));
+            addValue(builder, getValue(fields, "loopInfo"));
             reqFile.println(builder.toString());
             reqFile.flush();
             builder.setLength(0);
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowContext.java	Tue Nov 07 16:24:51 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpFlowContext.java	Wed Nov 08 09:25:54 2017 +0100
@@ -1,14 +1,11 @@
 package com.passus.st.client.http;
 
 import com.passus.data.ByteBuff;
-import com.passus.data.HeapByteBuff;
 import com.passus.net.http.HttpFullMessageDecoder;
 import com.passus.net.http.HttpRequest;
 import com.passus.net.http.HttpResponse;
 import com.passus.st.emitter.ChannelContext;
 import com.passus.st.emitter.SessionInfo;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 
 /**
  *
@@ -113,19 +110,19 @@
 
     public static String contextStateToString(int state) {
         switch (state) {
-            case HttpFlowContext.STATE_ERROR:
+            case STATE_ERROR:
                 return "error";
-            case HttpFlowContext.STATE_CONNECTING:
+            case STATE_CONNECTING:
                 return "connecting";
-            case HttpFlowContext.STATE_CONNECTED:
+            case STATE_CONNECTED:
                 return "connected";
-            case HttpFlowContext.STATE_REQ_SENT:
+            case STATE_REQ_SENT:
                 return "req_sent";
-            case HttpFlowContext.STATE_RESP_RECEIVED:
+            case STATE_RESP_RECEIVED:
                 return "resp_received";
-            case HttpFlowContext.STATE_DISCONNECTING:
+            case STATE_DISCONNECTING:
                 return "disconnecting";
-            case HttpFlowContext.STATE_DISCONNECTED:
+            case STATE_DISCONNECTED:
                 return "disconnected";
             default:
                 return "unknown";
--- a/stress-tester/src/main/java/com/passus/st/client/http/HttpRequestResponseMetric.java	Tue Nov 07 16:24:51 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/HttpRequestResponseMetric.java	Wed Nov 08 09:25:54 2017 +0100
@@ -13,9 +13,9 @@
  * @author mikolaj.podbielski
  */
 public class HttpRequestResponseMetric implements Metric {
-    
+
     protected static final Map<String, Class> ATTRS;
-    
+
     static {
         Map<String, Class> attrs = new HashMap<>();
         attrs.put(Constants.clientIp, String.class);
@@ -26,12 +26,12 @@
         attrs.put(Constants.origClientPort, Integer.class);
         attrs.put(Constants.origServerIp, String.class);
         attrs.put(Constants.origServerPort, Integer.class);
-        
+
         attrs.put(Constants.reqId, String.class);
         attrs.put(Constants.reqHdrs, Map.class);
         attrs.put(Constants.respHdrs, Map.class);
         attrs.put(Constants.misc, Map.class);
-        
+
         attrs.put(Constants.reqHdrSize, Long.class);
         attrs.put(Constants.reqCntSize, Long.class);
         attrs.put(Constants.reqStart, Long.class);
@@ -39,7 +39,7 @@
         attrs.put(Constants.method, String.class);
         attrs.put(Constants.url, String.class);
         attrs.put(Constants.reqVersion, String.class);
-        
+
         attrs.put(Constants.respHdrSize, Long.class);
         attrs.put(Constants.respCntSize, Long.class);
         attrs.put(Constants.respStart, Long.class);
@@ -47,14 +47,14 @@
         attrs.put(Constants.code, Integer.class);
         attrs.put(Constants.reason, String.class);
         attrs.put(Constants.respVersion, String.class);
-        
+
         ATTRS = Collections.unmodifiableMap(attrs);
     }
-    
+
     private final String name = "httpRequestResponse";
-    
+
     private boolean active;
-    
+
     private String clientIp;
     private Integer clientPort;
     private String serverIp;
@@ -63,235 +63,244 @@
     private Integer origClientPort;
     private String origServerIp;
     private Integer origServerPort;
-    
+    private String loopInfo;
+
     private String reqId;
     private HashMap<ByteString, ByteString> reqHdrs = new HashMap<>();
     private HashMap<ByteString, ByteString> respHdrs = new HashMap<>();
     private HashMap<String, String> misc = new HashMap<>();
-    
+
     private Long reqHdrSize;
     private Long reqCntSize;
     private Long reqStart;
     private Long reqStop;
-    
+
     private String method;
     private String url;
     private String reqVersion;
-    
+
     private Long respHdrSize;
     private Long respCntSize;
     private Long respStart;
     private Long respStop;
-    
+
     private Integer code;
     private String reason;
     private String respVersion;
-    
+
 //<editor-fold defaultstate="collapsed" desc="get set">
     public String getClientIp() {
         return clientIp;
     }
-    
+
     public void setClientIp(String clientIp) {
         this.clientIp = clientIp;
     }
-    
+
     public Integer getClientPort() {
         return clientPort;
     }
-    
+
     public void setClientPort(Integer clientPort) {
         this.clientPort = clientPort;
     }
-    
+
     public String getServerIp() {
         return serverIp;
     }
-    
+
     public void setServerIp(String serverIp) {
         this.serverIp = serverIp;
     }
-    
+
     public Integer getServerPort() {
         return serverPort;
     }
-    
+
     public void setServerPort(Integer serverPort) {
         this.serverPort = serverPort;
     }
-    
+
     public String getOrigClientIp() {
         return origClientIp;
     }
-    
+
     public void setOrigClientIp(String origClientIp) {
         this.origClientIp = origClientIp;
     }
-    
+
     public Integer getOrigClientPort() {
         return origClientPort;
     }
-    
+
     public void setOrigClientPort(Integer origClientPort) {
         this.origClientPort = origClientPort;
     }
-    
+
     public String getOrigServerIp() {
         return origServerIp;
     }
-    
+
     public void setOrigServerIp(String origServerIp) {
         this.origServerIp = origServerIp;
     }
-    
+
     public Integer getOrigServerPort() {
         return origServerPort;
     }
-    
+
     public void setOrigServerPort(Integer origServerPort) {
         this.origServerPort = origServerPort;
     }
-    
+
+    public String getLoopInfo() {
+        return loopInfo;
+    }
+
+    public void setLoopInfo(String loopInfo) {
+        this.loopInfo = loopInfo;
+    }
+
     public String getReqId() {
         return reqId;
     }
-    
+
     public void setReqId(String reqId) {
         this.reqId = reqId;
     }
-    
+
     public HashMap<ByteString, ByteString> getReqHdrs() {
         return reqHdrs;
     }
-    
+
     public void setReqHdrs(HashMap<ByteString, ByteString> reqHdrs) {
         this.reqHdrs = reqHdrs;
     }
-    
+
     public HashMap<ByteString, ByteString> getRespHdrs() {
         return respHdrs;
     }
-    
+
     public void setRespHdrs(HashMap<ByteString, ByteString> respHdrs) {
         this.respHdrs = respHdrs;
     }
-    
+
     public HashMap<String, String> getMisc() {
         return misc;
     }
-    
+
     public void setMisc(HashMap<String, String> misc) {
         this.misc = misc;
     }
-    
+
     public Long getReqHdrSize() {
         return reqHdrSize;
     }
-    
+
     public void setReqHdrSize(Long reqHdrSize) {
         this.reqHdrSize = reqHdrSize;
     }
-    
+
     public Long getReqCntSize() {
         return reqCntSize;
     }
-    
+
     public void setReqCntSize(Long reqCntSize) {
         this.reqCntSize = reqCntSize;
     }
-    
+
     public Long getReqStart() {
         return reqStart;
     }
-    
+
     public void setReqStart(Long reqStart) {
         this.reqStart = reqStart;
     }
-    
+
     public Long getReqStop() {
         return reqStop;
     }
-    
+
     public void setReqStop(Long reqStop) {
         this.reqStop = reqStop;
     }
-    
+
     public String getMethod() {
         return method;
     }
-    
+
     public void setMethod(String method) {
         this.method = method;
     }
-    
+
     public String getUrl() {
         return url;
     }
-    
+
     public void setUrl(String url) {
         this.url = url;
     }
-    
+
     public String getReqVersion() {
         return reqVersion;
     }
-    
+
     public void setReqVersion(String reqVersion) {
         this.reqVersion = reqVersion;
     }
-    
+
     public Long getRespHdrSize() {
         return respHdrSize;
     }
-    
+
     public void setRespHdrSize(Long respHdrSize) {
         this.respHdrSize = respHdrSize;
     }
-    
+
     public Long getRespCntSize() {
         return respCntSize;
     }
-    
+
     public void setRespCntSize(Long respCntSize) {
         this.respCntSize = respCntSize;
     }
-    
+
     public Long getRespStart() {
         return respStart;
     }
-    
+
     public void setRespStart(Long respStart) {
         this.respStart = respStart;
     }
-    
+
     public Long getRespStop() {
         return respStop;
     }
-    
+
     public void setRespStop(Long respStop) {
         this.respStop = respStop;
     }
-    
+
     public Integer getCode() {
         return code;
     }
-    
+
     public void setCode(Integer code) {
         this.code = code;
     }
-    
+
     public String getReason() {
         return reason;
     }
-    
+
     public void setReason(String reason) {
         this.reason = reason;
     }
-    
+
     public String getRespVersion() {
         return respVersion;
     }
-    
+
     public void setRespVersion(String respVersion) {
         this.respVersion = respVersion;
     }
@@ -301,47 +310,47 @@
     public String getName() {
         return name;
     }
-    
+
     @Override
     public boolean isActive() {
         return active;
     }
-    
+
     @Override
     public void activate() {
         active = true;
     }
-    
+
     @Override
     public void deactivate() {
         if (!active) {
             return;
         }
-        
+
         reset();
         active = false;
     }
-    
+
     @Override
     public Class getAttributeClass(String name) {
         Class clazz = ATTRS.get(name);
         if (clazz == null) {
             throw new IllegalArgumentException("No such attribute '" + name + "'.");
         }
-        
+
         return clazz;
     }
-    
+
     @Override
     public boolean hasAttribute(String name) {
         return ATTRS.containsKey(name);
     }
-    
+
     @Override
     public Set<String> getAttributesName() {
         return ATTRS.keySet();
     }
-    
+
     @Override
     public Serializable getAttributeValue(String name) {
         switch (name) {
@@ -361,7 +370,9 @@
                 return origServerIp;
             case Constants.origServerPort:
                 return origServerPort;
-            
+            case Constants.loopInfo:
+                return loopInfo;
+
             case Constants.reqId:
                 return reqId;
             case Constants.reqHdrs:
@@ -370,7 +381,7 @@
                 return respHdrs;
             case Constants.misc:
                 return misc;
-            
+
             case Constants.reqHdrSize:
                 return reqHdrSize;
             case Constants.reqCntSize:
@@ -385,7 +396,7 @@
                 return url;
             case Constants.reqVersion:
                 return reqVersion;
-            
+
             case Constants.respHdrSize:
                 return respHdrSize;
             case Constants.respCntSize:
@@ -404,7 +415,7 @@
                 throw new IllegalArgumentException("Unknown attribute '" + name + "'.");
         }
     }
-    
+
     @Override
     public Map<String, Serializable> getAttributesValue() {
         Set<String> names = getAttributesName();
@@ -412,22 +423,22 @@
         for (String name : names) {
             values.put(name, getAttributeValue(name));
         }
-        
+
         return values;
     }
-    
+
     @Override
     public void update(Metric metric) {
-        
+
     }
-    
+
     @Override
     public void reset() {
-        
+
     }
-    
+
     public static final class Constants {
-        
+
         public static final String clientIp = "clientIp";
         public static final String clientPort = "clientPort";
         public static final String serverIp = "serverIp";
@@ -436,12 +447,13 @@
         public static final String origClientPort = "origClientPort";
         public static final String origServerIp = "origServerIp";
         public static final String origServerPort = "origServerPort";
-        
+        public static final String loopInfo = "loopInfo";
+
         public static final String reqId = "reqId";
         public static final String reqHdrs = "reqHdrs";
         public static final String respHdrs = "respHdrs";
         public static final String misc = "misc";
-        
+
         public static final String reqHdrSize = "reqHdrSize";
         public static final String reqCntSize = "reqCntSize";
         public static final String reqStart = "reqStart";
@@ -449,7 +461,7 @@
         public static final String method = "method";
         public static final String url = "url";
         public static final String reqVersion = "reqVersion";
-        
+
         public static final String respHdrSize = "respHdrSize";
         public static final String respCntSize = "respCntSize";
         public static final String respStart = "respStart";
@@ -457,6 +469,6 @@
         public static final String code = "code";
         public static final String reason = "reason";
         public static final String respVersion = "respVersion";
-        
+
     }
 }
--- a/stress-tester/src/main/java/com/passus/st/client/http/ReporterDestination.java	Tue Nov 07 16:24:51 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/ReporterDestination.java	Wed Nov 08 09:25:54 2017 +0100
@@ -24,4 +24,9 @@
             HttpHeaders.CONTENT_TYPE
     ));
 
+    public static String getLoopInfo(HttpFlowContext context) {
+        String sourceName = context.sentEvent.getSourceName();
+        int loop = context.getParameters().getLoop();
+        return sourceName + "_loop" + loop;
+    }
 }
--- a/stress-tester/src/main/java/com/passus/st/client/http/ReporterFileDestination.java	Tue Nov 07 16:24:51 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/ReporterFileDestination.java	Wed Nov 08 09:25:54 2017 +0100
@@ -103,6 +103,7 @@
                 ReporterRemoteDestination.populateMisc(misc, context, request);
                 addValue(builder, misc.get("sessionId"));
                 addValue(builder, misc.get("username"));
+                addValue(builder, ReporterDestination.getLoopInfo(context));
             } else {
                 addValue(builder, null);
             }
--- a/stress-tester/src/main/java/com/passus/st/client/http/ReporterRemoteDestination.java	Tue Nov 07 16:24:51 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/ReporterRemoteDestination.java	Wed Nov 08 09:25:54 2017 +0100
@@ -85,6 +85,7 @@
         metric.setOrigClientPort(session.getSrcPort());
         metric.setOrigServerIp(session.getDstIp().toString());
         metric.setOrigServerPort(session.getDstPort());
+        metric.setLoopInfo(ReporterDestination.getLoopInfo(context));
 
         if (request != null) {
             metric.setReqId(request.getId());