Package com.lucidworks.apollo.component
Class BufferingSolrServer
- java.lang.Object
-
- org.apache.solr.client.solrj.SolrClient
-
- com.lucidworks.apollo.component.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 aSolrClient
instance and adds a simple buffer on top of it. The buffer can hold a series ofBufferingSolrServer.BufferedRequest
s 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BufferingSolrServer.Action
-
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
-
-
-
-
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 onlycollectionId
- for diagnostic purposes onlymetricRegistry
-
-
-
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 classorg.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 classorg.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 classorg.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 classorg.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 classorg.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 classorg.apache.solr.client.solrj.SolrClient
-
deleteById
public org.apache.solr.client.solrj.response.UpdateResponse deleteById(java.lang.String id)
- Overrides:
deleteById
in classorg.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 classorg.apache.solr.client.solrj.SolrClient
-
deleteById
public org.apache.solr.client.solrj.response.UpdateResponse deleteById(java.lang.String id, int commitWithinMs)
- Overrides:
deleteById
in classorg.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 classorg.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 classorg.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 classorg.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 classorg.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 classorg.apache.solr.client.solrj.SolrClient
-
deleteByQuery
public org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery(java.lang.String query)
- Overrides:
deleteByQuery
in classorg.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 classorg.apache.solr.client.solrj.SolrClient
-
deleteByQuery
public org.apache.solr.client.solrj.response.UpdateResponse deleteByQuery(java.lang.String query, int commitWithinMs)
- Overrides:
deleteByQuery
in classorg.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 classorg.apache.solr.client.solrj.SolrClient
- Throws:
org.apache.solr.client.solrj.SolrServerException
java.io.IOException
-
getNumberOfRequestsInBuffer
public int getNumberOfRequestsInBuffer()
-
-