src/dirbs/cli/db.py
def repartition(ctx, num_physical_shards):
    """Repartition DIRBS Core tables into a new number of physical IMEI shards."""
    logger = logging.getLogger('dirbs.db')
    config = common.ensure_config(ctx)
    with utils.create_db_connection(config.db_config) as conn, conn.cursor() as cursor:
        logger.info('Repartitioning DB schema in DB %s on host %s into %d physical shards...',
                    config.db_config.database,
                    config.db_config.host,
                    num_physical_shards)

        logger.info('Re-partitioning classification_state table...')
        partition_utils.repartition_classification_state(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned classification_state table')

        logger.info('Re-partitioning registration_list table...')
        partition_utils.repartition_registration_list(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned registration_list table')

        logger.info('Re-partitioning stolen_list table...')
        partition_utils.repartition_stolen_list(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned stolen_list table')

        logger.info('Re-partitioning pairing_list table...')
        partition_utils.repartition_pairing_list(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned pairing_list table')

        logger.info('Re-partitioning blacklist table...')
        partition_utils.repartition_blacklist(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned blacklist table')

        logger.info('Re-partitioning notifications_lists table...')
        partition_utils.repartition_notifications_lists(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned notifications_lists table')

        logger.info('Re-partitioning exceptions_lists table...')
        partition_utils.repartition_exceptions_lists(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned exceptions_lists table')

        logger.info('Re-partitioning network_imeis table...')
        partition_utils.repartition_network_imeis(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned network_imeis table')

        logger.info('Re-partitioning monthly_network_triplets tables...')
        partition_utils.repartition_monthly_network_triplets(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned monthly_network_triplets tables')

        # Update schema metadata table
        cursor.execute('UPDATE schema_metadata SET phys_shards = %s', [num_physical_shards])
Repartition DIRBS Core tables into a new number of physical IMEI shards.
Repartition DIRBS Core tables into a new number of physical IMEI shards.
Repartition DIRBS Core tables into a new number of physical IMEI shards .
def repartition(ctx, num_physical_shards):
    logger = logging.getLogger('dirbs.db')
    config = common.ensure_config(ctx)
    with utils.create_db_connection(config.db_config) as conn, conn.cursor() as cursor:
        logger.info('Repartitioning DB schema in DB %s on host %s into %d physical shards...',
                    config.db_config.database,
                    config.db_config.host,
                    num_physical_shards)
        logger.info('Re-partitioning classification_state table...')
        partition_utils.repartition_classification_state(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned classification_state table')
        logger.info('Re-partitioning registration_list table...')
        partition_utils.repartition_registration_list(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned registration_list table')
        logger.info('Re-partitioning stolen_list table...')
        partition_utils.repartition_stolen_list(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned stolen_list table')
        logger.info('Re-partitioning pairing_list table...')
        partition_utils.repartition_pairing_list(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned pairing_list table')
        logger.info('Re-partitioning blacklist table...')
        partition_utils.repartition_blacklist(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned blacklist table')
        logger.info('Re-partitioning notifications_lists table...')
        partition_utils.repartition_notifications_lists(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned notifications_lists table')
        logger.info('Re-partitioning exceptions_lists table...')
        partition_utils.repartition_exceptions_lists(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned exceptions_lists table')
        logger.info('Re-partitioning network_imeis table...')
        partition_utils.repartition_network_imeis(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned network_imeis table')
        logger.info('Re-partitioning monthly_network_triplets tables...')
        partition_utils.repartition_monthly_network_triplets(conn, num_physical_shards=num_physical_shards)
        logger.info('Re-partitioned monthly_network_triplets tables')
        cursor.execute('UPDATE schema_metadata SET phys_shards = %s', [num_physical_shards])
def repartition ( ctx , num_physical_shards ) : logger = logging . getLogger ( 'dirbs.db' ) config = common . ensure_config ( ctx ) with utils . create_db_connection ( config . db_config ) as conn , conn . cursor ( ) as cursor : logger . info ( 'Repartitioning DB schema in DB %s on host %s into %d physical shards...' , config . db_config . database , config . db_config . host , num_physical_shards ) logger . info ( 'Re-partitioning classification_state table...' ) partition_utils . repartition_classification_state ( conn , num_physical_shards = num_physical_shards ) logger . info ( 'Re-partitioned classification_state table' ) logger . info ( 'Re-partitioning registration_list table...' ) partition_utils . repartition_registration_list ( conn , num_physical_shards = num_physical_shards ) logger . info ( 'Re-partitioned registration_list table' ) logger . info ( 'Re-partitioning stolen_list table...' ) partition_utils . repartition_stolen_list ( conn , num_physical_shards = num_physical_shards ) logger . info ( 'Re-partitioned stolen_list table' ) logger . info ( 'Re-partitioning pairing_list table...' ) partition_utils . repartition_pairing_list ( conn , num_physical_shards = num_physical_shards ) logger . info ( 'Re-partitioned pairing_list table' ) logger . info ( 'Re-partitioning blacklist table...' ) partition_utils . repartition_blacklist ( conn , num_physical_shards = num_physical_shards ) logger . info ( 'Re-partitioned blacklist table' ) logger . info ( 'Re-partitioning notifications_lists table...' ) partition_utils . repartition_notifications_lists ( conn , num_physical_shards = num_physical_shards ) logger . info ( 'Re-partitioned notifications_lists table' ) logger . info ( 'Re-partitioning exceptions_lists table...' ) partition_utils . repartition_exceptions_lists ( conn , num_physical_shards = num_physical_shards ) logger . info ( 'Re-partitioned exceptions_lists table' ) logger . info ( 'Re-partitioning network_imeis table...' ) partition_utils . repartition_network_imeis ( conn , num_physical_shards = num_physical_shards ) logger . info ( 'Re-partitioned network_imeis table' ) logger . info ( 'Re-partitioning monthly_network_triplets tables...' ) partition_utils . repartition_monthly_network_triplets ( conn , num_physical_shards = num_physical_shards ) logger . info ( 'Re-partitioned monthly_network_triplets tables' ) cursor . execute ( 'UPDATE schema_metadata SET phys_shards = %s' , [ num_physical_shards ] )
Repartition DIRBS Core tables into a new number of physical IMEI shards.
Repartition DIRBS Core tables into a new number of physical IMEI shards .
"""Repartition DIRBS Core tables into a new number of physical IMEI shards.""" # Update schema metadata table
ctx
num_physical_shards