Class ConcurrentQueryLoader

java.lang.Object
org.apache.lucene.monitor.ConcurrentQueryLoader
All Implemented Interfaces:
Closeable, AutoCloseable

public class ConcurrentQueryLoader extends Object implements Closeable
Utility class for concurrently loading queries into a Monitor.

This is useful to speed up startup times for a Monitor. You can use multiple threads to parse and index queries before starting matches.

Use as follows:

     List<QueryError> errors = new ArrayList<>();
     try (ConcurrentQueryLoader loader = new ConcurrentQueryLoader(monitor, errors)) {
         for (MonitorQuery mq : getQueries()) {
             loader.add(mq);
         }
     }
 

The Monitor's MonitorQueryParser must be thread-safe for this to work correctly.

  • Field Details

  • Constructor Details

    • ConcurrentQueryLoader

      public ConcurrentQueryLoader(Monitor monitor)
      Create a new ConcurrentQueryLoader for a Monitor
      Parameters:
      monitor - Monitor
    • ConcurrentQueryLoader

      public ConcurrentQueryLoader(Monitor monitor, int threads, int queueSize)
      Create a new ConcurrentQueryLoader
      Parameters:
      monitor - the Monitor to load queries to
      threads - the number of threads to use
      queueSize - the size of the buffer to hold queries in
  • Method Details