Skip to content

Commit 144b696

Browse files
authored
Merge pull request #743 from ceache/fix/exceptions
fix(core): Add missing Zookeeper exceptions codes
2 parents 242d91e + 4c6bad8 commit 144b696

File tree

1 file changed

+90
-25
lines changed

1 file changed

+90
-25
lines changed

kazoo/exceptions.py

Lines changed: 90 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Kazoo Exceptions"""
2+
23
from collections import defaultdict
34

45

@@ -66,130 +67,194 @@ def decorator(klass):
6667
return decorator
6768

6869

70+
# Pulled from zookeeper-server/src/main/java/org/apache/zookeeper/
71+
# KeeperException.java in the Java Zookeeper server source code.
72+
73+
6974
@_zookeeper_exception(0)
7075
class RolledBackError(ZookeeperError):
7176
pass
7277

7378

7479
@_zookeeper_exception(-1)
7580
class SystemZookeeperError(ZookeeperError):
76-
pass
81+
"""System and server-side errors.
82+
This is never thrown by the server, it shouldn't be used other than to
83+
indicate a range. Specifically error codes greater than this value, but
84+
lesser than APIError, are system errors.
85+
"""
7786

7887

7988
@_zookeeper_exception(-2)
8089
class RuntimeInconsistency(ZookeeperError):
81-
pass
90+
"""A runtime inconsistency was found."""
8291

8392

8493
@_zookeeper_exception(-3)
8594
class DataInconsistency(ZookeeperError):
86-
pass
95+
"""A data inconsistency was found."""
8796

8897

8998
@_zookeeper_exception(-4)
9099
class ConnectionLoss(ZookeeperError):
91-
pass
100+
"""Connection to the server has been lost."""
92101

93102

94103
@_zookeeper_exception(-5)
95104
class MarshallingError(ZookeeperError):
96-
pass
105+
"""Error while marshalling or unmarshalling data."""
97106

98107

99108
@_zookeeper_exception(-6)
100109
class UnimplementedError(ZookeeperError):
101-
pass
110+
"""Operation is unimplemented."""
102111

103112

104113
@_zookeeper_exception(-7)
105114
class OperationTimeoutError(ZookeeperError):
106-
pass
115+
"""Operation timeout."""
107116

108117

109118
@_zookeeper_exception(-8)
110119
class BadArgumentsError(ZookeeperError):
111-
pass
120+
"""Invalid arguments."""
121+
122+
123+
@_zookeeper_exception(-12)
124+
class UnknownSessionError(ZookeeperError):
125+
"""Unknown session (internal server use only)."""
112126

113127

114128
@_zookeeper_exception(-13)
115129
class NewConfigNoQuorumError(ZookeeperError):
116-
pass
130+
"""No quorum of new config is connected and up-to-date with the leader of
131+
last commmitted config - try invoking reconfiguration after new servers are
132+
connected and synced.
133+
"""
117134

118135

119136
@_zookeeper_exception(-14)
120137
class ReconfigInProcessError(ZookeeperError):
121-
pass
138+
"""Another reconfiguration is in progress -- concurrent reconfigs not
139+
supported (yet).
140+
"""
122141

123142

124143
@_zookeeper_exception(-100)
125144
class APIError(ZookeeperError):
126-
pass
145+
"""API errors.
146+
This is never thrown by the server, it shouldn't be used other than to
147+
indicate a range. Specifically error codes greater than this value are API
148+
errors (while values less than this indicate a system error.
149+
"""
127150

128151

129152
@_zookeeper_exception(-101)
130153
class NoNodeError(ZookeeperError):
131-
pass
154+
"""Node does not exist."""
132155

133156

134157
@_zookeeper_exception(-102)
135158
class NoAuthError(ZookeeperError):
136-
pass
159+
"""Not authenticated."""
137160

138161

139162
@_zookeeper_exception(-103)
140163
class BadVersionError(ZookeeperError):
141-
pass
164+
"""Version conflict. In case of reconfiguration: reconfig requested from
165+
config version X but last seen config has a different version Y.
166+
"""
142167

143168

144169
@_zookeeper_exception(-108)
145170
class NoChildrenForEphemeralsError(ZookeeperError):
146-
pass
171+
"""Ephemeral nodes may not have children."""
147172

148173

149174
@_zookeeper_exception(-110)
150175
class NodeExistsError(ZookeeperError):
151-
pass
176+
"""The node already exists."""
152177

153178

154179
@_zookeeper_exception(-111)
155180
class NotEmptyError(ZookeeperError):
156-
pass
181+
"""The node has children."""
157182

158183

159184
@_zookeeper_exception(-112)
160185
class SessionExpiredError(ZookeeperError):
161-
pass
186+
"""The session has been expired by the server."""
162187

163188

164189
@_zookeeper_exception(-113)
165190
class InvalidCallbackError(ZookeeperError):
166-
pass
191+
"""Invalid callback specified."""
167192

168193

169194
@_zookeeper_exception(-114)
170195
class InvalidACLError(ZookeeperError):
171-
pass
196+
"""Invalid ACL specified"""
172197

173198

174199
@_zookeeper_exception(-115)
175200
class AuthFailedError(ZookeeperError):
176-
pass
201+
"""Client authentication failed."""
177202

178203

179204
@_zookeeper_exception(-118)
180205
class SessionMovedError(ZookeeperError):
181-
pass
206+
"""Session moved to another server, so operation is ignored."""
182207

183208

184209
@_zookeeper_exception(-119)
185210
class NotReadOnlyCallError(ZookeeperError):
186-
"""An API call that is not read-only was used while connected to
187-
a read-only server"""
211+
"""An API call that is not read-only was used while connected to a
212+
read-only server.
213+
"""
214+
215+
216+
@_zookeeper_exception(-120)
217+
class EphemeralOnLocalSessionError(ZookeeperError):
218+
"""Attempt to create ephemeral node on a local session."""
219+
220+
221+
@_zookeeper_exception(-121)
222+
class NoWatcherError(ZookeeperError):
223+
"""Attempts to remove a non-existing watcher."""
224+
225+
226+
@_zookeeper_exception(-122)
227+
class RequestTimeoutError(ZookeeperError):
228+
"""Request not completed within max allowed time."""
229+
230+
231+
@_zookeeper_exception(-123)
232+
class ReconfigDisabledError(ZookeeperError):
233+
"""Attempts to perform a reconfiguration operation when reconfiguration
234+
feature is disabled.
235+
"""
236+
237+
238+
@_zookeeper_exception(-124)
239+
class SessionClosedRequireSaslError(ZookeeperError):
240+
"""The session has been closed by server because server requires client to
241+
do authentication with configured authentication scheme at the server, but
242+
client is not configured with required authentication scheme or configured
243+
but authentication failed (i.e. wrong credential used.).
244+
"""
188245

189246

190247
@_zookeeper_exception(-125)
191248
class QuotaExceededError(ZookeeperError):
192-
"""Exceeded the quota that was set on the path"""
249+
"""Exceeded the quota that was set on the path."""
250+
251+
252+
@_zookeeper_exception(-127)
253+
class ThrottledOpError(ZookeeperError):
254+
"""Operation was throttled and not executed at all. This error code
255+
indicates that zookeeper server is under heavy load and can't process
256+
incoming requests at full speed; please retry with back off.
257+
"""
193258

194259

195260
class ConnectionClosedError(SessionExpiredError):

0 commit comments

Comments
 (0)