Class ReplicationClient
A client which monitors and obtains new revisions from a IReplicator. It can be used to either periodically check for updates by invoking StartUpdateThread(Int64, String), or manually by calling UpdateNow().
Whenever a new revision is available, the RequiredFiles(IDictionary<String, IList<RevisionFile>>) are copied to the Directory specified by PerSessionDirectoryFactory and a handler is notified.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Replicator
Assembly: Lucene.Net.Replicator.dll
Syntax
public class ReplicationClient : IDisposable
Remarks
Constructors
| Improve this Doc View SourceReplicationClient(IReplicator, IReplicationHandler, ISourceDirectoryFactory)
Constructor.
Declaration
public ReplicationClient(IReplicator replicator, IReplicationHandler handler, ISourceDirectoryFactory factory)
Parameters
Type | Name | Description |
---|---|---|
IReplicator | replicator | The IReplicator used for checking for updates |
IReplicationHandler | handler | The IReplicationHandler notified when new revisions are ready |
ISourceDirectoryFactory | factory | The ISourceDirectoryFactory for returning a Directory for a given source and session |
Fields
| Improve this Doc View SourceINFO_STREAM_COMPONENT
The component name to use with IsEnabled(String)
Declaration
public const string INFO_STREAM_COMPONENT = "ReplicationThread"
Field Value
Type | Description |
---|---|
System.String |
Properties
| Improve this Doc View SourceInfoStream
Gets or sets the InfoStream to use for logging messages.
Declaration
public virtual InfoStream InfoStream { get; set; }
Property Value
Type | Description |
---|---|
InfoStream |
IsUpdateThreadAlive
Returns true if the update thread is alive. The update thread is alive if it has been StartUpdateThread(Int64, String) and not StopUpdateThread(), as well as didn't hit an error which caused it to terminate (i.e. HandleUpdateException(Exception) threw the exception further).
Declaration
public virtual bool IsUpdateThreadAlive { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceDispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
EnsureOpen()
Throws System.ObjectDisposedException if the client has already been disposed.
Declaration
protected void EnsureOpen()
HandleUpdateException(Exception)
Called when an exception is hit by the replication thread. The default implementation prints the full stacktrace to the InfoStream set in InfoStream, or the Default one. You can override to log the exception elsewhere.
Declaration
protected virtual void HandleUpdateException(Exception exception)
Parameters
Type | Name | Description |
---|---|---|
System.Exception | exception |
Remarks
NOTE: If you override this method to throw the exception further, the replication thread will be terminated. The only way to restart it is to call StopUpdateThread() followed by StartUpdateThread(Int64, String).
RequiredFiles(IDictionary<String, IList<RevisionFile>>)
Returns the files required for replication. By default, this method returns all files that exist in the new revision, but not in the handler.
Declaration
protected virtual IDictionary<string, IList<RevisionFile>> RequiredFiles(IDictionary<string, IList<RevisionFile>> newRevisionFiles)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String, System.Collections.Generic.IList<RevisionFile>> | newRevisionFiles |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Collections.Generic.IList<RevisionFile>> |
StartUpdateThread(Int64, String)
Start the update thread with the specified interval in milliseconds. For
debugging purposes, you can optionally set the name to set on
Lucene.Net.Replicator.ReplicationClient.ReplicationThread.Name. If you pass null
, a default name
will be set.
Declaration
public virtual void StartUpdateThread(long intervalMillis, string threadName)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | intervalMillis | |
System.String | threadName |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | if the thread has already been started |
StopUpdateThread()
Stop the update thread. If the update thread is not running, silently does nothing. This method returns after the update thread has stopped.
Declaration
public virtual void StopUpdateThread()
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
UpdateNow()
Executes the update operation immediately, regardless if an update thread is running or not.
Declaration
public virtual void UpdateNow()
Exceptions
Type | Condition |
---|---|
System.IO.IOException |