Package com.lucidworks.apollo.component
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.solr.client.solrj.SolrClientprotected static final ScheduledExecutorServiceThis is shared between all BufferingSolrServer instances; they'll each register a scheduled Runnable in here as they start up.protected final intprotected final long -
Constructor Summary
ConstructorsConstructorDescriptionBufferingSolrServer(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 TypeMethodDescriptionorg.apache.solr.client.solrj.response.UpdateResponseadd(String solrCollection, Collection<org.apache.solr.common.SolrInputDocument> docs, int commitWithinMs) org.apache.solr.client.solrj.response.UpdateResponseorg.apache.solr.client.solrj.response.UpdateResponseadd(Collection<org.apache.solr.common.SolrInputDocument> docs) org.apache.solr.client.solrj.response.UpdateResponseadd(Collection<org.apache.solr.common.SolrInputDocument> docs, int commitWithinMs) org.apache.solr.client.solrj.response.UpdateResponseadd(org.apache.solr.common.SolrInputDocument doc, int commitWithinMs) voidclose()org.apache.solr.client.solrj.response.UpdateResponsedeleteById(String id) org.apache.solr.client.solrj.response.UpdateResponsedeleteById(String id, int commitWithinMs) org.apache.solr.client.solrj.response.UpdateResponsedeleteById(String collection, String id) org.apache.solr.client.solrj.response.UpdateResponsedeleteById(String collection, String id, int commitWithinMs) org.apache.solr.client.solrj.response.UpdateResponsedeleteById(String collection, List<String> ids) org.apache.solr.client.solrj.response.UpdateResponsedeleteById(String collection, List<String> ids, int commitWithinMs) org.apache.solr.client.solrj.response.UpdateResponsedeleteById(List<String> ids) org.apache.solr.client.solrj.response.UpdateResponsedeleteById(List<String> ids, int commitWithinMs) org.apache.solr.client.solrj.response.UpdateResponsedeleteByQuery(String query) org.apache.solr.client.solrj.response.UpdateResponsedeleteByQuery(String query, int commitWithinMs) org.apache.solr.client.solrj.response.UpdateResponsedeleteByQuery(String collection, String query) org.apache.solr.client.solrj.response.UpdateResponsedeleteByQuery(String collection, String query, int commitWithinMs) intflush()intorg.apache.solr.common.util.NamedList<Object>voidMethods 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
-
Field Details
-
delegate
protected final org.apache.solr.client.solrj.SolrClient delegate -
maxBufferSize
protected final int maxBufferSize -
maxFlushInterval
protected final long maxFlushInterval -
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 onlycollectionId- for diagnostic purposes onlymetricRegistry-
-
-
Method Details
-
syncFlush
public void syncFlush() -
flush
public int flush() -
close
- Throws:
IOException
-
add
public org.apache.solr.client.solrj.response.UpdateResponse add(org.apache.solr.common.SolrInputDocument doc, int commitWithinMs) - Overrides:
addin classorg.apache.solr.client.solrj.SolrClient
-
add
public org.apache.solr.client.solrj.response.UpdateResponse add(Collection<org.apache.solr.common.SolrInputDocument> docs) - Overrides:
addin classorg.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:
addin classorg.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:
addin classorg.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:
addin classorg.apache.solr.client.solrj.SolrClient
-
deleteById
public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String collection, String id) - Overrides:
deleteByIdin classorg.apache.solr.client.solrj.SolrClient
-
deleteById
- Overrides:
deleteByIdin classorg.apache.solr.client.solrj.SolrClient
-
deleteById
public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String collection, String id, int commitWithinMs) - Overrides:
deleteByIdin classorg.apache.solr.client.solrj.SolrClient
-
deleteById
public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String id, int commitWithinMs) - Overrides:
deleteByIdin classorg.apache.solr.client.solrj.SolrClient
-
deleteById
public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String collection, List<String> ids) - Overrides:
deleteByIdin classorg.apache.solr.client.solrj.SolrClient
-
deleteById
- Overrides:
deleteByIdin classorg.apache.solr.client.solrj.SolrClient
-
deleteById
public org.apache.solr.client.solrj.response.UpdateResponse deleteById(String collection, List<String> ids, int commitWithinMs) - Overrides:
deleteByIdin classorg.apache.solr.client.solrj.SolrClient
-
deleteById
public org.apache.solr.client.solrj.response.UpdateResponse deleteById(List<String> ids, int commitWithinMs) - Overrides:
deleteByIdin classorg.apache.solr.client.solrj.SolrClient
-
deleteByQuery
public org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery(String collection, String query) - Overrides:
deleteByQueryin classorg.apache.solr.client.solrj.SolrClient
-
deleteByQuery
- Overrides:
deleteByQueryin classorg.apache.solr.client.solrj.SolrClient
-
deleteByQuery
public org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery(String collection, String query, int commitWithinMs) - Overrides:
deleteByQueryin classorg.apache.solr.client.solrj.SolrClient
-
deleteByQuery
public org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery(String query, int commitWithinMs) - Overrides:
deleteByQueryin classorg.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:
requestin classorg.apache.solr.client.solrj.SolrClient- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
getNumberOfRequestsInBuffer
public int getNumberOfRequestsInBuffer()
-