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
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use base64 encoding to support dump and import binary data
  • Loading branch information
Mao Geng committed May 12, 2015
commit dcbbab576511cea2cbac6b7f8f40dfa6492fa6ca
2 changes: 1 addition & 1 deletion usr/share/zookeeper-util/bin/zk_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
zk.create_path(a[0].chomp)
elsif(a.size == 2)
puts "# Writing data '#{a[1]}' to Path #{a[0]}" if options[:verbose]
zk.set_data(a[0].chomp, a[1].chomp)
zk.set_data(a[0].chomp, javax.xml.bind.DatatypeConverter.parseBase64Binary(a[1]))
else
puts "#{line} is broken"
end
Expand Down
11 changes: 7 additions & 4 deletions usr/share/zookeeper-util/bin/zookeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ def dump(path, separator=DEFAULT_SEPARATOR)
next if path.eql?('/') && node.eql?('zookeeper')
stat = Stat.new
new_path = File.join(path, node)
d = @zk.get_data(new_path, false, stat) || ''.to_java_bytes
node_data = "#{String.from_java_bytes(d)}"
puts node_data.to_s.empty? ? "#{new_path}" : "#{new_path}#{separator}#{node_data}"

d = @zk.get_data(new_path, false, stat)
if d == nil or d.length == 0
puts "#{new_path}"
else
node_data = "#{javax.xml.bind.DatatypeConverter.printBase64Binary(d)}"
puts "#{new_path}#{separator}#{node_data}"
end
dump(new_path, separator) unless (stat.getNumChildren == 0)
end
end
Expand Down