|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.replicator.ReplicationClient
public class ReplicationClient
A client which monitors and obtains new revisions from a Replicator
.
It can be used to either periodically check for updates by invoking
startUpdateThread(long, java.lang.String)
, or manually by calling updateNow()
.
Whenever a new revision is available, the requiredFiles(Map)
are
copied to the Directory
specified by PerSessionDirectoryFactory
and
a handler is notified.
Nested Class Summary | |
---|---|
static interface |
ReplicationClient.ReplicationHandler
Handler for revisions obtained by the client. |
static interface |
ReplicationClient.SourceDirectoryFactory
Resolves a session and source into a Directory to use for copying
the session files to. |
Field Summary | |
---|---|
static String |
INFO_STREAM_COMPONENT
The component name to use with InfoStream.isEnabled(String) . |
Constructor Summary | |
---|---|
ReplicationClient(Replicator replicator,
ReplicationClient.ReplicationHandler handler,
ReplicationClient.SourceDirectoryFactory factory)
Constructor. |
Method Summary | |
---|---|
void |
close()
|
protected void |
ensureOpen()
Throws AlreadyClosedException if the client has already been closed. |
protected void |
handleUpdateException(Throwable t)
Called when an exception is hit by the replication thread. |
boolean |
isUpdateThreadAlive()
Returns true if the update thread is alive. |
protected Map<String,List<RevisionFile>> |
requiredFiles(Map<String,List<RevisionFile>> newRevisionFiles)
Returns the files required for replication. |
void |
setInfoStream(InfoStream infoStream)
Sets the InfoStream to use for logging messages. |
void |
startUpdateThread(long intervalMillis,
String threadName)
Start the update thread with the specified interval in milliseconds. |
void |
stopUpdateThread()
Stop the update thread. |
String |
toString()
|
void |
updateNow()
Executes the update operation immediately, irregardess if an update thread is running or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String INFO_STREAM_COMPONENT
InfoStream.isEnabled(String)
.
Constructor Detail |
---|
public ReplicationClient(Replicator replicator, ReplicationClient.ReplicationHandler handler, ReplicationClient.SourceDirectoryFactory factory)
replicator
- the Replicator
used for checking for updateshandler
- notified when new revisions are readyfactory
- returns a Directory
for a given source and sessionMethod Detail |
---|
protected final void ensureOpen()
AlreadyClosedException
if the client has already been closed.
protected void handleUpdateException(Throwable t)
InfoStream
set in
setInfoStream(InfoStream)
, or the default
one. 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 by
startUpdateThread(long, String)
.
protected Map<String,List<RevisionFile>> requiredFiles(Map<String,List<RevisionFile>> newRevisionFiles)
public void close()
close
in interface Closeable
public void startUpdateThread(long intervalMillis, String threadName)
Thread.setName(String)
. If you pass null
, a default name
will be set.
IllegalStateException
- if the thread has already been startedpublic void stopUpdateThread()
public boolean isUpdateThreadAlive()
started
and not
stopped
, as well as didn't hit an error which
caused it to terminate (i.e. handleUpdateException(Throwable)
threw the exception further).
public String toString()
toString
in class Object
public void updateNow() throws IOException
IOException
public void setInfoStream(InfoStream infoStream)
InfoStream
to use for logging messages.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |