node.js - Nodejs Cassandra Client [node-cassandra-client] -
node.js - Nodejs Cassandra Client [node-cassandra-client] -
i tried connecting cassandra cluster [version 1.0.6] via nodejs using node-cassandra-client
this sample script
var connection = require('cassandra-client').connection; var con = new connection({host:'x.x.x.x', port:9160, keyspace:'stats', timeout:10000}); console.log(con); con.execute('update testcf ?=? key=?', ['cola', '1', '20120132'], function(err) { if (err) { console.log("failed"); } else { console.log("success"); } });
on executing script
"sys" module called "util". should have similar interface. node-cassandra-client.driver: connecting x.x.x.x:9160 {} { validators: {}, client: null, connectioninfo: { host: 'x.x.x.x', port: 9160, keyspace: 'stats', timeout: 10000 }, timeout: 10000 } node.js:201 throw e; // process.nexttick error, or 'error' event on first tick ^ typeerror: cannot phone call method 'execute_cql_query' of null @ [object object].execute (/home/tamil/workspace/testprojects/node-cass/node_modules/cassandra-client/lib/driver.js:367:17) @ object.<anonymous> (/home/tamil/workspace/testprojects/node-cass/index.js:5:5) @ module._compile (module.js:432:26) @ object..js (module.js:450:10) @ module.load (module.js:351:31) @ function._load (module.js:310:12) @ array.0 (module.js:470:10) @ eventemitter._tickcallback (node.js:192:40)
my nodetool stats
address dc rack status state load owns token x.x.x.x datacenter1 rack1 normal 1.03 mb 100.00% 0
what error reason? , need help prepare this
the client within connection null. need connect() first. here's illustration (ignores errors):
var con = new connection({host:'x.x.x.x', port:9160, keyspace:'stats', timeout:10000}); con.connect(function(err) { assert.iferror(err); con.execute('select count(*) testcf', [], function(err, rows) { con.close(function(err) { // you're done now. }); }); });
i recommend using async handle ordering of connct, query, close, etc.
node.js cassandra
Comments
Post a Comment