Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-636

Make PersistentTtlNode initialDelay more configurable

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • Recipes
    • None

    Description

      Currently when PersistentTtlNode starts, it will

      1. create a CONTAINER node
      2. 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<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit 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` 

      Attachments

        Activity

          People

            Unassigned Unassigned
            yang-wei Lim Yang Wei
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified