Beispiel #1
0
def __schedule_requests():
    """
    Schedule requests
    """
    try:
        throttler_mode = config_core.get('throttler',
                                         'mode',
                                         default='DEST_PER_ACT',
                                         use_cache=False)
        direction, all_activities = get_parsed_throttler_mode(throttler_mode)
        result_dict = __get_request_stats(all_activities, direction)
        if direction == 'destination' or direction == 'source':
            for rse_id in result_dict:
                rse_name = result_dict[rse_id]['rse']
                availability = get_rse(rse_id).availability
                # dest_rse is not blacklisted for write or src_rse is not blacklisted for read
                if (direction == 'destination'
                        and availability & 2) or (direction == 'source'
                                                  and availability & 4):
                    if all_activities:
                        __release_all_activities(result_dict[rse_id],
                                                 direction, rse_name, rse_id)
                    else:
                        __release_per_activity(result_dict[rse_id], direction,
                                               rse_name, rse_id)
    except Exception:
        logging.critical("Failed to schedule requests, error: %s" %
                         (traceback.format_exc()))
Beispiel #2
0
def run_once(worker_number=0, logger=logging.log, session=None, **kwargs):
    """
    Schedule requests
    """
    if worker_number != 0:
        logger(logging.INFO, 'Throttler thread id is not 0, will sleep. Only thread 0 will work')
        return True
    logger(logging.INFO, "Throttler - schedule requests")
    try:
        throttler_mode = config_core.get('throttler', 'mode', default='DEST_PER_ACT', use_cache=False)
        direction, all_activities = get_parsed_throttler_mode(throttler_mode)
        result_dict = __get_request_stats(all_activities, direction)
        if direction == 'destination' or direction == 'source':
            for rse_id in result_dict:
                rse_name = result_dict[rse_id]['rse']
                availability = get_rse(rse_id).availability
                # dest_rse is not blocklisted for write or src_rse is not blocklisted for read
                if (direction == 'destination' and availability & 2) or (direction == 'source' and availability & 4):
                    if all_activities:
                        __release_all_activities(result_dict[rse_id], direction, rse_name, rse_id, logger=logger, session=session)
                    else:
                        __release_per_activity(result_dict[rse_id], direction, rse_name, rse_id, logger=logger, session=session)
    except Exception:
        logger(logging.CRITICAL, "Failed to schedule requests, error: %s" % (traceback.format_exc()))
    return True