com.netflix.curator.framework.recipes.locks
Class Reaper

java.lang.Object
  extended by com.netflix.curator.framework.recipes.locks.Reaper
All Implemented Interfaces:
java.io.Closeable

public class Reaper
extends java.lang.Object
implements java.io.Closeable

Utility to clean up parent lock nodes so that they don't stay around as garbage


Nested Class Summary
static class Reaper.Mode
           
 
Constructor Summary
Reaper(com.netflix.curator.framework.CuratorFramework client)
          Uses the default reaping threshold of 5 minutes and creates an internal thread pool
Reaper(com.netflix.curator.framework.CuratorFramework client, int reapingThresholdMs)
          Uses the given reaping threshold and creates an internal thread pool
Reaper(com.netflix.curator.framework.CuratorFramework client, java.util.concurrent.ScheduledExecutorService executor, int reapingThresholdMs)
           
 
Method Summary
 void addPath(java.lang.String path)
          Add a path (using Mode.REAP_INDEFINITELY) to be checked by the reaper.
 void addPath(java.lang.String path, Reaper.Mode mode)
          Add a path to be checked by the reaper.
 void close()
           
 boolean removePath(java.lang.String path)
          Stop reaping the given path
 void start()
          The reaper must be started
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Reaper

public Reaper(com.netflix.curator.framework.CuratorFramework client)
Uses the default reaping threshold of 5 minutes and creates an internal thread pool

Parameters:
client - client

Reaper

public Reaper(com.netflix.curator.framework.CuratorFramework client,
              int reapingThresholdMs)
Uses the given reaping threshold and creates an internal thread pool

Parameters:
client - client
reapingThresholdMs - threshold in milliseconds that determines that a path can be deleted

Reaper

public Reaper(com.netflix.curator.framework.CuratorFramework client,
              java.util.concurrent.ScheduledExecutorService executor,
              int reapingThresholdMs)
Parameters:
client - client
executor - thread pool
reapingThresholdMs - threshold in milliseconds that determines that a path can be deleted
Method Detail

addPath

public void addPath(java.lang.String path)
Add a path (using Mode.REAP_INDEFINITELY) to be checked by the reaper. The path will be checked periodically until the reaper is closed.

Parameters:
path - path to check

addPath

public void addPath(java.lang.String path,
                    Reaper.Mode mode)
Add a path to be checked by the reaper. The path will be checked periodically until the reaper is closed, or until the point specified by the Mode

Parameters:
path - path to check
mode - reaping mode

removePath

public boolean removePath(java.lang.String path)
Stop reaping the given path

Parameters:
path - path to remove
Returns:
true if the path was removed

start

public void start()
           throws java.lang.Exception
The reaper must be started

Throws:
java.lang.Exception - errors

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException