Class BufferingSolrServer

java.lang.Object
org.apache.solr.client.solrj.SolrClient
com.lucidworks.apollo.component.BufferingSolrServer
All Implemented Interfaces:
Closeable, Serializable, AutoCloseable

public class BufferingSolrServer extends org.apache.solr.client.solrj.SolrClient
Simple class that wraps a SolrClient instance and adds a simple buffer on top of it. The buffer can hold a series of BufferingSolrServer.BufferedRequests up to a maximum of maxBufferSize. Once exceeded, the buffer is flushed. Currently, the buffer will handle requests to add a document or delete a document either by ID or query. The life cycle of wrapped SolrClient instance should be managed elsewhere. You should properly shutdown this instance with a shutdown method.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.apache.solr.client.solrj.SolrClient
     
    protected static final ScheduledExecutorService
    This is shared between all BufferingSolrServer instances; they'll each register a scheduled Runnable in here as they start up.
    protected final int
     
    protected final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BufferingSolrServer(org.apache.solr.client.solrj.SolrClient delegate, int maxBufferSize, long maxFlushIntervalMillis)
     
    BufferingSolrServer(org.apache.solr.client.solrj.SolrClient delegate, int maxBufferSize, long maxFlushIntervalMillis, int concurrency, String searchClusterName, String collectionId, com.codahale.metrics.MetricRegistry metricRegistry, String defaultSolrCollection)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.solr.client.solrj.response.UpdateResponse
    add(String solrCollection, Collection<org.apache.solr.common.SolrInputDocument> docs, int commitWithinMs)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    add(String collection, org.apache.solr.common.SolrInputDocument doc, int commitWithinMs)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    add(Collection<org.apache.solr.common.SolrInputDocument> docs)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    add(Collection<org.apache.solr.common.SolrInputDocument> docs, int commitWithinMs)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    add(org.apache.solr.common.SolrInputDocument doc, int commitWithinMs)
     
    void
     
    org.apache.solr.client.solrj.response.UpdateResponse
     
    org.apache.solr.client.solrj.response.UpdateResponse
    deleteById(String id, int commitWithinMs)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    deleteById(String collection, String id)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    deleteById(String collection, String id, int commitWithinMs)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    deleteById(String collection, List<String> ids)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    deleteById(String collection, List<String> ids, int commitWithinMs)
     
    org.apache.solr.client.solrj.response.UpdateResponse
     
    org.apache.solr.client.solrj.response.UpdateResponse
    deleteById(List<String> ids, int commitWithinMs)
     
    org.apache.solr.client.solrj.response.UpdateResponse
     
    org.apache.solr.client.solrj.response.UpdateResponse
    deleteByQuery(String query, int commitWithinMs)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    deleteByQuery(String collection, String query)
     
    org.apache.solr.client.solrj.response.UpdateResponse
    deleteByQuery(String collection, String query, int commitWithinMs)
     
    int
     
    int
     
    org.apache.solr.common.util.NamedList<Object>
    request(org.apache.solr.client.solrj.SolrRequest request, String collection)
     
    void
     

    Methods inherited from class org.apache.solr.client.solrj.SolrClient

    add, add, add, add, add, addBean, addBean, addBean, addBean, addBeans, addBeans, addBeans, addBeans, addBeans, addBeans, commit, commit, commit, commit, commit, commit, getBinder, getById, getById, getById, getById, getById, getById, getById, getById, getContext, optimize, optimize, optimize, optimize, optimize, optimize, ping, ping, query, query, query, query, queryAndStreamResponse, queryAndStreamResponse, queryAndStreamResponse, request, rollback, rollback

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • delegate

      protected final org.apache.solr.client.solrj.SolrClient delegate
    • maxBufferSize

      protected final int maxBufferSize
    • maxFlushInterval

      protected final long maxFlushInterval
    • flushExecutor

      protected static final transient ScheduledExecutorService flushExecutor
      This is shared between all BufferingSolrServer instances; they'll each register a scheduled Runnable in here as they start up.
  • Constructor Details

    • BufferingSolrServer

      public BufferingSolrServer(org.apache.solr.client.solrj.SolrClient delegate, int maxBufferSize, long maxFlushIntervalMillis)
    • BufferingSolrServer

      public BufferingSolrServer(org.apache.solr.client.solrj.SolrClient delegate, int maxBufferSize, long maxFlushIntervalMillis, int concurrency, String searchClusterName, String collectionId, com.codahale.metrics.MetricRegistry metricRegistry, String defaultSolrCollection)
      Parameters:
      delegate -
      maxBufferSize -
      maxFlushIntervalMillis -
      concurrency -
      searchClusterName - for diagnostic purposes only
      collectionId - for diagnostic purposes only
      metricRegistry -
  • Method Details

    • syncFlush

      public void syncFlush()
    • flush

      public int flush()
    • close

      public void close() throws IOException
      Throws:
      IOException
    • add

      public org.apache.solr.client.solrj.response.UpdateResponse add(org.apache.solr.common.SolrInputDocument doc, int commitWithinMs)
      Overrides:
      add in class org.apache.solr.client.solrj.SolrClient
    • add

      public org.apache.solr.client.solrj.response.UpdateResponse add(Collection<org.apache.solr.common.SolrInputDocument> docs)
      Overrides:
      add in class org.apache.solr.client.solrj.SolrClient
    • add

      public org.apache.solr.client.solrj.response.UpdateResponse add(Collection<org.apache.solr.common.SolrInputDocument> docs, int commitWithinMs)
      Overrides:
      add in class org.apache.solr.client.solrj.SolrClient
    • add

      public org.apache.solr.client.solrj.response.UpdateResponse add(String solrCollection, Collection<org.apache.solr.common.SolrInputDocument> docs, int commitWithinMs)
      Overrides:
      add in class org.apache.solr.client.solrj.SolrClient
    • add

      public org.apache.solr.client.solrj.response.UpdateResponse add(String collection, org.apache.solr.common.SolrInputDocument doc, int commitWithinMs)
      Overrides:
      add in class org.apache.solr.client.solrj.SolrClient
    • deleteById

      public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String collection, String id)
      Overrides:
      deleteById in class org.apache.solr.client.solrj.SolrClient
    • deleteById

      public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String id)
      Overrides:
      deleteById in class org.apache.solr.client.solrj.SolrClient
    • deleteById

      public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String collection, String id, int commitWithinMs)
      Overrides:
      deleteById in class org.apache.solr.client.solrj.SolrClient
    • deleteById

      public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String id, int commitWithinMs)
      Overrides:
      deleteById in class org.apache.solr.client.solrj.SolrClient
    • deleteById

      public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String collection, List<String> ids)
      Overrides:
      deleteById in class org.apache.solr.client.solrj.SolrClient
    • deleteById

      public org.apache.solr.client.solrj.response.UpdateResponse deleteById(List<String> ids)
      Overrides:
      deleteById in class org.apache.solr.client.solrj.SolrClient
    • deleteById

      public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String collection, List<String> ids, int commitWithinMs)
      Overrides:
      deleteById in class org.apache.solr.client.solrj.SolrClient
    • deleteById

      public org.apache.solr.client.solrj.response.UpdateResponse deleteById(List<String> ids, int commitWithinMs)
      Overrides:
      deleteById in class org.apache.solr.client.solrj.SolrClient
    • deleteByQuery

      public org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery(String collection, String query)
      Overrides:
      deleteByQuery in class org.apache.solr.client.solrj.SolrClient
    • deleteByQuery

      public org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery(String query)
      Overrides:
      deleteByQuery in class org.apache.solr.client.solrj.SolrClient
    • deleteByQuery

      public org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery(String collection, String query, int commitWithinMs)
      Overrides:
      deleteByQuery in class org.apache.solr.client.solrj.SolrClient
    • deleteByQuery

      public org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery(String query, int commitWithinMs)
      Overrides:
      deleteByQuery in class org.apache.solr.client.solrj.SolrClient
    • request

      public org.apache.solr.common.util.NamedList<Object> request(org.apache.solr.client.solrj.SolrRequest request, String collection) throws org.apache.solr.client.solrj.SolrServerException, IOException
      Specified by:
      request in class org.apache.solr.client.solrj.SolrClient
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
    • getNumberOfRequestsInBuffer

      public int getNumberOfRequestsInBuffer()