Last active
May 7, 2017 00:30
-
-
Save ciscorn/22867eb4f5af698298dd2a7331ea31c1 to your computer and use it in GitHub Desktop.
Edit the ReplicaReplacement value of Seaweedfs's dat file.
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
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