-
Notifications
You must be signed in to change notification settings - Fork 1
/
Zookeeper.php
211 lines (176 loc) · 4.82 KB
/
Zookeeper.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
/**
* Zookeeper class.
*
* https://secure.php.net/manual/en/class.zookeeper.php
* https://github.com/andreiz/php-zookeeper/blob/master/zookeeper-api.php
*/
class Zookeeper {
//ZooKeeper Permissions
const PERM_READ = 1 ;
const PERM_WRITE = 2 ;
const PERM_CREATE = 4 ;
const PERM_DELETE = 8 ;
const PERM_ADMIN = 16 ;
const PERM_ALL = 31 ;
//ZooKeeper Log Levels
const LOG_LEVEL_ERROR = 1 ;
const LOG_LEVEL_WARN = 2 ;
const LOG_LEVEL_INFO = 3 ;
const LOG_LEVEL_DEBUG = 4 ;
//ZooKeeper States
const EXPIRED_SESSION_STATE = -112 ;
const AUTH_FAILED_STATE = -113 ;
const CONNECTING_STATE = 1 ;
const ASSOCIATING_STATE = 2 ;
const CONNECTED_STATE = 3 ;
const READONLY_STATE = 5 ;
const NOTCONNECTED_STATE = 999 ;
//flags
const EPHEMERAL = 1;
const SEQUENCE = 2;
const CREATED_EVENT = 1;
const DELETED_EVENT = 2;
const CHANGED_EVENT = 3;
const CHILD_EVENT = 4;
const SESSION_EVENT = -1;
const NOTWATCHING_EVENT = -2;
const SYSTEMERROR = -1;
const RUNTIMEINCONSISTENCY = -2;
const DATAINCONSISTENCY = -3;
const CONNECTIONLOSS = -4;
const MARSHALLINGERROR = -5;
const UNIMPLEMENTED = -6;
const OPERATIONTIMEOUT = -7;
const BADARGUMENTS = -8;
const INVALIDSTATE = -9;
const OK = 0;
const APIERROR = -100;
const NONODE = -101;
const NOAUTH = -102;
const BADVERSION = -103;
const NOCHILDRENFOREPHEMERALS = -108;
const NODEEXISTS = -110;
const NOTEMPTY = -111;
const SESSIONEXPIRED = -112;
const INVALIDCALLBACK = -113;
const INVALIDACL = -114;
const AUTHFAILED = -115;
const CLOSING = -116;
const NOTHING = -117;
const SESSIONMOVED = -118;
/* if the host is provided, attempt to connect. */
/**
* Zookeeper constructor.
*
* @param string $host
* @param callable $watcher_cb
* @param int $recv_timeout
*/
public function __construct( $host = '', $watcher_cb = null, $recv_timeout = 10000) {}
/**
* @param string $host
* @param callable $watcher_cb
* @param int $recv_timeout
*/
public function connect( $host, $watcher_cb = null, $recv_timeout = 10000) {}
/**
* @param string $path
* @param string $value
* @param array $acls
* @param int $flags
* @return string
*/
public function create( $path, $value, $acls, $flags = null ) {}
/**
* @param string $path
* @param int $version
* @return bool
*/
public function delete( $path, $version = -1 ) {}
/**
* @param string $path
* @param string $value
* @param int $version
* @param array $stat
* @return bool
*/
public function set( $path, $value, $version = -1, &$stat = null ) {}
/**
* @param $path
* @param callable $watcher_cb
* @param array $stat
* @param int $max_size
* @return string
*/
public function get( $path, $watcher_cb = null, &$stat = null, $max_size = 0) {}
/**
* @param string $path
* @param callable $watcher_cb
* @return array
*/
public function getChildren( $path, $watcher_cb = null ) {}
/**
* @param string $path
* @param callable $watcher_cb
* @return bool
*/
public function exists( $path, $watcher_cb = null ) {}
/**
* @param string $path
* @return array
*/
public function getAcl( $path ) {}
/**
* @param string $path
* @param int $version
* @param array $acls
* @return bool
*/
public function setAcl( $path, $version, $acls ) {}
/**
* @return int
*/
public function getClientId( ) {}
/**
* @param callable $watcher_cb
* @return bool
*/
public function setWatcher( $watcher_cb ) {}
/**
* @return int
*/
public function getState( ) {}
/**
* @return int
*/
public function getRecvTimeout( ) {}
/**
* @param string $scheme
* @param string $cert
* @param callable $completion_cb
* @return bool
*/
public function addAuth( $scheme, $cert, $completion_cb = null ) {}
/**
* @return bool
*/
public function isRecoverable( ) {}
/**
* @param resource $file
* @return bool
*/
public function setLogStream( $file ) {} // TODO: might be able to set a stream like php://stderr or something
public function getResultMessage( ) {}
// static methods
/**
* @param int $level
* @return bool
*/
static public function setDebugLevel( $level ) {}
/**
* @param bool $trueOrFalse
* @return bool
*/
static public function setDeterministicConnOrder( $trueOrFalse ) {}
}