Reputation: 2608
i am trying to create a shell script which will delete my znodes. Here is the command:
echo "ls /" | zookeeper-client
echo "rmr /collections" | zookeeper-client
There are many such nodes i want to delete. Whenever i execute the above commands, sometimes it successfully delete the collections node and sometime it throws error. The reason i found is whenever we run "zookeeper-client" through a shell script, it takes time for the zookeeper shell to come up. Is there any way i can delete such nodes ?
Any help will be appreciated.
Thanks.
Upvotes: 0
Views: 2713
Reputation: 36
You can delete with this zookeeper-client rmr
e.g zookeeper-client rmr /test
Upvotes: 2
Reputation: 295403
The amount of hackery here is horrendous -- I'm having trouble retaining any self-respect after writing the below.
Please, please use a different language rather than adopting the below collection of awful hacks.
IFS=$'\n ' read -r -d '' -a names \
< <(./cli_st 127.0.0.1:2181 < <(sleep 1; echo 'ls /'; sleep 1) 2>&1 | grep '^[[:space:]]')
./cli_st 127.0.0.1:2181 < <(sleep 1; printf 'rmr %s\n' "${names[@]}"; sleep 1; )
cli_st
, here, is the command-line client included in the Zookeeper codebase's C-language bits.
Upvotes: 0