def display_assignment_changes(plan_details, to_log=True):
    """Display current and proposed changes in
    topic-partition to replica layout over brokers.
    """
    curr_plan_list, new_plan_list, total_changes = plan_details
    action_cnt = '\n[INFO] Total actions required {0}'.format(total_changes)
    _log_or_display(to_log, action_cnt)
    action_cnt = (
        '[INFO] Total actions that will be executed {0}'
        .format(len(new_plan_list))
    )
    _log_or_display(to_log, action_cnt)
    changes = ('[INFO] Proposed Changes in current cluster-layout:\n')
    _log_or_display(to_log, changes)

    tp_str = 'Topic - Partition'
    curr_repl_str = 'Previous-Assignment'
    new_rep_str = 'Proposed-Assignment'
    tp_list = [tp_repl[0] for tp_repl in curr_plan_list]

    # Display heading
    msg = '=' * 80
    _log_or_display(to_log, msg)
    row = (
        '{tp:^30s}: {curr_rep_str:^20s} ==> {new_rep_str:^20s}' .format(
            tp=tp_str,
            curr_rep_str=curr_repl_str,
            new_rep_str=new_rep_str,
        )
    )
    _log_or_display(to_log, row)
    msg = '=' * 80
    _log_or_display(to_log, msg)

    # Display each topic-partition list with changes
    tp_list_sorted = sorted(tp_list, key=lambda tp: (tp[0], tp[1]))
    for tp in tp_list_sorted:
        curr_repl = [
            tp_repl[1] for tp_repl in curr_plan_list if tp_repl[0] == tp
        ][0]
        proposed_repl = [
            tp_repl[1] for tp_repl in new_plan_list if tp_repl[0] == tp
        ][0]
        tp_str = '{topic} - {partition:<2d}'.format(topic=tp[0], partition=tp[1])
        row = (
            '{tp:<30s}: {curr_repl:<20s} ==> {proposed_repl:<20s}'.format(
                tp=tp_str,
                curr_repl=curr_repl,
                proposed_repl=proposed_repl,
            )
        )
        _log_or_display(to_log, row)
def display_assignment_changes ( plan_details , to_log = True ) : curr_plan_list , new_plan_list , total_changes = plan_details action_cnt = '\n[INFO] Total actions required {0}' . format ( total_changes ) _log_or_display ( to_log , action_cnt ) action_cnt = ( '[INFO] Total actions that will be executed {0}' . format ( len ( new_plan_list ) ) ) _log_or_display ( to_log , action_cnt ) changes = ( '[INFO] Proposed Changes in current cluster-layout:\n' ) _log_or_display ( to_log , changes ) tp_str = 'Topic - Partition' curr_repl_str = 'Previous-Assignment' new_rep_str = 'Proposed-Assignment' tp_list = [ tp_repl [ 0 ] for tp_repl in curr_plan_list ] msg = '=' * 80 _log_or_display ( to_log , msg ) row = ( '{tp:^30s}: {curr_rep_str:^20s} ==> {new_rep_str:^20s}' . format ( tp = tp_str , curr_rep_str = curr_repl_str , new_rep_str = new_rep_str , ) ) _log_or_display ( to_log , row ) msg = '=' * 80 _log_or_display ( to_log , msg ) tp_list_sorted = sorted ( tp_list , key = lambda tp : ( tp [ 0 ] , tp [ 1 ] ) ) for tp in tp_list_sorted : curr_repl = [ tp_repl [ 1 ] for tp_repl in curr_plan_list if tp_repl [ 0 ] == tp ] [ 0 ] proposed_repl = [ tp_repl [ 1 ] for tp_repl in new_plan_list if tp_repl [ 0 ] == tp ] [ 0 ] tp_str = '{topic} - {partition:<2d}' . format ( topic = tp [ 0 ] , partition = tp [ 1 ] ) row = ( '{tp:<30s}: {curr_repl:<20s} ==> {proposed_repl:<20s}' . format ( tp = tp_str , curr_repl = curr_repl , proposed_repl = proposed_repl , ) ) _log_or_display ( to_log , row )
Display current and proposed changes in
    topic-partition to replica layout over brokers.