예제 #1
0
    def _handle_sync_response(self,
                              node,
                              response,
                              info,
                              broker,
                              http,
                              different_region=False):
        if is_success(response.status):
            remote_info = json.loads(response.data)
            if incorrect_policy_index(info, remote_info):
                status_changed_at = Timestamp.now()
                broker.set_storage_policy_index(
                    remote_info['storage_policy_index'],
                    timestamp=status_changed_at.internal)
            sync_timestamps = ('created_at', 'put_timestamp',
                               'delete_timestamp')
            if any(info[key] != remote_info[key] for key in sync_timestamps):
                broker.merge_timestamps(*(remote_info[key]
                                          for key in sync_timestamps))

            # Grab remote's shard ranges, too
            self._fetch_and_merge_shard_ranges(http, broker)

        return super(ContainerReplicator,
                     self)._handle_sync_response(node, response, info, broker,
                                                 http, different_region)
예제 #2
0
 def _handle_sync_response(self, node, response, info, broker, http):
     parent = super(ContainerReplicator, self)
     if is_success(response.status):
         remote_info = json.loads(response.data)
         if incorrect_policy_index(info, remote_info):
             status_changed_at = Timestamp(time.time())
             broker.set_storage_policy_index(
                 remote_info["storage_policy_index"], timestamp=status_changed_at.internal
             )
         sync_timestamps = ("created_at", "put_timestamp", "delete_timestamp")
         if any(info[key] != remote_info[key] for key in sync_timestamps):
             broker.merge_timestamps(*(remote_info[key] for key in sync_timestamps))
     rv = parent._handle_sync_response(node, response, info, broker, http)
     return rv
예제 #3
0
 def _handle_sync_response(self, node, response, info, broker, http):
     parent = super(ContainerReplicator, self)
     if is_success(response.status):
         remote_info = json.loads(response.data)
         if incorrect_policy_index(info, remote_info):
             status_changed_at = Timestamp(time.time())
             broker.set_storage_policy_index(
                 remote_info['storage_policy_index'],
                 timestamp=status_changed_at.internal)
         broker.merge_timestamps(*(remote_info[key]
                                   for key in ('created_at',
                                               'put_timestamp',
                                               'delete_timestamp')))
     rv = parent._handle_sync_response(node, response, info, broker, http)
     return rv
예제 #4
0
    def _get_synced_replication_info(self, broker, remote_info):
        """
        Sync the remote_info storage_policy_index if needed and return the
        newly synced replication info.

        :param broker: the database broker
        :param remote_info: the remote replication info

        :returns: local broker replication info
        """
        info = broker.get_replication_info()
        if incorrect_policy_index(info, remote_info):
            status_changed_at = Timestamp(time.time()).internal
            broker.set_storage_policy_index(remote_info["storage_policy_index"], timestamp=status_changed_at)
            info = broker.get_replication_info()
        return info
예제 #5
0
    def _get_synced_replication_info(self, broker, remote_info):
        """
        Sync the remote_info storage_policy_index if needed and return the
        newly synced replication info.

        :param broker: the database broker
        :param remote_info: the remote replication info

        :returns: local broker replication info
        """
        info = broker.get_replication_info()
        if incorrect_policy_index(info, remote_info):
            status_changed_at = Timestamp.now().internal
            broker.set_storage_policy_index(
                remote_info['storage_policy_index'],
                timestamp=status_changed_at)
            info = broker.get_replication_info()
        return info
예제 #6
0
 def _handle_sync_response(self, node, response, info, broker, http,
                           different_region):
     parent = super(ContainerReplicator, self)
     if is_success(response.status):
         remote_info = json.loads(response.data)
         if incorrect_policy_index(info, remote_info):
             status_changed_at = Timestamp.now()
             broker.set_storage_policy_index(
                 remote_info['storage_policy_index'],
                 timestamp=status_changed_at.internal)
         sync_timestamps = ('created_at', 'put_timestamp',
                            'delete_timestamp')
         if any(info[key] != remote_info[key] for key in sync_timestamps):
             broker.merge_timestamps(*(remote_info[key] for key in
                                       sync_timestamps))
     rv = parent._handle_sync_response(
         node, response, info, broker, http, different_region)
     return rv
예제 #7
0
    def _handle_sync_response(self, node, response, info, broker, http,
                              different_region=False):
        if is_success(response.status):
            remote_info = json.loads(response.data)
            if incorrect_policy_index(info, remote_info):
                status_changed_at = Timestamp.now()
                broker.set_storage_policy_index(
                    remote_info['storage_policy_index'],
                    timestamp=status_changed_at.internal)
            sync_timestamps = ('created_at', 'put_timestamp',
                               'delete_timestamp')
            if any(info[key] != remote_info[key] for key in sync_timestamps):
                broker.merge_timestamps(*(remote_info[key] for key in
                                          sync_timestamps))

            if 'shard_max_row' in remote_info:
                # Grab remote's shard ranges, too
                self._fetch_and_merge_shard_ranges(http, broker)

        return super(ContainerReplicator, self)._handle_sync_response(
            node, response, info, broker, http, different_region)