public final class FetchResultPersister<T extends FetchResult> extends Object implements Runnable
ResultWriter. The lifecycle is the following, you can submit an
instance of this class as a thread and if you want to stop it you can call
the stop() method. Then it will make the backed queue read-only and
flush all items in it to the result writer.| Constructor and Description |
|---|
FetchResultPersister(ResultWriter<T> resWriter) |
FetchResultPersister(ResultWriter<T> resWriter,
org.apache.hadoop.conf.Configuration conf) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(T result)
Add a crawled result to the back queue.
|
void |
run()
Run logic of this
Runnable. |
void |
stop()
Stop this persister and make the queue read-only.
|
public FetchResultPersister(ResultWriter<T> resWriter) throws IOException
IOExceptionpublic FetchResultPersister(ResultWriter<T> resWriter, org.apache.hadoop.conf.Configuration conf) throws IOException
IOExceptionpublic final void add(T result)
stop()
has been called, this queue will not accept any items anymore.public void stop()
public final void run()
Runnable. Basically if we haven't stopped, we
will poll the queue, if there is no item anymore we will wait for 10
seconds. If we have received a stop() command, the queue will be
freezed and all exisiting items will be flushed to disk.
ResultWriter close is guaranteed to run in case of failure (guarded
by finally).Copyright © 2016. All rights reserved.