Fork me on GitHub
  • API

    Show / Hide Table of Contents

    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(long, string), or manually by calling UpdateNow().

    Whenever a new revision is available, the RequiredFiles(IDictionary<string, IList<RevisionFile>>) are copied to the Lucene.Net.Store.Directory specified by PerSessionDirectoryFactory and a handler is notified.
    Inheritance
    object
    ReplicationClient
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Replicator
    Assembly: Lucene.Net.Replicator.dll
    Syntax
    public class ReplicationClient : IDisposable
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Constructors

    ReplicationClient(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 Lucene.Net.Store.Directory for a given source and session

    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Fields

    INFO_STREAM_COMPONENT

    The component name to use with IsEnabled(string)

    Declaration
    public const string INFO_STREAM_COMPONENT = "ReplicationThread"
    Field Value
    Type Description
    string
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Properties

    InfoStream

    Gets or sets the Lucene.Net.Util.InfoStream to use for logging messages.

    Declaration
    public virtual InfoStream InfoStream { get; set; }
    Property Value
    Type Description
    InfoStream
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    IsUpdateThreadAlive

    Returns true if the update thread is alive. The update thread is alive if it has been StartUpdateThread(long, 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
    bool
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Methods

    Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    public void Dispose()
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Dispose(bool)

    A client which monitors and obtains new revisions from a IReplicator. It can be used to either periodically check for updates by invoking StartUpdateThread(long, string), or manually by calling UpdateNow().

    Whenever a new revision is available, the RequiredFiles(IDictionary<string, IList<RevisionFile>>) are copied to the Lucene.Net.Store.Directory specified by PerSessionDirectoryFactory and a handler is notified.
    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    EnsureOpen()

    Throws ObjectDisposedException if the client has already been disposed.

    Declaration
    protected void EnsureOpen()
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    HandleUpdateException(Exception)

    Called when an exception is hit by the replication thread. The default implementation prints the full stacktrace to the Lucene.Net.Util.InfoStream set in InfoStream, or the Lucene.Net.Util.InfoStream.Default one. You can override to log the exception elsewhere.

    Declaration
    protected virtual void HandleUpdateException(Exception exception)
    Parameters
    Type Name Description
    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(long, 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
    IDictionary<string, IList<RevisionFile>> newRevisionFiles
    Returns
    Type Description
    IDictionary<string, IList<RevisionFile>>
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    StartUpdateThread(long, string)

    Start the update thread with the specified interval in milliseconds. For debugging purposes, you can optionally set the name to set on J2N.Threading.ThreadJob.Name. If you pass null, a default name will be set.

    Declaration
    public virtual void StartUpdateThread(long intervalInMilliseconds, string threadName)
    Parameters
    Type Name Description
    long intervalInMilliseconds
    string threadName
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Exceptions
    Type Condition
    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()
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    ToString()

    Returns a string that represents the current object.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that represents the current object.

    Overrides
    object.ToString()
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    UpdateNow()

    Executes the update operation immediately, regardless if an update thread is running or not.

    Declaration
    public virtual void UpdateNow()
    Remarks

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Exceptions
    Type Condition
    IOException

    Implements

    IDisposable
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.