Class IndexingClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.http.client.HttpClient
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:
- read/write in
/tmp
- install bundles via
OsgiConsoleClient
(if the query servlet was not previously installed)
In short, it requires administrative rights.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sling.testing.clients.SlingClient
SlingClient.Builder, SlingClient.InternalBuilder<T extends SlingClient>
-
Field Summary
FieldsFields inherited from class org.apache.sling.testing.clients.SlingClient
CLIENT_CONNECTION_TIMEOUT_PROP, DEFAULT_NODE_TYPE, SUDO_COOKIE_NAME
-
Constructor Summary
ConstructorsConstructorDescriptionIndexingClient
(URI url, String user, String password) Handy constructor easy to use in simple tests.IndexingClient
(org.apache.http.impl.client.CloseableHttpClient http, SlingClientConfig config) Constructor used by Builders and adaptTo(). -
Method Summary
Modifier and TypeMethodDescriptionReturn the list of indexing lanes configured bysetLaneNames(java.lang.String...)
, if any.void
install()
Creates the necessary custom indices in the repository, if not already present.void
setLaneNames
(String... laneNames) Set providedlaneNames
to config map.void
Deprecated.Use #uninstallWithRetryvoid
Retries cleaning all the data generated byinstall()
andwaitForAsyncIndexing(long, long)
.void
Same aswaitForAsyncIndexing(long timeout, long delay)
, but with default values fortimeout=1min
anddelay=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.Methods inherited from class org.apache.sling.testing.clients.SlingClient
createFolder, createNode, createNodeRecursive, deletePath, doGetJson, endImpersonation, exists, getJsonNode, getJsonNode, getNodeNameFromPath, getParentPath, getUser, getUUId, getUUID, impersonate, importContent, importContent, importJson, move, setPropertiesString, setPropertyString, setPropertyStringArray, upload, waitExists, waitUntilExists
Methods inherited from class org.apache.sling.testing.clients.AbstractSlingClient
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, getValue, getValues, hasValue
-
Field Details
-
ASYNC_INDEXER_CONFIG
- See Also:
-
-
Constructor Details
-
IndexingClient
public IndexingClient(org.apache.http.impl.client.CloseableHttpClient http, SlingClientConfig config) throws ClientException Constructor used by Builders and adaptTo(). Should never be called directly from the code.- Parameters:
http
- the underlying HttpClient to be usedconfig
- sling specific configs- Throws:
ClientException
- if the client could not be created
-
IndexingClient
Handy constructor easy to use in simple tests. Creates a client that uses basic authentication.
For constructing clients with complex configurations, use a
SlingClient.InternalBuilder
For constructing clients with the same configuration, but a different class, use
AbstractSlingClient.adaptTo(Class)
- Parameters:
url
- url of the server (including context path)user
- username for basic authenticationpassword
- password for basic authentication- Throws:
ClientException
- never, kept for uniformity with the other constructors
-
-
Method Details
-
setLaneNames
Set providedlaneNames
to config map. This allows for subsequent initializations usingadaptTo
that shard the same config map to not require further configuration of lane names- Parameters:
laneNames
- lane names to work on
-
getLaneNames
Return the list of indexing lanes configured bysetLaneNames(java.lang.String...)
, if any. Else, retrieves configured lanes on the instance- Returns:
- list of lane names
- Throws:
ClientException
- in case of problems
-
waitForAsyncIndexing
public 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 "/tmp/testing/waitForAsyncIndexing"
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 "/tmp/testing/waitForAsyncIndexing"
- Parameters:
timeout
- max time to wait, in milliseconds, before throwingTimeoutException
delay
- time to sleep between retries- Throws:
TimeoutException
- if thetimeout
was reached before all the indices were updatedInterruptedException
- to mark this method as waitingClientException
- if an error occurs during http requests/responses
-
waitForAsyncIndexing
Same aswaitForAsyncIndexing(long timeout, long delay)
, but with default values fortimeout=1min
anddelay=500ms
.- Throws:
TimeoutException
- if thetimeout
was reached before all the indices were updatedInterruptedException
- to mark this method as waitingClientException
- if an error occurs during http requests/responses- See Also:
-
install
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.
- Throws:
ClientException
- if the installation fails
-
uninstall
Deprecated.Use #uninstallWithRetryCleans all the data generated by
install()
andwaitForAsyncIndexing(long, long)
.User must manually call this if needed, as opposed to
install()
, which is called automatically.- Throws:
ClientException
- if the cleanup failed
-
uninstallWithRetry
Retries cleaning all the data generated by
install()
andwaitForAsyncIndexing(long, long)
.User must manually call this if needed, as opposed to
install()
, which is called automatically.- Throws:
TimeoutException
- if retry operation times out and the path still existsInterruptedException
- if the retry operation was interrupted by the user
-