Skip to content

Instantly share code, notes, and snippets.

@ciscorn
Last active May 7, 2017 00:30
Show Gist options
  • Save ciscorn/22867eb4f5af698298dd2a7331ea31c1 to your computer and use it in GitHub Desktop.
Save ciscorn/22867eb4f5af698298dd2a7331ea31c1 to your computer and use it in GitHub Desktop.
Edit the ReplicaReplacement value of Seaweedfs's dat file.
import sys
import mmap
# usage:
# $ python3 rewrite_rp.py 1.dat 001
with open(sys.argv[1], 'rb+') as f:
with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_WRITE) as m:
(curr_rp, new_rp) = (m[1], int(sys.argv[2]))
print("{0:03d} -> {1:03d}".format(curr_rp, new_rp))
m[1] = new_rp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment