Repository navigation
Expand file tree
/
Copy pathzookeeper-api.php
More file actions
333 lines (296 loc) · 7.38 KB
/
Copy pathzookeeper-api.php
File metadata and controls
333 lines (296 loc) · 7.38 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
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<?php
/**
* Zookeeper class.
*/
class Zookeeper
{
/* class constants */
const PERM_READ = 1;
const PERM_WRITE = 2;
const PERM_CREATE = 4;
const PERM_DELETE = 8;
const PERM_ADMIN = 16;
const PERM_ALL = 31;
const EPHEMERAL = 1;
const SEQUENCE = 2;
const EXPIRED_SESSION_STATE = -112;
const AUTH_FAILED_STATE = -113;
const CONNECTING_STATE = 1;
const ASSOCIATING_STATE = 2;
const CONNECTED_STATE = 3;
const NOTCONNECTED_STATE = 999;
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 LOG_LEVEL_ERROR = 1;
const LOG_LEVEL_WARN = 2;
const LOG_LEVEL_INFO = 3;
const LOG_LEVEL_DEBUG = 4;
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;
/**
* Create a handle to used communicate with zookeeper. * if the host is provided, attempt to connect.
*
* @param string $host
* @param callable $watcher_cb
* @param int $recv_timeout
*
* @throws ZookeeperConnectionException when host is provided and when failed to connect to the host.
*/
public function __construct($host = '', $watcher_cb = null, $recv_timeout = 10000)
{
}
/**
* Create a handle to used communicate with zookeeper.
*
* @param string $host
* @param callable $watcher_cb
* @param int $recv_timeout
*
* @throws ZookeeperConnectionException when failed to connect to Zookeeper
*/
public function connect($host, $watcher_cb = null, $recv_timeout = 10000)
{
}
/**
* Create a node synchronously.
*
* @param string $path
* @param string $value
* @param array $acl
* @param int $flags
*
* @return string
* @throws ZookeeperException
*/
public function create($path, $value, $acl, $flags = null)
{
}
/**
* Delete a node in zookeeper synchronously.
*
* @param string $path
* @param int $version
*
* @return bool
* @throws ZookeeperException
*/
public function delete($path, $version = -1)
{
}
/**
* Sets the data associated with a node.
*
* @param string $path
* @param string $data
* @param int $version
* @param array $stat
*
* @return bool
* @throws ZookeeperException
*/
public function set($path, $data, $version = -1, &$stat = null)
{
}
/**
* Gets the data associated with a node synchronously.
*
* @param string $path
* @param callable $watcher_cb
* @param array $stat
* @param int $max_size
*
* @return string
* @throws ZookeeperException
*/
public function get($path, $watcher_cb = null, &$stat = null, $max_size = 0)
{
}
/**
* Get children data of a path.
*
* @param string $path
* @param callable $watcher_cb
*
* @return array
* @throws ZookeeperException when connection not in connected status
*/
public function getChildren($path, $watcher_cb = null)
{
}
/**
* Checks the existence of a node in zookeeper synchronously.
*
* @param string $path
* @param callable $watcher_cb
*
* @return bool
* @throws ZookeeperException
*/
public function exists($path, $watcher_cb = null)
{
}
/**
* Gets the acl associated with a node synchronously.
*
* @param string $path
*
* @return array
* @throws ZookeeperException when connection not in connected status
*/
public function getAcl($path)
{
}
/**
* Sets the acl associated with a node synchronously.
*
* @param string $path
* @param int $version
* @param array $acls
*
* @return bool
* @throws ZookeeperException when connection not in connected status
*/
public function setAcl($path, $version, $acls)
{
}
/**
* return the client session id, only valid if the connections is currently connected
* (ie. last watcher state is ZOO_CONNECTED_STATE)
*
* @return int
* @throws ZookeeperConnectionException when connection not in connected status
*/
public function getClientId()
{
}
/**
* Set a watcher function.
*
* @param callable $watcher_cb
*
* @return bool
* @throws ZookeeperConnectionException when connection not in connected status
*/
public function setWatcher($watcher_cb)
{
}
/**
* Get the state of the zookeeper connection.
*
* @return int
* @throws ZookeeperConnectionException when connection not in connected status
*/
public function getState()
{
}
/**
* Return the timeout for this session, only valid if the connections is currently connected
* (ie. last watcher state is ZOO_CONNECTED_STATE). This value may change after a server reconnect.
*
* @return int
* @throws ZookeeperConnectionException when connection not in connected status
*/
public function getRecvTimeout()
{
}
/**
* Specify application credentials.
*
* @param string $scheme
* @param string $cert
* @param callable $completion_cb
*
* @return bool
*/
public function addAuth($scheme, $cert, $completion_cb = null)
{
}
/**
* Checks if the current zookeeper connection state can be recovered.
*
* @return bool
* @throws ZookeeperConnectionException when connection not in connected status
*/
public function isRecoverable()
{
}
/**
* Sets the stream to be used by the library for logging.
*
* TODO: might be able to set a stream like php://stderr or something
*
* @param resource $file
*
* @return bool
*/
public function setLogStream($file)
{
}
/**
* Sets the debugging level for the library.
*
* @param int $level
*
* @return bool
*/
public static function setDebugLevel($level)
{
}
/**
* Enable/disable quorum endpoint order randomization.
*
* @param bool $trueOrFalse
*
* @return bool
*/
public static function setDeterministicConnOrder($trueOrFalse)
{
}
}
class ZookeeperException extends Exception
{
}
class ZookeeperOperationTimeoutException extends ZookeeperException
{
}
class ZookeeperConnectionException extends ZookeeperException
{
}
class ZookeeperMarshallingException extends ZookeeperException
{
}
class ZookeeperAuthenticationException extends ZookeeperException
{
}
class ZookeeperSessionException extends ZookeeperException
{
}
class ZookeeperNoNodeException extends ZookeeperException
{
}