org.apache.curator.framework.recipes.locks
Class Reaper

java.lang.Object
  extended by org.apache.curator.framework.recipes.locks.Reaper
All Implemented Interfaces:
Closeable

public class Reaper
extends Object
implements 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(org.apache.curator.framework.CuratorFramework client)
          Uses the default reaping threshold of 5 minutes and creates an internal thread pool
Reaper(org.apache.curator.framework.CuratorFramework client, int reapingThresholdMs)
          Uses the given reaping threshold and creates an internal thread pool
Reaper(org.apache.curator.framework.CuratorFramework client, ScheduledExecutorService executor, int reapingThresholdMs)
           
Reaper(org.apache.curator.framework.CuratorFramework client, ScheduledExecutorService executor, int reapingThresholdMs, String leaderPath)
           
 
Method Summary
 void addPath(String path)
          Add a path (using Mode.REAP_INDEFINITELY) to be checked by the reaper.
 void addPath(String path, Reaper.Mode mode)
          Add a path to be checked by the reaper.
 void close()
           
static ScheduledExecutorService newExecutorService()
          Allocate an executor service for the reaper
protected  void reap(org.apache.curator.framework.recipes.locks.Reaper.PathHolder holder)
           
 boolean removePath(String path)
          Stop reaping the given path
protected  Future<?> schedule(org.apache.curator.framework.recipes.locks.Reaper.PathHolder pathHolder, int reapingThresholdMs)
           
 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(org.apache.curator.framework.CuratorFramework client)
Uses the default reaping threshold of 5 minutes and creates an internal thread pool

Parameters:
client - client

Reaper

public Reaper(org.apache.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(org.apache.curator.framework.CuratorFramework client,
              ScheduledExecutorService executor,
              int reapingThresholdMs)
Parameters:
client - client
executor - thread pool
reapingThresholdMs - threshold in milliseconds that determines that a path can be deleted

Reaper

public Reaper(org.apache.curator.framework.CuratorFramework client,
              ScheduledExecutorService executor,
              int reapingThresholdMs,
              String leaderPath)
Parameters:
client - client
executor - thread pool
reapingThresholdMs - threshold in milliseconds that determines that a path can be deleted
leaderPath - if not null, uses a leader selection so that only 1 reaper is active in the cluster
Method Detail

addPath

public void addPath(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(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(String path)
Stop reaping the given path

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

start

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

Throws:
Exception - errors

close

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

schedule

protected Future<?> schedule(org.apache.curator.framework.recipes.locks.Reaper.PathHolder pathHolder,
                             int reapingThresholdMs)

reap

protected void reap(org.apache.curator.framework.recipes.locks.Reaper.PathHolder holder)

newExecutorService

public static ScheduledExecutorService newExecutorService()
Allocate an executor service for the reaper

Returns:
service


Copyright © 2011–2014 The Apache Software Foundation. All rights reserved.