Use base64 encoding to support dump and import binary data
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 This worked like a charm - Thanks!
I love you. Also, who cares if the data isn't readable anymore: I shat my pants when our dumps didn't import correctly.
🍻