Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gengmao
Copy link

@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

yongjunj commented Jul 6, 2015

@gengmao This worked like a charm - Thanks!

@19h
Copy link

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