def __init__(self, conf): super(CarbonaraBasedStorage, self).__init__(conf) try: self.coord = coordination.get_coordinator( conf.coordination_url, str(uuid.uuid4()).encode('ascii')) self.coord.start(start_heart=True) except Exception as e: raise storage.StorageError("Unable to start coordinator: %s" % e) self.aggregation_workers_number = conf.aggregation_workers_number
def bulk_delete(conn, container, objects): objects = [quote(('/%s/%s' % (container, obj['name'])).encode('utf-8')) for obj in objects] resp = {} headers, body = conn.post_account( headers=POST_HEADERS, query_string='bulk-delete', data=b''.join(obj.encode('utf-8') + b'\n' for obj in objects), response_dict=resp) if resp['status'] != 200: raise storage.StorageError( "Unable to bulk-delete, is bulk-delete enabled in Swift?") resp = swift_utils.parse_api_response(headers, body) LOG.debug('# of objects deleted: %s, # of objects skipped: %s', resp['Number Deleted'], resp['Number Not Found'])
def __init__(self, conf): super(CarbonaraBasedStorage, self).__init__(conf) try: self.coord = coordination.get_coordinator( conf.coordination_url, str(uuid.uuid4()).encode('ascii')) self.coord.start() except Exception as e: raise storage.StorageError("Unable to start coordinator: %s" % e) if conf.aggregation_workers_number is None: try: self.aggregation_workers_number = multiprocessing.cpu_count() except NotImplementedError: self.aggregation_workers_number = 2 else: self.aggregation_workers_number = conf.aggregation_workers_number self.partition = 0 self._stop_heartbeat = threading.Event() self.heartbeater = threading.Thread(target=self._heartbeat, name='heartbeat') self.heartbeater.setDaemon(True) self.heartbeater.start()