You could use the transaction api to create a new node and delete the old node. 

-JZ


From: Mudit Verma [email protected]
Reply: [email protected] [email protected]
Date: June 16, 2014 at 8:38:11 AM
To: [email protected] [email protected]
Subject:  renaming a znode  

Hello People,  

Sorry for asking many questions these days. :)  

I am wondering if it is possible to rename a znode? I am building a distributed 
map on top of zookeeper for special needs. From time to time, I need to freeze 
the map without restricting write access to the map.  

I plan to do it by maintaining two maps:  

map_current  
map_frozen  

all the map entries are maintained as separate children znodes where key is the 
name of the child node and value is the value stored on the child node ..  
for example /map_current/entry1(kv)  
/map_current/entry2(kv)  


Now at some point of time, I need to iterate the map while still allowing write 
access by other clients. While I iterate, I don’t want other clients to see 
these entries. Once I process map_frozen entries I will delete them (I don’t 
need them anymore) by just deleting the parent node.  

I plan to rename existing map from map_current to map_frozen and create new map 
as map_current with empty data for further writes. Other clients will continue 
to write new entries in map_current .. so on so forth ..  

Any suggestions on how can I do it efficiently.  

Thanks  
Mudit

Reply via email to