Class BackgroundIndexer

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class BackgroundIndexer
    extends java.lang.Object
    implements java.lang.AutoCloseable
    • Constructor Summary

      Constructors 
      Constructor Description
      BackgroundIndexer​(java.lang.String index, java.lang.String type, Client client, int numOfDocs)
      Start indexing in the background using a random number of threads.
      BackgroundIndexer​(java.lang.String index, java.lang.String type, Client client, int numOfDocs, int writerCount)
      Start indexing in the background using a given number of threads.
      BackgroundIndexer​(java.lang.String index, java.lang.String type, Client client, int numOfDocs, int writerCount, boolean autoStart, java.util.Random random)
      Start indexing in the background using a given number of threads.
    • Constructor Detail

      • BackgroundIndexer

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

        public BackgroundIndexer​(java.lang.String index,
                                 java.lang.String type,
                                 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
        type - document type
        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​(java.lang.String index,
                                 java.lang.String type,
                                 Client client,
                                 int numOfDocs,
                                 int writerCount,
                                 boolean autoStart,
                                 java.util.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
        type - document type
        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 Detail

      • setRequestTimeout

        public void setRequestTimeout​(TimeValue timeout)
      • 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()
                  throws java.lang.InterruptedException
        Stop all background threads *
        Throws:
        java.lang.InterruptedException
      • totalIndexedDocs

        public long totalIndexedDocs()
      • getFailures

        public java.lang.Throwable[] getFailures()
      • assertNoFailures

        public void assertNoFailures()
      • setAssertNoFailuresOnStop

        public void setAssertNoFailuresOnStop​(boolean assertNoFailuresOnStop)
      • close

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

        public Client getClient()
      • getIds

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