From 16d4ec7248dc0f2ebe95f97ff939f875febc7cdc Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Thu, 20 Mar 2014 11:11:56 +0800 Subject: [PATCH] Merge Bench4Q-Agent --- .../ScenarioParameters}/param1.txt | 0 .../345376a7-d01c-4faa-af89-4a3e1a182048.xml | 0 .../Scripts}/behaviorModel.xml | 32 +- .../Scripts}/forGoodRecord.xml | 0 .../Scripts}/goodForBatch.xml | 290 ++++----- .../Scripts}/goodForPage.xml | 0 {Scripts => Bench4Q-Agent/Scripts}/testJD.xml | 0 .../StorageTest}/testInput.txt | 0 .../StorageTest}/test_123.txt | 0 .../configure}/agent-config.properties | 0 .../descriptor.xml | 48 +- pom.xml => Bench4Q-Agent/pom.xml | 0 .../java/org/bench4q/agent/AgentServer.java | 128 ++-- .../main/java/org/bench4q/agent/Main.java | 0 .../org/bench4q/agent/api/HomeController.java | 98 +-- .../bench4q/agent/api/PluginController.java | 162 ++--- .../org/bench4q/agent/api/TestController.java | 0 .../agent/datacollector/DataCollector.java | 0 .../impl/AbstractDataCollector.java | 0 .../impl/BehaviorResultCollector.java | 10 +- .../impl/BehaviorStatusCodeResult.java | 102 ++-- .../impl/PageResultCollector.java | 220 +++---- .../impl/ScenarioResultCollector.java | 556 +++++++++--------- .../helper/ApplicationContextHelper.java | 52 +- .../ParameterFileCollector.java | 0 .../agent/parameterization/SessionObject.java | 0 .../impl/InstanceControler.java | 0 .../impl/MyFileClassLoader.java | 0 .../parameterization/impl/Para_File.java | 0 .../impl/Para_GetEletronicCombine.java | 0 .../impl/Para_IteratorNumber.java | 0 .../impl/Para_RandomNumber.java | 0 .../parameterization/impl/Para_Table.java | 0 .../parameterization/impl/Para_Table.xml | 0 .../impl/Para_UniqueNumber.java | 0 .../impl/Para_UserNameAndPassword.java | 0 .../impl/ParameterThreadOption.java | 0 .../impl/ParameterizationParser.java | 0 .../impl/ParametersFactory.java | 0 .../org/bench4q/agent/plugin/Behavior.java | 22 +- .../bench4q/agent/plugin/BehaviorInfo.java | 46 +- .../org/bench4q/agent/plugin/ClassHelper.java | 248 ++++---- .../org/bench4q/agent/plugin/Parameter.java | 24 +- .../bench4q/agent/plugin/ParameterInfo.java | 46 +- .../java/org/bench4q/agent/plugin/Plugin.java | 24 +- .../org/bench4q/agent/plugin/PluginInfo.java | 64 +- .../bench4q/agent/plugin/PluginManager.java | 538 ++++++++--------- .../bench4q/agent/plugin/TypeConverter.java | 88 +-- .../agent/plugin/basic/CommandLinePlugin.java | 178 +++--- .../plugin/basic/ConstantTimerPlugin.java | 54 +- .../bench4q/agent/plugin/basic/LogPlugin.java | 38 +- .../agent/plugin/basic/http/HttpPlugin.java | 0 .../plugin/basic/http/ParameterConstant.java | 0 .../plugin/result/CommandLineReturn.java | 14 +- .../agent/plugin/result/HttpReturn.java | 0 .../agent/plugin/result/LogReturn.java | 14 +- .../agent/plugin/result/PluginReturn.java | 0 .../agent/plugin/result/TimerReturn.java | 24 +- .../org/bench4q/agent/scenario/Batch.java | 86 +-- .../agent/scenario/BehaviorResult.java | 250 ++++---- .../java/org/bench4q/agent/scenario/Page.java | 0 .../bench4q/agent/scenario/PageResult.java | 154 ++--- .../org/bench4q/agent/scenario/Parameter.java | 46 +- .../org/bench4q/agent/scenario/Scenario.java | 0 .../agent/scenario/ScenarioContext.java | 0 .../agent/scenario/ScenarioEngine.java | 0 .../agent/scenario/SessionContext.java | 0 .../bench4q/agent/scenario/TestResult.java | 222 +++---- .../agent/scenario/TestResultItem.java | 186 +++--- .../org/bench4q/agent/scenario/UsePlugin.java | 64 +- .../org/bench4q/agent/scenario/Worker.java | 0 .../agent/scenario/behavior/Behavior.java | 0 .../scenario/behavior/BehaviorFactory.java | 28 +- .../scenario/behavior/TimerBehavior.java | 0 .../agent/scenario/behavior/UserBehavior.java | 0 .../agent/scenario/util/ParameterParser.java | 0 .../bench4q/agent/scenario/util/Table.java | 0 .../org/bench4q/agent/share/DealWithLog.java | 26 +- .../org/bench4q/agent/storage/Buffer.java | 114 ++-- .../agent/storage/DoubleBufferStorage.java | 314 +++++----- .../bench4q/agent/storage/HdfsStorage.java | 280 ++++----- .../bench4q/agent/storage/LocalStorage.java | 0 .../bench4q/agent/storage/MooseStorage.java | 34 +- .../org/bench4q/agent/storage/Storage.java | 0 .../bench4q/agent/storage/StorageHelper.java | 0 .../src}/main/resources/log4j.properties | 62 +- .../agent/config/application-context.xml | 0 .../agent/test/ExtractScenarioTest.java | 54 +- .../agent/test/HomeControllerTest.java | 10 +- .../java/org/bench4q/agent/test/MainTest.java | 0 .../agent/test/PluginControllerTest.java | 10 +- .../agent/test/TestWithScriptFile.java | 0 .../datastatistics/DetailStatisticsTest.java | 0 .../PageResultStatisticsTest.java | 0 .../ScenarioStatisticsTest.java | 0 .../bench4q/agent/test/model/ModelTest.java | 60 +- .../test/model/UserBehaviorModelTest.java | 52 +- .../parameterization/TEST_HelloThread.java | 0 .../test/parameterization/TEST_UserName.java | 0 .../Test_ParameterizationParser.java | 0 .../agent/test/plugin/Test_HttpPlugin.java | 0 .../test/scenario/Test_ScenarioContext.java | 0 .../scenario/utils/Test_ParameterParser.java | 0 .../utils/Test_RegularExpression.java | 0 .../test/storage/TestDoubleBufferStorage.java | 0 .../test/resources/test-storage-context.xml | 22 +- license.txt | 339 ----------- 107 files changed, 2597 insertions(+), 2936 deletions(-) rename {ScenarioParameters => Bench4Q-Agent/ScenarioParameters}/param1.txt (100%) rename {Scripts => Bench4Q-Agent/Scripts}/345376a7-d01c-4faa-af89-4a3e1a182048.xml (100%) rename {Scripts => Bench4Q-Agent/Scripts}/behaviorModel.xml (90%) rename {Scripts => Bench4Q-Agent/Scripts}/forGoodRecord.xml (100%) rename {Scripts => Bench4Q-Agent/Scripts}/goodForBatch.xml (95%) rename {Scripts => Bench4Q-Agent/Scripts}/goodForPage.xml (100%) rename {Scripts => Bench4Q-Agent/Scripts}/testJD.xml (100%) rename {StorageTest => Bench4Q-Agent/StorageTest}/testInput.txt (100%) rename {StorageTest => Bench4Q-Agent/StorageTest}/test_123.txt (100%) rename {configure => Bench4Q-Agent/configure}/agent-config.properties (100%) rename descriptor.xml => Bench4Q-Agent/descriptor.xml (95%) rename pom.xml => Bench4Q-Agent/pom.xml (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/AgentServer.java (95%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/Main.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/api/HomeController.java (97%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/api/PluginController.java (97%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/api/TestController.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/datacollector/DataCollector.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/datacollector/impl/AbstractDataCollector.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/datacollector/impl/BehaviorResultCollector.java (94%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/datacollector/impl/BehaviorStatusCodeResult.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/datacollector/impl/PageResultCollector.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/datacollector/impl/ScenarioResultCollector.java (97%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/helper/ApplicationContextHelper.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/ParameterFileCollector.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/SessionObject.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/InstanceControler.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/MyFileClassLoader.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/Para_File.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/Para_GetEletronicCombine.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/Para_IteratorNumber.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/Para_RandomNumber.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/Para_Table.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/Para_Table.xml (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/Para_UniqueNumber.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/Para_UserNameAndPassword.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/ParameterThreadOption.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/ParameterizationParser.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/parameterization/impl/ParametersFactory.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/Behavior.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/BehaviorInfo.java (94%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/ClassHelper.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/Parameter.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/ParameterInfo.java (93%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/Plugin.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/PluginInfo.java (94%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/PluginManager.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/TypeConverter.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/basic/CommandLinePlugin.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/basic/ConstantTimerPlugin.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/basic/LogPlugin.java (95%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/basic/http/HttpPlugin.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/basic/http/ParameterConstant.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/result/CommandLineReturn.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/result/HttpReturn.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/result/LogReturn.java (95%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/result/PluginReturn.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/plugin/result/TimerReturn.java (94%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/Batch.java (94%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/BehaviorResult.java (94%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/Page.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/PageResult.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/Parameter.java (93%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/Scenario.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/ScenarioContext.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/ScenarioEngine.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/SessionContext.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/TestResult.java (95%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/TestResultItem.java (94%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/UsePlugin.java (93%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/Worker.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/behavior/Behavior.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/behavior/BehaviorFactory.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/behavior/TimerBehavior.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/behavior/UserBehavior.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/util/ParameterParser.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/scenario/util/Table.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/share/DealWithLog.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/storage/Buffer.java (95%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/storage/DoubleBufferStorage.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/storage/HdfsStorage.java (96%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/storage/LocalStorage.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/storage/MooseStorage.java (94%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/storage/Storage.java (100%) rename {src => Bench4Q-Agent/src}/main/java/org/bench4q/agent/storage/StorageHelper.java (100%) rename {src => Bench4Q-Agent/src}/main/resources/log4j.properties (97%) rename {src => Bench4Q-Agent/src}/main/resources/org/bench4q/agent/config/application-context.xml (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/ExtractScenarioTest.java (96%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/HomeControllerTest.java (93%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/MainTest.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/PluginControllerTest.java (93%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/TestWithScriptFile.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/datastatistics/DetailStatisticsTest.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/datastatistics/PageResultStatisticsTest.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/datastatistics/ScenarioStatisticsTest.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/model/ModelTest.java (96%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/model/UserBehaviorModelTest.java (96%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/parameterization/TEST_HelloThread.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/parameterization/TEST_UserName.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/parameterization/Test_ParameterizationParser.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/plugin/Test_HttpPlugin.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/scenario/Test_ScenarioContext.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/scenario/utils/Test_ParameterParser.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/scenario/utils/Test_RegularExpression.java (100%) rename {src => Bench4Q-Agent/src}/test/java/org/bench4q/agent/test/storage/TestDoubleBufferStorage.java (100%) rename {src => Bench4Q-Agent/src}/test/resources/test-storage-context.xml (98%) delete mode 100644 license.txt diff --git a/ScenarioParameters/param1.txt b/Bench4Q-Agent/ScenarioParameters/param1.txt similarity index 100% rename from ScenarioParameters/param1.txt rename to Bench4Q-Agent/ScenarioParameters/param1.txt diff --git a/Scripts/345376a7-d01c-4faa-af89-4a3e1a182048.xml b/Bench4Q-Agent/Scripts/345376a7-d01c-4faa-af89-4a3e1a182048.xml similarity index 100% rename from Scripts/345376a7-d01c-4faa-af89-4a3e1a182048.xml rename to Bench4Q-Agent/Scripts/345376a7-d01c-4faa-af89-4a3e1a182048.xml diff --git a/Scripts/behaviorModel.xml b/Bench4Q-Agent/Scripts/behaviorModel.xml similarity index 90% rename from Scripts/behaviorModel.xml rename to Bench4Q-Agent/Scripts/behaviorModel.xml index 22f09364..136480d0 100644 --- a/Scripts/behaviorModel.xml +++ b/Bench4Q-Agent/Scripts/behaviorModel.xml @@ -1,17 +1,17 @@ - - 0 - Get - - - url - http://133.133.12.3:8080/Bench4QTestCase/testcase.html - - - - parameters - - - - USERBEHAVIOR - http + + 0 + Get + + + url + http://133.133.12.3:8080/Bench4QTestCase/testcase.html + + + + parameters + + + + USERBEHAVIOR + http \ No newline at end of file diff --git a/Scripts/forGoodRecord.xml b/Bench4Q-Agent/Scripts/forGoodRecord.xml similarity index 100% rename from Scripts/forGoodRecord.xml rename to Bench4Q-Agent/Scripts/forGoodRecord.xml diff --git a/Scripts/goodForBatch.xml b/Bench4Q-Agent/Scripts/goodForBatch.xml similarity index 95% rename from Scripts/goodForBatch.xml rename to Bench4Q-Agent/Scripts/goodForBatch.xml index 985d6fa6..8be2d6e7 100644 --- a/Scripts/goodForBatch.xml +++ b/Bench4Q-Agent/Scripts/goodForBatch.xml @@ -1,146 +1,146 @@ - - - - - - - 1 - Get - - - url - http://133.133.12.3:8080/Bench4QTestCase/testcase.html - - - - parameters - - - - http - - - 2 - 0 - -1 - - - - - 0 - Sleep - - - time - 2500 - - - timer - - - -1 - 1 - -1 - - - - - 3 - Get - - - url - http://133.133.12.3:8080/Bench4QTestCase/images/3.jpg - - - - parameters - - - - http - - - 4 - Get - - - url - http://133.133.12.3:8080/Bench4QTestCase/script/agentTable.js - - - - parameters - - - - http - - - 5 - Get - - - url - http://133.133.12.3:8080/Bench4QTestCase/script/base.js - - - - parameters - - - - http - - - 6 - Get - - - url - http://133.133.12.3:8080/Bench4QTestCase/images/1.jpg - - - - parameters - - - - http - - - 7 - Get - - - url - http://133.133.12.3:8080/Bench4QTestCase/images/2.jpg - - - - parameters - - - - http - - - -1 - 2 - 0 - - - 0 - - - http - Http - - - - timer - ConstantTimer - - - + + + + + + + 1 + Get + + + url + http://133.133.12.3:8080/Bench4QTestCase/testcase.html + + + + parameters + + + + http + + + 2 + 0 + -1 + + + + + 0 + Sleep + + + time + 2500 + + + timer + + + -1 + 1 + -1 + + + + + 3 + Get + + + url + http://133.133.12.3:8080/Bench4QTestCase/images/3.jpg + + + + parameters + + + + http + + + 4 + Get + + + url + http://133.133.12.3:8080/Bench4QTestCase/script/agentTable.js + + + + parameters + + + + http + + + 5 + Get + + + url + http://133.133.12.3:8080/Bench4QTestCase/script/base.js + + + + parameters + + + + http + + + 6 + Get + + + url + http://133.133.12.3:8080/Bench4QTestCase/images/1.jpg + + + + parameters + + + + http + + + 7 + Get + + + url + http://133.133.12.3:8080/Bench4QTestCase/images/2.jpg + + + + parameters + + + + http + + + -1 + 2 + 0 + + + 0 + + + http + Http + + + + timer + ConstantTimer + + + \ No newline at end of file diff --git a/Scripts/goodForPage.xml b/Bench4Q-Agent/Scripts/goodForPage.xml similarity index 100% rename from Scripts/goodForPage.xml rename to Bench4Q-Agent/Scripts/goodForPage.xml diff --git a/Scripts/testJD.xml b/Bench4Q-Agent/Scripts/testJD.xml similarity index 100% rename from Scripts/testJD.xml rename to Bench4Q-Agent/Scripts/testJD.xml diff --git a/StorageTest/testInput.txt b/Bench4Q-Agent/StorageTest/testInput.txt similarity index 100% rename from StorageTest/testInput.txt rename to Bench4Q-Agent/StorageTest/testInput.txt diff --git a/StorageTest/test_123.txt b/Bench4Q-Agent/StorageTest/test_123.txt similarity index 100% rename from StorageTest/test_123.txt rename to Bench4Q-Agent/StorageTest/test_123.txt diff --git a/configure/agent-config.properties b/Bench4Q-Agent/configure/agent-config.properties similarity index 100% rename from configure/agent-config.properties rename to Bench4Q-Agent/configure/agent-config.properties diff --git a/descriptor.xml b/Bench4Q-Agent/descriptor.xml similarity index 95% rename from descriptor.xml rename to Bench4Q-Agent/descriptor.xml index a7581f81..ca85606d 100644 --- a/descriptor.xml +++ b/Bench4Q-Agent/descriptor.xml @@ -1,25 +1,25 @@ - - - publish - - tar.gz - - false - - - lib - false - false - runtime - - - - - target/bench4q-agent.jar - / - - + + + publish + + tar.gz + + false + + + lib + false + false + runtime + + + + + target/bench4q-agent.jar + / + + \ No newline at end of file diff --git a/pom.xml b/Bench4Q-Agent/pom.xml similarity index 100% rename from pom.xml rename to Bench4Q-Agent/pom.xml diff --git a/src/main/java/org/bench4q/agent/AgentServer.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/AgentServer.java similarity index 95% rename from src/main/java/org/bench4q/agent/AgentServer.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/AgentServer.java index 0f21e431..66a95382 100644 --- a/src/main/java/org/bench4q/agent/AgentServer.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/AgentServer.java @@ -1,64 +1,64 @@ -package org.bench4q.agent; - -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.springframework.web.servlet.DispatcherServlet; - -public class AgentServer { - private Server server; - private int port; - - private Server getServer() { - return server; - } - - private void setServer(Server server) { - this.server = server; - } - - private int getPort() { - return port; - } - - private void setPort(int port) { - this.port = port; - } - - public AgentServer(int port) { - this.setPort(port); - } - - public boolean start() { - try { - this.setServer(new Server(this.getPort())); - ServletContextHandler servletContextHandler = new ServletContextHandler(); - ServletHolder servletHolder = servletContextHandler.addServlet( - DispatcherServlet.class, "/"); - servletHolder - .setInitParameter("contextConfigLocation", - "classpath*:/org/bench4q/agent/config/application-context.xml"); - servletHolder.setInitOrder(1); - this.getServer().setHandler(servletContextHandler); - this.getServer().start(); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean stop() { - try { - if (this.getServer() != null) { - this.getServer().stop(); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } finally { - this.setServer(null); - } - } -} +package org.bench4q.agent; + +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.springframework.web.servlet.DispatcherServlet; + +public class AgentServer { + private Server server; + private int port; + + private Server getServer() { + return server; + } + + private void setServer(Server server) { + this.server = server; + } + + private int getPort() { + return port; + } + + private void setPort(int port) { + this.port = port; + } + + public AgentServer(int port) { + this.setPort(port); + } + + public boolean start() { + try { + this.setServer(new Server(this.getPort())); + ServletContextHandler servletContextHandler = new ServletContextHandler(); + ServletHolder servletHolder = servletContextHandler.addServlet( + DispatcherServlet.class, "/"); + servletHolder + .setInitParameter("contextConfigLocation", + "classpath*:/org/bench4q/agent/config/application-context.xml"); + servletHolder.setInitOrder(1); + this.getServer().setHandler(servletContextHandler); + this.getServer().start(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public boolean stop() { + try { + if (this.getServer() != null) { + this.getServer().stop(); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + this.setServer(null); + } + } +} diff --git a/src/main/java/org/bench4q/agent/Main.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/Main.java similarity index 100% rename from src/main/java/org/bench4q/agent/Main.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/Main.java diff --git a/src/main/java/org/bench4q/agent/api/HomeController.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/HomeController.java similarity index 97% rename from src/main/java/org/bench4q/agent/api/HomeController.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/api/HomeController.java index 6c3599cd..22d6d739 100644 --- a/src/main/java/org/bench4q/agent/api/HomeController.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/HomeController.java @@ -1,49 +1,49 @@ -package org.bench4q.agent.api; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bench4q.agent.scenario.ScenarioContext; -import org.bench4q.agent.scenario.ScenarioEngine; -import org.bench4q.share.models.agent.ServerStatusModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping("/") -public class HomeController { - private ScenarioEngine scenarioEngine; - - private ScenarioEngine getScenarioEngine() { - return scenarioEngine; - } - - @Autowired - private void setScenarioEngine(ScenarioEngine scenarioEngine) { - this.scenarioEngine = scenarioEngine; - } - - @RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }) - @ResponseBody - public ServerStatusModel index() { - ServerStatusModel serverStatusModel = new ServerStatusModel(); - serverStatusModel.setFinishedTests(new ArrayList()); - serverStatusModel.setRunningTests(new ArrayList()); - Map contexts = new HashMap( - getScenarioEngine().getRunningTests()); - for (UUID key : contexts.keySet()) { - ScenarioContext value = contexts.get(key); - if (value.isFinished()) { - serverStatusModel.getFinishedTests().add(key); - } else { - serverStatusModel.getRunningTests().add(key); - } - } - return serverStatusModel; - } -} +package org.bench4q.agent.api; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bench4q.agent.scenario.ScenarioContext; +import org.bench4q.agent.scenario.ScenarioEngine; +import org.bench4q.share.models.agent.ServerStatusModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/") +public class HomeController { + private ScenarioEngine scenarioEngine; + + private ScenarioEngine getScenarioEngine() { + return scenarioEngine; + } + + @Autowired + private void setScenarioEngine(ScenarioEngine scenarioEngine) { + this.scenarioEngine = scenarioEngine; + } + + @RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }) + @ResponseBody + public ServerStatusModel index() { + ServerStatusModel serverStatusModel = new ServerStatusModel(); + serverStatusModel.setFinishedTests(new ArrayList()); + serverStatusModel.setRunningTests(new ArrayList()); + Map contexts = new HashMap( + getScenarioEngine().getRunningTests()); + for (UUID key : contexts.keySet()) { + ScenarioContext value = contexts.get(key); + if (value.isFinished()) { + serverStatusModel.getFinishedTests().add(key); + } else { + serverStatusModel.getRunningTests().add(key); + } + } + return serverStatusModel; + } +} diff --git a/src/main/java/org/bench4q/agent/api/PluginController.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/PluginController.java similarity index 97% rename from src/main/java/org/bench4q/agent/api/PluginController.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/api/PluginController.java index 244a08ec..f903984b 100644 --- a/src/main/java/org/bench4q/agent/api/PluginController.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/PluginController.java @@ -1,81 +1,81 @@ -package org.bench4q.agent.api; - -import java.util.ArrayList; -import java.util.List; - -import org.bench4q.agent.plugin.BehaviorInfo; -import org.bench4q.agent.plugin.ParameterInfo; -import org.bench4q.agent.plugin.PluginInfo; -import org.bench4q.agent.plugin.PluginManager; -import org.bench4q.share.models.agent.BehaviorInfoModel; -import org.bench4q.share.models.agent.ParameterInfoModel; -import org.bench4q.share.models.agent.PluginInfoListModel; -import org.bench4q.share.models.agent.PluginInfoModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -@RequestMapping("/plugin") -public class PluginController { - private PluginManager pluginManager; - - public PluginManager getPluginManager() { - return pluginManager; - } - - @Autowired - public void setPluginManager(PluginManager pluginManager) { - this.pluginManager = pluginManager; - } - - @RequestMapping(method = RequestMethod.GET) - @ResponseBody - public PluginInfoListModel list() { - List pluginInfos = this.getPluginManager().getPluginInfo(); - PluginInfoListModel pluginInfoListModel = new PluginInfoListModel(); - pluginInfoListModel.setPlugins(new ArrayList()); - for (PluginInfo pluginInfo : pluginInfos) { - PluginInfoModel pluginInfoModel = buildPluginInfoModel(pluginInfo); - pluginInfoListModel.getPlugins().add(pluginInfoModel); - } - return pluginInfoListModel; - } - - private PluginInfoModel buildPluginInfoModel(PluginInfo pluginInfo) { - PluginInfoModel pluginInfoModel = new PluginInfoModel(); - pluginInfoModel.setName(pluginInfo.getName()); - pluginInfoModel.setParameters(new ArrayList()); - for (ParameterInfo param : pluginInfo.getParameters()) { - ParameterInfoModel model = buildParameterInfoModel(param); - pluginInfoModel.getParameters().add(model); - } - pluginInfoModel.setBehaviors(new ArrayList()); - for (BehaviorInfo behaviorInfo : pluginInfo.getBehaviors()) { - BehaviorInfoModel behaviorInfoModel = buildBehaviorInfoModel(behaviorInfo); - pluginInfoModel.getBehaviors().add(behaviorInfoModel); - } - return pluginInfoModel; - } - - private BehaviorInfoModel buildBehaviorInfoModel(BehaviorInfo behaviorInfo) { - BehaviorInfoModel behaviorInfoModel = new BehaviorInfoModel(); - behaviorInfoModel.setName(behaviorInfo.getName()); - behaviorInfoModel.setParameters(new ArrayList()); - for (ParameterInfo param : behaviorInfo.getParameters()) { - ParameterInfoModel model = buildParameterInfoModel(param); - behaviorInfoModel.getParameters().add(model); - } - return behaviorInfoModel; - } - - private ParameterInfoModel buildParameterInfoModel(ParameterInfo param) { - ParameterInfoModel model = new ParameterInfoModel(); - model.setName(param.getName()); - model.setType(param.getType()); - return model; - } - -} +package org.bench4q.agent.api; + +import java.util.ArrayList; +import java.util.List; + +import org.bench4q.agent.plugin.BehaviorInfo; +import org.bench4q.agent.plugin.ParameterInfo; +import org.bench4q.agent.plugin.PluginInfo; +import org.bench4q.agent.plugin.PluginManager; +import org.bench4q.share.models.agent.BehaviorInfoModel; +import org.bench4q.share.models.agent.ParameterInfoModel; +import org.bench4q.share.models.agent.PluginInfoListModel; +import org.bench4q.share.models.agent.PluginInfoModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/plugin") +public class PluginController { + private PluginManager pluginManager; + + public PluginManager getPluginManager() { + return pluginManager; + } + + @Autowired + public void setPluginManager(PluginManager pluginManager) { + this.pluginManager = pluginManager; + } + + @RequestMapping(method = RequestMethod.GET) + @ResponseBody + public PluginInfoListModel list() { + List pluginInfos = this.getPluginManager().getPluginInfo(); + PluginInfoListModel pluginInfoListModel = new PluginInfoListModel(); + pluginInfoListModel.setPlugins(new ArrayList()); + for (PluginInfo pluginInfo : pluginInfos) { + PluginInfoModel pluginInfoModel = buildPluginInfoModel(pluginInfo); + pluginInfoListModel.getPlugins().add(pluginInfoModel); + } + return pluginInfoListModel; + } + + private PluginInfoModel buildPluginInfoModel(PluginInfo pluginInfo) { + PluginInfoModel pluginInfoModel = new PluginInfoModel(); + pluginInfoModel.setName(pluginInfo.getName()); + pluginInfoModel.setParameters(new ArrayList()); + for (ParameterInfo param : pluginInfo.getParameters()) { + ParameterInfoModel model = buildParameterInfoModel(param); + pluginInfoModel.getParameters().add(model); + } + pluginInfoModel.setBehaviors(new ArrayList()); + for (BehaviorInfo behaviorInfo : pluginInfo.getBehaviors()) { + BehaviorInfoModel behaviorInfoModel = buildBehaviorInfoModel(behaviorInfo); + pluginInfoModel.getBehaviors().add(behaviorInfoModel); + } + return pluginInfoModel; + } + + private BehaviorInfoModel buildBehaviorInfoModel(BehaviorInfo behaviorInfo) { + BehaviorInfoModel behaviorInfoModel = new BehaviorInfoModel(); + behaviorInfoModel.setName(behaviorInfo.getName()); + behaviorInfoModel.setParameters(new ArrayList()); + for (ParameterInfo param : behaviorInfo.getParameters()) { + ParameterInfoModel model = buildParameterInfoModel(param); + behaviorInfoModel.getParameters().add(model); + } + return behaviorInfoModel; + } + + private ParameterInfoModel buildParameterInfoModel(ParameterInfo param) { + ParameterInfoModel model = new ParameterInfoModel(); + model.setName(param.getName()); + model.setType(param.getType()); + return model; + } + +} diff --git a/src/main/java/org/bench4q/agent/api/TestController.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java similarity index 100% rename from src/main/java/org/bench4q/agent/api/TestController.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java diff --git a/src/main/java/org/bench4q/agent/datacollector/DataCollector.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/DataCollector.java similarity index 100% rename from src/main/java/org/bench4q/agent/datacollector/DataCollector.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/DataCollector.java diff --git a/src/main/java/org/bench4q/agent/datacollector/impl/AbstractDataCollector.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/AbstractDataCollector.java similarity index 100% rename from src/main/java/org/bench4q/agent/datacollector/impl/AbstractDataCollector.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/AbstractDataCollector.java diff --git a/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorResultCollector.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorResultCollector.java similarity index 94% rename from src/main/java/org/bench4q/agent/datacollector/impl/BehaviorResultCollector.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorResultCollector.java index 82db2c4b..09cd8dab 100644 --- a/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorResultCollector.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorResultCollector.java @@ -1,5 +1,5 @@ -package org.bench4q.agent.datacollector.impl; - -public class BehaviorResultCollector { - -} +package org.bench4q.agent.datacollector.impl; + +public class BehaviorResultCollector { + +} diff --git a/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorStatusCodeResult.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorStatusCodeResult.java similarity index 96% rename from src/main/java/org/bench4q/agent/datacollector/impl/BehaviorStatusCodeResult.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorStatusCodeResult.java index 771aaaa0..5fe233de 100644 --- a/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorStatusCodeResult.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/BehaviorStatusCodeResult.java @@ -1,52 +1,52 @@ -package org.bench4q.agent.datacollector.impl; - -import java.lang.reflect.Field; - -public class BehaviorStatusCodeResult { - public long count; - public long contentLength; - public long minResponseTime; - public long maxResponseTime; - public long totalResponseTimeThisTime; - public String contentType; - - public BehaviorStatusCodeResult(String contentType) { - this.totalResponseTimeThisTime = 0; - this.contentType = contentType; - this.count = 0; - this.contentLength = 0; - this.minResponseTime = Long.MAX_VALUE; - this.maxResponseTime = Long.MIN_VALUE; - } - - public static boolean isSuccess(int statusCode) { - return statusCode == 200; - } - - public boolean equals(Object expectedObj) { - Field[] fields = this.getClass().getDeclaredFields(); - boolean equal = true; - try { - for (Field field : fields) { - field.setAccessible(true); - if (field.getName().equals("contentType")) { - field.get(expectedObj).equals(field.get(this)); - continue; - } - if (field.getLong(this) != field.getLong(expectedObj)) { - System.out.println(field.getName() - + " is diferent, this is " + field.getLong(this) - + ", and the expected is " - + field.getLong(expectedObj)); - equal = false; - } - - } - } catch (Exception e) { - e.printStackTrace(); - equal = false; - - } - return equal; - } +package org.bench4q.agent.datacollector.impl; + +import java.lang.reflect.Field; + +public class BehaviorStatusCodeResult { + public long count; + public long contentLength; + public long minResponseTime; + public long maxResponseTime; + public long totalResponseTimeThisTime; + public String contentType; + + public BehaviorStatusCodeResult(String contentType) { + this.totalResponseTimeThisTime = 0; + this.contentType = contentType; + this.count = 0; + this.contentLength = 0; + this.minResponseTime = Long.MAX_VALUE; + this.maxResponseTime = Long.MIN_VALUE; + } + + public static boolean isSuccess(int statusCode) { + return statusCode == 200; + } + + public boolean equals(Object expectedObj) { + Field[] fields = this.getClass().getDeclaredFields(); + boolean equal = true; + try { + for (Field field : fields) { + field.setAccessible(true); + if (field.getName().equals("contentType")) { + field.get(expectedObj).equals(field.get(this)); + continue; + } + if (field.getLong(this) != field.getLong(expectedObj)) { + System.out.println(field.getName() + + " is diferent, this is " + field.getLong(this) + + ", and the expected is " + + field.getLong(expectedObj)); + equal = false; + } + + } + } catch (Exception e) { + e.printStackTrace(); + equal = false; + + } + return equal; + } } \ No newline at end of file diff --git a/src/main/java/org/bench4q/agent/datacollector/impl/PageResultCollector.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/PageResultCollector.java similarity index 96% rename from src/main/java/org/bench4q/agent/datacollector/impl/PageResultCollector.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/PageResultCollector.java index 7638549f..f046c746 100644 --- a/src/main/java/org/bench4q/agent/datacollector/impl/PageResultCollector.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/PageResultCollector.java @@ -1,110 +1,110 @@ -package org.bench4q.agent.datacollector.impl; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import org.bench4q.agent.scenario.BehaviorResult; -import org.bench4q.agent.scenario.PageResult; -import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; - -public class PageResultCollector extends AbstractDataCollector { - Map pageBriefMap; - - private Map getPageBriefMap() { - return pageBriefMap; - } - - private void setPageBriefMap(Map pageBriefMap) { - this.pageBriefMap = pageBriefMap; - } - - public PageResultCollector() { - this.setPageBriefMap(new HashMap()); - } - - public void add(PageResult pageResult) { - if (pageResult == null || pageResult.getPageId() < 0) { - return; - } - PageBrief pageBrief = guardTheValueOfThePageIdExists(pageResult - .getPageId()); - pageBrief.countThisTime++; - pageBrief.countFromBegin++; - pageBrief.totalResponseTimeThisTime += pageResult.getExecuteRange(); - pageBrief.latesTimeResponseTime = pageResult.getExecuteRange(); - if (pageResult.getExecuteRange() > pageBrief.maxResponseTimeFromBegin) { - pageBrief.maxResponseTimeFromBegin = pageResult.getExecuteRange(); - } - if (pageResult.getExecuteRange() < pageBrief.minResponseTimeFromBegin) { - pageBrief.minResponseTimeFromBegin = pageResult.getExecuteRange(); - } - } - - private synchronized PageBrief guardTheValueOfThePageIdExists(int pageId) { - if (!this.getPageBriefMap().containsKey(pageId)) { - this.getPageBriefMap().put(pageId, new PageBrief()); - } - return this.getPageBriefMap().get(pageId); - } - - public Object getPageBriefStatistics(int pageId) { - PageBrief pageBrief = guardTheValueOfThePageIdExists(pageId); - AgentPageBriefModel result = new AgentPageBriefModel(); - result.setCountFromBegin(pageBrief.countFromBegin); - result.setCountThisTime(pageBrief.countThisTime); - result.setMaxResponseTimeFromBegin(pageBrief.maxResponseTimeFromBegin); - result.setMinResponseTimeFromBegin(pageBrief.minResponseTimeFromBegin); - result.setTotalResponseTimeThisTime(pageBrief.totalResponseTimeThisTime); - result.setPageId(pageId); - long nowTime = new Date().getTime(); - result.setTimeFrame(nowTime - pageBrief.lastSampleTime); - result.setLatestResponseTime(pageBrief.latesTimeResponseTime); - pageBrief.resetTemperatyField(); - return result; - } - - @Override - public void add(BehaviorResult behaviorResult) { - } - - @Override - protected String calculateSavePath(BehaviorResult behaviorResult) { - return null; - } - - @Override - public Object getScenarioBriefStatistics() { - return null; - } - - @Override - public Map getBehaviorBriefStatistics( - int id) { - return null; - } - - public class PageBrief { - public long lastSampleTime; - public long countThisTime; - public long totalResponseTimeThisTime; - public long maxResponseTimeFromBegin; - public long minResponseTimeFromBegin; - public long countFromBegin; - public long latesTimeResponseTime; - - public PageBrief() { - resetTemperatyField(); - this.maxResponseTimeFromBegin = Long.MIN_VALUE; - this.minResponseTimeFromBegin = Long.MAX_VALUE; - this.countFromBegin = 0; - this.latesTimeResponseTime = 0; - } - - public void resetTemperatyField() { - this.lastSampleTime = new Date().getTime(); - this.countThisTime = 0; - this.totalResponseTimeThisTime = 0; - } - } -} +package org.bench4q.agent.datacollector.impl; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.bench4q.agent.scenario.BehaviorResult; +import org.bench4q.agent.scenario.PageResult; +import org.bench4q.share.models.agent.statistics.AgentPageBriefModel; + +public class PageResultCollector extends AbstractDataCollector { + Map pageBriefMap; + + private Map getPageBriefMap() { + return pageBriefMap; + } + + private void setPageBriefMap(Map pageBriefMap) { + this.pageBriefMap = pageBriefMap; + } + + public PageResultCollector() { + this.setPageBriefMap(new HashMap()); + } + + public void add(PageResult pageResult) { + if (pageResult == null || pageResult.getPageId() < 0) { + return; + } + PageBrief pageBrief = guardTheValueOfThePageIdExists(pageResult + .getPageId()); + pageBrief.countThisTime++; + pageBrief.countFromBegin++; + pageBrief.totalResponseTimeThisTime += pageResult.getExecuteRange(); + pageBrief.latesTimeResponseTime = pageResult.getExecuteRange(); + if (pageResult.getExecuteRange() > pageBrief.maxResponseTimeFromBegin) { + pageBrief.maxResponseTimeFromBegin = pageResult.getExecuteRange(); + } + if (pageResult.getExecuteRange() < pageBrief.minResponseTimeFromBegin) { + pageBrief.minResponseTimeFromBegin = pageResult.getExecuteRange(); + } + } + + private synchronized PageBrief guardTheValueOfThePageIdExists(int pageId) { + if (!this.getPageBriefMap().containsKey(pageId)) { + this.getPageBriefMap().put(pageId, new PageBrief()); + } + return this.getPageBriefMap().get(pageId); + } + + public Object getPageBriefStatistics(int pageId) { + PageBrief pageBrief = guardTheValueOfThePageIdExists(pageId); + AgentPageBriefModel result = new AgentPageBriefModel(); + result.setCountFromBegin(pageBrief.countFromBegin); + result.setCountThisTime(pageBrief.countThisTime); + result.setMaxResponseTimeFromBegin(pageBrief.maxResponseTimeFromBegin); + result.setMinResponseTimeFromBegin(pageBrief.minResponseTimeFromBegin); + result.setTotalResponseTimeThisTime(pageBrief.totalResponseTimeThisTime); + result.setPageId(pageId); + long nowTime = new Date().getTime(); + result.setTimeFrame(nowTime - pageBrief.lastSampleTime); + result.setLatestResponseTime(pageBrief.latesTimeResponseTime); + pageBrief.resetTemperatyField(); + return result; + } + + @Override + public void add(BehaviorResult behaviorResult) { + } + + @Override + protected String calculateSavePath(BehaviorResult behaviorResult) { + return null; + } + + @Override + public Object getScenarioBriefStatistics() { + return null; + } + + @Override + public Map getBehaviorBriefStatistics( + int id) { + return null; + } + + public class PageBrief { + public long lastSampleTime; + public long countThisTime; + public long totalResponseTimeThisTime; + public long maxResponseTimeFromBegin; + public long minResponseTimeFromBegin; + public long countFromBegin; + public long latesTimeResponseTime; + + public PageBrief() { + resetTemperatyField(); + this.maxResponseTimeFromBegin = Long.MIN_VALUE; + this.minResponseTimeFromBegin = Long.MAX_VALUE; + this.countFromBegin = 0; + this.latesTimeResponseTime = 0; + } + + public void resetTemperatyField() { + this.lastSampleTime = new Date().getTime(); + this.countThisTime = 0; + this.totalResponseTimeThisTime = 0; + } + } +} diff --git a/src/main/java/org/bench4q/agent/datacollector/impl/ScenarioResultCollector.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/ScenarioResultCollector.java similarity index 97% rename from src/main/java/org/bench4q/agent/datacollector/impl/ScenarioResultCollector.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/ScenarioResultCollector.java index 04958f4d..557282d1 100644 --- a/src/main/java/org/bench4q/agent/datacollector/impl/ScenarioResultCollector.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/datacollector/impl/ScenarioResultCollector.java @@ -1,278 +1,278 @@ -package org.bench4q.agent.datacollector.impl; - -import java.text.SimpleDateFormat; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bench4q.agent.scenario.BehaviorResult; -import org.bench4q.agent.scenario.PageResult; -import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel; - -/** - * This class collect the behavior result and statistic it. - * - * @author coderfengyun - * - */ -public class ScenarioResultCollector extends AbstractDataCollector { - private long timeOfPreviousCall; - private long failCountOfThisCall; - private long successCountOfThisCall; - private long totalResponseTimeOfThisCall; - private long maxResponseTimeOfThisCall; - private long minResponseTimeOfThisCall; - private long totalSqureResponseTimeOfThisCall; - private long cumulativeSucessfulCount; - private long cumulativeFailCount; - private static long TIME_UNIT = 1000; - private UUID testID; - private PageResultCollector pageResultCollector; - // The first integer is the behavior's id, and the second integer is - // the StatusCode of this behaviorResult. - private Map> detailMap; - - private void setTimeOfPreviousCall(long timeOfPreviousCall) { - this.timeOfPreviousCall = timeOfPreviousCall; - } - - private void setFailCountOfThisCall(long failCountOfThisCall) { - this.failCountOfThisCall = failCountOfThisCall; - } - - private long getSuccessCountOfThisCall() { - return successCountOfThisCall; - } - - private void setSuccessCountOfThisCall(long successCountOfThisCall) { - this.successCountOfThisCall = successCountOfThisCall; - } - - private void setTotalResponseTimeOfThisCall(long totalResponseTimeOfThisCall) { - this.totalResponseTimeOfThisCall = totalResponseTimeOfThisCall; - } - - private long getMaxResponseTimeOfThisCall() { - return maxResponseTimeOfThisCall; - } - - private void setMaxResponseTimeOfThisCall(long maxResponseTimeOfThisCall) { - this.maxResponseTimeOfThisCall = maxResponseTimeOfThisCall; - } - - private long getMinResponseTimeOfThisCall() { - return minResponseTimeOfThisCall; - } - - private void setMinResponseTimeOfThisCall(long minResponseTimeOfThisCall) { - this.minResponseTimeOfThisCall = minResponseTimeOfThisCall; - } - - private void setTotalSqureResponseTimeOfThisCall( - long totalSqureResponseTimeOfThisCall) { - this.totalSqureResponseTimeOfThisCall = totalSqureResponseTimeOfThisCall; - } - - private void setCumulativeSucessfulCount(long cumulativeSucessfulCount) { - this.cumulativeSucessfulCount = cumulativeSucessfulCount; - } - - private void setCumulativeFailCount(long cumulativeFailCount) { - this.cumulativeFailCount = cumulativeFailCount; - } - - private String getTestID() { - return testID == null ? "default" : testID.toString(); - } - - private void setTestID(UUID testID) { - this.testID = testID; - } - - private void setDetailMap( - Map> detailMap) { - this.detailMap = detailMap; - } - - private PageResultCollector getPageResultCollector() { - return pageResultCollector; - } - - private void setPageResultCollector(PageResultCollector pageResultCollector) { - this.pageResultCollector = pageResultCollector; - } - - public ScenarioResultCollector(UUID testId) { - this.setTestID(testId); - this.setPageResultCollector(new PageResultCollector()); - init(); - } - - private void init() { - reset(); - this.setCumulativeFailCount(0); - this.setCumulativeSucessfulCount(0); - this.setDetailMap(new HashMap>()); - } - - private void reset() { - this.setTimeOfPreviousCall(System.currentTimeMillis()); - this.setFailCountOfThisCall(0); - this.setMaxResponseTimeOfThisCall(Long.MIN_VALUE); - this.setMinResponseTimeOfThisCall(Long.MAX_VALUE); - this.setSuccessCountOfThisCall(0); - this.setTotalResponseTimeOfThisCall(0); - this.setTotalSqureResponseTimeOfThisCall(0); - } - - // /////////////////////////////// - // DataStatistics Interface start - // /////////////////////////////// - - public AgentBriefStatusModel getScenarioBriefStatistics() { - AgentBriefStatusModel result = new AgentBriefStatusModel(); - result.setTimeFrame(System.currentTimeMillis() - - this.timeOfPreviousCall); - if (this.getSuccessCountOfThisCall() == 0) { - result.setMaxResponseTime(0); - result.setMinResponseTime(0); - } else { - result.setMinResponseTime(this.minResponseTimeOfThisCall); - result.setMaxResponseTime(this.maxResponseTimeOfThisCall); - } - this.cumulativeSucessfulCount += this.successCountOfThisCall; - result.setSuccessCountFromBegin(this.cumulativeSucessfulCount); - this.cumulativeFailCount += this.failCountOfThisCall; - result.setFailCountFromBegin(this.cumulativeFailCount); - if (result.getTimeFrame() == 0) { - result.setSuccessThroughputThisTime(0); - result.setFailThroughputThisTime(0); - } else { - result.setSuccessThroughputThisTime(this.successCountOfThisCall - * TIME_UNIT / result.getTimeFrame()); - result.setFailThroughputThisTime(this.failCountOfThisCall - * TIME_UNIT / result.getTimeFrame()); - } - result.setTotalResponseTimeThisTime(this.totalResponseTimeOfThisCall); - result.setSuccessCountThisTime(this.successCountOfThisCall); - result.setFailCountThisTime(this.failCountOfThisCall); - result.setTotalSqureResponseTimeThisTime(this.totalSqureResponseTimeOfThisCall); - reset(); - return result; - } - - // /////////////////////////////// - // DataStatistics Interface end - // /////////////////////////////// - /** - * For the failed one, only the fail count statistics will be added, Others - * of this failed one will be ignored. - * - * @param behaviorResult - */ - - private void statisticScenarioBriefResult(BehaviorResult behaviorResult) { - if (behaviorResult.isSuccess()) { - this.successCountOfThisCall++; - this.totalResponseTimeOfThisCall += behaviorResult - .getResponseTime(); - this.totalSqureResponseTimeOfThisCall += ((long) behaviorResult - .getResponseTime()) * behaviorResult.getResponseTime(); - if (behaviorResult.getResponseTime() > this - .getMaxResponseTimeOfThisCall()) { - this.setMaxResponseTimeOfThisCall(behaviorResult - .getResponseTime()); - } - if (behaviorResult.getResponseTime() < this - .getMinResponseTimeOfThisCall()) { - this.setMinResponseTimeOfThisCall(behaviorResult - .getResponseTime()); - } - } else { - this.failCountOfThisCall++; - } - } - - private void statisticBehaviorBriefResult(BehaviorResult behaviorResult) { - insertWhenNotExist(behaviorResult); - Map detailStatusMap = this.detailMap - .get(behaviorResult.getBehaviorId()); - // TODO: there's a problem about concurrency - guardStatusMapExists(behaviorResult, detailStatusMap); - BehaviorStatusCodeResult statusCodeResult = detailStatusMap - .get(behaviorResult.getStatusCode()); - statusCodeResult.count++; - if (!behaviorResult.isSuccess()) { - statusCodeResult.maxResponseTime = 0; - statusCodeResult.minResponseTime = 0; - statusCodeResult.contentLength = 0; - statusCodeResult.totalResponseTimeThisTime = 0; - return; - } - statusCodeResult.contentLength += behaviorResult.getContentLength(); - statusCodeResult.totalResponseTimeThisTime += behaviorResult - .getResponseTime(); - if (behaviorResult.getResponseTime() > statusCodeResult.maxResponseTime) { - statusCodeResult.maxResponseTime = behaviorResult.getResponseTime(); - } - if (behaviorResult.getResponseTime() < statusCodeResult.minResponseTime) { - statusCodeResult.minResponseTime = behaviorResult.getResponseTime(); - } - } - - private synchronized void guardStatusMapExists( - BehaviorResult behaviorResult, - Map detailStatusMap) { - if (!detailStatusMap.containsKey(behaviorResult.getStatusCode())) { - detailStatusMap.put( - new Integer(behaviorResult.getStatusCode()), - new BehaviorStatusCodeResult(behaviorResult - .getContentType())); - } - } - - private synchronized void insertWhenNotExist(BehaviorResult behaviorResult) { - if (!this.detailMap.containsKey(behaviorResult.getBehaviorId())) { - this.detailMap.put(new Integer(behaviorResult.getBehaviorId()), - new HashMap()); - } - } - - @Override - protected String calculateSavePath(BehaviorResult behaviorResult) { - Date now = new Date(); - - return "DetailResults" + System.getProperty("file.separator") - + new SimpleDateFormat("yyyyMMdd").format(now) - + System.getProperty("file.separator") + this.getTestID() + "_" - + behaviorResult.getBehaviorId() + "_" - + new SimpleDateFormat("hhmm") + ".txt"; - } - - public void add(PageResult pageResult) { - this.getPageResultCollector().add(pageResult); - } - - @Override - public void add(BehaviorResult behaviorResult) { - super.add(behaviorResult); - statisticScenarioBriefResult(behaviorResult); - statisticBehaviorBriefResult(behaviorResult); - } - - @Override - public Map getBehaviorBriefStatistics( - int behaviorId) { - if (!this.detailMap.containsKey(behaviorId)) { - return null; - } - return Collections.unmodifiableMap(this.detailMap.get(behaviorId)); - } - - public Object getPageBriefStatistics(int pageId) { - return this.getPageResultCollector().getPageBriefStatistics(pageId); - } - -} +package org.bench4q.agent.datacollector.impl; + +import java.text.SimpleDateFormat; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bench4q.agent.scenario.BehaviorResult; +import org.bench4q.agent.scenario.PageResult; +import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel; + +/** + * This class collect the behavior result and statistic it. + * + * @author coderfengyun + * + */ +public class ScenarioResultCollector extends AbstractDataCollector { + private long timeOfPreviousCall; + private long failCountOfThisCall; + private long successCountOfThisCall; + private long totalResponseTimeOfThisCall; + private long maxResponseTimeOfThisCall; + private long minResponseTimeOfThisCall; + private long totalSqureResponseTimeOfThisCall; + private long cumulativeSucessfulCount; + private long cumulativeFailCount; + private static long TIME_UNIT = 1000; + private UUID testID; + private PageResultCollector pageResultCollector; + // The first integer is the behavior's id, and the second integer is + // the StatusCode of this behaviorResult. + private Map> detailMap; + + private void setTimeOfPreviousCall(long timeOfPreviousCall) { + this.timeOfPreviousCall = timeOfPreviousCall; + } + + private void setFailCountOfThisCall(long failCountOfThisCall) { + this.failCountOfThisCall = failCountOfThisCall; + } + + private long getSuccessCountOfThisCall() { + return successCountOfThisCall; + } + + private void setSuccessCountOfThisCall(long successCountOfThisCall) { + this.successCountOfThisCall = successCountOfThisCall; + } + + private void setTotalResponseTimeOfThisCall(long totalResponseTimeOfThisCall) { + this.totalResponseTimeOfThisCall = totalResponseTimeOfThisCall; + } + + private long getMaxResponseTimeOfThisCall() { + return maxResponseTimeOfThisCall; + } + + private void setMaxResponseTimeOfThisCall(long maxResponseTimeOfThisCall) { + this.maxResponseTimeOfThisCall = maxResponseTimeOfThisCall; + } + + private long getMinResponseTimeOfThisCall() { + return minResponseTimeOfThisCall; + } + + private void setMinResponseTimeOfThisCall(long minResponseTimeOfThisCall) { + this.minResponseTimeOfThisCall = minResponseTimeOfThisCall; + } + + private void setTotalSqureResponseTimeOfThisCall( + long totalSqureResponseTimeOfThisCall) { + this.totalSqureResponseTimeOfThisCall = totalSqureResponseTimeOfThisCall; + } + + private void setCumulativeSucessfulCount(long cumulativeSucessfulCount) { + this.cumulativeSucessfulCount = cumulativeSucessfulCount; + } + + private void setCumulativeFailCount(long cumulativeFailCount) { + this.cumulativeFailCount = cumulativeFailCount; + } + + private String getTestID() { + return testID == null ? "default" : testID.toString(); + } + + private void setTestID(UUID testID) { + this.testID = testID; + } + + private void setDetailMap( + Map> detailMap) { + this.detailMap = detailMap; + } + + private PageResultCollector getPageResultCollector() { + return pageResultCollector; + } + + private void setPageResultCollector(PageResultCollector pageResultCollector) { + this.pageResultCollector = pageResultCollector; + } + + public ScenarioResultCollector(UUID testId) { + this.setTestID(testId); + this.setPageResultCollector(new PageResultCollector()); + init(); + } + + private void init() { + reset(); + this.setCumulativeFailCount(0); + this.setCumulativeSucessfulCount(0); + this.setDetailMap(new HashMap>()); + } + + private void reset() { + this.setTimeOfPreviousCall(System.currentTimeMillis()); + this.setFailCountOfThisCall(0); + this.setMaxResponseTimeOfThisCall(Long.MIN_VALUE); + this.setMinResponseTimeOfThisCall(Long.MAX_VALUE); + this.setSuccessCountOfThisCall(0); + this.setTotalResponseTimeOfThisCall(0); + this.setTotalSqureResponseTimeOfThisCall(0); + } + + // /////////////////////////////// + // DataStatistics Interface start + // /////////////////////////////// + + public AgentBriefStatusModel getScenarioBriefStatistics() { + AgentBriefStatusModel result = new AgentBriefStatusModel(); + result.setTimeFrame(System.currentTimeMillis() + - this.timeOfPreviousCall); + if (this.getSuccessCountOfThisCall() == 0) { + result.setMaxResponseTime(0); + result.setMinResponseTime(0); + } else { + result.setMinResponseTime(this.minResponseTimeOfThisCall); + result.setMaxResponseTime(this.maxResponseTimeOfThisCall); + } + this.cumulativeSucessfulCount += this.successCountOfThisCall; + result.setSuccessCountFromBegin(this.cumulativeSucessfulCount); + this.cumulativeFailCount += this.failCountOfThisCall; + result.setFailCountFromBegin(this.cumulativeFailCount); + if (result.getTimeFrame() == 0) { + result.setSuccessThroughputThisTime(0); + result.setFailThroughputThisTime(0); + } else { + result.setSuccessThroughputThisTime(this.successCountOfThisCall + * TIME_UNIT / result.getTimeFrame()); + result.setFailThroughputThisTime(this.failCountOfThisCall + * TIME_UNIT / result.getTimeFrame()); + } + result.setTotalResponseTimeThisTime(this.totalResponseTimeOfThisCall); + result.setSuccessCountThisTime(this.successCountOfThisCall); + result.setFailCountThisTime(this.failCountOfThisCall); + result.setTotalSqureResponseTimeThisTime(this.totalSqureResponseTimeOfThisCall); + reset(); + return result; + } + + // /////////////////////////////// + // DataStatistics Interface end + // /////////////////////////////// + /** + * For the failed one, only the fail count statistics will be added, Others + * of this failed one will be ignored. + * + * @param behaviorResult + */ + + private void statisticScenarioBriefResult(BehaviorResult behaviorResult) { + if (behaviorResult.isSuccess()) { + this.successCountOfThisCall++; + this.totalResponseTimeOfThisCall += behaviorResult + .getResponseTime(); + this.totalSqureResponseTimeOfThisCall += ((long) behaviorResult + .getResponseTime()) * behaviorResult.getResponseTime(); + if (behaviorResult.getResponseTime() > this + .getMaxResponseTimeOfThisCall()) { + this.setMaxResponseTimeOfThisCall(behaviorResult + .getResponseTime()); + } + if (behaviorResult.getResponseTime() < this + .getMinResponseTimeOfThisCall()) { + this.setMinResponseTimeOfThisCall(behaviorResult + .getResponseTime()); + } + } else { + this.failCountOfThisCall++; + } + } + + private void statisticBehaviorBriefResult(BehaviorResult behaviorResult) { + insertWhenNotExist(behaviorResult); + Map detailStatusMap = this.detailMap + .get(behaviorResult.getBehaviorId()); + // TODO: there's a problem about concurrency + guardStatusMapExists(behaviorResult, detailStatusMap); + BehaviorStatusCodeResult statusCodeResult = detailStatusMap + .get(behaviorResult.getStatusCode()); + statusCodeResult.count++; + if (!behaviorResult.isSuccess()) { + statusCodeResult.maxResponseTime = 0; + statusCodeResult.minResponseTime = 0; + statusCodeResult.contentLength = 0; + statusCodeResult.totalResponseTimeThisTime = 0; + return; + } + statusCodeResult.contentLength += behaviorResult.getContentLength(); + statusCodeResult.totalResponseTimeThisTime += behaviorResult + .getResponseTime(); + if (behaviorResult.getResponseTime() > statusCodeResult.maxResponseTime) { + statusCodeResult.maxResponseTime = behaviorResult.getResponseTime(); + } + if (behaviorResult.getResponseTime() < statusCodeResult.minResponseTime) { + statusCodeResult.minResponseTime = behaviorResult.getResponseTime(); + } + } + + private synchronized void guardStatusMapExists( + BehaviorResult behaviorResult, + Map detailStatusMap) { + if (!detailStatusMap.containsKey(behaviorResult.getStatusCode())) { + detailStatusMap.put( + new Integer(behaviorResult.getStatusCode()), + new BehaviorStatusCodeResult(behaviorResult + .getContentType())); + } + } + + private synchronized void insertWhenNotExist(BehaviorResult behaviorResult) { + if (!this.detailMap.containsKey(behaviorResult.getBehaviorId())) { + this.detailMap.put(new Integer(behaviorResult.getBehaviorId()), + new HashMap()); + } + } + + @Override + protected String calculateSavePath(BehaviorResult behaviorResult) { + Date now = new Date(); + + return "DetailResults" + System.getProperty("file.separator") + + new SimpleDateFormat("yyyyMMdd").format(now) + + System.getProperty("file.separator") + this.getTestID() + "_" + + behaviorResult.getBehaviorId() + "_" + + new SimpleDateFormat("hhmm") + ".txt"; + } + + public void add(PageResult pageResult) { + this.getPageResultCollector().add(pageResult); + } + + @Override + public void add(BehaviorResult behaviorResult) { + super.add(behaviorResult); + statisticScenarioBriefResult(behaviorResult); + statisticBehaviorBriefResult(behaviorResult); + } + + @Override + public Map getBehaviorBriefStatistics( + int behaviorId) { + if (!this.detailMap.containsKey(behaviorId)) { + return null; + } + return Collections.unmodifiableMap(this.detailMap.get(behaviorId)); + } + + public Object getPageBriefStatistics(int pageId) { + return this.getPageResultCollector().getPageBriefStatistics(pageId); + } + +} diff --git a/src/main/java/org/bench4q/agent/helper/ApplicationContextHelper.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/helper/ApplicationContextHelper.java similarity index 96% rename from src/main/java/org/bench4q/agent/helper/ApplicationContextHelper.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/helper/ApplicationContextHelper.java index fcfa9dfc..4ace1b14 100644 --- a/src/main/java/org/bench4q/agent/helper/ApplicationContextHelper.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/helper/ApplicationContextHelper.java @@ -1,26 +1,26 @@ -package org.bench4q.agent.helper; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -@Component -public class ApplicationContextHelper implements ApplicationContextAware { - - private static ApplicationContext context; - - public static ApplicationContext getContext() { - return context; - } - - private void setContext(ApplicationContext context) { - ApplicationContextHelper.context = context; - } - - public void setApplicationContext(ApplicationContext applicationContext) - throws BeansException { - this.setContext(applicationContext); - } - -} +package org.bench4q.agent.helper; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +@Component +public class ApplicationContextHelper implements ApplicationContextAware { + + private static ApplicationContext context; + + public static ApplicationContext getContext() { + return context; + } + + private void setContext(ApplicationContext context) { + ApplicationContextHelper.context = context; + } + + public void setApplicationContext(ApplicationContext applicationContext) + throws BeansException { + this.setContext(applicationContext); + } + +} diff --git a/src/main/java/org/bench4q/agent/parameterization/ParameterFileCollector.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/ParameterFileCollector.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/ParameterFileCollector.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/ParameterFileCollector.java diff --git a/src/main/java/org/bench4q/agent/parameterization/SessionObject.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/SessionObject.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/SessionObject.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/SessionObject.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/InstanceControler.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/InstanceControler.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/InstanceControler.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/InstanceControler.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/MyFileClassLoader.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/MyFileClassLoader.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/MyFileClassLoader.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/MyFileClassLoader.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/Para_File.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_File.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/Para_File.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_File.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/Para_GetEletronicCombine.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_GetEletronicCombine.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/Para_GetEletronicCombine.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_GetEletronicCombine.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/Para_IteratorNumber.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_IteratorNumber.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/Para_IteratorNumber.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_IteratorNumber.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/Para_RandomNumber.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_RandomNumber.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/Para_RandomNumber.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_RandomNumber.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.xml b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.xml similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.xml rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.xml diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/Para_UniqueNumber.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_UniqueNumber.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/Para_UniqueNumber.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_UniqueNumber.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/Para_UserNameAndPassword.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_UserNameAndPassword.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/Para_UserNameAndPassword.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/Para_UserNameAndPassword.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/ParameterThreadOption.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/ParameterThreadOption.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/ParameterThreadOption.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/ParameterThreadOption.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/ParameterizationParser.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/ParameterizationParser.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/ParameterizationParser.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/ParameterizationParser.java diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/ParametersFactory.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/ParametersFactory.java similarity index 100% rename from src/main/java/org/bench4q/agent/parameterization/impl/ParametersFactory.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/parameterization/impl/ParametersFactory.java diff --git a/src/main/java/org/bench4q/agent/plugin/Behavior.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/Behavior.java similarity index 96% rename from src/main/java/org/bench4q/agent/plugin/Behavior.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/Behavior.java index 3fab5f99..ad20e417 100644 --- a/src/main/java/org/bench4q/agent/plugin/Behavior.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/Behavior.java @@ -1,12 +1,12 @@ -package org.bench4q.agent.plugin; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Behavior { - String value(); +package org.bench4q.agent.plugin; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Behavior { + String value(); } \ No newline at end of file diff --git a/src/main/java/org/bench4q/agent/plugin/BehaviorInfo.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/BehaviorInfo.java similarity index 94% rename from src/main/java/org/bench4q/agent/plugin/BehaviorInfo.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/BehaviorInfo.java index 8489b801..d09d4b88 100644 --- a/src/main/java/org/bench4q/agent/plugin/BehaviorInfo.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/BehaviorInfo.java @@ -1,23 +1,23 @@ -package org.bench4q.agent.plugin; - -public class BehaviorInfo { - private String name; - private ParameterInfo[] parameters; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public ParameterInfo[] getParameters() { - return parameters; - } - - public void setParameters(ParameterInfo[] parameters) { - this.parameters = parameters; - } - -} +package org.bench4q.agent.plugin; + +public class BehaviorInfo { + private String name; + private ParameterInfo[] parameters; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ParameterInfo[] getParameters() { + return parameters; + } + + public void setParameters(ParameterInfo[] parameters) { + this.parameters = parameters; + } + +} diff --git a/src/main/java/org/bench4q/agent/plugin/ClassHelper.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/ClassHelper.java similarity index 96% rename from src/main/java/org/bench4q/agent/plugin/ClassHelper.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/ClassHelper.java index cf5edc7f..950bab2f 100644 --- a/src/main/java/org/bench4q/agent/plugin/ClassHelper.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/ClassHelper.java @@ -1,124 +1,124 @@ -package org.bench4q.agent.plugin; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import org.springframework.stereotype.Component; - -@Component -public class ClassHelper { - - public List getClassNames(String packageName, - boolean searchInChildPackage) { - try { - List classNames = new ArrayList(); - URLClassLoader classLoader = (URLClassLoader) Thread - .currentThread().getContextClassLoader(); - URL[] urls = classLoader.getURLs(); - for (URL url : urls) { - if (url.getProtocol().equals("file")) { - File file = new File(url.getFile()); - String root = file.getPath().replace("\\", "/"); - if (file.isDirectory()) { - classNames.addAll(this.getClassNamesFromDirectory(root, - packageName, searchInChildPackage, file, true)); - } else if (file.getName().endsWith(".jar")) { - classNames.addAll(this.getClassNameFromJar(packageName, - searchInChildPackage, file)); - } - } - } - return classNames; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private List getClassNamesFromDirectory(String root, - String packageName, boolean searchInChildPackage, File directory, - boolean continueSearch) { - List classNames = new ArrayList(); - File[] files = directory.listFiles(); - for (File file : files) { - String filePath = file.getPath().replace("\\", "/"); - if (file.isDirectory()) { - if (searchInChildPackage || continueSearch) { - boolean needToContinue = continueSearch; - if (filePath.endsWith(packageName.replace(".", "/"))) { - needToContinue = needToContinue & false; - } - classNames.addAll(this.getClassNamesFromDirectory(root, - packageName, searchInChildPackage, file, - needToContinue)); - } - } else { - if (filePath.endsWith(".class")) { - String classFileName = filePath.replace(root + "/", ""); - if (classFileName.startsWith(packageName.replace(".", "/"))) { - String className = classFileName.substring(0, - classFileName.length() - ".class".length()) - .replace("/", "."); - classNames.add(className); - } - } - } - } - return classNames; - } - - private List getClassNameFromJar(String packageName, - boolean searchInChildPackage, File file) { - List classNames = new ArrayList(); - JarFile jarFile = null; - try { - jarFile = new JarFile(file); - Enumeration jarEntries = jarFile.entries(); - while (jarEntries.hasMoreElements()) { - JarEntry jarEntry = jarEntries.nextElement(); - String entryName = jarEntry.getName(); - if (entryName.endsWith(".class")) { - String packagePath = packageName.replace(".", "/"); - if (searchInChildPackage) { - if (entryName.startsWith(packagePath)) { - entryName = entryName.replace("/", ".").substring( - 0, entryName.lastIndexOf(".")); - classNames.add(entryName); - } - } else { - int index = entryName.lastIndexOf("/"); - String entryPath; - if (index != -1) { - entryPath = entryName.substring(0, index); - } else { - entryPath = entryName; - } - if (entryPath.equals(packagePath)) { - entryName = entryName.replace("/", ".").substring( - 0, entryName.lastIndexOf(".")); - classNames.add(entryName); - } - } - } - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (jarFile != null) { - try { - jarFile.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return classNames; - } -} +package org.bench4q.agent.plugin; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import org.springframework.stereotype.Component; + +@Component +public class ClassHelper { + + public List getClassNames(String packageName, + boolean searchInChildPackage) { + try { + List classNames = new ArrayList(); + URLClassLoader classLoader = (URLClassLoader) Thread + .currentThread().getContextClassLoader(); + URL[] urls = classLoader.getURLs(); + for (URL url : urls) { + if (url.getProtocol().equals("file")) { + File file = new File(url.getFile()); + String root = file.getPath().replace("\\", "/"); + if (file.isDirectory()) { + classNames.addAll(this.getClassNamesFromDirectory(root, + packageName, searchInChildPackage, file, true)); + } else if (file.getName().endsWith(".jar")) { + classNames.addAll(this.getClassNameFromJar(packageName, + searchInChildPackage, file)); + } + } + } + return classNames; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + private List getClassNamesFromDirectory(String root, + String packageName, boolean searchInChildPackage, File directory, + boolean continueSearch) { + List classNames = new ArrayList(); + File[] files = directory.listFiles(); + for (File file : files) { + String filePath = file.getPath().replace("\\", "/"); + if (file.isDirectory()) { + if (searchInChildPackage || continueSearch) { + boolean needToContinue = continueSearch; + if (filePath.endsWith(packageName.replace(".", "/"))) { + needToContinue = needToContinue & false; + } + classNames.addAll(this.getClassNamesFromDirectory(root, + packageName, searchInChildPackage, file, + needToContinue)); + } + } else { + if (filePath.endsWith(".class")) { + String classFileName = filePath.replace(root + "/", ""); + if (classFileName.startsWith(packageName.replace(".", "/"))) { + String className = classFileName.substring(0, + classFileName.length() - ".class".length()) + .replace("/", "."); + classNames.add(className); + } + } + } + } + return classNames; + } + + private List getClassNameFromJar(String packageName, + boolean searchInChildPackage, File file) { + List classNames = new ArrayList(); + JarFile jarFile = null; + try { + jarFile = new JarFile(file); + Enumeration jarEntries = jarFile.entries(); + while (jarEntries.hasMoreElements()) { + JarEntry jarEntry = jarEntries.nextElement(); + String entryName = jarEntry.getName(); + if (entryName.endsWith(".class")) { + String packagePath = packageName.replace(".", "/"); + if (searchInChildPackage) { + if (entryName.startsWith(packagePath)) { + entryName = entryName.replace("/", ".").substring( + 0, entryName.lastIndexOf(".")); + classNames.add(entryName); + } + } else { + int index = entryName.lastIndexOf("/"); + String entryPath; + if (index != -1) { + entryPath = entryName.substring(0, index); + } else { + entryPath = entryName; + } + if (entryPath.equals(packagePath)) { + entryName = entryName.replace("/", ".").substring( + 0, entryName.lastIndexOf(".")); + classNames.add(entryName); + } + } + } + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (jarFile != null) { + try { + jarFile.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return classNames; + } +} diff --git a/src/main/java/org/bench4q/agent/plugin/Parameter.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/Parameter.java similarity index 96% rename from src/main/java/org/bench4q/agent/plugin/Parameter.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/Parameter.java index ee7d8a11..a9e0a171 100644 --- a/src/main/java/org/bench4q/agent/plugin/Parameter.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/Parameter.java @@ -1,12 +1,12 @@ -package org.bench4q.agent.plugin; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.PARAMETER) -@Retention(RetentionPolicy.RUNTIME) -public @interface Parameter { - String value(); -} +package org.bench4q.agent.plugin; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface Parameter { + String value(); +} diff --git a/src/main/java/org/bench4q/agent/plugin/ParameterInfo.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/ParameterInfo.java similarity index 93% rename from src/main/java/org/bench4q/agent/plugin/ParameterInfo.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/ParameterInfo.java index 52be6ee2..4db0e540 100644 --- a/src/main/java/org/bench4q/agent/plugin/ParameterInfo.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/ParameterInfo.java @@ -1,23 +1,23 @@ -package org.bench4q.agent.plugin; - -public class ParameterInfo { - private String name; - private String type; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - -} +package org.bench4q.agent.plugin; + +public class ParameterInfo { + private String name; + private String type; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/src/main/java/org/bench4q/agent/plugin/Plugin.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/Plugin.java similarity index 96% rename from src/main/java/org/bench4q/agent/plugin/Plugin.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/Plugin.java index 7841b547..4647553c 100644 --- a/src/main/java/org/bench4q/agent/plugin/Plugin.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/Plugin.java @@ -1,12 +1,12 @@ -package org.bench4q.agent.plugin; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Plugin { - String value(); -} +package org.bench4q.agent.plugin; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface Plugin { + String value(); +} diff --git a/src/main/java/org/bench4q/agent/plugin/PluginInfo.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/PluginInfo.java similarity index 94% rename from src/main/java/org/bench4q/agent/plugin/PluginInfo.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/PluginInfo.java index 0063d172..aadc176a 100644 --- a/src/main/java/org/bench4q/agent/plugin/PluginInfo.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/PluginInfo.java @@ -1,32 +1,32 @@ -package org.bench4q.agent.plugin; - -public class PluginInfo { - private String name; - private ParameterInfo[] parameters; - private BehaviorInfo[] behaviors; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public ParameterInfo[] getParameters() { - return parameters; - } - - public void setParameters(ParameterInfo[] parameters) { - this.parameters = parameters; - } - - public BehaviorInfo[] getBehaviors() { - return behaviors; - } - - public void setBehaviors(BehaviorInfo[] behaviors) { - this.behaviors = behaviors; - } - -} +package org.bench4q.agent.plugin; + +public class PluginInfo { + private String name; + private ParameterInfo[] parameters; + private BehaviorInfo[] behaviors; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ParameterInfo[] getParameters() { + return parameters; + } + + public void setParameters(ParameterInfo[] parameters) { + this.parameters = parameters; + } + + public BehaviorInfo[] getBehaviors() { + return behaviors; + } + + public void setBehaviors(BehaviorInfo[] behaviors) { + this.behaviors = behaviors; + } + +} diff --git a/src/main/java/org/bench4q/agent/plugin/PluginManager.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/PluginManager.java similarity index 96% rename from src/main/java/org/bench4q/agent/plugin/PluginManager.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/PluginManager.java index d5e6629f..735d3a37 100644 --- a/src/main/java/org/bench4q/agent/plugin/PluginManager.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/PluginManager.java @@ -1,269 +1,269 @@ -package org.bench4q.agent.plugin; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.bench4q.agent.share.DealWithLog; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class PluginManager { - private ClassHelper classHelper; - private TypeConverter typeConverter; - private Map> plugins; - private Logger logger = Logger.getLogger(PluginManager.class); - - @Autowired - public PluginManager(ClassHelper classHelper, TypeConverter typeConverter) { - this.setClassHelper(classHelper); - this.setTypeConverter(typeConverter); - this.setPlugins(this.loadPlugins("org.bench4q.agent.plugin")); - } - - private ClassHelper getClassHelper() { - return classHelper; - } - - private void setClassHelper(ClassHelper classHelper) { - this.classHelper = classHelper; - } - - private TypeConverter getTypeConverter() { - return typeConverter; - } - - private void setTypeConverter(TypeConverter typeConverter) { - this.typeConverter = typeConverter; - } - - public Map> getPlugins() { - return plugins; - } - - private void setPlugins(Map> plugins) { - this.plugins = plugins; - } - - public Map> loadPlugins(String packageName) { - try { - List classNames = this.getClassHelper().getClassNames( - packageName, true); - Map> ret = new HashMap>(); - for (String className : classNames) { - Class plugin = Class.forName(className); - if (plugin.isAnnotationPresent(Plugin.class)) { - ret.put(plugin.getAnnotation(Plugin.class).value(), plugin); - } - } - return ret; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public List getPluginInfo() { - try { - Map> plugins = this.getPlugins(); - List ret = new ArrayList(); - for (Class plugin : plugins.values()) { - PluginInfo pluginInfo = new PluginInfo(); - pluginInfo - .setName((plugin.getAnnotation(Plugin.class)).value()); - pluginInfo.setParameters(this.getParameters(plugin - .getConstructors()[0])); - Method[] behaviors = this.getBehaviors(plugin); - pluginInfo.setBehaviors(new BehaviorInfo[behaviors.length]); - int i = 0; - for (i = 0; i < behaviors.length; i++) { - Method behaviorMethod = behaviors[i]; - BehaviorInfo behaviorInfo = buildBehaviorInfo(behaviorMethod); - pluginInfo.getBehaviors()[i] = behaviorInfo; - } - ret.add(pluginInfo); - } - return ret; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private BehaviorInfo buildBehaviorInfo(Method behaviorMethod) - throws ClassNotFoundException { - BehaviorInfo behaviorInfo = new BehaviorInfo(); - behaviorInfo.setName((behaviorMethod.getAnnotation(Behavior.class)) - .value()); - behaviorInfo.setParameters(this.getParameters(behaviorMethod)); - return behaviorInfo; - } - - private ParameterInfo[] getParameters(Method behavior) { - try { - int parameterCount = behavior.getParameterTypes().length; - Annotation[][] parameterAnnotations = behavior - .getParameterAnnotations(); - ParameterInfo[] parameterNames = new ParameterInfo[parameterCount]; - int i; - for (i = 0; i < parameterCount; i++) { - Annotation[] annotations = parameterAnnotations[i]; - Parameter parameter = (Parameter) annotations[0]; - Class type = behavior.getParameterTypes()[i]; - ParameterInfo parameterInfo = buildParameterInfo( - parameter.value(), type.getName()); - parameterNames[i] = parameterInfo; - } - return parameterNames; - } catch (Exception e) { - logger.error(DealWithLog.getExceptionStackTrace(e)); - return null; - } - } - - private ParameterInfo[] getParameters(Constructor behavior) { - try { - int parameterCount = behavior.getParameterTypes().length; - Annotation[][] parameterAnnotations = behavior - .getParameterAnnotations(); - ParameterInfo[] parameterNames = new ParameterInfo[parameterCount]; - int i; - for (i = 0; i < parameterCount; i++) { - Annotation[] annotations = parameterAnnotations[i]; - Parameter parameter = (Parameter) annotations[0]; - Class type = behavior.getParameterTypes()[i]; - ParameterInfo parameterInfo = buildParameterInfo( - parameter.value(), type.getName()); - parameterNames[i] = parameterInfo; - } - return parameterNames; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private ParameterInfo buildParameterInfo(String name, String type) { - ParameterInfo parameterInfo = new ParameterInfo(); - parameterInfo.setName(name); - parameterInfo.setType(type); - return parameterInfo; - } - - private Method[] getBehaviors(Class plugin) { - try { - Method[] methods = plugin.getMethods(); - List ret = new ArrayList(); - int i = 0; - for (i = 0; i < methods.length; i++) { - if (methods[i].isAnnotationPresent(Behavior.class)) { - ret.add(methods[i]); - } - } - return ret.toArray(new Method[0]); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public Object initializePlugin(Class plugin, - Map parameters) { - try { - Constructor[] ctConstructors = plugin.getConstructors(); - if (ctConstructors.length != 1) { - return null; - } - Constructor constructor = ctConstructors[0]; - Object[] params = prepareParameters(constructor, parameters); - return plugin.getConstructors()[0].newInstance(params); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private Object[] prepareParameters(Constructor behavior, - Map parameters) { - try { - ParameterInfo[] parameterInfo = this.getParameters(behavior); - Object values[] = new Object[parameterInfo.length]; - int i = 0; - for (i = 0; i < parameterInfo.length; i++) { - Object value = parameters.get(parameterInfo[i].getName()); - if (value == null) { - values[i] = null; - } else { - values[i] = this.getTypeConverter().convert(value, - parameterInfo[i].getType()); - } - } - return values; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private Object[] prepareParameters(Method behavior, - Map parameters) { - try { - ParameterInfo[] parameterInfo = this.getParameters(behavior); - Object values[] = new Object[parameterInfo.length]; - int i = 0; - for (i = 0; i < parameterInfo.length; i++) { - Object value = parameters.get(parameterInfo[i].getName()); - if (value == null) { - values[i] = null; - } else { - values[i] = this.getTypeConverter().convert(value, - parameterInfo[i].getType()); - } - } - return values; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public Object doBehavior(Object plugin, String behaviorName, - Map parameters) { - try { - Method method = findMethod(plugin, behaviorName); - if (method == null) { - return null; - } - Object[] params = prepareParameters(method, parameters); - return method.invoke(plugin, params); - } catch (Exception e) { - - return null; - } - } - - private Method findMethod(Object plugin, String behaviorName) { - try { - Method[] methods = plugin.getClass().getMethods(); - int i = 0; - for (i = 0; i < methods.length; i++) { - if (methods[i].isAnnotationPresent(Behavior.class)) { - if (((Behavior) methods[i].getAnnotation(Behavior.class)) - .value().equals(behaviorName)) { - return methods[i]; - } - } - } - return null; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} +package org.bench4q.agent.plugin; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.bench4q.agent.share.DealWithLog; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class PluginManager { + private ClassHelper classHelper; + private TypeConverter typeConverter; + private Map> plugins; + private Logger logger = Logger.getLogger(PluginManager.class); + + @Autowired + public PluginManager(ClassHelper classHelper, TypeConverter typeConverter) { + this.setClassHelper(classHelper); + this.setTypeConverter(typeConverter); + this.setPlugins(this.loadPlugins("org.bench4q.agent.plugin")); + } + + private ClassHelper getClassHelper() { + return classHelper; + } + + private void setClassHelper(ClassHelper classHelper) { + this.classHelper = classHelper; + } + + private TypeConverter getTypeConverter() { + return typeConverter; + } + + private void setTypeConverter(TypeConverter typeConverter) { + this.typeConverter = typeConverter; + } + + public Map> getPlugins() { + return plugins; + } + + private void setPlugins(Map> plugins) { + this.plugins = plugins; + } + + public Map> loadPlugins(String packageName) { + try { + List classNames = this.getClassHelper().getClassNames( + packageName, true); + Map> ret = new HashMap>(); + for (String className : classNames) { + Class plugin = Class.forName(className); + if (plugin.isAnnotationPresent(Plugin.class)) { + ret.put(plugin.getAnnotation(Plugin.class).value(), plugin); + } + } + return ret; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getPluginInfo() { + try { + Map> plugins = this.getPlugins(); + List ret = new ArrayList(); + for (Class plugin : plugins.values()) { + PluginInfo pluginInfo = new PluginInfo(); + pluginInfo + .setName((plugin.getAnnotation(Plugin.class)).value()); + pluginInfo.setParameters(this.getParameters(plugin + .getConstructors()[0])); + Method[] behaviors = this.getBehaviors(plugin); + pluginInfo.setBehaviors(new BehaviorInfo[behaviors.length]); + int i = 0; + for (i = 0; i < behaviors.length; i++) { + Method behaviorMethod = behaviors[i]; + BehaviorInfo behaviorInfo = buildBehaviorInfo(behaviorMethod); + pluginInfo.getBehaviors()[i] = behaviorInfo; + } + ret.add(pluginInfo); + } + return ret; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + private BehaviorInfo buildBehaviorInfo(Method behaviorMethod) + throws ClassNotFoundException { + BehaviorInfo behaviorInfo = new BehaviorInfo(); + behaviorInfo.setName((behaviorMethod.getAnnotation(Behavior.class)) + .value()); + behaviorInfo.setParameters(this.getParameters(behaviorMethod)); + return behaviorInfo; + } + + private ParameterInfo[] getParameters(Method behavior) { + try { + int parameterCount = behavior.getParameterTypes().length; + Annotation[][] parameterAnnotations = behavior + .getParameterAnnotations(); + ParameterInfo[] parameterNames = new ParameterInfo[parameterCount]; + int i; + for (i = 0; i < parameterCount; i++) { + Annotation[] annotations = parameterAnnotations[i]; + Parameter parameter = (Parameter) annotations[0]; + Class type = behavior.getParameterTypes()[i]; + ParameterInfo parameterInfo = buildParameterInfo( + parameter.value(), type.getName()); + parameterNames[i] = parameterInfo; + } + return parameterNames; + } catch (Exception e) { + logger.error(DealWithLog.getExceptionStackTrace(e)); + return null; + } + } + + private ParameterInfo[] getParameters(Constructor behavior) { + try { + int parameterCount = behavior.getParameterTypes().length; + Annotation[][] parameterAnnotations = behavior + .getParameterAnnotations(); + ParameterInfo[] parameterNames = new ParameterInfo[parameterCount]; + int i; + for (i = 0; i < parameterCount; i++) { + Annotation[] annotations = parameterAnnotations[i]; + Parameter parameter = (Parameter) annotations[0]; + Class type = behavior.getParameterTypes()[i]; + ParameterInfo parameterInfo = buildParameterInfo( + parameter.value(), type.getName()); + parameterNames[i] = parameterInfo; + } + return parameterNames; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + private ParameterInfo buildParameterInfo(String name, String type) { + ParameterInfo parameterInfo = new ParameterInfo(); + parameterInfo.setName(name); + parameterInfo.setType(type); + return parameterInfo; + } + + private Method[] getBehaviors(Class plugin) { + try { + Method[] methods = plugin.getMethods(); + List ret = new ArrayList(); + int i = 0; + for (i = 0; i < methods.length; i++) { + if (methods[i].isAnnotationPresent(Behavior.class)) { + ret.add(methods[i]); + } + } + return ret.toArray(new Method[0]); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public Object initializePlugin(Class plugin, + Map parameters) { + try { + Constructor[] ctConstructors = plugin.getConstructors(); + if (ctConstructors.length != 1) { + return null; + } + Constructor constructor = ctConstructors[0]; + Object[] params = prepareParameters(constructor, parameters); + return plugin.getConstructors()[0].newInstance(params); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + private Object[] prepareParameters(Constructor behavior, + Map parameters) { + try { + ParameterInfo[] parameterInfo = this.getParameters(behavior); + Object values[] = new Object[parameterInfo.length]; + int i = 0; + for (i = 0; i < parameterInfo.length; i++) { + Object value = parameters.get(parameterInfo[i].getName()); + if (value == null) { + values[i] = null; + } else { + values[i] = this.getTypeConverter().convert(value, + parameterInfo[i].getType()); + } + } + return values; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + private Object[] prepareParameters(Method behavior, + Map parameters) { + try { + ParameterInfo[] parameterInfo = this.getParameters(behavior); + Object values[] = new Object[parameterInfo.length]; + int i = 0; + for (i = 0; i < parameterInfo.length; i++) { + Object value = parameters.get(parameterInfo[i].getName()); + if (value == null) { + values[i] = null; + } else { + values[i] = this.getTypeConverter().convert(value, + parameterInfo[i].getType()); + } + } + return values; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public Object doBehavior(Object plugin, String behaviorName, + Map parameters) { + try { + Method method = findMethod(plugin, behaviorName); + if (method == null) { + return null; + } + Object[] params = prepareParameters(method, parameters); + return method.invoke(plugin, params); + } catch (Exception e) { + + return null; + } + } + + private Method findMethod(Object plugin, String behaviorName) { + try { + Method[] methods = plugin.getClass().getMethods(); + int i = 0; + for (i = 0; i < methods.length; i++) { + if (methods[i].isAnnotationPresent(Behavior.class)) { + if (((Behavior) methods[i].getAnnotation(Behavior.class)) + .value().equals(behaviorName)) { + return methods[i]; + } + } + } + return null; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/main/java/org/bench4q/agent/plugin/TypeConverter.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/TypeConverter.java similarity index 96% rename from src/main/java/org/bench4q/agent/plugin/TypeConverter.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/TypeConverter.java index de1216e3..8b6b29b0 100644 --- a/src/main/java/org/bench4q/agent/plugin/TypeConverter.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/TypeConverter.java @@ -1,44 +1,44 @@ -package org.bench4q.agent.plugin; - -import org.springframework.stereotype.Component; - -@Component -public class TypeConverter { - public Object convert(Object source, String targetClassName) { - if (targetClassName.equals("boolean")) { - return Boolean.parseBoolean(source.toString()); - } - if (targetClassName.equals("char")) { - return source.toString().toCharArray()[0]; - } - if (targetClassName.equals("byte")) { - return Byte.parseByte(source.toString()); - } - if (targetClassName.equals("short")) { - return Short.parseShort(source.toString()); - } - if (targetClassName.equals("int")) { - return Integer.parseInt(source.toString()); - } - if (targetClassName.equals("long")) { - return Long.parseLong(source.toString()); - } - if (targetClassName.equals("float")) { - return Float.parseFloat(source.toString()); - } - if (targetClassName.equals("double")) { - return Double.parseDouble(source.toString()); - } - - try { - Class targetClass = Class.forName(targetClassName); - if (targetClass.isAssignableFrom(String.class)) { - return source.toString(); - } - return targetClass.cast(source); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} +package org.bench4q.agent.plugin; + +import org.springframework.stereotype.Component; + +@Component +public class TypeConverter { + public Object convert(Object source, String targetClassName) { + if (targetClassName.equals("boolean")) { + return Boolean.parseBoolean(source.toString()); + } + if (targetClassName.equals("char")) { + return source.toString().toCharArray()[0]; + } + if (targetClassName.equals("byte")) { + return Byte.parseByte(source.toString()); + } + if (targetClassName.equals("short")) { + return Short.parseShort(source.toString()); + } + if (targetClassName.equals("int")) { + return Integer.parseInt(source.toString()); + } + if (targetClassName.equals("long")) { + return Long.parseLong(source.toString()); + } + if (targetClassName.equals("float")) { + return Float.parseFloat(source.toString()); + } + if (targetClassName.equals("double")) { + return Double.parseDouble(source.toString()); + } + + try { + Class targetClass = Class.forName(targetClassName); + if (targetClass.isAssignableFrom(String.class)) { + return source.toString(); + } + return targetClass.cast(source); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/main/java/org/bench4q/agent/plugin/basic/CommandLinePlugin.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/CommandLinePlugin.java similarity index 96% rename from src/main/java/org/bench4q/agent/plugin/basic/CommandLinePlugin.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/CommandLinePlugin.java index 1ab199af..97072a39 100644 --- a/src/main/java/org/bench4q/agent/plugin/basic/CommandLinePlugin.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/CommandLinePlugin.java @@ -1,89 +1,89 @@ -package org.bench4q.agent.plugin.basic; - -import java.io.BufferedReader; -import java.io.InputStreamReader; - -import org.bench4q.agent.plugin.Behavior; -import org.bench4q.agent.plugin.Parameter; -import org.bench4q.agent.plugin.Plugin; -import org.bench4q.agent.plugin.result.CommandLineReturn; - -@Plugin("CommandLine") -public class CommandLinePlugin { - private String standardOutput; - private String standardError; - - public String getStandardOutput() { - return standardOutput; - } - - private void setStandardOutput(String standardOutput) { - this.standardOutput = standardOutput; - } - - public String getStandardError() { - return standardError; - } - - private void setStandardError(String standardError) { - this.standardError = standardError; - } - - public CommandLinePlugin() { - - } - - @Behavior("Command") - public CommandLineReturn command(@Parameter("command") String command) { - try { - final Process process = Runtime.getRuntime().exec(command); - new Thread() { - public void run() { - try { - BufferedReader reader = new BufferedReader( - new InputStreamReader(process.getInputStream())); - String streamline = ""; - try { - setStandardOutput(""); - while ((streamline = reader.readLine()) != null) { - setStandardOutput(getStandardOutput() - + streamline - + System.getProperty("line.separator")); - } - } finally { - reader.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - }.start(); - new Thread() { - public void run() { - try { - BufferedReader reader = new BufferedReader( - new InputStreamReader(process.getErrorStream())); - String streamline = ""; - try { - setStandardError(""); - while ((streamline = reader.readLine()) != null) { - setStandardError(getStandardError() - + streamline - + System.getProperty("line.separator")); - } - } finally { - reader.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - }.start(); - process.waitFor(); - return new CommandLineReturn(true); - } catch (Exception e) { - e.printStackTrace(); - return new CommandLineReturn(false); - } - } -} +package org.bench4q.agent.plugin.basic; + +import java.io.BufferedReader; +import java.io.InputStreamReader; + +import org.bench4q.agent.plugin.Behavior; +import org.bench4q.agent.plugin.Parameter; +import org.bench4q.agent.plugin.Plugin; +import org.bench4q.agent.plugin.result.CommandLineReturn; + +@Plugin("CommandLine") +public class CommandLinePlugin { + private String standardOutput; + private String standardError; + + public String getStandardOutput() { + return standardOutput; + } + + private void setStandardOutput(String standardOutput) { + this.standardOutput = standardOutput; + } + + public String getStandardError() { + return standardError; + } + + private void setStandardError(String standardError) { + this.standardError = standardError; + } + + public CommandLinePlugin() { + + } + + @Behavior("Command") + public CommandLineReturn command(@Parameter("command") String command) { + try { + final Process process = Runtime.getRuntime().exec(command); + new Thread() { + public void run() { + try { + BufferedReader reader = new BufferedReader( + new InputStreamReader(process.getInputStream())); + String streamline = ""; + try { + setStandardOutput(""); + while ((streamline = reader.readLine()) != null) { + setStandardOutput(getStandardOutput() + + streamline + + System.getProperty("line.separator")); + } + } finally { + reader.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }.start(); + new Thread() { + public void run() { + try { + BufferedReader reader = new BufferedReader( + new InputStreamReader(process.getErrorStream())); + String streamline = ""; + try { + setStandardError(""); + while ((streamline = reader.readLine()) != null) { + setStandardError(getStandardError() + + streamline + + System.getProperty("line.separator")); + } + } finally { + reader.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }.start(); + process.waitFor(); + return new CommandLineReturn(true); + } catch (Exception e) { + e.printStackTrace(); + return new CommandLineReturn(false); + } + } +} diff --git a/src/main/java/org/bench4q/agent/plugin/basic/ConstantTimerPlugin.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/ConstantTimerPlugin.java similarity index 96% rename from src/main/java/org/bench4q/agent/plugin/basic/ConstantTimerPlugin.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/ConstantTimerPlugin.java index 12af61e7..589d0b40 100644 --- a/src/main/java/org/bench4q/agent/plugin/basic/ConstantTimerPlugin.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/ConstantTimerPlugin.java @@ -1,27 +1,27 @@ -package org.bench4q.agent.plugin.basic; - -import org.apache.log4j.Logger; -import org.bench4q.agent.plugin.Behavior; -import org.bench4q.agent.plugin.Parameter; -import org.bench4q.agent.plugin.Plugin; -import org.bench4q.agent.plugin.result.TimerReturn; - -@Plugin("ConstantTimer") -public class ConstantTimerPlugin { - private Logger logger = Logger.getLogger(ConstantTimerPlugin.class); - - public ConstantTimerPlugin() { - - } - - @Behavior("Sleep") - public TimerReturn sleep(@Parameter("time") int time) { - try { - Thread.sleep(time); - return new TimerReturn(true); - } catch (Exception e) { - logger.info("sleep interrupted!"); - return new TimerReturn(false); - } - } -} +package org.bench4q.agent.plugin.basic; + +import org.apache.log4j.Logger; +import org.bench4q.agent.plugin.Behavior; +import org.bench4q.agent.plugin.Parameter; +import org.bench4q.agent.plugin.Plugin; +import org.bench4q.agent.plugin.result.TimerReturn; + +@Plugin("ConstantTimer") +public class ConstantTimerPlugin { + private Logger logger = Logger.getLogger(ConstantTimerPlugin.class); + + public ConstantTimerPlugin() { + + } + + @Behavior("Sleep") + public TimerReturn sleep(@Parameter("time") int time) { + try { + Thread.sleep(time); + return new TimerReturn(true); + } catch (Exception e) { + logger.info("sleep interrupted!"); + return new TimerReturn(false); + } + } +} diff --git a/src/main/java/org/bench4q/agent/plugin/basic/LogPlugin.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/LogPlugin.java similarity index 95% rename from src/main/java/org/bench4q/agent/plugin/basic/LogPlugin.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/LogPlugin.java index 01ed60e2..473ef163 100644 --- a/src/main/java/org/bench4q/agent/plugin/basic/LogPlugin.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/LogPlugin.java @@ -1,19 +1,19 @@ -package org.bench4q.agent.plugin.basic; - -import org.bench4q.agent.plugin.Behavior; -import org.bench4q.agent.plugin.Parameter; -import org.bench4q.agent.plugin.Plugin; -import org.bench4q.agent.plugin.result.LogReturn; - -@Plugin("Log") -public class LogPlugin { - public LogPlugin() { - - } - - @Behavior("Log") - public LogReturn log(@Parameter("message") String message) { - System.out.println(message); - return new LogReturn(true); - } -} +package org.bench4q.agent.plugin.basic; + +import org.bench4q.agent.plugin.Behavior; +import org.bench4q.agent.plugin.Parameter; +import org.bench4q.agent.plugin.Plugin; +import org.bench4q.agent.plugin.result.LogReturn; + +@Plugin("Log") +public class LogPlugin { + public LogPlugin() { + + } + + @Behavior("Log") + public LogReturn log(@Parameter("message") String message) { + System.out.println(message); + return new LogReturn(true); + } +} diff --git a/src/main/java/org/bench4q/agent/plugin/basic/http/HttpPlugin.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/http/HttpPlugin.java similarity index 100% rename from src/main/java/org/bench4q/agent/plugin/basic/http/HttpPlugin.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/http/HttpPlugin.java diff --git a/src/main/java/org/bench4q/agent/plugin/basic/http/ParameterConstant.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/http/ParameterConstant.java similarity index 100% rename from src/main/java/org/bench4q/agent/plugin/basic/http/ParameterConstant.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/http/ParameterConstant.java diff --git a/src/main/java/org/bench4q/agent/plugin/result/CommandLineReturn.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/CommandLineReturn.java similarity index 96% rename from src/main/java/org/bench4q/agent/plugin/result/CommandLineReturn.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/CommandLineReturn.java index 4e682097..15679f69 100644 --- a/src/main/java/org/bench4q/agent/plugin/result/CommandLineReturn.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/CommandLineReturn.java @@ -1,7 +1,7 @@ -package org.bench4q.agent.plugin.result; - -public class CommandLineReturn extends PluginReturn { - public CommandLineReturn(boolean success) { - this.setSuccess(success); - } -} +package org.bench4q.agent.plugin.result; + +public class CommandLineReturn extends PluginReturn { + public CommandLineReturn(boolean success) { + this.setSuccess(success); + } +} diff --git a/src/main/java/org/bench4q/agent/plugin/result/HttpReturn.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/HttpReturn.java similarity index 100% rename from src/main/java/org/bench4q/agent/plugin/result/HttpReturn.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/HttpReturn.java diff --git a/src/main/java/org/bench4q/agent/plugin/result/LogReturn.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/LogReturn.java similarity index 95% rename from src/main/java/org/bench4q/agent/plugin/result/LogReturn.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/LogReturn.java index 3fdfaa05..d26ff1eb 100644 --- a/src/main/java/org/bench4q/agent/plugin/result/LogReturn.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/LogReturn.java @@ -1,7 +1,7 @@ -package org.bench4q.agent.plugin.result; - -public class LogReturn extends PluginReturn { - public LogReturn(boolean success) { - this.setSuccess(success); - } -} +package org.bench4q.agent.plugin.result; + +public class LogReturn extends PluginReturn { + public LogReturn(boolean success) { + this.setSuccess(success); + } +} diff --git a/src/main/java/org/bench4q/agent/plugin/result/PluginReturn.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/PluginReturn.java similarity index 100% rename from src/main/java/org/bench4q/agent/plugin/result/PluginReturn.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/PluginReturn.java diff --git a/src/main/java/org/bench4q/agent/plugin/result/TimerReturn.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/TimerReturn.java similarity index 94% rename from src/main/java/org/bench4q/agent/plugin/result/TimerReturn.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/TimerReturn.java index 97b7b183..9f3ecad0 100644 --- a/src/main/java/org/bench4q/agent/plugin/result/TimerReturn.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/result/TimerReturn.java @@ -1,12 +1,12 @@ -package org.bench4q.agent.plugin.result; - -/** - * - * @author coderfengyun - * - */ -public class TimerReturn extends PluginReturn { - public TimerReturn(boolean success) { - this.setSuccess(success); - } -} +package org.bench4q.agent.plugin.result; + +/** + * + * @author coderfengyun + * + */ +public class TimerReturn extends PluginReturn { + public TimerReturn(boolean success) { + this.setSuccess(success); + } +} diff --git a/src/main/java/org/bench4q/agent/scenario/Batch.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Batch.java similarity index 94% rename from src/main/java/org/bench4q/agent/scenario/Batch.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Batch.java index 82ee79d2..f05a3a2f 100644 --- a/src/main/java/org/bench4q/agent/scenario/Batch.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Batch.java @@ -1,43 +1,43 @@ -package org.bench4q.agent.scenario; - -import org.bench4q.agent.scenario.behavior.Behavior; - -public class Batch { - private int id; - private int parentId; - private int childId; - private Behavior[] behaviors; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getParentId() { - return parentId; - } - - public void setParentId(int parentId) { - this.parentId = parentId; - } - - public int getChildId() { - return childId; - } - - public void setChildId(int childId) { - this.childId = childId; - } - - public Behavior[] getBehaviors() { - return behaviors; - } - - public void setBehaviors(Behavior[] behaviors) { - this.behaviors = behaviors; - } - -} +package org.bench4q.agent.scenario; + +import org.bench4q.agent.scenario.behavior.Behavior; + +public class Batch { + private int id; + private int parentId; + private int childId; + private Behavior[] behaviors; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getParentId() { + return parentId; + } + + public void setParentId(int parentId) { + this.parentId = parentId; + } + + public int getChildId() { + return childId; + } + + public void setChildId(int childId) { + this.childId = childId; + } + + public Behavior[] getBehaviors() { + return behaviors; + } + + public void setBehaviors(Behavior[] behaviors) { + this.behaviors = behaviors; + } + +} diff --git a/src/main/java/org/bench4q/agent/scenario/BehaviorResult.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/BehaviorResult.java similarity index 94% rename from src/main/java/org/bench4q/agent/scenario/BehaviorResult.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/BehaviorResult.java index 501cddc1..3311f076 100644 --- a/src/main/java/org/bench4q/agent/scenario/BehaviorResult.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/BehaviorResult.java @@ -1,125 +1,125 @@ -package org.bench4q.agent.scenario; - -import java.util.Date; - -public class BehaviorResult { - private String pluginId; - private String pluginName; - private String behaviorName; - private Date startDate; - private Date endDate; - private long responseTime; - private boolean success; - - private int behaviorId; - private String behaviorUrl; - private long contentLength; - private int statusCode; - private String contentType; - private boolean shouldBeCountResponseTime; - - public String getPluginId() { - return pluginId; - } - - public void setPluginId(String pluginId) { - this.pluginId = pluginId; - } - - public String getPluginName() { - return pluginName; - } - - public void setPluginName(String pluginName) { - this.pluginName = pluginName; - } - - public String getBehaviorName() { - return behaviorName; - } - - public void setBehaviorName(String behaviorName) { - this.behaviorName = behaviorName; - } - - public Date getStartDate() { - return startDate; - } - - public void setStartDate(Date startDate) { - this.startDate = startDate; - } - - public Date getEndDate() { - return endDate; - } - - public void setEndDate(Date endDate) { - this.endDate = endDate; - } - - public long getResponseTime() { - return responseTime; - } - - public void setResponseTime(long responseTime) { - this.responseTime = responseTime; - } - - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } - - public int getBehaviorId() { - return behaviorId; - } - - public void setBehaviorId(int behaviorId) { - this.behaviorId = behaviorId; - } - - public String getBehaviorUrl() { - return behaviorUrl; - } - - public void setBehaviorUrl(String behaviorUrl) { - this.behaviorUrl = behaviorUrl; - } - - public long getContentLength() { - return contentLength; - } - - public void setContentLength(long contentLength) { - this.contentLength = contentLength; - } - - public int getStatusCode() { - return statusCode; - } - - public void setStatusCode(int statusCode) { - this.statusCode = statusCode; - } - - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public boolean isShouldBeCountResponseTime() { - return shouldBeCountResponseTime; - } - - public void setShouldBeCountResponseTime(boolean shouldBeCountResponseTime) { - this.shouldBeCountResponseTime = shouldBeCountResponseTime; - } - -} +package org.bench4q.agent.scenario; + +import java.util.Date; + +public class BehaviorResult { + private String pluginId; + private String pluginName; + private String behaviorName; + private Date startDate; + private Date endDate; + private long responseTime; + private boolean success; + + private int behaviorId; + private String behaviorUrl; + private long contentLength; + private int statusCode; + private String contentType; + private boolean shouldBeCountResponseTime; + + public String getPluginId() { + return pluginId; + } + + public void setPluginId(String pluginId) { + this.pluginId = pluginId; + } + + public String getPluginName() { + return pluginName; + } + + public void setPluginName(String pluginName) { + this.pluginName = pluginName; + } + + public String getBehaviorName() { + return behaviorName; + } + + public void setBehaviorName(String behaviorName) { + this.behaviorName = behaviorName; + } + + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + public long getResponseTime() { + return responseTime; + } + + public void setResponseTime(long responseTime) { + this.responseTime = responseTime; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public int getBehaviorId() { + return behaviorId; + } + + public void setBehaviorId(int behaviorId) { + this.behaviorId = behaviorId; + } + + public String getBehaviorUrl() { + return behaviorUrl; + } + + public void setBehaviorUrl(String behaviorUrl) { + this.behaviorUrl = behaviorUrl; + } + + public long getContentLength() { + return contentLength; + } + + public void setContentLength(long contentLength) { + this.contentLength = contentLength; + } + + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public boolean isShouldBeCountResponseTime() { + return shouldBeCountResponseTime; + } + + public void setShouldBeCountResponseTime(boolean shouldBeCountResponseTime) { + this.shouldBeCountResponseTime = shouldBeCountResponseTime; + } + +} diff --git a/src/main/java/org/bench4q/agent/scenario/Page.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Page.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/Page.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Page.java diff --git a/src/main/java/org/bench4q/agent/scenario/PageResult.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/PageResult.java similarity index 96% rename from src/main/java/org/bench4q/agent/scenario/PageResult.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/PageResult.java index e9572c94..fcadd468 100644 --- a/src/main/java/org/bench4q/agent/scenario/PageResult.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/PageResult.java @@ -1,77 +1,77 @@ -package org.bench4q.agent.scenario; - -import java.util.ArrayList; -import java.util.List; - -public class PageResult { - private int pageId; - private long pageStartTime; - private long pageEndTime; - private long executeRange; - - public int getPageId() { - return pageId; - } - - private void setPageId(int pageId) { - this.pageId = pageId; - } - - public long getPageStartTime() { - return pageStartTime; - } - - private void setPageStartTime(long pageStartTime) { - this.pageStartTime = pageStartTime; - } - - public long getPageEndTime() { - return pageEndTime; - } - - private void setPageEndTime(long pageEndTime) { - this.pageEndTime = pageEndTime; - } - - public long getExecuteRange() { - return executeRange; - } - - private void setExecuteRange(long executeRange) { - this.executeRange = executeRange; - } - - private PageResult() { - init(); - } - - private void init() { - this.setPageStartTime(Long.MAX_VALUE); - this.setPageEndTime(Long.MIN_VALUE); - this.setExecuteRange(0); - } - - public static PageResult buildPageResult(int pageId, - List behaviorResults) { - PageResult result = new PageResult(); - result.setPageId(pageId); - if (behaviorResults == null) { - behaviorResults = new ArrayList(); - } - for (BehaviorResult behaviorResult : behaviorResults) { - if (behaviorResult.getStartDate().getTime() < result - .getPageStartTime()) { - result.setPageStartTime(behaviorResult.getStartDate().getTime()); - } - if (behaviorResult.getEndDate().getTime() > result.getPageEndTime()) { - result.setPageEndTime(behaviorResult.getEndDate().getTime()); - } - // Page excuteRange rely on the behaviors' execute way, if it's - // executed in batch, i should take the longest behavior in batch - // to calculate this One. - } - result.setExecuteRange(result.getPageEndTime() - - result.getPageStartTime()); - return result; - } -} +package org.bench4q.agent.scenario; + +import java.util.ArrayList; +import java.util.List; + +public class PageResult { + private int pageId; + private long pageStartTime; + private long pageEndTime; + private long executeRange; + + public int getPageId() { + return pageId; + } + + private void setPageId(int pageId) { + this.pageId = pageId; + } + + public long getPageStartTime() { + return pageStartTime; + } + + private void setPageStartTime(long pageStartTime) { + this.pageStartTime = pageStartTime; + } + + public long getPageEndTime() { + return pageEndTime; + } + + private void setPageEndTime(long pageEndTime) { + this.pageEndTime = pageEndTime; + } + + public long getExecuteRange() { + return executeRange; + } + + private void setExecuteRange(long executeRange) { + this.executeRange = executeRange; + } + + private PageResult() { + init(); + } + + private void init() { + this.setPageStartTime(Long.MAX_VALUE); + this.setPageEndTime(Long.MIN_VALUE); + this.setExecuteRange(0); + } + + public static PageResult buildPageResult(int pageId, + List behaviorResults) { + PageResult result = new PageResult(); + result.setPageId(pageId); + if (behaviorResults == null) { + behaviorResults = new ArrayList(); + } + for (BehaviorResult behaviorResult : behaviorResults) { + if (behaviorResult.getStartDate().getTime() < result + .getPageStartTime()) { + result.setPageStartTime(behaviorResult.getStartDate().getTime()); + } + if (behaviorResult.getEndDate().getTime() > result.getPageEndTime()) { + result.setPageEndTime(behaviorResult.getEndDate().getTime()); + } + // Page excuteRange rely on the behaviors' execute way, if it's + // executed in batch, i should take the longest behavior in batch + // to calculate this One. + } + result.setExecuteRange(result.getPageEndTime() + - result.getPageStartTime()); + return result; + } +} diff --git a/src/main/java/org/bench4q/agent/scenario/Parameter.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Parameter.java similarity index 93% rename from src/main/java/org/bench4q/agent/scenario/Parameter.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Parameter.java index 325733d8..10785505 100644 --- a/src/main/java/org/bench4q/agent/scenario/Parameter.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Parameter.java @@ -1,23 +1,23 @@ -package org.bench4q.agent.scenario; - -public class Parameter { - private String key; - private String value; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - -} +package org.bench4q.agent.scenario; + +public class Parameter { + private String key; + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/main/java/org/bench4q/agent/scenario/Scenario.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Scenario.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/Scenario.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Scenario.java diff --git a/src/main/java/org/bench4q/agent/scenario/ScenarioContext.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/ScenarioContext.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/ScenarioContext.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/ScenarioContext.java diff --git a/src/main/java/org/bench4q/agent/scenario/ScenarioEngine.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/ScenarioEngine.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/ScenarioEngine.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/ScenarioEngine.java diff --git a/src/main/java/org/bench4q/agent/scenario/SessionContext.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/SessionContext.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/SessionContext.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/SessionContext.java diff --git a/src/main/java/org/bench4q/agent/scenario/TestResult.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/TestResult.java similarity index 95% rename from src/main/java/org/bench4q/agent/scenario/TestResult.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/TestResult.java index 26c000f3..6457ca30 100644 --- a/src/main/java/org/bench4q/agent/scenario/TestResult.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/TestResult.java @@ -1,111 +1,111 @@ -package org.bench4q.agent.scenario; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "testResult") -public class TestResult implements Serializable { - private static final long serialVersionUID = -370091935554266546L; - private UUID runId; - private int poolSize; - private int totalCount; - private Date startDate; - private long elapsedTime; - private int successCount; - private int failCount; - private int finishedCount; - private double averageResponseTime; - private List results; - - @XmlElement - public UUID getRunId() { - return runId; - } - - public void setRunId(UUID runId) { - this.runId = runId; - } - - @XmlElement - public int getPoolSize() { - return poolSize; - } - - public void setPoolSize(int poolSize) { - this.poolSize = poolSize; - } - - @XmlElement - public int getTotalCount() { - return totalCount; - } - - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - @XmlElement - public Date getStartDate() { - return startDate; - } - - public void setStartDate(Date startDate) { - this.startDate = startDate; - } - - public long getElapsedTime() { - return elapsedTime; - } - - public void setElapsedTime(long elapsedTime) { - this.elapsedTime = elapsedTime; - } - - public int getSuccessCount() { - return successCount; - } - - public void setSuccessCount(int successCount) { - this.successCount = successCount; - } - - public int getFailCount() { - return failCount; - } - - public void setFailCount(int failCount) { - this.failCount = failCount; - } - - public int getFinishedCount() { - return finishedCount; - } - - public void setFinishedCount(int finishedCount) { - this.finishedCount = finishedCount; - } - - public double getAverageResponseTime() { - return averageResponseTime; - } - - public void setAverageResponseTime(double averageResponseTime) { - this.averageResponseTime = averageResponseTime; - } - - @XmlElementWrapper(name = "results") - @XmlElement(name = "result") - public List getResults() { - return results; - } - - public void setResults(List results) { - this.results = results; - } -} +package org.bench4q.agent.scenario; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "testResult") +public class TestResult implements Serializable { + private static final long serialVersionUID = -370091935554266546L; + private UUID runId; + private int poolSize; + private int totalCount; + private Date startDate; + private long elapsedTime; + private int successCount; + private int failCount; + private int finishedCount; + private double averageResponseTime; + private List results; + + @XmlElement + public UUID getRunId() { + return runId; + } + + public void setRunId(UUID runId) { + this.runId = runId; + } + + @XmlElement + public int getPoolSize() { + return poolSize; + } + + public void setPoolSize(int poolSize) { + this.poolSize = poolSize; + } + + @XmlElement + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + @XmlElement + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + public long getElapsedTime() { + return elapsedTime; + } + + public void setElapsedTime(long elapsedTime) { + this.elapsedTime = elapsedTime; + } + + public int getSuccessCount() { + return successCount; + } + + public void setSuccessCount(int successCount) { + this.successCount = successCount; + } + + public int getFailCount() { + return failCount; + } + + public void setFailCount(int failCount) { + this.failCount = failCount; + } + + public int getFinishedCount() { + return finishedCount; + } + + public void setFinishedCount(int finishedCount) { + this.finishedCount = finishedCount; + } + + public double getAverageResponseTime() { + return averageResponseTime; + } + + public void setAverageResponseTime(double averageResponseTime) { + this.averageResponseTime = averageResponseTime; + } + + @XmlElementWrapper(name = "results") + @XmlElement(name = "result") + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } +} diff --git a/src/main/java/org/bench4q/agent/scenario/TestResultItem.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/TestResultItem.java similarity index 94% rename from src/main/java/org/bench4q/agent/scenario/TestResultItem.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/TestResultItem.java index da9e9271..39481fa8 100644 --- a/src/main/java/org/bench4q/agent/scenario/TestResultItem.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/TestResultItem.java @@ -1,93 +1,93 @@ -package org.bench4q.agent.scenario; - -import java.io.Serializable; -import java.util.Date; -import java.util.UUID; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "testResultItem") -public class TestResultItem implements Serializable { - private static final long serialVersionUID = 3307951299814477213L; - private UUID id; - private String pluginId; - private String pluginName; - private String behaviorName; - private Date startDate; - private Date endDate; - private long responseTime; - private boolean success; - - @XmlElement - public UUID getId() { - return id; - } - - public void setId(UUID id) { - this.id = id; - } - - @XmlElement - public String getPluginId() { - return pluginId; - } - - public void setPluginId(String pluginId) { - this.pluginId = pluginId; - } - - @XmlElement - public String getPluginName() { - return pluginName; - } - - public void setPluginName(String pluginName) { - this.pluginName = pluginName; - } - - @XmlElement - public String getBehaviorName() { - return behaviorName; - } - - public void setBehaviorName(String behaviorName) { - this.behaviorName = behaviorName; - } - - @XmlElement - public Date getStartDate() { - return startDate; - } - - public void setStartDate(Date startDate) { - this.startDate = startDate; - } - - @XmlElement - public Date getEndDate() { - return endDate; - } - - public void setEndDate(Date endDate) { - this.endDate = endDate; - } - - @XmlElement - public long getResponseTime() { - return responseTime; - } - - public void setResponseTime(long responseTime) { - this.responseTime = responseTime; - } - - @XmlElement - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } -} +package org.bench4q.agent.scenario; + +import java.io.Serializable; +import java.util.Date; +import java.util.UUID; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "testResultItem") +public class TestResultItem implements Serializable { + private static final long serialVersionUID = 3307951299814477213L; + private UUID id; + private String pluginId; + private String pluginName; + private String behaviorName; + private Date startDate; + private Date endDate; + private long responseTime; + private boolean success; + + @XmlElement + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + @XmlElement + public String getPluginId() { + return pluginId; + } + + public void setPluginId(String pluginId) { + this.pluginId = pluginId; + } + + @XmlElement + public String getPluginName() { + return pluginName; + } + + public void setPluginName(String pluginName) { + this.pluginName = pluginName; + } + + @XmlElement + public String getBehaviorName() { + return behaviorName; + } + + public void setBehaviorName(String behaviorName) { + this.behaviorName = behaviorName; + } + + @XmlElement + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + @XmlElement + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + @XmlElement + public long getResponseTime() { + return responseTime; + } + + public void setResponseTime(long responseTime) { + this.responseTime = responseTime; + } + + @XmlElement + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } +} diff --git a/src/main/java/org/bench4q/agent/scenario/UsePlugin.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/UsePlugin.java similarity index 93% rename from src/main/java/org/bench4q/agent/scenario/UsePlugin.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/UsePlugin.java index ac353a2f..3e7379dd 100644 --- a/src/main/java/org/bench4q/agent/scenario/UsePlugin.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/UsePlugin.java @@ -1,32 +1,32 @@ -package org.bench4q.agent.scenario; - -public class UsePlugin { - private String id; - private String name; - private Parameter[] parameters; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Parameter[] getParameters() { - return parameters; - } - - public void setParameters(Parameter[] parameters) { - this.parameters = parameters; - } - -} +package org.bench4q.agent.scenario; + +public class UsePlugin { + private String id; + private String name; + private Parameter[] parameters; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Parameter[] getParameters() { + return parameters; + } + + public void setParameters(Parameter[] parameters) { + this.parameters = parameters; + } + +} diff --git a/src/main/java/org/bench4q/agent/scenario/Worker.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Worker.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/Worker.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/Worker.java diff --git a/src/main/java/org/bench4q/agent/scenario/behavior/Behavior.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/behavior/Behavior.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/behavior/Behavior.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/behavior/Behavior.java diff --git a/src/main/java/org/bench4q/agent/scenario/behavior/BehaviorFactory.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/behavior/BehaviorFactory.java similarity index 96% rename from src/main/java/org/bench4q/agent/scenario/behavior/BehaviorFactory.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/behavior/BehaviorFactory.java index 9c050110..e5761868 100644 --- a/src/main/java/org/bench4q/agent/scenario/behavior/BehaviorFactory.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/behavior/BehaviorFactory.java @@ -1,14 +1,14 @@ -package org.bench4q.agent.scenario.behavior; - -import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; - -public class BehaviorFactory { - public static Behavior getBuisinessObject(BehaviorModel modelInput) { - if (modelInput.getType().equalsIgnoreCase("TIMERBEHAVIOR")) { - return new TimerBehavior(); - } else if (modelInput.getType().equalsIgnoreCase("USERBEHAVIOR")) { - return new UserBehavior(); - } - return null; - } -} +package org.bench4q.agent.scenario.behavior; + +import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; + +public class BehaviorFactory { + public static Behavior getBuisinessObject(BehaviorModel modelInput) { + if (modelInput.getType().equalsIgnoreCase("TIMERBEHAVIOR")) { + return new TimerBehavior(); + } else if (modelInput.getType().equalsIgnoreCase("USERBEHAVIOR")) { + return new UserBehavior(); + } + return null; + } +} diff --git a/src/main/java/org/bench4q/agent/scenario/behavior/TimerBehavior.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/behavior/TimerBehavior.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/behavior/TimerBehavior.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/behavior/TimerBehavior.java diff --git a/src/main/java/org/bench4q/agent/scenario/behavior/UserBehavior.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/behavior/UserBehavior.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/behavior/UserBehavior.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/behavior/UserBehavior.java diff --git a/src/main/java/org/bench4q/agent/scenario/util/ParameterParser.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/util/ParameterParser.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/util/ParameterParser.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/util/ParameterParser.java diff --git a/src/main/java/org/bench4q/agent/scenario/util/Table.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/util/Table.java similarity index 100% rename from src/main/java/org/bench4q/agent/scenario/util/Table.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/util/Table.java diff --git a/src/main/java/org/bench4q/agent/share/DealWithLog.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/share/DealWithLog.java similarity index 96% rename from src/main/java/org/bench4q/agent/share/DealWithLog.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/share/DealWithLog.java index d2fca2da..3c18c981 100644 --- a/src/main/java/org/bench4q/agent/share/DealWithLog.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/share/DealWithLog.java @@ -1,13 +1,13 @@ -package org.bench4q.agent.share; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -public class DealWithLog { - public static ByteArrayOutputStream getExceptionStackTrace(Exception e) { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - PrintStream printStream = new PrintStream(outputStream); - e.printStackTrace(printStream); - return outputStream; - } -} +package org.bench4q.agent.share; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +public class DealWithLog { + public static ByteArrayOutputStream getExceptionStackTrace(Exception e) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + PrintStream printStream = new PrintStream(outputStream); + e.printStackTrace(printStream); + return outputStream; + } +} diff --git a/src/main/java/org/bench4q/agent/storage/Buffer.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/Buffer.java similarity index 95% rename from src/main/java/org/bench4q/agent/storage/Buffer.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/Buffer.java index 516c9212..a40de8bd 100644 --- a/src/main/java/org/bench4q/agent/storage/Buffer.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/Buffer.java @@ -1,57 +1,57 @@ -package org.bench4q.agent.storage; - -public class Buffer { - private byte[] content; - private int currentPos; - private int totalSize; - - public byte[] getContent() { - return content; - } - - public void setContent(byte[] content) { - this.content = content; - } - - public int getCurrentPos() { - return currentPos; - } - - public void setCurrentPos(int currentPos) { - this.currentPos = currentPos; - } - - public int getTotalSize() { - return totalSize; - } - - public void setTotalSize(int totalSize) { - this.totalSize = totalSize; - } - - public static Buffer createBuffer(int totalSize) { - Buffer buffer = new Buffer(); - buffer.setContent(new byte[totalSize]); - buffer.setCurrentPos(0); - buffer.setTotalSize(totalSize); - return buffer; - } - - public int getRemainSize() { - return this.totalSize - this.currentPos; - } - - public void reset() { - this.setCurrentPos(0); - } - - public void setFull() { - this.setCurrentPos(this.getTotalSize()); - } - - void writeToCurrentBuffer(int size, byte[] cache) { - System.arraycopy(cache, 0, this.getContent(), this.getCurrentPos(), - size); - this.setCurrentPos(this.getCurrentPos() + size); - } -} +package org.bench4q.agent.storage; + +public class Buffer { + private byte[] content; + private int currentPos; + private int totalSize; + + public byte[] getContent() { + return content; + } + + public void setContent(byte[] content) { + this.content = content; + } + + public int getCurrentPos() { + return currentPos; + } + + public void setCurrentPos(int currentPos) { + this.currentPos = currentPos; + } + + public int getTotalSize() { + return totalSize; + } + + public void setTotalSize(int totalSize) { + this.totalSize = totalSize; + } + + public static Buffer createBuffer(int totalSize) { + Buffer buffer = new Buffer(); + buffer.setContent(new byte[totalSize]); + buffer.setCurrentPos(0); + buffer.setTotalSize(totalSize); + return buffer; + } + + public int getRemainSize() { + return this.totalSize - this.currentPos; + } + + public void reset() { + this.setCurrentPos(0); + } + + public void setFull() { + this.setCurrentPos(this.getTotalSize()); + } + + void writeToCurrentBuffer(int size, byte[] cache) { + System.arraycopy(cache, 0, this.getContent(), this.getCurrentPos(), + size); + this.setCurrentPos(this.getCurrentPos() + size); + } +} diff --git a/src/main/java/org/bench4q/agent/storage/DoubleBufferStorage.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/DoubleBufferStorage.java similarity index 96% rename from src/main/java/org/bench4q/agent/storage/DoubleBufferStorage.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/DoubleBufferStorage.java index b59ff924..f92f050e 100644 --- a/src/main/java/org/bench4q/agent/storage/DoubleBufferStorage.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/DoubleBufferStorage.java @@ -1,157 +1,157 @@ -package org.bench4q.agent.storage; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FilenameFilter; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.bench4q.share.models.agent.CleanTestResultModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class DoubleBufferStorage { - private static final int THRESHOLD = 1024; - private static Charset charset = Charset.forName("utf-8"); - private static int BUFFER_SIZE = 48 * 1024; - private List bufferList; - private int currentBufferIndex; - private LocalStorage localStorage; - public CleanTestResultModel forTest = new CleanTestResultModel(); - - private int getCurrentBufferIndex() { - return currentBufferIndex; - } - - private void setCurrentBufferIndex(int currentBuffer) { - this.currentBufferIndex = currentBuffer; - } - - private List getBufferList() { - return bufferList; - } - - private void setBufferList(List bufferList) { - this.bufferList = bufferList; - } - - private LocalStorage getLocalStorage() { - return localStorage; - } - - @Autowired - private void setLocalStorage(LocalStorage localStorage) { - this.localStorage = localStorage; - } - - public DoubleBufferStorage() { - this.setBufferList(new ArrayList()); - this.getBufferList().add(Buffer.createBuffer(BUFFER_SIZE)); - this.getBufferList().add(Buffer.createBuffer(BUFFER_SIZE)); - this.setCurrentBufferIndex(0); - } - - public String readFiles(String pathPrefix) { - int pos = pathPrefix.lastIndexOf(System.getProperty("file.separator")); - String dirPath = pathPrefix.substring(0, pos); - final String prefix = pathPrefix.substring(pos + 1); - String result = new String(); - - File dirFile = new File(dirPath); - if (!dirFile.exists()) { - return ""; - } - File[] files = dirFile.listFiles(new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.contains(prefix); - } - }); - for (File file : files) { - if (!file.exists()) { - continue; - } - result += this.getLocalStorage().readFile(file.getAbsolutePath()); - } - return result; - } - - public boolean writeFile(String content, String path) { - ByteArrayInputStream inputStream = new ByteArrayInputStream( - content.getBytes(charset)); - int size = -1; - byte[] cache = new byte[THRESHOLD]; - while ((size = inputStream.read(cache, 0, THRESHOLD)) != -1) { - if (isCurrentBufferFull(size)) { - doSave(calculateSavePath(path)); - changeToTheMaxRemainBuffer(); - } - this.getCurrentBuffer().writeToCurrentBuffer(size, cache); - } - return true; - } - - private boolean isCurrentBufferFull(int size) { - return getCurrentBuffer().getRemainSize() <= THRESHOLD + size; - } - - public String calculateSavePath(String path, int index) { - return path.substring(0, path.lastIndexOf(".")) + "_" + index + ".xml"; - } - - private String calculateSavePath(String path) { - return calculateSavePath(path, this.getCurrentBufferIndex()); - } - - private void doSave(final String path) { - final Buffer bufferUnderSave = this.getCurrentBuffer(); - final String writeContent = this.getMeaningfulContent(); - Runnable runnable = new Runnable() { - public void run() { - getLocalStorage().writeFile(writeContent, path); - bufferUnderSave.reset(); - forTest.setSuccess(true); - } - }; - ExecutorService service = Executors.newFixedThreadPool(1); - service.execute(runnable); - service.shutdown(); - - } - - private String getMeaningfulContent() { - byte[] meaningfulContent = new byte[getCurrentBuffer().getCurrentPos()]; - System.arraycopy(getCurrentBuffer().getContent(), 0, meaningfulContent, - 0, getCurrentBuffer().getCurrentPos()); - return new String(meaningfulContent); - } - - private void changeToTheMaxRemainBuffer() { - int maxRemainSize = 2 * THRESHOLD; - int maxRemainSizeBufferIndex = -1; - for (int i = 0; i < this.getBufferList().size(); ++i) { - System.out.println(i + " remain : " - + this.getBufferList().get(i).getRemainSize()); - if (this.getBufferList().get(i).getRemainSize() > maxRemainSize) { - maxRemainSize = this.getBufferList().get(i).getRemainSize(); - maxRemainSizeBufferIndex = i; - } - } - if (maxRemainSizeBufferIndex == -1) { - this.getBufferList().add(Buffer.createBuffer(BUFFER_SIZE)); - maxRemainSizeBufferIndex = this.getBufferList().size() - 1; - } - this.setCurrentBufferIndex(maxRemainSizeBufferIndex); - } - - private Buffer getCurrentBuffer() { - return this.getBufferList().get(this.getCurrentBufferIndex()); - } - - public void flush() { - - } -} +package org.bench4q.agent.storage; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FilenameFilter; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import org.bench4q.share.models.agent.CleanTestResultModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class DoubleBufferStorage { + private static final int THRESHOLD = 1024; + private static Charset charset = Charset.forName("utf-8"); + private static int BUFFER_SIZE = 48 * 1024; + private List bufferList; + private int currentBufferIndex; + private LocalStorage localStorage; + public CleanTestResultModel forTest = new CleanTestResultModel(); + + private int getCurrentBufferIndex() { + return currentBufferIndex; + } + + private void setCurrentBufferIndex(int currentBuffer) { + this.currentBufferIndex = currentBuffer; + } + + private List getBufferList() { + return bufferList; + } + + private void setBufferList(List bufferList) { + this.bufferList = bufferList; + } + + private LocalStorage getLocalStorage() { + return localStorage; + } + + @Autowired + private void setLocalStorage(LocalStorage localStorage) { + this.localStorage = localStorage; + } + + public DoubleBufferStorage() { + this.setBufferList(new ArrayList()); + this.getBufferList().add(Buffer.createBuffer(BUFFER_SIZE)); + this.getBufferList().add(Buffer.createBuffer(BUFFER_SIZE)); + this.setCurrentBufferIndex(0); + } + + public String readFiles(String pathPrefix) { + int pos = pathPrefix.lastIndexOf(System.getProperty("file.separator")); + String dirPath = pathPrefix.substring(0, pos); + final String prefix = pathPrefix.substring(pos + 1); + String result = new String(); + + File dirFile = new File(dirPath); + if (!dirFile.exists()) { + return ""; + } + File[] files = dirFile.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.contains(prefix); + } + }); + for (File file : files) { + if (!file.exists()) { + continue; + } + result += this.getLocalStorage().readFile(file.getAbsolutePath()); + } + return result; + } + + public boolean writeFile(String content, String path) { + ByteArrayInputStream inputStream = new ByteArrayInputStream( + content.getBytes(charset)); + int size = -1; + byte[] cache = new byte[THRESHOLD]; + while ((size = inputStream.read(cache, 0, THRESHOLD)) != -1) { + if (isCurrentBufferFull(size)) { + doSave(calculateSavePath(path)); + changeToTheMaxRemainBuffer(); + } + this.getCurrentBuffer().writeToCurrentBuffer(size, cache); + } + return true; + } + + private boolean isCurrentBufferFull(int size) { + return getCurrentBuffer().getRemainSize() <= THRESHOLD + size; + } + + public String calculateSavePath(String path, int index) { + return path.substring(0, path.lastIndexOf(".")) + "_" + index + ".xml"; + } + + private String calculateSavePath(String path) { + return calculateSavePath(path, this.getCurrentBufferIndex()); + } + + private void doSave(final String path) { + final Buffer bufferUnderSave = this.getCurrentBuffer(); + final String writeContent = this.getMeaningfulContent(); + Runnable runnable = new Runnable() { + public void run() { + getLocalStorage().writeFile(writeContent, path); + bufferUnderSave.reset(); + forTest.setSuccess(true); + } + }; + ExecutorService service = Executors.newFixedThreadPool(1); + service.execute(runnable); + service.shutdown(); + + } + + private String getMeaningfulContent() { + byte[] meaningfulContent = new byte[getCurrentBuffer().getCurrentPos()]; + System.arraycopy(getCurrentBuffer().getContent(), 0, meaningfulContent, + 0, getCurrentBuffer().getCurrentPos()); + return new String(meaningfulContent); + } + + private void changeToTheMaxRemainBuffer() { + int maxRemainSize = 2 * THRESHOLD; + int maxRemainSizeBufferIndex = -1; + for (int i = 0; i < this.getBufferList().size(); ++i) { + System.out.println(i + " remain : " + + this.getBufferList().get(i).getRemainSize()); + if (this.getBufferList().get(i).getRemainSize() > maxRemainSize) { + maxRemainSize = this.getBufferList().get(i).getRemainSize(); + maxRemainSizeBufferIndex = i; + } + } + if (maxRemainSizeBufferIndex == -1) { + this.getBufferList().add(Buffer.createBuffer(BUFFER_SIZE)); + maxRemainSizeBufferIndex = this.getBufferList().size() - 1; + } + this.setCurrentBufferIndex(maxRemainSizeBufferIndex); + } + + private Buffer getCurrentBuffer() { + return this.getBufferList().get(this.getCurrentBufferIndex()); + } + + public void flush() { + + } +} diff --git a/src/main/java/org/bench4q/agent/storage/HdfsStorage.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/HdfsStorage.java similarity index 96% rename from src/main/java/org/bench4q/agent/storage/HdfsStorage.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/HdfsStorage.java index 8738ef3b..9d9e0694 100644 --- a/src/main/java/org/bench4q/agent/storage/HdfsStorage.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/HdfsStorage.java @@ -1,140 +1,140 @@ -package org.bench4q.agent.storage; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FSDataInputStream; -import org.apache.hadoop.fs.FSDataOutputStream; -import org.apache.hadoop.fs.FileStatus; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.io.IOUtils; -import org.springframework.stereotype.Component; - -@Component -public class HdfsStorage implements Storage { - private FileSystem getFileSystem() throws IOException { - Configuration conf = new Configuration(); - conf.set("mapred.jop.tracker", "hdfs://133.133.12.21:9001"); - conf.set("fs.default.name", "hdfs://133.133.12.21:9000"); - return FileSystem.get(conf); - } - - public boolean uploadFile(String localPath, String remotePath) { - try { - FileSystem fs = this.getFileSystem(); - fs.copyFromLocalFile(new Path(localPath), new Path(remotePath)); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean writeFile(String content, String remotePath) { - try { - InputStream in = new ByteArrayInputStream(content.getBytes()); - FileSystem fs = this.getFileSystem(); - OutputStream out = fs.create(new Path(remotePath)); - IOUtils.copyBytes(in, out, 4096, true); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean downloadFile(String localPath, String remotePath) { - try { - FileSystem fs = this.getFileSystem(); - fs.copyToLocalFile(new Path(remotePath), new Path(localPath)); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public String readFile(String remotePath) { - try { - FileSystem fs = this.getFileSystem(); - FSDataInputStream hdfsInStream = fs.open(new Path(remotePath)); - OutputStream out = new ByteArrayOutputStream(); - byte[] ioBuffer = new byte[1024]; - int readLen = hdfsInStream.read(ioBuffer); - while (-1 != readLen) { - out.write(ioBuffer, 0, readLen); - readLen = hdfsInStream.read(ioBuffer); - } - out.close(); - String ret = out.toString(); - hdfsInStream.close(); - return ret; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public boolean appendFile(String content, String remotePath) { - try { - FileSystem fs = this.getFileSystem(); - FSDataOutputStream out = fs.append(new Path(remotePath)); - int readLen = content.getBytes().length; - while (-1 != readLen) { - out.write(content.getBytes(), 0, readLen); - } - out.close(); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean deleteFile(String remotePath) { - try { - FileSystem fs = this.getFileSystem(); - return fs.delete(new Path(remotePath), false); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean deleteDirectory(String remotePath) { - try { - FileSystem fs = this.getFileSystem(); - return fs.delete(new Path(remotePath), true); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean renameFile(String fromPath, String toPath) { - try { - FileSystem fs = this.getFileSystem(); - return fs.rename(new Path(fromPath), new Path(toPath)); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public FileStatus[] listFile(String remotePath) { - try { - FileSystem fs = this.getFileSystem(); - FileStatus[] fileList = fs.listStatus(new Path(remotePath)); - return fileList; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - -} +package org.bench4q.agent.storage; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.IOUtils; +import org.springframework.stereotype.Component; + +@Component +public class HdfsStorage implements Storage { + private FileSystem getFileSystem() throws IOException { + Configuration conf = new Configuration(); + conf.set("mapred.jop.tracker", "hdfs://133.133.12.21:9001"); + conf.set("fs.default.name", "hdfs://133.133.12.21:9000"); + return FileSystem.get(conf); + } + + public boolean uploadFile(String localPath, String remotePath) { + try { + FileSystem fs = this.getFileSystem(); + fs.copyFromLocalFile(new Path(localPath), new Path(remotePath)); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public boolean writeFile(String content, String remotePath) { + try { + InputStream in = new ByteArrayInputStream(content.getBytes()); + FileSystem fs = this.getFileSystem(); + OutputStream out = fs.create(new Path(remotePath)); + IOUtils.copyBytes(in, out, 4096, true); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public boolean downloadFile(String localPath, String remotePath) { + try { + FileSystem fs = this.getFileSystem(); + fs.copyToLocalFile(new Path(remotePath), new Path(localPath)); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public String readFile(String remotePath) { + try { + FileSystem fs = this.getFileSystem(); + FSDataInputStream hdfsInStream = fs.open(new Path(remotePath)); + OutputStream out = new ByteArrayOutputStream(); + byte[] ioBuffer = new byte[1024]; + int readLen = hdfsInStream.read(ioBuffer); + while (-1 != readLen) { + out.write(ioBuffer, 0, readLen); + readLen = hdfsInStream.read(ioBuffer); + } + out.close(); + String ret = out.toString(); + hdfsInStream.close(); + return ret; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public boolean appendFile(String content, String remotePath) { + try { + FileSystem fs = this.getFileSystem(); + FSDataOutputStream out = fs.append(new Path(remotePath)); + int readLen = content.getBytes().length; + while (-1 != readLen) { + out.write(content.getBytes(), 0, readLen); + } + out.close(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public boolean deleteFile(String remotePath) { + try { + FileSystem fs = this.getFileSystem(); + return fs.delete(new Path(remotePath), false); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public boolean deleteDirectory(String remotePath) { + try { + FileSystem fs = this.getFileSystem(); + return fs.delete(new Path(remotePath), true); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public boolean renameFile(String fromPath, String toPath) { + try { + FileSystem fs = this.getFileSystem(); + return fs.rename(new Path(fromPath), new Path(toPath)); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public FileStatus[] listFile(String remotePath) { + try { + FileSystem fs = this.getFileSystem(); + FileStatus[] fileList = fs.listStatus(new Path(remotePath)); + return fileList; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/org/bench4q/agent/storage/LocalStorage.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/LocalStorage.java similarity index 100% rename from src/main/java/org/bench4q/agent/storage/LocalStorage.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/LocalStorage.java diff --git a/src/main/java/org/bench4q/agent/storage/MooseStorage.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/MooseStorage.java similarity index 94% rename from src/main/java/org/bench4q/agent/storage/MooseStorage.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/MooseStorage.java index 729e8520..ec8eabfb 100644 --- a/src/main/java/org/bench4q/agent/storage/MooseStorage.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/MooseStorage.java @@ -1,17 +1,17 @@ -package org.bench4q.agent.storage; - -import org.springframework.stereotype.Component; - -@Component -public class MooseStorage implements Storage { - - public String readFile(String path) { - - return null; - } - - public boolean writeFile(String content, String path) { - return false; - } - -} +package org.bench4q.agent.storage; + +import org.springframework.stereotype.Component; + +@Component +public class MooseStorage implements Storage { + + public String readFile(String path) { + + return null; + } + + public boolean writeFile(String content, String path) { + return false; + } + +} diff --git a/src/main/java/org/bench4q/agent/storage/Storage.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/Storage.java similarity index 100% rename from src/main/java/org/bench4q/agent/storage/Storage.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/Storage.java diff --git a/src/main/java/org/bench4q/agent/storage/StorageHelper.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/StorageHelper.java similarity index 100% rename from src/main/java/org/bench4q/agent/storage/StorageHelper.java rename to Bench4Q-Agent/src/main/java/org/bench4q/agent/storage/StorageHelper.java diff --git a/src/main/resources/log4j.properties b/Bench4Q-Agent/src/main/resources/log4j.properties similarity index 97% rename from src/main/resources/log4j.properties rename to Bench4Q-Agent/src/main/resources/log4j.properties index 92df3136..0fa2c1c5 100644 --- a/src/main/resources/log4j.properties +++ b/Bench4Q-Agent/src/main/resources/log4j.properties @@ -1,31 +1,31 @@ -log4j.rootLogger = INFO,WARN,ERROR,FALTAL,D - -log4j.appender.WARN = org.apache.log4j.DailyRollingFileAppender -log4j.appender.WARN.File = logs/log.log -log4j.appender.WARN.Append = true -log4j.appender.WARN.Threshold = WARN -log4j.appender.WARN.layout = org.apache.log4j.PatternLayout -log4j.appender.WARN.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n - -log4j.appender.ERROR = org.apache.log4j.DailyRollingFileAppender -log4j.appender.ERROR.File = logs/log.log -log4j.appender.ERROR.Append = true -log4j.appender.ERROR.Threshold = ERROR -log4j.appender.ERROR.layout = org.apache.log4j.PatternLayout -log4j.appender.ERROR.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n - -log4j.appender.FALTAL = org.apache.log4j.DailyRollingFileAppender -log4j.appender.FALTAL.File = logs/log.log -log4j.appender.FALTAL.Append = true -log4j.appender.FALTAL.Threshold = ERROR -log4j.appender.FALTAL.layout = org.apache.log4j.PatternLayout -log4j.appender.FALTAL.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n - - -log4j.appender.D = org.apache.log4j.DailyRollingFileAppender -log4j.appender.D.File = logs/log.log -log4j.appender.D.Append = true -log4j.appender.D.Threshold = INFO -log4j.appender.D.layout = org.apache.log4j.PatternLayout -log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n - +log4j.rootLogger = INFO,WARN,ERROR,FALTAL,D + +log4j.appender.WARN = org.apache.log4j.DailyRollingFileAppender +log4j.appender.WARN.File = logs/log.log +log4j.appender.WARN.Append = true +log4j.appender.WARN.Threshold = WARN +log4j.appender.WARN.layout = org.apache.log4j.PatternLayout +log4j.appender.WARN.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n + +log4j.appender.ERROR = org.apache.log4j.DailyRollingFileAppender +log4j.appender.ERROR.File = logs/log.log +log4j.appender.ERROR.Append = true +log4j.appender.ERROR.Threshold = ERROR +log4j.appender.ERROR.layout = org.apache.log4j.PatternLayout +log4j.appender.ERROR.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n + +log4j.appender.FALTAL = org.apache.log4j.DailyRollingFileAppender +log4j.appender.FALTAL.File = logs/log.log +log4j.appender.FALTAL.Append = true +log4j.appender.FALTAL.Threshold = ERROR +log4j.appender.FALTAL.layout = org.apache.log4j.PatternLayout +log4j.appender.FALTAL.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n + + +log4j.appender.D = org.apache.log4j.DailyRollingFileAppender +log4j.appender.D.File = logs/log.log +log4j.appender.D.Append = true +log4j.appender.D.Threshold = INFO +log4j.appender.D.layout = org.apache.log4j.PatternLayout +log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n + diff --git a/src/main/resources/org/bench4q/agent/config/application-context.xml b/Bench4Q-Agent/src/main/resources/org/bench4q/agent/config/application-context.xml similarity index 100% rename from src/main/resources/org/bench4q/agent/config/application-context.xml rename to Bench4Q-Agent/src/main/resources/org/bench4q/agent/config/application-context.xml diff --git a/src/test/java/org/bench4q/agent/test/ExtractScenarioTest.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/ExtractScenarioTest.java similarity index 96% rename from src/test/java/org/bench4q/agent/test/ExtractScenarioTest.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/ExtractScenarioTest.java index f6e137e8..8912eea5 100644 --- a/src/test/java/org/bench4q/agent/test/ExtractScenarioTest.java +++ b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/ExtractScenarioTest.java @@ -1,27 +1,27 @@ -package org.bench4q.agent.test; - -import static org.junit.Assert.*; - -import java.io.File; -import java.io.IOException; - -import javax.xml.bind.JAXBException; - -import org.apache.commons.io.FileUtils; -import org.bench4q.agent.scenario.Scenario; -import org.bench4q.share.helper.MarshalHelper; -import org.bench4q.share.models.agent.RunScenarioModel; -import org.junit.Test; - -public class ExtractScenarioTest { - - @Test - public void test() throws JAXBException, IOException { - RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper - .unmarshal(RunScenarioModel.class, FileUtils - .readFileToString(new File("Scripts/goodForPage.xml"))); - Scenario scenario = Scenario.scenarioBuilder(runScenarioModel); - - assertTrue(scenario.getPages().length > 0); - } -} +package org.bench4q.agent.test; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; + +import javax.xml.bind.JAXBException; + +import org.apache.commons.io.FileUtils; +import org.bench4q.agent.scenario.Scenario; +import org.bench4q.share.helper.MarshalHelper; +import org.bench4q.share.models.agent.RunScenarioModel; +import org.junit.Test; + +public class ExtractScenarioTest { + + @Test + public void test() throws JAXBException, IOException { + RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper + .unmarshal(RunScenarioModel.class, FileUtils + .readFileToString(new File("Scripts/goodForPage.xml"))); + Scenario scenario = Scenario.scenarioBuilder(runScenarioModel); + + assertTrue(scenario.getPages().length > 0); + } +} diff --git a/src/test/java/org/bench4q/agent/test/HomeControllerTest.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/HomeControllerTest.java similarity index 93% rename from src/test/java/org/bench4q/agent/test/HomeControllerTest.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/HomeControllerTest.java index b71431f8..6902b437 100644 --- a/src/test/java/org/bench4q/agent/test/HomeControllerTest.java +++ b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/HomeControllerTest.java @@ -1,5 +1,5 @@ -package org.bench4q.agent.test; - -public class HomeControllerTest { - -} +package org.bench4q.agent.test; + +public class HomeControllerTest { + +} diff --git a/src/test/java/org/bench4q/agent/test/MainTest.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/MainTest.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/MainTest.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/MainTest.java diff --git a/src/test/java/org/bench4q/agent/test/PluginControllerTest.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/PluginControllerTest.java similarity index 93% rename from src/test/java/org/bench4q/agent/test/PluginControllerTest.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/PluginControllerTest.java index f800f1b5..ca35983c 100644 --- a/src/test/java/org/bench4q/agent/test/PluginControllerTest.java +++ b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/PluginControllerTest.java @@ -1,5 +1,5 @@ -package org.bench4q.agent.test; - -public class PluginControllerTest { - -} +package org.bench4q.agent.test; + +public class PluginControllerTest { + +} diff --git a/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/TestWithScriptFile.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java diff --git a/src/test/java/org/bench4q/agent/test/datastatistics/DetailStatisticsTest.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/datastatistics/DetailStatisticsTest.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/datastatistics/DetailStatisticsTest.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/datastatistics/DetailStatisticsTest.java diff --git a/src/test/java/org/bench4q/agent/test/datastatistics/PageResultStatisticsTest.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/datastatistics/PageResultStatisticsTest.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/datastatistics/PageResultStatisticsTest.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/datastatistics/PageResultStatisticsTest.java diff --git a/src/test/java/org/bench4q/agent/test/datastatistics/ScenarioStatisticsTest.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/datastatistics/ScenarioStatisticsTest.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/datastatistics/ScenarioStatisticsTest.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/datastatistics/ScenarioStatisticsTest.java diff --git a/src/test/java/org/bench4q/agent/test/model/ModelTest.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/model/ModelTest.java similarity index 96% rename from src/test/java/org/bench4q/agent/test/model/ModelTest.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/model/ModelTest.java index 698d2df9..b11ce4b3 100644 --- a/src/test/java/org/bench4q/agent/test/model/ModelTest.java +++ b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/model/ModelTest.java @@ -1,30 +1,30 @@ -package org.bench4q.agent.test.model; - -import java.io.File; -import java.io.IOException; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.annotation.XmlRootElement; - -import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; -import org.junit.Test; - -import static org.junit.Assert.*; - -@XmlRootElement(name = "modelTest") -public class ModelTest { - - @Test - public void unmarshalVerify() throws IOException, JAXBException { - Object object = JAXBContext - .newInstance(BehaviorModel.class) - .createUnmarshaller() - .unmarshal( - new File("Scripts" - + System.getProperty("file.separator") - + "behaviorModel.xml")); - assertTrue(object instanceof BehaviorModel); - } - -} +package org.bench4q.agent.test.model; + +import java.io.File; +import java.io.IOException; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.annotation.XmlRootElement; + +import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; +import org.junit.Test; + +import static org.junit.Assert.*; + +@XmlRootElement(name = "modelTest") +public class ModelTest { + + @Test + public void unmarshalVerify() throws IOException, JAXBException { + Object object = JAXBContext + .newInstance(BehaviorModel.class) + .createUnmarshaller() + .unmarshal( + new File("Scripts" + + System.getProperty("file.separator") + + "behaviorModel.xml")); + assertTrue(object instanceof BehaviorModel); + } + +} diff --git a/src/test/java/org/bench4q/agent/test/model/UserBehaviorModelTest.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/model/UserBehaviorModelTest.java similarity index 96% rename from src/test/java/org/bench4q/agent/test/model/UserBehaviorModelTest.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/model/UserBehaviorModelTest.java index 6be857b2..c74138d7 100644 --- a/src/test/java/org/bench4q/agent/test/model/UserBehaviorModelTest.java +++ b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/model/UserBehaviorModelTest.java @@ -1,26 +1,26 @@ -package org.bench4q.agent.test.model; - -import static org.junit.Assert.*; - -import java.io.File; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; -import org.junit.Test; - -public class UserBehaviorModelTest { - - @Test - public void testUnmarshal() throws JAXBException { - Unmarshaller unmarshaller = JAXBContext.newInstance( - BehaviorModel.class).createUnmarshaller(); - Object object = unmarshaller.unmarshal(new File("Scripts" - + System.getProperty("file.separator") + "behaviorModel.xml")); - BehaviorModel userBehaviorModel = (BehaviorModel) object; - System.out.println(userBehaviorModel.getUse()); - assertTrue(object instanceof BehaviorModel); - } -} +package org.bench4q.agent.test.model; + +import static org.junit.Assert.*; + +import java.io.File; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; +import org.junit.Test; + +public class UserBehaviorModelTest { + + @Test + public void testUnmarshal() throws JAXBException { + Unmarshaller unmarshaller = JAXBContext.newInstance( + BehaviorModel.class).createUnmarshaller(); + Object object = unmarshaller.unmarshal(new File("Scripts" + + System.getProperty("file.separator") + "behaviorModel.xml")); + BehaviorModel userBehaviorModel = (BehaviorModel) object; + System.out.println(userBehaviorModel.getUse()); + assertTrue(object instanceof BehaviorModel); + } +} diff --git a/src/test/java/org/bench4q/agent/test/parameterization/TEST_HelloThread.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/parameterization/TEST_HelloThread.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/parameterization/TEST_HelloThread.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/parameterization/TEST_HelloThread.java diff --git a/src/test/java/org/bench4q/agent/test/parameterization/TEST_UserName.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/parameterization/TEST_UserName.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/parameterization/TEST_UserName.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/parameterization/TEST_UserName.java diff --git a/src/test/java/org/bench4q/agent/test/parameterization/Test_ParameterizationParser.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/parameterization/Test_ParameterizationParser.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/parameterization/Test_ParameterizationParser.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/parameterization/Test_ParameterizationParser.java diff --git a/src/test/java/org/bench4q/agent/test/plugin/Test_HttpPlugin.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/plugin/Test_HttpPlugin.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/plugin/Test_HttpPlugin.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/plugin/Test_HttpPlugin.java diff --git a/src/test/java/org/bench4q/agent/test/scenario/Test_ScenarioContext.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/Test_ScenarioContext.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/scenario/Test_ScenarioContext.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/Test_ScenarioContext.java diff --git a/src/test/java/org/bench4q/agent/test/scenario/utils/Test_ParameterParser.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/utils/Test_ParameterParser.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/scenario/utils/Test_ParameterParser.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/utils/Test_ParameterParser.java diff --git a/src/test/java/org/bench4q/agent/test/scenario/utils/Test_RegularExpression.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/utils/Test_RegularExpression.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/scenario/utils/Test_RegularExpression.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/utils/Test_RegularExpression.java diff --git a/src/test/java/org/bench4q/agent/test/storage/TestDoubleBufferStorage.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/storage/TestDoubleBufferStorage.java similarity index 100% rename from src/test/java/org/bench4q/agent/test/storage/TestDoubleBufferStorage.java rename to Bench4Q-Agent/src/test/java/org/bench4q/agent/test/storage/TestDoubleBufferStorage.java diff --git a/src/test/resources/test-storage-context.xml b/Bench4Q-Agent/src/test/resources/test-storage-context.xml similarity index 98% rename from src/test/resources/test-storage-context.xml rename to Bench4Q-Agent/src/test/resources/test-storage-context.xml index a9e939f0..dcef0042 100644 --- a/src/test/resources/test-storage-context.xml +++ b/Bench4Q-Agent/src/test/resources/test-storage-context.xml @@ -1,11 +1,11 @@ - - - - - + + + + + diff --git a/license.txt b/license.txt deleted file mode 100644 index ed5165d8..00000000 --- a/license.txt +++ /dev/null @@ -1,339 +0,0 @@ -GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., [http://fsf.org/] - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {description} - Copyright (C) {year} {fullname} - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - {signature of Ty Coon}, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. \ No newline at end of file