Package org.elasticsearch.test
Class BackgroundIndexer
java.lang.Object
org.elasticsearch.test.BackgroundIndexer
- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionBackgroundIndexer(String index, Client client, int numOfDocs) Start indexing in the background using a random number of threads.BackgroundIndexer(String index, Client client, int numOfDocs, int writerCount) Start indexing in the background using a given number of threads.BackgroundIndexer(String index, Client client, int numOfDocs, int writerCount, boolean autoStart, Random random) Start indexing in the background using a given number of threads. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidclose()voidcontinueIndexing(int numOfDocs) Continue indexing after it has paused.getIds()Returns the ID set of all documents indexed by this indexer runvoidPausing indexing by setting current document limit to 0voidsetFailureAssertion(Consumer<Exception> failureAssertion) Set a consumer that can be used to run assertions on failures during indexing.voidsetIgnoreIndexingFailures(boolean ignoreIndexingFailures) voidsetRequestTimeout(org.elasticsearch.core.TimeValue requestTimeout) voidstart(int numOfDocs) Start indexingvoidstop()Stop all background threads but don't wait for ongoing indexing operations to finish *voidStop all background threads and wait for ongoing indexing operations to finish *long
-
Constructor Details
-
BackgroundIndexer
Start indexing in the background using a random number of threads. Indexing will be paused after numOfDocs docs has been indexed.- Parameters:
index- index name to index intoclient- client to usenumOfDocs- number of document to index before pausing. Set to -1 to have no limit.
-
BackgroundIndexer
Start indexing in the background using a given number of threads. Indexing will be paused after numOfDocs docs has been indexed.- Parameters:
index- index name to index intoclient- client to usenumOfDocs- number of document to index before pausing. Set to -1 to have no limit.writerCount- number of indexing threads to use
-
BackgroundIndexer
public BackgroundIndexer(String index, Client client, int numOfDocs, int writerCount, boolean autoStart, Random random) Start indexing in the background using a given number of threads. Indexing will be paused after numOfDocs docs has been indexed.- Parameters:
index- index name to index intoclient- client to usenumOfDocs- number of document to index before pausing. Set to -1 to have no limit.writerCount- number of indexing threads to useautoStart- set to true to start indexing as soon as all threads have been created.random- random instance to use
-
-
Method Details
-
setRequestTimeout
public void setRequestTimeout(org.elasticsearch.core.TimeValue requestTimeout) -
setIgnoreIndexingFailures
public void setIgnoreIndexingFailures(boolean ignoreIndexingFailures) -
start
public void start(int numOfDocs) Start indexing- Parameters:
numOfDocs- number of document to index before pausing. Set to -1 to have no limit.
-
pauseIndexing
public void pauseIndexing()Pausing indexing by setting current document limit to 0 -
continueIndexing
public void continueIndexing(int numOfDocs) Continue indexing after it has paused.- Parameters:
numOfDocs- number of document to index before pausing. Set to -1 to have no limit.
-
stop
public void stop()Stop all background threads but don't wait for ongoing indexing operations to finish * -
awaitStopped
- Throws:
InterruptedException
-
stopAndAwaitStopped
Stop all background threads and wait for ongoing indexing operations to finish *- Throws:
InterruptedException
-
totalIndexedDocs
public long totalIndexedDocs() -
assertNoFailures
public void assertNoFailures() -
setFailureAssertion
Set a consumer that can be used to run assertions on failures during indexing. If such a consumer is set then it disables adding failures tofailures. Should be used if the number of expected failures during indexing could become very large. -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
getClient
-
getIds
Returns the ID set of all documents indexed by this indexer run
-