Package org.apache.lucene.replicator
Class ReplicationClient
- java.lang.Object
-
- org.apache.lucene.replicator.ReplicationClient
-
- All Implemented Interfaces:
Closeable,AutoCloseable
@Deprecated public class ReplicationClient extends Object implements Closeable
Deprecated.use org.apache.lucene.replicator.nrt insteadA client which monitors and obtains new revisions from aReplicator. It can be used to either periodically check for updates by invokingstartUpdateThread(long, java.lang.String), or manually by callingupdateNow().Whenever a new revision is available, the
requiredFiles(Map)are copied to theDirectoryspecified byPerSessionDirectoryFactoryand a handler is notified.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceReplicationClient.ReplicationHandlerDeprecated.Handler for revisions obtained by the client.static interfaceReplicationClient.SourceDirectoryFactoryDeprecated.Resolves a session and source into aDirectoryto use for copying the session files to.
-
Field Summary
Fields Modifier and Type Field Description static StringINFO_STREAM_COMPONENTDeprecated.The component name to use withInfoStream.isEnabled(String).
-
Constructor Summary
Constructors Constructor Description ReplicationClient(Replicator replicator, ReplicationClient.ReplicationHandler handler, ReplicationClient.SourceDirectoryFactory factory)Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()Deprecated.protected voidensureOpen()Deprecated.ThrowsAlreadyClosedExceptionif the client has already been closed.protected voidhandleUpdateException(Throwable t)Deprecated.Called when an exception is hit by the replication thread.booleanisUpdateThreadAlive()Deprecated.Returns true if the update thread is alive.protected Map<String,List<RevisionFile>>requiredFiles(Map<String,List<RevisionFile>> newRevisionFiles)Deprecated.Returns the files required for replication.voidsetInfoStream(InfoStream infoStream)Deprecated.Sets theInfoStreamto use for logging messages.voidstartUpdateThread(long intervalMillis, String threadName)Deprecated.Start the update thread with the specified interval in milliseconds.voidstopUpdateThread()Deprecated.Stop the update thread.StringtoString()Deprecated.voidupdateNow()Deprecated.Executes the update operation immediately, irregardless if an update thread is running or not.
-
-
-
Field Detail
-
INFO_STREAM_COMPONENT
public static final String INFO_STREAM_COMPONENT
Deprecated.The component name to use withInfoStream.isEnabled(String).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ReplicationClient
public ReplicationClient(Replicator replicator, ReplicationClient.ReplicationHandler handler, ReplicationClient.SourceDirectoryFactory factory)
Deprecated.Constructor.- Parameters:
replicator- theReplicatorused for checking for updateshandler- notified when new revisions are readyfactory- returns aDirectoryfor a given source and session
-
-
Method Detail
-
ensureOpen
protected final void ensureOpen()
Deprecated.ThrowsAlreadyClosedExceptionif the client has already been closed.
-
handleUpdateException
protected void handleUpdateException(Throwable t)
Deprecated.Called when an exception is hit by the replication thread. The default implementation prints the full stacktrace to theInfoStreamset insetInfoStream(InfoStream), or thedefaultone. You can override to log the exception elswhere.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 bystartUpdateThread(long, String).
-
requiredFiles
protected Map<String,List<RevisionFile>> requiredFiles(Map<String,List<RevisionFile>> newRevisionFiles)
Deprecated.Returns the files required for replication. By default, this method returns all files that exist in the new revision, but not in the handler.
-
close
public void close()
Deprecated.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
startUpdateThread
public void startUpdateThread(long intervalMillis, String threadName)Deprecated.Start the update thread with the specified interval in milliseconds. For debugging purposes, you can optionally set the name to set onThread.setName(String). If you passnull, a default name will be set.- Throws:
IllegalStateException- if the thread has already been started
-
stopUpdateThread
public void stopUpdateThread()
Deprecated.Stop the update thread. If the update thread is not running, silently does nothing. This method returns after the update thread has stopped.
-
isUpdateThreadAlive
public boolean isUpdateThreadAlive()
Deprecated.Returns true if the update thread is alive. The update thread is alive if it has beenstartedand notstopped, as well as didn't hit an error which caused it to terminate (i.e.handleUpdateException(Throwable)threw the exception further).
-
updateNow
public void updateNow() throws IOExceptionDeprecated.Executes the update operation immediately, irregardless if an update thread is running or not.- Throws:
IOException
-
setInfoStream
public void setInfoStream(InfoStream infoStream)
Deprecated.Sets theInfoStreamto use for logging messages.
-
-