original_docstring: Accepts AuthDB push from Primary and applies it to the replica.
  
    TODO(vadimsh): Delete all AuthGroup etc. entities on replicas.
  
    Args:
      revision: replication_pb2.AuthDBRevision describing revision of pushed DB.
      auth_db: replication_pb2.AuthDB with pushed DB.
  
    Returns:
      Tuple (True if update was applied, stored or updated AuthReplicationState).
    
docstring: Accepts AuthDB push from Primary and applies it to the replica.
  TODO(vadimsh): Delete all AuthGroup etc. entities on replicas.
docstring_tokens: Accepts AuthDB push from Primary and applies it to the replica . TODO ( vadimsh ) : Delete all AuthGroup etc . entities on replicas .
code: def push_auth_db(revision, auth_db):
    """Accepts AuthDB push from Primary and applies it to the replica.
  
    TODO(vadimsh): Delete all AuthGroup etc. entities on replicas.
  
    Args:
      revision: replication_pb2.AuthDBRevision describing revision of pushed DB.
      auth_db: replication_pb2.AuthDB with pushed DB.
  
    Returns:
      Tuple (True if update was applied, stored or updated AuthReplicationState).
    """
    # Already up-to-date? Check it first before doing heavy calls.
    state = model.get_replication_state()
    if (state.primary_id != revision.primary_id or
        state.auth_db_rev >= revision.auth_db_rev):
      return False, state
  
    # Zero revision in AuthReplicationState is special, it means "waiting for the
    # first AuthDB push". The Primary must never try to send it.
    assert revision.auth_db_rev > 0
  
    # Store AuthDB message as is first by deflating it and splitting it up into
    # multiple AuthDBSnapshotShard messages. If it fails midway, no big deal. It
    # will just hang in the datastore as unreferenced garbage.
    shard_ids = store_sharded_auth_db(
        auth_db,
        state.primary_url,
        revision.auth_db_rev,
        512*1024)
  
    # Put shard IDs into AuthReplicationState, they are used in api.fetch_auth_db.
    @ndb.transactional
    def update_replication_state():
      state = model.get_replication_state()
      if (state.primary_id != revision.primary_id or
          state.auth_db_rev >= revision.auth_db_rev):
        return False, state  # already up-to-date or newer
      state.auth_db_rev = revision.auth_db_rev
      state.modified_ts = utils.timestamp_to_datetime(revision.modified_ts)
      state.shard_ids = shard_ids
      state.put()
      return True, state
  
    return update_replication_state()
code_tokens: def push_auth_db ( revision , auth_db ) : state = model . get_replication_state ( ) if ( state . primary_id != revision . primary_id or state . auth_db_rev >= revision . auth_db_rev ) : return False , state assert revision . auth_db_rev > 0 shard_ids = store_sharded_auth_db ( auth_db , state . primary_url , revision . auth_db_rev , 512 * 1024 ) @ ndb . transactional def update_replication_state ( ) : state = model . get_replication_state ( ) if ( state . primary_id != revision . primary_id or state . auth_db_rev >= revision . auth_db_rev ) : return False , state state . auth_db_rev = revision . auth_db_rev state . modified_ts = utils . timestamp_to_datetime ( revision . modified_ts ) state . shard_ids = shard_ids state . put ( ) return True , state return update_replication_state ( )
short_docstring: Accepts AuthDB push from Primary and applies it to the replica.
short_docstring_tokens: Accepts AuthDB push from Primary and applies it to the replica .
comment: """Accepts AuthDB push from Primary and applies it to the replica.
  
    TODO(vadimsh): Delete all AuthGroup etc. entities on replicas.
  
    Args:
      revision: replication_pb2.AuthDBRevision describing revision of pushed DB.
      auth_db: replication_pb2.AuthDB with pushed DB.
  
    Returns:
      Tuple (True if update was applied, stored or updated AuthReplicationState).
    """$SEP$# Already up-to-date? Check it first before doing heavy calls.$SEP$# Zero revision in AuthReplicationState is special, it means "waiting for the$SEP$# first AuthDB push". The Primary must never try to send it.$SEP$# Store AuthDB message as is first by deflating it and splitting it up into$SEP$# multiple AuthDBSnapshotShard messages. If it fails midway, no big deal. It$SEP$# will just hang in the datastore as unreferenced garbage.$SEP$# Put shard IDs into AuthReplicationState, they are used in api.fetch_auth_db.$SEP$# already up-to-date or newer