I am keeping some configuration on Zookeeper which a what to expire after some time if it has not being updated.
By using TTL, I can achieve that, but how do I renew the TTL? remove and add node is an option but produce inconsistent states.
Would setData(same data) or Op.check renew the TTL of the node?
Thanks in advance!
setData
will renew the TTL of the node.
Actually, not renew the ttl, but renew the mtime of the node. In Zookeeper, the way to check if a node should expire is to compare the return of getElapsed
and configured TTL
. setData
will renew the mtime.
protected long getElapsed(DataNode node) {
return Time.currentWallTime() - node.stat.getMtime();
}