Example #1
0
def test_get_supported_transfertools_default(vo, db_session):
    with GeneratedRSE(vo=vo, db_session=db_session) as generated_rse:
        transfertools = get_supported_transfertools(rse_id=generated_rse.rse_id, session=db_session)

    assert len(transfertools) == 2
    assert 'fts3' in transfertools
    assert 'globus' in transfertools
Example #2
0
def run_once(bulk: int = 100, heartbeat_handler: "Optional[HeartbeatHandler]" = None, limit: "Optional[int]" = None, session: "Optional[Session]" = None, **kwargs) -> bool:
    if heartbeat_handler:
        worker_number, total_workers, logger = heartbeat_handler.live()
    else:
        # This is used in tests
        worker_number, total_workers, logger = 0, 0, logging.log

    start_time = time()
    try:
        req_sources = list_transfer_requests_and_source_replicas(
            total_workers=total_workers,
            worker_number=worker_number,
            limit=limit,
            request_state=RequestState.PREPARING,
            session=session
        )
        if not req_sources:
            count = 0
            updated_msg = 'had nothing to do'
        else:
            transfertool_filter = get_transfertool_filter(lambda rse_id: get_supported_transfertools(rse_id=rse_id, session=session))
            requests = reduce_requests(req_sources, [rse_lookup_filter, sort_requests_minimum_distance, transfertool_filter], logger=logger)
            count = preparer_update_requests(requests, session=session)
            updated_msg = f'updated {count}/{limit} requests'
    except RucioException:
        logger(logging.ERROR, 'errored with a RucioException, retrying later', exc_info=True)
        count = 0
        updated_msg = 'errored'
    logger(logging.INFO, '%s, taking %.3f seconds' % (updated_msg, time() - start_time))

    queue_empty = False
    if count < bulk:
        queue_empty = True
    return queue_empty
Example #3
0
def run_once(total_workers: int = 0, worker_number: int = 0, limit: "Optional[int]" = None, logger=logging.log, session: "Optional[Session]" = None) -> str:
    req_sources = __list_transfer_requests_and_source_replicas(
        total_workers=total_workers,
        worker_number=worker_number,
        limit=limit,
        request_state=RequestState.PREPARING,
        session=session
    )
    if not req_sources:
        return 'had nothing to do'

    transfertool_filter = get_transfertool_filter(lambda rse_id: get_supported_transfertools(rse_id=rse_id, session=session))
    requests = reduce_requests(req_sources, [rse_lookup_filter, sort_requests_minimum_distance, transfertool_filter], logger=logger)
    count = preparer_update_requests(requests, session=session)
    return f'updated {count}/{limit} requests'