java.io.Closeable, java.lang.AutoCloseable, org.apache.lucene.search.ReferenceManager.RefreshListenerpublic 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 | Description |
|---|---|
RefreshListeners(java.util.function.IntSupplier getMaxRefreshListeners,
java.lang.Runnable forceRefresh,
java.util.concurrent.Executor listenerExecutor,
org.apache.logging.log4j.Logger logger,
ThreadContext threadContext) |
| Modifier and Type | Method | 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 |
setCurrentRefreshLocationSupplier(java.util.function.Supplier<Translog.Location> currentRefreshLocationSupplier) |
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,
ThreadContext threadContext)
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.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOExceptionpublic boolean refreshNeeded()
public int pendingCount()
public void setCurrentRefreshLocationSupplier(java.util.function.Supplier<Translog.Location> currentRefreshLocationSupplier)
public void beforeRefresh()
throws java.io.IOException
beforeRefresh in interface org.apache.lucene.search.ReferenceManager.RefreshListenerjava.io.IOExceptionpublic void afterRefresh(boolean didRefresh)
throws java.io.IOException
afterRefresh in interface org.apache.lucene.search.ReferenceManager.RefreshListenerjava.io.IOException