Skip to content

Instantly share code, notes, and snippets.

@guyboertje
Created December 1, 2016 09:49
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 guyboertje/32aa4e5abcbe8b60f7361627992983a4 to your computer and use it in GitHub Desktop.
Save guyboertje/32aa4e5abcbe8b60f7361627992983a4 to your computer and use it in GitHub Desktop.
rakelib/queue.rake
namespace "queue" do
desc "print out contents of checkpoint file (specify path)"
task "print-checkpoint", [:ckpfile] do |t, args|
bin = IO.read(args.ckpfile, mode: "rb")
# + Short.BYTES // version 16 bits
# + Integer.BYTES // pageNum 32 bits
# + Integer.BYTES // firstUnackedPageNum 32 bits
# + Long.BYTES // firstUnackedSeqNum 64 bits
# + Long.BYTES // minSeqNum 64 bits
# + Integer.BYTES // eventCount 32 bits
# + Integer.BYTES; // checksum 32 bits
ints = []
i = 0
[[2, "n"], [4, "N"], [4, "N"], [4, "N"], [4, "N"], [4, "N"], [4, "N"], [4, "N"], [4, "N"]].each do |pos, unp|
ints << bin[i, pos].unpack(unp).first
i = i + pos
end
hiusn = ints[3] << 32
hisn = ints[5] << 32
puts("version: #{ints[0]}, pageNum: #{ints[1]}, firstUnackedPageNum: #{ints[2]}, firstUnackedSeqNum: #{hiusn + ints[4]}, minSeqNum: #{hisn + ints[6]}, eventCount: #{ints[7]}, checksum: #{ints[8]}.")
end
end
@guyboertje
Copy link
Author

usage:

rake queue:print-checkpoint[~/elastic/logstash/data/queue/checkpoint.head]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment