def _update_pl_proxy_cluster(existing_config, verbose): existing_shards = _get_current_shards(existing_config) new_shard_configs = partition_config.get_shards() if verbose: print('{0} Existing config {0}'.format('-' * 42)) print(existing_config) print('-' * 100) shards_to_update = get_shards_to_update(existing_shards, new_shard_configs) if not shards_to_update: print('No changes. Exiting.') else: print("Shards to update:") existing_shards_by_id = {shard.id: shard for shard in existing_shards} for new in shards_to_update: print(" {} -> {}".format( existing_shards_by_id[new.id].get_server_option_string(), new.get_server_option_string())) if _confirm("Update these shards?"): alter_sql = _get_alter_server_sql(shards_to_update) if verbose: print(alter_sql) with connections[ partition_config.get_proxy_db()].cursor() as cursor: cursor.execute(alter_sql) else: print('Abort')
def _update_pl_proxy_cluster(existing_config, verbose): existing_shards = _get_current_shards(existing_config) new_shard_configs = partition_config.get_shards() if verbose: print '{0} Existing config {0}'.format('-' * 42) print existing_config print '-' * 100 shards_to_update = get_shards_to_update(existing_shards, new_shard_configs) if not shards_to_update: print 'No changes. Exiting.' else: print "Shards to update:" existing_shards_by_id = {shard.id: shard for shard in existing_shards} for new in shards_to_update: print " {} -> {}".format( existing_shards_by_id[new.id].get_server_option_string(), new.get_server_option_string() ) if _confirm("Update these shards?"): alter_sql = _get_alter_server_sql(shards_to_update) if verbose: print alter_sql with connections[partition_config.get_proxy_db()].cursor() as cursor: cursor.execute(alter_sql) else: print 'Abort'
def create_update_pl_proxy_config(): if not (settings.UNIT_TESTING and settings.USE_PARTITIONED_DATABASE): return noop_migration() drop_server_sql = get_drop_server_sql() sql_statements = [ get_pl_proxy_server_config_sql(partition_config.get_shards()), get_user_mapping_sql() ] return migrations.RunSQL('\n'.join(sql_statements), drop_server_sql)
def create_update_pl_proxy_config(): if not (settings.UNIT_TESTING and settings.USE_PARTITIONED_DATABASE): return noop_migration() drop_server_sql = get_drop_server_sql() sql_statements = [ get_pl_proxy_server_config_sql(partition_config.get_shards()), get_user_mapping_sql() ] return HqRunSQL( '\n'.join(sql_statements), drop_server_sql )
def create_pl_proxy_cluster(verbose=False, drop_existing=False): proxy_db = partition_config.get_proxy_db() if drop_existing: with connections[proxy_db].cursor() as cursor: cursor.execute(get_drop_server_sql()) config_sql = get_pl_proxy_server_config_sql(partition_config.get_shards()) user_mapping_sql = get_user_mapping_sql() if verbose: print('Running SQL') print(config_sql) print(user_mapping_sql) with connections[proxy_db].cursor() as cursor: cursor.execute(config_sql) cursor.execute(user_mapping_sql)
def create_pl_proxy_cluster(verbose=False, drop_existing=False): proxy_db = partition_config.get_proxy_db() if drop_existing: with connections[proxy_db].cursor() as cursor: cursor.execute(get_drop_server_sql()) config_sql = get_pl_proxy_server_config_sql(partition_config.get_shards()) user_mapping_sql = get_user_mapping_sql() if verbose: print 'Running SQL' print config_sql print user_mapping_sql with connections[proxy_db].cursor() as cursor: cursor.execute(config_sql) cursor.execute(user_mapping_sql)