public class TaskLockbox extends Object
| Constructor and Description | 
|---|
TaskLockbox(TaskStorage taskStorage)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
add(Task task)  | 
<T> T | 
doInCriticalSection(Task task,
                   List<org.joda.time.Interval> intervals,
                   CriticalAction<T> action)
Perform the given action with a guarantee that the locks of the task are not revoked in the middle of action. 
 | 
List<TaskLock> | 
findLocksForTask(Task task)
Return the currently-active locks for some task. 
 | 
Map<String,NavigableMap<org.joda.time.Interval,List<io.druid.indexing.overlord.TaskLockbox.TaskLockPosse>>> | 
getAllLocks()  | 
LockResult | 
lock(TaskLockType lockType,
    Task task,
    org.joda.time.Interval interval)
Acquires a lock on behalf of a task. 
 | 
LockResult | 
lock(TaskLockType lockType,
    Task task,
    org.joda.time.Interval interval,
    long timeoutMs)
Acquires a lock on behalf of a task, waiting up to the specified wait time if necessary. 
 | 
void | 
remove(Task task)
Release all locks for a task and remove task from set of active tasks. 
 | 
void | 
syncFromStorage()
Wipe out our current in-memory state and resync it from our bundled  
TaskStorage. | 
LockResult | 
tryLock(TaskLockType lockType,
       Task task,
       org.joda.time.Interval interval)
Attempt to acquire a lock for a task, without removing it from the queue. 
 | 
void | 
unlock(Task task,
      org.joda.time.Interval interval)
Release lock held for a task on a particular interval. 
 | 
@Inject public TaskLockbox(TaskStorage taskStorage)
public void syncFromStorage()
TaskStorage.public LockResult lock(TaskLockType lockType, Task task, org.joda.time.Interval interval) throws InterruptedException
lockType - lock typetask - task to acquire lock forinterval - interval to lockLockResult containing a new or an existing lock if succeeded. Otherwise, LockResult with a
 LockResult.revoked flag.InterruptedException - if the current thread is interruptedpublic LockResult lock(TaskLockType lockType, Task task, org.joda.time.Interval interval, long timeoutMs) throws InterruptedException
lockType - lock typetask - task to acquire a lock forinterval - interval to locktimeoutMs - maximum time to waitLockResult containing a new or an existing lock if succeeded. Otherwise, LockResult with a
 LockResult.revoked flag.InterruptedException - if the current thread is interruptedpublic LockResult tryLock(TaskLockType lockType, Task task, org.joda.time.Interval interval)
lockType - type of lock to be acquiredtask - task that wants a lockinterval - interval to lockLockResult containing a new or an existing lock if succeeded. Otherwise, LockResult with a
 LockResult.revoked flag.IllegalStateException - if the task is not a valid active taskpublic <T> T doInCriticalSection(Task task, List<org.joda.time.Interval> intervals, CriticalAction<T> action) throws Exception
task - task performing a critical actionintervals - intervalsaction - action to be performed inside of the critical sectionExceptionpublic List<TaskLock> findLocksForTask(Task task)
task - task for which to locate lockspublic void unlock(Task task, org.joda.time.Interval interval)
task - task to unlockinterval - interval to unlockpublic void remove(Task task)
task - task to unlockpublic void add(Task task)
public Map<String,NavigableMap<org.joda.time.Interval,List<io.druid.indexing.overlord.TaskLockbox.TaskLockPosse>>> getAllLocks()
Copyright © 2011–2018. All rights reserved.