Created
June 12, 2020 19:25
-
-
Save clayg/3aa46343f17ac4e7a84d761878b32455 to your computer and use it in GitHub Desktop.
Skip some shard dbs and prioritize other containers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from swift.container import sharder | |
| from swift.common.utils import parse_options | |
| from swift.common.daemon import run_daemon | |
| from optparse import OptionParser | |
| orig_sharding_enabled = sharder.sharding_enabled | |
| def make_priority_sharding_enabled(options): | |
| filter_containers = set(options.pop('filter_containers')) | |
| skip_containers = set(options.pop('skip_containers')) | |
| def priority_sharding_enabled(broker): | |
| broker_name = '%s/%s' % (broker.root_account, broker.root_container) | |
| if filter_containers and ( | |
| broker_name not in filter_containers): | |
| return False | |
| if skip_containers and ( | |
| broker_name in skip_containers): | |
| return False | |
| return orig_sharding_enabled(broker) | |
| return priority_sharding_enabled | |
| if __name__ == '__main__': | |
| parser = OptionParser("%prog CONFIG [options]") | |
| parser.add_option('--container', default=[], action='append', | |
| dest='filter_containers', | |
| help="Only process specific AUTH_acct/container(s)") | |
| parser.add_option('--skip', default=[], action='append', | |
| dest='skip_containers', | |
| help="Do not process skipped AUTH_acct/container(s)") | |
| conf_file, options = parse_options(parser=parser, once=True) | |
| sharder.sharding_enabled = make_priority_sharding_enabled(options) | |
| run_daemon(sharder.ContainerSharder, conf_file, **options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment