public class NamedResourceFirehose extends AbstractAdaptor implements PollingIncrementalLister
Constructor and Description |
---|
NamedResourceFirehose() |
Modifier and Type | Method and Description |
---|---|
void |
getDocContent(Request req,
Response resp)
Provides contents and metadata of particular document.
|
void |
getDocIds(DocIdPusher pusher)
Pushes all the
DocId s that are suppose to be indexed by the GSA. |
void |
getModifiedDocIds(DocIdPusher pusher)
Check for documents modified since the last call to the method.
|
void |
init(AdaptorContext context)
Initialize adaptor with the current context.
|
void |
initConfig(Config config)
Provides the opportunity for the Adaptor to create new configuration values
or override default values.
|
static void |
main(String[] args)
Call default main for adaptors.
|
destroy, main
public void initConfig(Config config)
AbstractAdaptor
Config.addKey(java.lang.String, java.lang.String)
should likely be
called. The user's configuration will override any values set in this way.
This method is called by AbstractAdaptor.main(com.google.enterprise.adaptor.Adaptor, java.lang.String[])
before Adaptor.init(com.google.enterprise.adaptor.AdaptorContext)
is called.
This implementation does nothing.
initConfig
in interface Adaptor
initConfig
in class AbstractAdaptor
config
- to modify with additional keyspublic void init(AdaptorContext context) throws Exception
AbstractAdaptor
context
points to other useful objects that can be used at any time. For example,
methods on DocIdPusher
provided via AdaptorContext.getDocIdPusher()
are allowed to be called whenever the
Adaptor wishes. This allows doing event-based incremental pushes at any
time.
The method is called at the end of GsaCommunicationHandler.start(java.lang.Runnable)
.
If you experience a fatal error during initialization, feel free to
throw an Exception
to cancel the startup process.
This implementation does nothing.
init
in interface Adaptor
init
in class AbstractAdaptor
context
- for instance includes completed configException
- if things are not going wellpublic void getDocIds(DocIdPusher pusher) throws InterruptedException
Adaptor
DocId
s that are suppose to be indexed by the GSA.
This will frequently involve re-sending DocId
s to the GSA, but this
allows healing previous errors and cache inconsistencies. Re-sending DocIds
is very fast and should be considered free on the GSA. This method
should determine a list of DocId
s to push and call DocIdPusher.pushDocIds(java.lang.Iterable<com.google.enterprise.adaptor.DocId>)
one or more times and DocIdPusher.pushNamedResources(java.util.Map<com.google.enterprise.adaptor.DocId, com.google.enterprise.adaptor.Acl>)
if using named resources.
pusher
is provided as convenience and is the same object
provided to Adaptor.init(com.google.enterprise.adaptor.AdaptorContext)
previously. This method may take a while and
implementations are free to call Thread.sleep(long)
occasionally to
reduce load.
If you experience a fatal error, feel free to throw an IOException
or RuntimeException
. In the case of an error, the
ExceptionHandler
in use in AdaptorContext
will
determine if and when to retry.
getDocIds
in interface Adaptor
pusher
- used to send doc ids to GSAInterruptedException
- if an IO operations throws itpublic void getDocContent(Request req, Response resp) throws IOException
Adaptor
If you experience a fatal error, feel free to throw an IOException
or RuntimeException
. In the case of an error, the GSA
will determine if and when to retry.
getDocContent
in interface Adaptor
req
- info about document being soughtresp
- place to put document dataIOException
- if getting data failspublic void getModifiedDocIds(DocIdPusher pusher) throws IOException, InterruptedException
PollingIncrementalLister
Adaptor.getDocIds(com.google.enterprise.adaptor.DocIdPusher)
will
provide additions.
For the first invocation, implementations can simply provide a small amount of very recent history (e.g., last five revisions or last hour of modifications) or provide no history and just initialize data structures for future invocations. Adaptors are always encouraged to not persist state; providing recent history during the first invocation allows the adaptor to handle upgrades, computer restarts, and power outages without trouble and still provide low-latency for those time periods. If an hour is too short a period of time, then feel free to send a day's worth of history instead. However, remember that missing modifications here only increases the amount of latency before the GSA notices the modification.
getModifiedDocIds
in interface PollingIncrementalLister
pusher
- convenience reference to pusherIOException
- on failure getting doc idsInterruptedException
- may percolate from IO callspublic static void main(String[] args)
args
- argv