now we can run the HBasePlugin

now we can run the HBasePlugin
This commit is contained in:
coderfengyun 2014-03-28 09:53:47 +08:00
parent e132fd792b
commit dc0d07a240
6 changed files with 279 additions and 288 deletions

View File

@ -1,264 +1,264 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<runScenario>
<pages>
<page>
<batches>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>1</value>
</parameter>
<parameter>
<key>endUser</key>
<value>100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>1</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>1001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>1100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>2</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>2001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>2100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>3</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>3001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>3100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>4</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>4001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>4100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>5</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>5001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>5100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>6</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>6001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>6100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>7</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>7001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>7100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>8</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>8001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>8100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>9</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>9001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>9100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>0</id>
<parentId>-1</parentId>
</batch>
</batches>
</page>
</pages>
<poolSize>0</poolSize>
<usePlugins>
<usePlugin>
<id>hBase</id>
<name>HBase</name>
<parameters />
</usePlugin>
</usePlugins>
<pages>
<page>
<batches>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>1</value>
</parameter>
<parameter>
<key>endUser</key>
<value>100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>1</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>1001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>1100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>2</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>2001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>2100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>3</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>3001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>3100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>4</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>4001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>4100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>5</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>5001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>5100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>6</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>6001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>6100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>7</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>7001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>7100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>8</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>8001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>8100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>9</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>9001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>9100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>0</id>
<parentId>-1</parentId>
</batch>
</batches>
</page>
</pages>
<poolSize>1</poolSize>
<usePlugins>
<usePlugin>
<id>hBase</id>
<name>Hbase</name>
<parameters/>
</usePlugin>
</usePlugins>
</runScenario>

View File

@ -1,6 +1,5 @@
package org.bench4q.agent.plugin.basic;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@ -13,7 +12,7 @@ public abstract class PluginReturn {
return successCount;
}
public void setSuccessCount(int successCount) {
private void setSuccessCount(int successCount) {
this.successCount = successCount;
}
@ -21,7 +20,7 @@ public abstract class PluginReturn {
return failCount;
}
public void setFailCount(int failCount) {
private void setFailCount(int failCount) {
this.failCount = failCount;
}
@ -38,9 +37,15 @@ public abstract class PluginReturn {
}
public PluginReturn(boolean success) {
this();
this.setSuccessCount(success ? 1 : 0);
this.setFailCount(success ? 0 : 1);
this.setRunTimeParams(new HashMap<String, String>());
}
public PluginReturn(int successCount, int failCount) {
this();
this.setSuccessCount(successCount);
this.setFailCount(failCount);
}
public boolean hasRunTimeParams() {

View File

@ -3,24 +3,7 @@ package org.bench4q.agent.plugin.basic.hbase;
import org.bench4q.agent.plugin.basic.PluginReturn;
public class ElectReturn extends PluginReturn {
long succNum;
long failNum;
public ElectReturn(long s , long f)
{
this.setSuccNum(s);
this.setFailNum(f);
public ElectReturn(int succ, int fail) {
super(succ, fail);
}
public long getSuccNum() {
return succNum;
}
public void setSuccNum(long succNum) {
this.succNum = succNum;
}
public long getFailNum() {
return failNum;
}
public void setFailNum(long failNum) {
this.failNum = failNum;
}
}

View File

@ -42,8 +42,8 @@ public class HBasePlugin {
for (int i = 0; i <= eu - bu; i++) {
sum[i] = 0;
}
long succ = 0;
long fail = 0;
int succ = 0;
int fail = 0;
for (Date a = new Date(beginDatetime.getTime()); a.before(endDatetime);) {
for (int i = bu; i <= eu; i++) {
usage = r.nextDouble() * 1000;

View File

@ -27,7 +27,7 @@ public class Test_HBasePlugin {
RunScenarioModel result = buildScenario(10);
assertEquals(1, result.getUsePlugins().size());
assertEquals("hBase", result.getUsePlugins().get(0).getId());
assertEquals("HBase", result.getUsePlugins().get(0).getName());
assertEquals("Hbase", result.getUsePlugins().get(0).getName());
assertEquals(1, result.getPages().size());
assertEquals(1, result.getPages().get(0).getBatches().size());
assertEquals(10, result.getPages().get(0).getBatches().get(0)
@ -54,6 +54,7 @@ public class Test_HBasePlugin {
assertEquals("endUser", behavior.getParameters().get(3).getKey());
}
try {
result.setPoolSize(1);
File scriptFile = new File("Scripts"
+ System.getProperty("file.separator") + "HBaseScript.xml");
TestHelper.createFileIfNotExist(scriptFile);
@ -70,7 +71,7 @@ public class Test_HBasePlugin {
List<UsePluginModel> usePluginList = new ArrayList<UsePluginModel>();
UsePluginModel plugin = new UsePluginModel();
plugin.setId("hBase");
plugin.setName("HBase");
plugin.setName("Hbase");
plugin.setParameters(Collections.<ParameterModel> emptyList());
usePluginList.add(plugin);
runScenarioModel.setUsePlugins(usePluginList);

View File

@ -53,6 +53,8 @@ public class Test_Worker {
Worker testWorker = createAWorker();
try {
HttpReturn httpReturn = new HttpReturn(true, 200, 100, "text/html");
// TestHelper.invokePrivate(httpReturn, "setRunTimeParams",
// new Class[] { Map.class }, new Object[] { null });
httpReturn.setRunTimeParams(null);
TestHelper.invokePrivate(testWorker, "extractRunTimeParams",
new Class[] { PluginReturn.class },