public class IndexingClient extends SlingClient
Interface to the oak indexing mechanism
Exposes waitForAsyncIndexing(long, long)
for waiting all the indexing lanes to finish
indexing and to guarantee all the indices are up to date
For using waitForAsyncIndexing(long, long)
, the user must have access rights to:
/tmp
OsgiConsoleClient
(if the query servlet was not previously installed)In short, it requires administrative rights.
SlingClient.Builder, SlingClient.InternalBuilder<T extends SlingClient>
DEFAULT_NODE_TYPE
Constructor and Description |
---|
IndexingClient(org.apache.http.impl.client.CloseableHttpClient http,
SlingClientConfig config)
Constructor used by Builders and adaptTo().
|
IndexingClient(URI url,
String user,
String password)
Handy constructor easy to use in simple tests.
|
Modifier and Type | Method and Description |
---|---|
List<String> |
getLaneNames()
Retrieves the list of indexing lanes configured on the instance
|
void |
install()
Creates the necessary custom indices in the repository, if not already present.
|
void |
uninstall()
Cleans all the data generated by
install() and waitForAsyncIndexing(long, long) . |
void |
waitForAsyncIndexing()
Same as
waitForAsyncIndexing(long timeout, long delay) ,
but with default values for timeout=1min and delay=500ms . |
void |
waitForAsyncIndexing(long timeout,
long delay)
Blocks until all the async indices are up to date, to guarantee that the susequent queries return
all the results.
|
createFolder, createNode, createNodeRecursive, deletePath, doGetJson, exists, getJsonNode, getJsonNode, getNodeNameFromPath, getParentPath, getUUId, getUUID, importContent, importContent, importJson, move, setPropertiesString, setPropertyString, setPropertyStringArray, upload, waitExists, waitUntilExists
adaptTo, addValue, close, doDelete, doGet, doGet, doGet, doHead, doPatch, doPost, doPost, doPut, doRawRequest, doRequest, doStreamGet, doStreamPost, doStreamRequest, execute, execute, execute, execute, execute, execute, execute, execute, getClientId, getConnectionManager, getCookieStore, getCredentialsProvider, getParams, getPassword, getPath, getPath, getUrl, getUrl, getUrl, getUser, getValue, getValues, hasValue
public IndexingClient(org.apache.http.impl.client.CloseableHttpClient http, SlingClientConfig config) throws ClientException
http
- the underlying HttpClient to be usedconfig
- sling specific configsClientException
- if the client could not be createdpublic IndexingClient(URI url, String user, String password) throws ClientException
Handy constructor easy to use in simple tests. Creates a client that uses basic authentication.
For constructing clients with complex configurations, use a InternalBuilder
For constructing clients with the same configuration, but a different class, use AbstractSlingClient.adaptTo(Class)
url
- url of the server (including context path)user
- username for basic authenticationpassword
- password for basic authenticationClientException
- never, kept for uniformity with the other constructorspublic List<String> getLaneNames() throws ClientException
ClientException
- if the request failspublic void waitForAsyncIndexing(long timeout, long delay) throws TimeoutException, InterruptedException, ClientException
Blocks until all the async indices are up to date, to guarantee that the susequent queries return all the results.
Works by creating a custom index for each lane, adding specific content to be indexed by these indices and then repeatedly searching this content until everything is found (indexed). All the content is created under
Indices are automatically created, but only if not already present.
This method does not delete the indices at the end to avoid generating too much noise on the instance.
To completely clean any traces, the user must call uninstall()
Requires administrative rights to install bundles and to create nodes under
timeout
- max time to wait, in milliseconds, before throwing TimeoutException
delay
- time to sleep between retriesTimeoutException
- if the timeout
was reached before all the indices were updatedInterruptedException
- to mark this method as waitingClientException
- if an error occurs during http requests/responsespublic void waitForAsyncIndexing() throws InterruptedException, ClientException, TimeoutException
waitForAsyncIndexing(long timeout, long delay)
,
but with default values for timeout=1min
and delay=500ms
.TimeoutException
- if the timeout
was reached before all the indices were updatedInterruptedException
- to mark this method as waitingClientException
- if an error occurs during http requests/responseswaitForAsyncIndexing(long, long)
public void install() throws ClientException
Creates the necessary custom indices in the repository, if not already present.
It is automatically called in each wait, there's no need to explicitly invoke it from the test.
ClientException
- if the installation failspublic void uninstall() throws ClientException
Cleans all the data generated by install()
and waitForAsyncIndexing(long, long)
.
User must manually call this if needed, as opposed to install()
, which is called
automatically.
ClientException
- if the cleanup failedCopyright © 2007–2018 The Apache Software Foundation. All rights reserved.