changeset 1226:20b9a2c14db3

flow - minor refactoring
author Devel 1
date Thu, 25 Jun 2020 14:10:53 +0200
parents 214d097dd288
children 940aa00f4790
files stress-tester/src/main/java/com/passus/st/scanner/HttpUrlSequencePayloadAnalyzer.java
diffstat 1 files changed, 9 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/scanner/HttpUrlSequencePayloadAnalyzer.java	Thu Jun 25 14:06:44 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/scanner/HttpUrlSequencePayloadAnalyzer.java	Thu Jun 25 14:10:53 2020 +0200
@@ -41,7 +41,6 @@
 import static com.passus.st.config.CommonNodeDefs.FLOAT_GREATER_EQUAL_ZERO_DEF;
 import static com.passus.st.config.CommonNodeDefs.INT_GREATER_THAN_ZERO_DEF;
 import static com.passus.st.config.CommonNodeDefs.STRING_DEF;
-import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -57,12 +56,7 @@
 
     private UserIdExtractor userIdExtractor;
 
-    private String dataPath;
-    private List<String> cleanRules;
-    private float pmin = FlowAnalyzerCommand.DEFAULT_PMIN;
-    private int lmin = FlowAnalyzerCommand.DEFAULT_LMIN;
-    private int lmax = FlowAnalyzerCommand.DEFAULT_LMAX;
-    private boolean useFold;
+    private final FlowAnalyzerCommand command = new FlowAnalyzerCommand();
 
     private CSVWriter dataWriter;
 
@@ -74,12 +68,12 @@
     public void configure(Configuration config, ConfigurationContext context) {
         String userIdSource = config.getString("userIdSource", "ip");
         userIdExtractor = resolveUserIdExtractor(userIdSource);
-        dataPath = config.getString("dataPath", "sequence_data.csv");
-        pmin = config.getFloat("pmin", FlowAnalyzerCommand.DEFAULT_PMIN);
-        lmin = config.getInteger("lmin", FlowAnalyzerCommand.DEFAULT_LMIN);
-        lmax = config.getInteger("lmax", FlowAnalyzerCommand.DEFAULT_LMAX);
-        useFold = config.getBoolean("useFold", FlowAnalyzerCommand.DEFAULT_USE_FOLD);
-        cleanRules = config.getList("cleanRules");
+        command.dataPath = config.getString("dataPath", "sequence_data.csv");
+        command.pmin = config.getFloat("pmin", FlowAnalyzerCommand.DEFAULT_PMIN);
+        command.lmin = config.getInteger("lmin", FlowAnalyzerCommand.DEFAULT_LMIN);
+        command.lmax = config.getInteger("lmax", FlowAnalyzerCommand.DEFAULT_LMAX);
+        command.useFold = config.getBoolean("useFold", FlowAnalyzerCommand.DEFAULT_USE_FOLD);
+        command.cleanRules = config.getList("cleanRules");
     }
 
     @Override
@@ -88,7 +82,8 @@
         metric.activate();
 
         try {
-            FileOutputStream fos = new FileOutputStream(dataPath);
+            FlowAnalyzerCommand.extractEmbeddedScript(new File(command.scriptPath));
+            FileOutputStream fos = new FileOutputStream(command.dataPath);
             OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
             dataWriter = new CSVWriter(osw);
         } catch (IOException ex) {
@@ -155,14 +150,6 @@
     private void populateMetric() {
         try {
             dataWriter.flush(); // TODO: ???
-            FlowAnalyzerCommand command = new FlowAnalyzerCommand();
-            FlowAnalyzerCommand.extractEmbeddedScript(new File(command.scriptPath));
-            command.dataPath = dataPath;
-            command.cleanRules = cleanRules;
-            command.pmin = pmin;
-            command.lmin = lmin;
-            command.lmax = lmax;
-            command.useFold = useFold;
             command.run();
 
             File dir = new File(".");