Class ControlledRealTimeReopenThread<T>
Utility class that runs a thread to manage periodic reopens of a ReferenceManager<G>, with methods to wait for a specific index changes to become visible. To use this class you must first wrap your IndexWriter with a TrackingIndexWriter and always use it to make changes to the index, saving the returned generation. Then, when a given search request needs to see a specific index change, call the WaitForGeneration(long) to wait for that change to be visible. Note that this will only scale well if most searches do not need to wait for a specific index generation.
Note
This API is experimental and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public class ControlledRealTimeReopenThread<T> : ThreadJob, IEquatable<ThreadJob>, IEquatable<Thread>, IDisposable where T : class
Type Parameters
Name | Description |
---|---|
T |
Constructors
ControlledRealTimeReopenThread(TrackingIndexWriter, ReferenceManager<T>, double, double)
Create ControlledRealTimeReopenThread<T>, to periodically reopen the a ReferenceManager<G>.
Declaration
public ControlledRealTimeReopenThread(TrackingIndexWriter writer, ReferenceManager<T> manager, double targetMaxStaleSec, double targetMinStaleSec)
Parameters
Type | Name | Description |
---|---|---|
TrackingIndexWriter | writer | |
ReferenceManager<T> | manager | |
double | targetMaxStaleSec | Maximum time until a new reader must be opened; this sets the upper bound on how slowly reopens may occur, when no caller is waiting for a specific generation to become visible. |
double | targetMinStaleSec | Mininum time until a new reader can be opened; this sets the lower bound on how quickly reopens may occur, when a caller is waiting for a specific generation to become visible. |
Fields
m_notify
Utility class that runs a thread to manage periodic reopens of a ReferenceManager<G>, with methods to wait for a specific index changes to become visible. To use this class you must first wrap your IndexWriter with a TrackingIndexWriter and always use it to make changes to the index, saving the returned generation. Then, when a given search request needs to see a specific index change, call the WaitForGeneration(long) to wait for that change to be visible. Note that this will only scale well if most searches do not need to wait for a specific index generation.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
protected readonly EventWaitHandle m_notify
Field Value
Type | Description |
---|---|
EventWaitHandle |
Methods
Dispose()
Kills the thread and releases all resources used by the ControlledRealTimeReopenThread<T>. Also joins to the thread so that when this method returns the thread is no longer alive.
Declaration
public void Dispose()
Dispose(bool)
Kills the thread and releases all resources used by the ControlledRealTimeReopenThread<T>. Also joins to the thread so that when this method returns the thread is no longer alive.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
Run()
Invokes the ThreadStart delegate that was passed into the constructor. If no ThreadStart was set, does nothing. Alternatively, this method may be overridden by subclasses to provide an implementation for the thread to run.
Declaration
public override void Run()
Overrides
WaitForGeneration(long)
Waits for the target generation to become visible in the searcher. If the current searcher is older than the target generation, this method will block until the searcher is reopened, by another via MaybeRefresh() or until the ReferenceManager<G> is closed.
Declaration
public virtual void WaitForGeneration(long targetGen)
Parameters
Type | Name | Description |
---|---|---|
long | targetGen | The generation to wait for |
WaitForGeneration(long, int)
Waits for the target generation to become visible in the searcher, up to a maximum specified milli-seconds. If the current searcher is older than the target generation, this method will block until the searcher has been reopened by another thread via MaybeRefresh(), the given waiting time has elapsed, or until the ReferenceManager<G> is closed.
NOTE: if the waiting time elapses before the requested target generation is available the current SearcherManager is returned instead.Declaration
public virtual bool WaitForGeneration(long targetGen, int maxMS)
Parameters
Type | Name | Description |
---|---|---|
long | targetGen | The generation to wait for |
int | maxMS | Maximum milliseconds to wait, or -1 to wait indefinitely |
Returns
Type | Description |
---|---|
bool |
|