Пример #1
0
    def pop(self, uuid_str):
        if not self.__lock.locked():
            raise store_exception.StoreLockException('the caller must hold DataStoreList lock')

        if not (uuid_str in self.__datastore_list):
            raise store_exception.StoreInvalidException('invalid datastore uuid')

        return self.__datastore_list.pop(uuid_str)
Пример #2
0
    def exists(self, uuid_str):
        if not self.__lock.locked():
            raise store_exception.StoreLockException('the caller must hold DataStoreList lock')

        if not (uuid_str in self.__datastore_list):
            return False

        return True
Пример #3
0
    def append(self, datastore):
        assert isinstance(datastore, DataStore)

        if not self.__lock.locked():
            raise store_exception.StoreLockException('the caller must hold DataStoreList lock')

        with datastore.lock:
            if datastore.uuid in self.__datastore_list:
                raise store_exception.StoreInvalidException('datastore(%s) already in datastore list' % datastore.uuid)
            else:
                self.__datastore_list[datastore.uuid] = datastore
Пример #4
0
    def __next__(self):
        if not self.__lock.locked():
            raise store_exception.StoreLockException('the caller must hold DataStoreList lock')

        return self.__datastore_list[next(self.it)]
Пример #5
0
    def __iter__(self):
        if not self.__lock.locked():
            raise store_exception.StoreLockException('the caller must hold DataStoreList lock')

        self.it = iter(self.__datastore_list)
        return self