public final class RefreshListeners
extends java.lang.Object
implements org.apache.lucene.search.ReferenceManager.RefreshListener, java.io.Closeable
IndexShard
but kept here so it can be tested without standing up the entire thing.
When Closeable.close()
d it will no longer accept listeners and flush any existing listeners.Constructor and Description |
---|
RefreshListeners(java.util.function.IntSupplier getMaxRefreshListeners,
java.lang.Runnable forceRefresh,
java.util.concurrent.Executor listenerExecutor,
org.apache.logging.log4j.Logger logger) |
Modifier and Type | Method and Description |
---|---|
boolean |
addOrNotify(Translog.Location location,
java.util.function.Consumer<java.lang.Boolean> listener)
Add a listener for refreshes, calling it immediately if the location is already visible.
|
void |
afterRefresh(boolean didRefresh) |
void |
beforeRefresh() |
void |
close() |
int |
pendingCount()
The number of pending listeners.
|
boolean |
refreshNeeded()
Returns true if there are pending listeners.
|
void |
setTranslog(Translog translog)
Setup the translog used to find the last refreshed location.
|
public RefreshListeners(java.util.function.IntSupplier getMaxRefreshListeners, java.lang.Runnable forceRefresh, java.util.concurrent.Executor listenerExecutor, org.apache.logging.log4j.Logger logger)
public boolean addOrNotify(Translog.Location location, java.util.function.Consumer<java.lang.Boolean> listener)
location
- the location to listen forlistener
- for the refresh. Called with true if registering the listener ran it out of slots and forced a refresh. Called with
false otherwise.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public boolean refreshNeeded()
public int pendingCount()
public void setTranslog(Translog translog)
public void beforeRefresh() throws java.io.IOException
beforeRefresh
in interface org.apache.lucene.search.ReferenceManager.RefreshListener
java.io.IOException
public void afterRefresh(boolean didRefresh) throws java.io.IOException
afterRefresh
in interface org.apache.lucene.search.ReferenceManager.RefreshListener
java.io.IOException