Lim Yang Wei created CURATOR-636:
------------------------------------

             Summary: Make PersistentTtlNode initialDelay more configurable
                 Key: CURATOR-636
                 URL: https://issues.apache.org/jira/browse/CURATOR-636
             Project: Apache Curator
          Issue Type: New Feature
          Components: Recipes
            Reporter: Lim Yang Wei


Currently when PersistentTtlNode starts, it will
 # create a CONTAINER node
 # create a CHILD node `_touch`

But there is a initialDelay between 1 and 2. If the initialDelay is long enough 
and the client is disconnected, 1 will not be deleted forever (because 
CONTAINER node only delete its parent when all its child is gone, but in this 
case, it never has any of them).

The initialDelay could be configured, but not so flexible. The initialDelay is 
calculated by the formula `ttl/touchScheduleFactor`, but this formula is also 
used to how frequent we want to ping Zookeeper to keep our znodes alive, aka 
period.

As you can see here (2nd parameter is initialDelay and 3rd parameter is for 
period)

|// PersistentTtlNode.java
Future<?> future = executorService.scheduleAtFixedRate(touchTask, ttlMs / 
touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
 
// Interface ScheduledExecutorService
[ScheduledFuture|https://docs.oracle.com/javase/jp/8/docs/api/java/util/concurrent/ScheduledFuture.html]<?>
 
scheduleAtFixedRate([Runnable|https://docs.oracle.com/javase/jp/8/docs/api/java/lang/Runnable.html]
 command, long initialDelay, long period, 
[TimeUnit|https://docs.oracle.com/javase/jp/8/docs/api/java/util/concurrent/TimeUnit.html]
 unit)|
||

Let's say we have ttl of 5 minutes. We want to have 0 initialDelay so we will 
set the touchScheduleFactor to 5 minutes too. This will give us 1ms (5 
minutes/5 minutes) of initialDelay (which solves our problem) but spamming 
Zookeeper every second.

So it would be nice if we can set `initialDelay` 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to