@transactional_session
def update_replicas_states(replicas, nowait=False, session=None):
    '\n    Update File replica information and state.\n\n    :param replicas:        The list of replicas.\n    :param nowait:          Nowait parameter for the for_update queries.\n    :param session:         The database session in use.\n    '
    for replica in replicas:
        query = session.query(models.RSEFileAssociation).filter_by(rse_id=replica['rse_id'], scope=replica['scope'], name=replica['name'])
        try:
            if nowait:
                query.with_for_update(nowait=True).one()
        except NoResultFound:
            raise exception.ReplicaNotFound(('No row found for scope: %s name: %s rse: %s' % (replica['scope'], replica['name'], get_rse_name(replica['rse_id'], session=session))))
        if isinstance(replica['state'], string_types):
            replica['state'] = ReplicaState(replica['state'])
        values = {'state': replica['state']}
        if (replica['state'] == ReplicaState.BEING_DELETED):
            query = query.filter_by(lock_cnt=0)
            stmt = exists([1]).where(and_((models.RSEFileAssociation.scope == models.Source.scope), (models.RSEFileAssociation.name == models.Source.name), (models.RSEFileAssociation.rse_id == models.Source.rse_id)))
            query = query.filter(not_(stmt))
            values['tombstone'] = OBSOLETE
        elif (replica['state'] == ReplicaState.AVAILABLE):
            rucio.core.lock.successful_transfer(scope=replica['scope'], name=replica['name'], rse_id=replica['rse_id'], nowait=nowait, session=session)
        elif (replica['state'] == ReplicaState.UNAVAILABLE):
            rucio.core.lock.failed_transfer(scope=replica['scope'], name=replica['name'], rse_id=replica['rse_id'], error_message=replica.get('error_message', None), broken_rule_id=replica.get('broken_rule_id', None), broken_message=replica.get('broken_message', None), nowait=nowait, session=session)
        elif (replica['state'] == ReplicaState.TEMPORARY_UNAVAILABLE):
            query = query.filter(or_((models.RSEFileAssociation.state == ReplicaState.AVAILABLE), (models.RSEFileAssociation.state == ReplicaState.TEMPORARY_UNAVAILABLE)))
        if (('path' in replica) and replica['path']):
            values['path'] = replica['path']
        if (not query.update(values, synchronize_session=False)):
            if ('rse' not in replica):
                replica['rse'] = get_rse_name(rse_id=replica['rse_id'], session=session)
            raise exception.UnsupportedOperation(('State %(state)s for replica %(scope)s:%(name)s on %(rse)s cannot be updated' % replica))
    return True
Update File replica information and state.

:param replicas:        The list of replicas.
:param nowait:          Nowait parameter for the for_update queries.
:param session:         The database session in use.
@transactional_session
def update_replicas_states(replicas, nowait=False, session=None):
    '\n    Update File replica information and state.\n\n    :param replicas:        The list of replicas.\n    :param nowait:          Nowait parameter for the for_update queries.\n    :param session:         The database session in use.\n    '
    for replica in replicas:
        query = session.query(models.RSEFileAssociation).filter_by(rse_id=replica['rse_id'], scope=replica['scope'], name=replica['name'])
        try:
            if nowait:
                query.with_for_update(nowait=True).one()
        except NoResultFound:
            raise exception.ReplicaNotFound(('No row found for scope: %s name: %s rse: %s' % (replica['scope'], replica['name'], get_rse_name(replica['rse_id'], session=session))))
        if isinstance(replica['state'], string_types):
            replica['state'] = ReplicaState(replica['state'])
        values = {'state': replica['state']}
        if (replica['state'] == ReplicaState.BEING_DELETED):
            query = query.filter_by(lock_cnt=0)
            stmt = exists([1]).where(and_((models.RSEFileAssociation.scope == models.Source.scope), (models.RSEFileAssociation.name == models.Source.name), (models.RSEFileAssociation.rse_id == models.Source.rse_id)))
            query = query.filter(not_(stmt))
            values['tombstone'] = OBSOLETE
        elif (replica['state'] == ReplicaState.AVAILABLE):
            rucio.core.lock.successful_transfer(scope=replica['scope'], name=replica['name'], rse_id=replica['rse_id'], nowait=nowait, session=session)
        elif (replica['state'] == ReplicaState.UNAVAILABLE):
            rucio.core.lock.failed_transfer(scope=replica['scope'], name=replica['name'], rse_id=replica['rse_id'], error_message=replica.get('error_message', None), broken_rule_id=replica.get('broken_rule_id', None), broken_message=replica.get('broken_message', None), nowait=nowait, session=session)
        elif (replica['state'] == ReplicaState.TEMPORARY_UNAVAILABLE):
            query = query.filter(or_((models.RSEFileAssociation.state == ReplicaState.AVAILABLE), (models.RSEFileAssociation.state == ReplicaState.TEMPORARY_UNAVAILABLE)))
        if (('path' in replica) and replica['path']):
            values['path'] = replica['path']
        if (not query.update(values, synchronize_session=False)):
            if ('rse' not in replica):
                replica['rse'] = get_rse_name(rse_id=replica['rse_id'], session=session)
            raise exception.UnsupportedOperation(('State %(state)s for replica %(scope)s:%(name)s on %(rse)s cannot be updated' % replica))
    return True