public class DocumentSnapshotRepositoryMonitor
extends java.lang.Object
implements java.lang.Runnable
SnapshotRepository
and makes callbacks
when changes occur.
This implementation works as follows. It repeatedly scans all the
DocumentSnapshot
entries returned by
SnapshotRepository.iterator()
. On each pass, it compares the current
contents of the repository to a record of what it saw on the previous pass.
The record is stored as a file in the local repository. Each discrepancy
is propagated to the client.
Using a local snapshot of the repository has some serious flaws for continuous crawl:
When an API to do that is available, this implementation should be fixed to use it.
Modifier and Type | Class and Description |
---|---|
static interface |
DocumentSnapshotRepositoryMonitor.Callback
The client provides an implementation of this interface to receive
notification of changes to the repository.
|
Constructor and Description |
---|
DocumentSnapshotRepositoryMonitor(java.lang.String name,
SnapshotRepository<? extends DocumentSnapshot> query,
SnapshotStore snapshotStore,
DocumentSnapshotRepositoryMonitor.Callback callback,
DocumentSink documentSink,
MonitorCheckpoint initialCp,
DocumentSnapshotFactory documentSnapshotFactory)
Creates a DocumentSnapshotRepositoryMonitor that monitors the
Repository rooted at
root . |
Modifier and Type | Method and Description |
---|---|
void |
acceptGuarantee(MonitorCheckpoint cp) |
void |
run() |
void |
setTraversalSchedule(TraversalSchedule traversalSchedule) |
void |
shutdown() |
void |
testTraversalSchedule() |
public DocumentSnapshotRepositoryMonitor(java.lang.String name, SnapshotRepository<? extends DocumentSnapshot> query, SnapshotStore snapshotStore, DocumentSnapshotRepositoryMonitor.Callback callback, DocumentSink documentSink, MonitorCheckpoint initialCp, DocumentSnapshotFactory documentSnapshotFactory)
root
.name
- the name of this monitor (a hash of the start path)query
- query for filessnapshotStore
- where snapshots are storedcallback
- client callbackdocumentSink
- destination for filtered out file infoinitialCp
- checkpoint when system initiated, could be null
documentSnapshotFactory
- for un-serializing
DocumentSnapshot
objects.public void run()
run
in interface java.lang.Runnable
public void acceptGuarantee(MonitorCheckpoint cp)
public void testTraversalSchedule() throws java.lang.NullPointerException, java.lang.InterruptedException
java.lang.NullPointerException
java.lang.InterruptedException
public void shutdown()
public void setTraversalSchedule(TraversalSchedule traversalSchedule)