-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdatabase.js
More file actions
50 lines (44 loc) · 1.16 KB
/
database.js
File metadata and controls
50 lines (44 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var hb_conf = require('./config.js').hbase,
moment = require('moment'),
hbase = require('hbase');
module.exports = {
client : hbase({
host : hb_conf.host,
port : hb_conf.port
}),
addPing : function (client, pk, datetime, trusted){
datetime = new Date(datetime);
dt = moment(datetime).format("YYYYMMDDHHmmss");
rowkey = dt+"|"+pk;
client
.getRow('validatorTracker', rowkey)
.put('data:trusted', trusted, function(error, success){
if (error) console.log(error);
});
},
createScanner : function(start,end,callback){
if (start == 0) start = '';
if (end == 0) end = '';
var pingScanner = new hbase.Scanner(client, 'validatorTracker');
pingScanner.create({
startRow: start,
endRow: end
},
function(error, cells){
if (error) callback(error);
else callback(null, pingScanner);
});
},
getPings : function (scanner, callback){
scanner.get(function(error, cells){
if (error) callback(error);
else if(cells){
callback(null, cells);
}
else{
this.delete();
callback("no entries with given filters");
}
});
}
}