forked from alexguan/node-zookeeper-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acl.js
43 lines (34 loc) · 1.03 KB
/
acl.js
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
/**
* 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];
var acls = [
new zookeeper.ACL(
zookeeper.Permission.ADMIN,
new zookeeper.Id('ip', '127.0.0.1')
)
];
client.on('connected', function (state) {
console.log('Connected to the server.');
client.setACL(path, acls, -1, function (error, stat) {
if (error) {
console.log('Failed to set ACL: %s.', error);
return;
}
console.log('ACL is set to: %j', acls);
client.getACL(path, function (error, acls, stat) {
if (error) {
console.log('Failed to get ACL: %s.', error);
return;
}
console.log('ACL of node: %s is: %j', path, acls);
client.close();
});
});
});
client.connect();