Class BufferingSolrServer

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Serializable, java.lang.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:
    Serialized Form
    • 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, java.lang.String searchClusterName, java.lang.String collectionId, com.codahale.metrics.MetricRegistry metricRegistry, java.lang.String defaultSolrCollection)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.solr.client.solrj.response.UpdateResponse add​(java.lang.String solrCollection, java.util.Collection<org.apache.solr.common.SolrInputDocument> docs, int commitWithinMs)  
      org.apache.solr.client.solrj.response.UpdateResponse add​(java.lang.String collection, org.apache.solr.common.SolrInputDocument doc, int commitWithinMs)  
      org.apache.solr.client.solrj.response.UpdateResponse add​(java.util.Collection<org.apache.solr.common.SolrInputDocument> docs)  
      org.apache.solr.client.solrj.response.UpdateResponse add​(java.util.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 close()  
      org.apache.solr.client.solrj.response.UpdateResponse deleteById​(java.lang.String id)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteById​(java.lang.String id, int commitWithinMs)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteById​(java.lang.String collection, java.lang.String id)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteById​(java.lang.String collection, java.lang.String id, int commitWithinMs)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteById​(java.lang.String collection, java.util.List<java.lang.String> ids)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteById​(java.lang.String collection, java.util.List<java.lang.String> ids, int commitWithinMs)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteById​(java.util.List<java.lang.String> ids)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteById​(java.util.List<java.lang.String> ids, int commitWithinMs)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery​(java.lang.String query)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery​(java.lang.String query, int commitWithinMs)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery​(java.lang.String collection, java.lang.String query)  
      org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery​(java.lang.String collection, java.lang.String query, int commitWithinMs)  
      int flush()  
      int getNumberOfRequestsInBuffer()  
      org.apache.solr.common.util.NamedList<java.lang.Object> request​(org.apache.solr.client.solrj.SolrRequest request, java.lang.String collection)  
      void syncFlush()  
      • 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, 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

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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,
                                   java.lang.String searchClusterName,
                                   java.lang.String collectionId,
                                   com.codahale.metrics.MetricRegistry metricRegistry,
                                   java.lang.String defaultSolrCollection)
        Parameters:
        delegate -
        maxBufferSize -
        maxFlushIntervalMillis -
        concurrency -
        searchClusterName - for diagnostic purposes only
        collectionId - for diagnostic purposes only
        metricRegistry -
    • Method Detail

      • syncFlush

        public void syncFlush()
      • flush

        public int flush()
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.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​(java.util.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​(java.util.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​(java.lang.String solrCollection,
                                                                        java.util.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​(java.lang.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​(java.lang.String collection,
                                                                               java.lang.String id)
        Overrides:
        deleteById in class org.apache.solr.client.solrj.SolrClient
      • deleteById

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

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

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

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

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

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

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

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

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

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

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

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

        public int getNumberOfRequestsInBuffer()