def _start_consistency_check(state, collection_id, row_id=None, retry_count=0): log = logging.getLogger("_start_consistency_check") timestamp = create_timestamp() state_key = (collection_id, timestamp, ) database = AuditResultDatabase(state["central-database-connection"]) if row_id is None: row_id = database.start_audit(collection_id, timestamp) else: database.restart_audit(row_id, timestamp) database.close() state["active-requests"][state_key] = _request_state_tuple( client_tag=None, timestamp=timestamp, timeout=time.time()+_request_timeout, retry_count=retry_count, replies=dict(), row_id=row_id, ) request = { "message-type" : "consistency-check", "collection-id" : collection_id, "timestamp-repr": repr(timestamp), } for anti_entropy_client in state["anti-entropy-clients"]: anti_entropy_client.queue_message_for_send(request)
def _handle_anti_entropy_audit_request(state, message, _data): """handle a requst to audit a specific collection, not some random one""" log = logging.getLogger("_handle_anti_entropy_audit_request") timestamp = create_timestamp() state_key = (message["collection-id"], timestamp, ) database = AuditResultDatabase(state["central-database-connection"]) row_id = database.start_audit(message["collection-id"], timestamp) database.close() state["active-requests"][state_key] = _request_state_tuple( client_tag=message["client-tag"], timestamp=timestamp, timeout=time.time()+_request_timeout, retry_count=max_retry_count, replies=dict(), row_id=row_id, ) request = { "message-type" : "consistency-check", "collection-id" : message["collection-id"], "timestamp-repr": repr(timestamp), } for anti_entropy_client in state["anti-entropy-clients"]: anti_entropy_client.queue_message_for_send(request)