parent
103153f737
commit
03601007eb
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -1 +0,0 @@
|
|||
row1;10;11~row2;20;21~row3,30,31~
|
|
@ -79,6 +79,12 @@
|
|||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<!-- for HBase plugin -->
|
||||
<dependency>
|
||||
<groupId>org.apache.hbase</groupId>
|
||||
<artifactId>hbase</artifactId>
|
||||
<version>0.94.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package org.bench4q.agent.plugin.basic.hbase;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
|
||||
public class GenerateDevices {
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
Configuration conf = HBaseConfiguration.create();
|
||||
try {
|
||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||
HTable table = new HTable(conf, "Devices");
|
||||
for (int i = 10002, j = 1002; i < 20000; i++, j++) {
|
||||
Put put = new Put(String.valueOf(i).getBytes());
|
||||
put.add("INFO".getBytes(), "UserId".getBytes(),
|
||||
String.valueOf(j).getBytes());
|
||||
table.put(put);
|
||||
System.out.println(i + "_" + j);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package org.bench4q.agent.plugin.basic.hbase;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.client.Get;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.client.Result;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
||||
public class GenerateRecords {
|
||||
public String userId = null;
|
||||
private Configuration conf = HBaseConfiguration.create();
|
||||
|
||||
public boolean openAndRes(byte[] type, String deviceId, String logicalName,
|
||||
String id, String contextName) {
|
||||
|
||||
try {
|
||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||
HTable table = new HTable(conf, "Devices");
|
||||
Get get = new Get(Bytes.toBytes(deviceId));
|
||||
Result retDev = table.get(get);
|
||||
if (retDev == null) {
|
||||
System.out.println("this dev is not register");
|
||||
return false;
|
||||
}
|
||||
userId = Bytes.toString(retDev.getValue("INFO".getBytes(),
|
||||
"UserId".getBytes()));
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean send(double sum, double usage, double U, double I,
|
||||
String time_userId) {
|
||||
try {
|
||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||
HTable table = new HTable(conf, "MeterLogData");
|
||||
Put put = new Put(time_userId.getBytes());
|
||||
put.add("AI".getBytes(), "Usage".getBytes(), String.valueOf(usage)
|
||||
.getBytes());
|
||||
put.add("EU".getBytes(), "Sum".getBytes(), String.valueOf(sum)
|
||||
.getBytes());
|
||||
put.add("SI".getBytes(), "U".getBytes(), String.valueOf(U)
|
||||
.getBytes());
|
||||
put.add("SI".getBytes(), "I".getBytes(), String.valueOf(I)
|
||||
.getBytes());
|
||||
table.put(put);
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue