edit hbase

edit hbase
This commit is contained in:
coderfengyun 2014-03-25 11:25:01 +08:00
parent 80611426e4
commit 9ac50dda44
1 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,64 @@
package org.bench4q.agent.plugin.basic.hbase;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Random;
import org.bench4q.agent.plugin.Behavior;
import org.bench4q.agent.plugin.Parameter;
import org.bench4q.agent.plugin.Plugin;
import org.bench4q.agent.plugin.result.HttpReturn;
import org.bench4q.agent.utils.Type.SupportTypes;
@Plugin("Hbase")
public class hBasePlugin {
@Behavior("send")
public HttpReturn send(
@Parameter(value = "beginTime", type = SupportTypes.Field) String beginTime,
@Parameter(value = "endTime", type = SupportTypes.Field) String endTime,
@Parameter(value = "beginUser", type = SupportTypes.Field) String beginUser,
@Parameter(value = "endUser", type = SupportTypes.Field) String endUser) {
Random r = new Random();
double usage = 0, U = 0, I = 0;
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhmmssS");
Date beginDatetime = new Date(0), endDatetime = new Date(0);
try {
beginDatetime = df.parse(beginTime);
endDatetime = df.parse(endTime);
} catch (ParseException e) {
e.printStackTrace();
}
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(beginDatetime);
int bu = Integer.parseInt(beginUser);
int eu = Integer.parseInt(endUser);
GenerateRecords gr = new GenerateRecords();
double[] sum = new double[eu - bu + 1];
for (int i = 0; i <= eu - bu; i++) {
sum[i] = 0;
}
for (Date a = new Date(beginDatetime.getTime()); a.before(endDatetime);) {
for (int i = bu; i <= eu; i++) {
usage = r.nextDouble() * 1000;
U = r.nextDouble() * 1000;
I = r.nextDouble() * 1000;
sum[i - bu] += usage;
System.out.println(sum[i - bu] + "-" + usage + "-" + U + "-"
+ I + "-" + df.format(gc.getTime()) + "_"
+ String.valueOf(i));
// gr.send(sum[i - bu], usage, U, I, df.format(gc.getTime()) +
// "_"
// + String.valueOf(i));
}
gc.add(7, 15);
a = gc.getTime();
}
return new HttpReturn(false, eu, eu, endUser);
}
}