public class IndexShardOperationsLock
extends java.lang.Object
implements java.io.Closeable
Constructor and Description |
---|
IndexShardOperationsLock(ShardId shardId,
org.apache.logging.log4j.Logger logger,
ThreadPool threadPool) |
Modifier and Type | Method and Description |
---|---|
void |
acquire(ActionListener<Releasable> onAcquired,
java.lang.String executorOnDelay,
boolean forceExecution)
Acquires a lock whenever lock acquisition is not blocked.
|
void |
blockOperations(long timeout,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Runnable onBlocked)
Wait for in-flight operations to finish and executes onBlocked under the guarantee that no new operations are started.
|
void |
close() |
int |
getActiveOperationsCount() |
public IndexShardOperationsLock(ShardId shardId, org.apache.logging.log4j.Logger logger, ThreadPool threadPool)
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void blockOperations(long timeout, java.util.concurrent.TimeUnit timeUnit, java.lang.Runnable onBlocked) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
timeout
- the maximum time to wait for the in-flight operations blocktimeUnit
- the time unit of the timeout
argumentonBlocked
- the action to run once the block has been acquiredjava.lang.InterruptedException
- if calling thread is interruptedjava.util.concurrent.TimeoutException
- if timed out waiting for in-flight operations to finishIndexShardClosedException
- if operation lock has been closedpublic void acquire(ActionListener<Releasable> onAcquired, java.lang.String executorOnDelay, boolean forceExecution)
blockOperations(long, TimeUnit, Runnable)
, lock
acquisition can be delayed. The provided ActionListener will then be called using the provided executor once blockOperations
terminates.onAcquired
- ActionListener that is invoked once acquisition is successful or failedexecutorOnDelay
- executor to use for delayed callforceExecution
- whether the runnable should force its execution in case it gets rejectedpublic int getActiveOperationsCount()