You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1022 B
42 lines
1022 B
/**
|
|
* Copyright (c) 2013 Yahoo! Inc. All rights reserved.
|
|
*
|
|
* Copyrights licensed under the MIT License. See the accompanying LICENSE file
|
|
* for terms.
|
|
*/
|
|
|
|
var zookeeper = require('../index.js');
|
|
|
|
var client = zookeeper.createClient(process.argv[2], { retries : 2 });
|
|
var path = process.argv[3];
|
|
|
|
function getData(client, path) {
|
|
client.getData(
|
|
path,
|
|
function (event) {
|
|
console.log('Got event: %s', event);
|
|
getData(client, path);
|
|
},
|
|
function (error, data, stat) {
|
|
if (error) {
|
|
console.log('Error occurred when getting data: %s.', error);
|
|
return;
|
|
}
|
|
|
|
console.log(
|
|
'Node: %s has data: %s, version: %d',
|
|
path,
|
|
data ? data.toString() : undefined,
|
|
stat.version
|
|
);
|
|
}
|
|
);
|
|
}
|
|
|
|
client.once('connected', function () {
|
|
console.log('Connected to ZooKeeper.');
|
|
getData(client, path);
|
|
});
|
|
|
|
client.connect();
|
|
|
|
|