Skip to content

Instantly share code, notes, and snippets.

@autocracy
Created April 24, 2015 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save autocracy/9467eaaff581ff24334c to your computer and use it in GitHub Desktop.
Save autocracy/9467eaaff581ff24334c to your computer and use it in GitHub Desktop.
import re
# Holy crap this library is so unoptimized ...
import spans
class longrange(spans.intrange):
type = long
class longrangeset(spans.intrangeset):
type = longrange
successes = set()
regex = re.compile('\[repair #([^\]]+)\] session completed successfully')
with open('successes') as f:
for l in f.readlines():
m = regex.match(l)
if not m:
continue
g = m.groups()
successes.add(g[0])
regex = re.compile(r'\[repair #([^\]]+)\].*on range \((.*)] for ([^.]+).')
ranges = longrangeset([])
with open('repairs') as f:
for l in f.readlines():
m = regex.match(l)
if not m:
continue
g = m.groups()
if g[0] not in successes:
continue
(lower, upper) = [long(x) for x in g[1].split(',')]
if lower < upper:
ranges.add(longrange(lower, upper))
else:
ranges.add(longrange(-2**63, upper))
ranges.add(longrange(lower, 2**63-1))
m = longrangeset([longrange(-2**63, 2**63-1)])
failed = m.difference(ranges)
for pair in failed._list:
print "nodetool repair -dcpar -st {} -et {}".format(pair.lower, pair.upper)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment