Package org.elasticsearch.test
Class BackgroundIndexer
java.lang.Object
org.elasticsearch.test.BackgroundIndexer
- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionBackgroundIndexer
(String index, org.elasticsearch.client.internal.Client client, int numOfDocs) Start indexing in the background using a random number of threads.BackgroundIndexer
(String index, org.elasticsearch.client.internal.Client client, int numOfDocs, int writerCount) Start indexing in the background using a given number of threads.BackgroundIndexer
(String index, org.elasticsearch.client.internal.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 TypeMethodDescriptionvoid
void
void
close()
void
continueIndexing
(int numOfDocs) Continue indexing after it has paused.org.elasticsearch.client.internal.Client
getIds()
Returns the ID set of all documents indexed by this indexer runvoid
Pausing indexing by setting current document limit to 0void
setFailureAssertion
(Consumer<Exception> failureAssertion) Set a consumer that can be used to run assertions on failures during indexing.void
setIgnoreIndexingFailures
(boolean ignoreIndexingFailures) void
setRequestTimeout
(org.elasticsearch.core.TimeValue requestTimeout) void
start
(int numOfDocs) Start indexingvoid
stop()
Stop all background threads but don't wait for ongoing indexing operations to finish *void
Stop all background threads and wait for ongoing indexing operations to finish *long
-
Constructor Details
-
BackgroundIndexer
public BackgroundIndexer(String index, org.elasticsearch.client.internal.Client client, int numOfDocs) 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
public BackgroundIndexer(String index, org.elasticsearch.client.internal.Client client, int numOfDocs, int writerCount) 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, org.elasticsearch.client.internal.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:
close
in interfaceAutoCloseable
- Throws:
Exception
-
getClient
public org.elasticsearch.client.internal.Client getClient() -
getIds
Returns the ID set of all documents indexed by this indexer run
-