Esempio n. 1
0
 def validate(self):
     with self._exc_wrapper():
         try:
             k_utils.check_compatible(self._client, MIN_ZK_VERSION)
         except exc.IncompatibleVersion as e:
             raise exc.StorageFailure("Backend storage is not a"
                                      " compatible version", e)
Esempio n. 2
0
    def connect(self, timeout=10.0):
        def try_clean():
            # Attempt to do the needed cleanup if post-connection setup does
            # not succeed (maybe the connection is lost right after it is
            # obtained).
            try:
                self.close()
            except k_exceptions.KazooException:
                LOG.exception("Failed cleaning-up after post-connection"
                              " initialization failed")

        try:
            if timeout is not None:
                timeout = float(timeout)
            self._client.start(timeout=timeout)
        except (self._client.handler.timeout_exception,
                k_exceptions.KazooException) as e:
            raise excp.ConnectionFailure("Failed to connect to"
                                         " zookeeper due to: %s" % (e))
        try:
            kazoo_utils.check_compatible(self._client, MIN_ZK_VERSION)
            self._client.ensure_path(self.path)
            self._job_watcher = watchers.ChildrenWatch(
                self._client,
                self.path,
                func=self._on_job_posting,
                allow_session_lost=False)
        except excp.IncompatibleVersion:
            with excutils.save_and_reraise_exception():
                try_clean()
        except (self._client.handler.timeout_exception,
                k_exceptions.KazooException) as e:
            try_clean()
            raise excp.ConnectionFailure("Failed to do post-connection"
                                         " initialization due to: %s" % (e))
Esempio n. 3
0
 def validate(self):
     with self._exc_wrapper():
         try:
             k_utils.check_compatible(self._client, MIN_ZK_VERSION)
         except exc.IncompatibleVersion as e:
             raise exc.StorageFailure(
                 "Backend storage is not a"
                 " compatible version", e)
Esempio n. 4
0
 def validate(self):
     with self._exc_wrapper():
         try:
             if self._conf.get('check_compatible', True):
                 k_utils.check_compatible(self._client, MIN_ZK_VERSION)
         except exc.IncompatibleVersion:
             exc.raise_with_cause(exc.StorageFailure, "Backend storage is"
                                  " not a compatible version")
 def validate(self):
     with self._exc_wrapper():
         try:
             if self._conf.get('check_compatible', True):
                 k_utils.check_compatible(self._client, MIN_ZK_VERSION)
         except exc.IncompatibleVersion:
             exc.raise_with_cause(
                 exc.StorageFailure, "Backend storage is"
                 " not a compatible version")
Esempio n. 6
0
    def connect(self, timeout=10.0):

        def try_clean():
            # Attempt to do the needed cleanup if post-connection setup does
            # not succeed (maybe the connection is lost right after it is
            # obtained).
            try:
                self.close()
            except k_exceptions.KazooException:
                LOG.exception("Failed cleaning-up after post-connection"
                              " initialization failed")

        try:
            if timeout is not None:
                timeout = float(timeout)
            self._client.start(timeout=timeout)
            self._closing = False
        except (self._client.handler.timeout_exception,
                k_exceptions.KazooException):
            excp.raise_with_cause(excp.JobFailure,
                                  "Failed to connect to zookeeper")
        try:
            if self._conf.get('check_compatible', True):
                kazoo_utils.check_compatible(self._client, self.MIN_ZK_VERSION)
            if self._worker is None and self._emit_notifications:
                self._worker = futurist.ThreadPoolExecutor(max_workers=1)
            self._client.ensure_path(self.path)
            self._client.ensure_path(self.trash_path)
            if self._job_watcher is None:
                self._job_watcher = watchers.ChildrenWatch(
                    self._client,
                    self.path,
                    func=self._on_job_posting,
                    allow_session_lost=True)
            self._connected = True
        except excp.IncompatibleVersion:
            with excutils.save_and_reraise_exception():
                try_clean()
        except (self._client.handler.timeout_exception,
                k_exceptions.KazooException):
            exc_type, exc, exc_tb = sys.exc_info()
            try:
                try_clean()
                excp.raise_with_cause(excp.JobFailure,
                                      "Failed to do post-connection"
                                      " initialization", cause=exc)
            finally:
                del(exc_type, exc, exc_tb)
Esempio n. 7
0
    def connect(self, timeout=10.0):

        def try_clean():
            # Attempt to do the needed cleanup if post-connection setup does
            # not succeed (maybe the connection is lost right after it is
            # obtained).
            try:
                self.close()
            except k_exceptions.KazooException:
                LOG.exception("Failed cleaning-up after post-connection"
                              " initialization failed")

        try:
            if timeout is not None:
                timeout = float(timeout)
            self._client.start(timeout=timeout)
            self._closing = False
        except (self._client.handler.timeout_exception,
                k_exceptions.KazooException):
            excp.raise_with_cause(excp.JobFailure,
                                  "Failed to connect to zookeeper")
        try:
            if self._conf.get('check_compatible', True):
                kazoo_utils.check_compatible(self._client, self.MIN_ZK_VERSION)
            if self._worker is None and self._emit_notifications:
                self._worker = futurist.ThreadPoolExecutor(max_workers=1)
            self._client.ensure_path(self.path)
            self._client.ensure_path(self.trash_path)
            if self._job_watcher is None:
                self._job_watcher = watchers.ChildrenWatch(
                    self._client,
                    self.path,
                    func=self._on_job_posting,
                    allow_session_lost=True)
            self._connected = True
        except excp.IncompatibleVersion:
            with excutils.save_and_reraise_exception():
                try_clean()
        except (self._client.handler.timeout_exception,
                k_exceptions.KazooException):
            exc_type, exc, exc_tb = sys.exc_info()
            try:
                try_clean()
                excp.raise_with_cause(excp.JobFailure,
                                      "Failed to do post-connection"
                                      " initialization", cause=exc)
            finally:
                del(exc_type, exc, exc_tb)
Esempio n. 8
0
    def connect(self, timeout=10.0):

        def try_clean():
            # Attempt to do the needed cleanup if post-connection setup does
            # not succeed (maybe the connection is lost right after it is
            # obtained).
            try:
                self.close()
            except k_exceptions.KazooException:
                LOG.exception("Failed cleaning-up after post-connection"
                              " initialization failed")

        try:
            if timeout is not None:
                timeout = float(timeout)
            self._client.start(timeout=timeout)
        except (self._client.handler.timeout_exception,
                k_exceptions.KazooException) as e:
            raise excp.ConnectionFailure("Failed to connect to"
                                         " zookeeper due to: %s" % (e))
        try:
            kazoo_utils.check_compatible(self._client, MIN_ZK_VERSION)
            self._client.ensure_path(self.path)
            self._job_watcher = watchers.ChildrenWatch(
                self._client,
                self.path,
                func=self._on_job_posting,
                allow_session_lost=False)
        except excp.IncompatibleVersion:
            with excutils.save_and_reraise_exception():
                try_clean()
        except (self._client.handler.timeout_exception,
                k_exceptions.KazooException) as e:
            try_clean()
            raise excp.ConnectionFailure("Failed to do post-connection"
                                         " initialization due to: %s" % (e))
Esempio n. 9
0
 def validate(self):
     with self._exc_wrapper():
         k_utils.check_compatible(self._client, MIN_ZK_VERSION)
Esempio n. 10
0
 def validate(self):
     with self._exc_wrapper():
         k_utils.check_compatible(self._client, MIN_ZK_VERSION)