Class BackgroundIndexer

java.lang.Object
org.elasticsearch.test.BackgroundIndexer
All Implemented Interfaces:
AutoCloseable

public class BackgroundIndexer extends Object implements AutoCloseable
  • Constructor Details

    • BackgroundIndexer

      public BackgroundIndexer(String index, 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 into
      client - client to use
      numOfDocs - number of document to index before pausing. Set to -1 to have no limit.
    • BackgroundIndexer

      public BackgroundIndexer(String index, 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 into
      client - client to use
      numOfDocs - 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 into
      client - client to use
      numOfDocs - number of document to index before pausing. Set to -1 to have no limit.
      writerCount - number of indexing threads to use
      autoStart - 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

      public void awaitStopped() throws InterruptedException
      Throws:
      InterruptedException
    • stopAndAwaitStopped

      public void stopAndAwaitStopped() throws InterruptedException
      Stop all background threads and wait for ongoing indexing operations to finish *
      Throws:
      InterruptedException
    • totalIndexedDocs

      public long totalIndexedDocs()
    • assertNoFailures

      public void assertNoFailures()
    • setFailureAssertion

      public void setFailureAssertion(Consumer<Exception> failureAssertion)
      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 to failures. Should be used if the number of expected failures during indexing could become very large.
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • getClient

      public Client getClient()
    • getIds

      public Set<String> getIds()
      Returns the ID set of all documents indexed by this indexer run