Package org.elasticsearch.index.shard
Class RefreshListeners
org.elasticsearch.index.shard.RefreshListeners
- All Implemented Interfaces:
,
,
org.apache.lucene.search.ReferenceManager.RefreshListener
public final class RefreshListeners
extends
implements org.apache.lucene.search.ReferenceManager.RefreshListener,
Allows for the registration of listeners that are called when a change becomes visible for search. This functionality is exposed from
IndexShard
but kept here so it can be tested without standing up the entire thing.
When d it will no longer accept listeners and flush any existing listeners.-
Constructor Summary
ConstructorDescriptiongetMaxRefreshListeners, forceRefresh, org.apache.logging.log4j.Logger logger, ThreadContext threadContext, MeanMetric refreshMetric)
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addOrNotify(Translog.Location location, <> listener)
Add a listener for refreshes, calling it immediately if the location is already visible.void
afterRefresh(boolean didRefresh)
void
void
close()
org.elasticsearch.core.Releasable
Force-refreshes newly added listeners and forces a refresh if there are currently listeners registered.int
The number of pending listeners.boolean
Returns true if there are pending listeners.void
<Translog.Location> currentRefreshLocationSupplier)
Setup the translog used to find the last refreshed location.Methods inherited from class java.lang.
, , , , , , , , , ,
-
Constructor Details
-
RefreshListeners
public RefreshListeners( getMaxRefreshListeners, forceRefresh, org.apache.logging.log4j.Logger logger, ThreadContext threadContext, MeanMetric refreshMetric)
-
-
Method Details
-
forceRefreshes
public org.elasticsearch.core.Releasable forceRefreshes()Force-refreshes newly added listeners and forces a refresh if there are currently listeners registered. SeerefreshForcers
. -
addOrNotify
Add a listener for refreshes, calling it immediately if the location is already visible. If this runs out of listener slots then it forces a refresh and calls the listener immediately as well.- Parameters:
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.- Returns:
- did we call the listener (true) or register the listener to call later (false)?
-
close
public void close() throws- Specified by:
in interface
- Specified by:
in interface
- Throws:
-
refreshNeeded
public boolean refreshNeeded()Returns true if there are pending listeners. -
pendingCount
public int pendingCount()The number of pending listeners. -
setCurrentRefreshLocationSupplier
Setup the translog used to find the last refreshed location. -
beforeRefresh
public void beforeRefresh() throws- Specified by:
beforeRefresh
in interfaceorg.apache.lucene.search.ReferenceManager.RefreshListener
- Throws:
-
afterRefresh
public void afterRefresh(boolean didRefresh) throws- Specified by:
afterRefresh
in interfaceorg.apache.lucene.search.ReferenceManager.RefreshListener
- Throws:
-