Last active
December 25, 2015 09:07
-
-
Save shaitan/77814fbc6aef8a84d780 to your computer and use it in GitHub Desktop.
This file contains 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 | |
import sys | |
import errno | |
import elliptics | |
def main(): | |
address = elliptics.Address.from_host_port_family(sys.argv[1]) | |
backend = int(sys.argv[2]) | |
s = elliptics.Session(elliptics.create_node(remotes=[sys.argv[1]], flags=elliptics.config_flags.no_route_list)) | |
if len(sys.argv) > 3: | |
s.trace_id = int(sys.argv[3], 16) | |
s.exceptions_policy = elliptics.exceptions_policy.no_exceptions | |
s.set_direct_id(address=address, backend_id=backend) | |
s.groups = s.routes.filter_by_backend(backend).groups() | |
print 'Iterating node: {}/{}'.format(address, backend) | |
async = s.start_iterator('', | |
[], | |
elliptics.iterator_types.network, | |
elliptics.iterator_flags.no_meta, | |
elliptics.Time(0, 0), | |
elliptics.Time(0, 0)) | |
results = async.get() | |
for result in results: | |
if result.response.record_flags & elliptics.record_flags.uncommitted: | |
continue | |
async = s.read_data(result.response.key, 0, 1) | |
async.wait() | |
if async.error().code not in (0, -errno.ENOENT): | |
print 'Failed to read key: {} , error: {}'.format(result.response.key, repr(async.error())) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment