Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def start(self):
adjust_zk_logging_level()
self.zk.start()
try:
ChildrenWatch(self.zk, '', self.choose)
except ZookeeperError:
self.agent.onNoMasterDetectedMessage()
self.stop()
EXCEPTIONS = defaultdict(_invalid_error_code)
def _zookeeper_exception(code):
def decorator(klass):
EXCEPTIONS[code] = klass
klass.code = code
return klass
return decorator
@_zookeeper_exception(0)
class RolledBackError(ZookeeperError):
pass
@_zookeeper_exception(-1)
class SystemZookeeperError(ZookeeperError):
pass
@_zookeeper_exception(-2)
class RuntimeInconsistency(ZookeeperError):
pass
@_zookeeper_exception(-3)
class DataInconsistency(ZookeeperError):
pass
class MarshallingError(ZookeeperError):
pass
@_zookeeper_exception(-6)
class UnimplementedError(ZookeeperError):
pass
@_zookeeper_exception(-7)
class OperationTimeoutError(ZookeeperError):
pass
@_zookeeper_exception(-8)
class BadArgumentsError(ZookeeperError):
pass
@_zookeeper_exception(-13)
class NewConfigNoQuorumError(ZookeeperError):
pass
@_zookeeper_exception(-14)
class ReconfigInProcessError(ZookeeperError):
pass
@_zookeeper_exception(-100)
class APIError(ZookeeperError):
pass
class NewConfigNoQuorumError(ZookeeperError):
pass
@_zookeeper_exception(-14)
class ReconfigInProcessError(ZookeeperError):
pass
@_zookeeper_exception(-100)
class APIError(ZookeeperError):
pass
@_zookeeper_exception(-101)
class NoNodeError(ZookeeperError):
pass
@_zookeeper_exception(-102)
class NoAuthError(ZookeeperError):
pass
@_zookeeper_exception(-103)
class BadVersionError(ZookeeperError):
pass
@_zookeeper_exception(-108)
class NoChildrenForEphemeralsError(ZookeeperError):
pass
class NoChildrenForEphemeralsError(ZookeeperError):
pass
@_zookeeper_exception(-110)
class NodeExistsError(ZookeeperError):
pass
@_zookeeper_exception(-111)
class NotEmptyError(ZookeeperError):
pass
@_zookeeper_exception(-112)
class SessionExpiredError(ZookeeperError):
pass
@_zookeeper_exception(-113)
class InvalidCallbackError(ZookeeperError):
pass
@_zookeeper_exception(-114)
class InvalidACLError(ZookeeperError):
pass
@_zookeeper_exception(-115)
class AuthFailedError(ZookeeperError):
pass
def delete_path_recursively(self):
try:
self.client.delete(self.path, recursive=True)
except NoNodeError:
pass
except NoAuthError:
raise AuthError("delete", self.path)
except ZookeeperError:
raise CopyError("Zookeeper server error")
class DataInconsistency(ZookeeperError):
pass
@_zookeeper_exception(-4)
class ConnectionLoss(ZookeeperError):
pass
@_zookeeper_exception(-5)
class MarshallingError(ZookeeperError):
pass
@_zookeeper_exception(-6)
class UnimplementedError(ZookeeperError):
pass
@_zookeeper_exception(-7)
class OperationTimeoutError(ZookeeperError):
pass
@_zookeeper_exception(-8)
class BadArgumentsError(ZookeeperError):
pass
@_zookeeper_exception(-13)
class NewConfigNoQuorumError(ZookeeperError):
pass
class ReconfigInProcessError(ZookeeperError):
pass
@_zookeeper_exception(-100)
class APIError(ZookeeperError):
pass
@_zookeeper_exception(-101)
class NoNodeError(ZookeeperError):
pass
@_zookeeper_exception(-102)
class NoAuthError(ZookeeperError):
pass
@_zookeeper_exception(-103)
class BadVersionError(ZookeeperError):
pass
@_zookeeper_exception(-108)
class NoChildrenForEphemeralsError(ZookeeperError):
pass
@_zookeeper_exception(-110)
class NodeExistsError(ZookeeperError):
pass
def _register_groomer(self):
""" Creates a ZooKeeper entry that broadcasts this service's presence. """
logger.info('Registering service with ZooKeeper')
node_prefix = '/'.join([self._registration_path, self._groomer_id]) + '-'
# Make sure an older node from this groomer did not remain.
self._clean_created_nodes()
# The groomer must be registered before it can continue working.
while True:
try:
full_path = self._zk_client.create(node_prefix, ephemeral=True,
sequence=True)
self._node = full_path[len(self._registration_path) + 1:]
break
except ZookeeperError:
self._clean_created_nodes()
continue
class BadVersionError(ZookeeperError):
pass
@_zookeeper_exception(-108)
class NoChildrenForEphemeralsError(ZookeeperError):
pass
@_zookeeper_exception(-110)
class NodeExistsError(ZookeeperError):
pass
@_zookeeper_exception(-111)
class NotEmptyError(ZookeeperError):
pass
@_zookeeper_exception(-112)
class SessionExpiredError(ZookeeperError):
pass
@_zookeeper_exception(-113)
class InvalidCallbackError(ZookeeperError):
pass
@_zookeeper_exception(-114)
class InvalidACLError(ZookeeperError):
pass