Java Code Examples for org.apache.curator.utils.CloseableScheduledExecutorService

The following examples show how to use org.apache.curator.utils.CloseableScheduledExecutorService. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: xian   Source File: ChildReaper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param client the client
 * @param path path to reap children from
 * @param executor executor to use for background tasks
 * @param reapingThresholdMs threshold in milliseconds that determines that a path can be deleted
 * @param mode reaping mode
 * @param leaderPath if not null, uses a leader selection so that only 1 reaper is active in the cluster
 * @param lockSchema a set of the possible subnodes of the children of path that must be reaped in addition to the child nodes
 */
public ChildReaper(CuratorFramework client, String path, Reaper.Mode mode, ScheduledExecutorService executor, int reapingThresholdMs, String leaderPath, Set<String> lockSchema)
{
    this.client = client;
    this.mode = mode;
    this.executor = new CloseableScheduledExecutorService(executor);
    this.reapingThresholdMs = reapingThresholdMs;
    if (leaderPath != null)
    {
        leaderLatch = new LeaderLatch(client, leaderPath);
    }
    else
    {
        leaderLatch = null;
    }
    this.reaper = new Reaper(client, executor, reapingThresholdMs, leaderLatch);
    this.lockSchema = lockSchema;
    addPath(path);
}
 
Example 2
Source Project: xian   Source File: Reaper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param client             client
 * @param executor           thread pool
 * @param reapingThresholdMs threshold in milliseconds that determines that a path can be deleted
 * @param leaderLatch        a pre-created leader latch to ensure only 1 reaper is active in the cluster
 * @param ownsLeaderLatch    indicates whether or not the reaper owns the leader latch (if it exists) and thus should start/stop it
 * */
private Reaper(CuratorFramework client, ScheduledExecutorService executor, int reapingThresholdMs, LeaderLatch leaderLatch, boolean ownsLeaderLatch)
{
    this.client = client;
    this.executor = new CloseableScheduledExecutorService(executor);
    this.reapingThresholdMs = reapingThresholdMs / EMPTY_COUNT_THRESHOLD;
    this.leaderLatch = leaderLatch;
    if (leaderLatch != null)
    {
        addListenerToLeaderLatch(leaderLatch);
    }
    this.ownsLeaderLatch = ownsLeaderLatch;
}
 
Example 3
Source Project: hadoop   Source File: ChildReaper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param client the client
 * @param path path to reap children from
 * @param executor executor to use for background tasks
 * @param reapingThresholdMs threshold in milliseconds that determines that a path can be deleted
 * @param mode reaping mode
 * @param leaderPath if not null, uses a leader selection so that only 1 reaper is active in the cluster
 */
public ChildReaper(CuratorFramework client, String path, Reaper.Mode mode, ScheduledExecutorService executor, int reapingThresholdMs, String leaderPath)
{
  this.client = client;
  this.mode = mode;
  this.executor = new CloseableScheduledExecutorService(executor);
  this.reapingThresholdMs = reapingThresholdMs;
  this.reaper = new Reaper(client, executor, reapingThresholdMs, leaderPath);
  addPath(path);
}
 
Example 4
Source Project: big-c   Source File: ChildReaper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param client the client
 * @param path path to reap children from
 * @param executor executor to use for background tasks
 * @param reapingThresholdMs threshold in milliseconds that determines that a path can be deleted
 * @param mode reaping mode
 * @param leaderPath if not null, uses a leader selection so that only 1 reaper is active in the cluster
 */
public ChildReaper(CuratorFramework client, String path, Reaper.Mode mode, ScheduledExecutorService executor, int reapingThresholdMs, String leaderPath)
{
  this.client = client;
  this.mode = mode;
  this.executor = new CloseableScheduledExecutorService(executor);
  this.reapingThresholdMs = reapingThresholdMs;
  this.reaper = new Reaper(client, executor, reapingThresholdMs, leaderPath);
  addPath(path);
}