zookeeper-util icon indicating copy to clipboard operation
zookeeper-util copied to clipboard

Use base64 encoding to support dump and import binary data

Open gengmao opened this issue 10 years ago • 2 comments

Some of my zookeeper nodes have binary data. When I dumped them out and import back, I hit following exception.

ArgumentError: invalid byte sequence in UTF-8
         =~ at org/jruby/RubyRegexp.java:1657
     (root) at /home/mao/zookeeper-util/usr/share/zookeeper-util/bin/zk_import.rb:64
  each_line at org/jruby/RubyIO.java:3547
     (root) at /home/mao/zookeeper-util/usr/share/zookeeper-util/bin/zk_import.rb:63

Then I studied source code and https://github.com/sroegner/zookeeper-util/pull/7, found the binary data was not processed correctly. As the dump file is only parsed as text file when import, the binary data need to be encoded in a revertible text format, for example base64. With this PR, multi-lines node data can be imported too. Just one drawback - node data in the dump file are not readable any more.

gengmao avatar May 13 '15 00:05 gengmao

@gengmao This worked like a charm - Thanks!

yongjunj avatar Jul 06 '15 18:07 yongjunj

I love you. Also, who cares if the data isn't readable anymore: I shat my pants when our dumps didn't import correctly.

🍻

19h avatar Aug 05 '16 20:08 19h