示例#1
0
    def sync_entries(self, log_entries, retries):
        try:
            bucket_instances = set([entry["key"] for entry in log_entries])
        except KeyError:
            log.error("log containing bad key is: %s", log_entries)
            raise

        new_retries = []
        for bucket_instance in bucket_instances.union(retries):
            if ":" not in bucket_instance:
                # it's just a plain bucket from an old version of the agent
                bucket_instance = self.get_bucket_instance(bucket_instance)

            bound = client.get_worker_bound(self.dest_conn, "bucket-index", bucket_instance)

            marker = bound["marker"]
            # remap dictionaries to object-like
            retries = [obj_.to_obj(i) for i in bound["retries"]]
            timestamp = bound["oldest_time"]

            try:
                sync_result = self.inc_sync_bucket_instance(bucket_instance, marker, timestamp, retries)
            except Exception as e:
                log.warn('error syncing bucket instance "%s": %s', bucket_instance, e, exc_info=True)
                sync_result = RESULT_ERROR
            if sync_result == RESULT_ERROR:
                new_retries.append(bucket_instance)

        return new_retries
示例#2
0
    def sync_entries(self, log_entries, retries):
        try:
            bucket_instances = set([entry['key'] for entry in log_entries])
        except KeyError:
            log.error('log containing bad key is: %s', log_entries)
            raise

        new_retries = []
        for bucket_instance in bucket_instances.union(retries):
            if ':' not in bucket_instance:
                # it's just a plain bucket from an old version of the agent
                bucket_instance = self.get_bucket_instance(bucket_instance)

            bound = client.get_worker_bound(self.dest_conn, 'bucket-index',
                                            bucket_instance)

            marker = bound['marker']
            # remap dictionaries to object-like
            retries = [obj_.to_obj(i) for i in bound['retries']]
            timestamp = bound['oldest_time']

            try:
                sync_result = self.inc_sync_bucket_instance(
                    bucket_instance, marker, timestamp, retries)
            except Exception as e:
                log.warn('error syncing bucket instance "%s": %s',
                         bucket_instance,
                         e,
                         exc_info=True)
                sync_result = RESULT_ERROR
            if sync_result == RESULT_ERROR:
                new_retries.append(bucket_instance)

        return new_retries
示例#3
0
 def test_replace_dashes(self):
     dictionary = {'dashed-word': 1}
     result = obj.to_obj(dictionary)
     assert result.dashed_word == 1