Skip to content

Use base64 encoding to support dump and import binary data#9

Open
gengmao wants to merge 2 commits intosroegner:masterfrom
gengmao:master
Open

Use base64 encoding to support dump and import binary data#9
gengmao wants to merge 2 commits intosroegner:masterfrom
gengmao:master

Conversation

@gengmao
Copy link
Copy Markdown

@gengmao gengmao commented May 13, 2015

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 #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.

@yongjunj
Copy link
Copy Markdown

yongjunj commented Jul 6, 2015

@gengmao This worked like a charm - Thanks!

@19h
Copy link
Copy Markdown

19h commented Aug 5, 2016

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

🍻

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants