Class CloudSolrClient
- java.lang.Object
- 
- org.apache.solr.client.solrj.SolrClient
- 
- org.apache.solr.client.solrj.impl.CloudSolrClient
 
 
- 
- All Implemented Interfaces:
- Closeable,- Serializable,- AutoCloseable
 - Direct Known Subclasses:
- CloudHttp2SolrClient,- CloudLegacySolrClient
 
 public abstract class CloudSolrClient extends SolrClient - See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classCloudSolrClient.BuilderConstructsCloudSolrClientinstances from provided configuration.static classCloudSolrClient.RouteExceptionstatic classCloudSolrClient.RouteResponse<T extends LBSolrClient.Req>
 - 
Field SummaryFields Modifier and Type Field Description protected org.apache.solr.client.solrj.impl.CloudSolrClient.StateCachecollectionStateCacheprotected Object[]locksprotected longretryExpiryTimeNanostatic StringSTATE_VERSION- 
Fields inherited from class org.apache.solr.client.solrj.SolrClientdefaultCollection
 
- 
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedCloudSolrClient(boolean updatesToLeaders, boolean parallelUpdates, boolean directUpdatesToLeadersOnly)
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()CloudSolrClient.RouteResponsecondenseResponse(NamedList<?> response, int timeMillis)protected <T extends CloudSolrClient.RouteResponse<?>>
 TcondenseResponse(NamedList<?> response, int timeMillis, Supplier<T> supplier)voidconnect()Deprecated.CallClusterStateProvider.getLiveNodes()instead.voidconnect(long duration, TimeUnit timeUnit)Deprecated.protected Map<String,? extends LBSolrClient.Req>createRoutes(UpdateRequest updateRequest, ModifiableSolrParams routableParams, DocCollection col, DocRouter router, Map<String,List<String>> urlMap, String routeField)ClusterStategetClusterState()Deprecated.problematic as a 'get' method, since one implementation will do a remote request each time this is called, potentially return lots of data that isn't even needed.abstract ClusterStateProvidergetClusterStateProvider()protected DocCollectiongetDocCollection(String collection, Integer expectedVersion)protected abstract LBSolrClientgetLbClient()intgetMinAchievedReplicationFactor(String collection, NamedList<?> resp)Useful for determining the minimum achieved replication factor across all shards involved in processing an update request, typically useful for gauging the replication factor of a batch.ResponseParsergetParser()RequestWritergetRequestWriter()protected CloudSolrClient.RouteExceptiongetRouteException(SolrException.ErrorCode serverError, NamedList<Throwable> exceptions, Map<String,? extends LBSolrClient.Req> routes)Map<String,Integer>getShardReplicationFactor(String collection, NamedList<?> resp)Walks the NamedList response after performing an update request looking for the replication factor that was achieved in each shard involved in the request.booleanisDirectUpdatesToLeadersOnly()If true, this client has been configured such that "direct updates" will only be sent to the current leader of the corresponding shard, and will not be retried with other replicas.booleanisParallelUpdates()Gets whether direct updates are sent in parallelbooleanisUpdatesToLeaders()If true, this client has been configured such that it will generally prefer to sendIsUpdateRequestrequests to a shard leader, if and only ifIsUpdateRequest.isSendToLeaders()is also true.protected static Object[]objectList(int n)NamedList<Object>request(SolrRequest<?> request, String collection)Execute a request against a Solr server for a given collectionprotected NamedList<Object>requestWithRetryOnStaleState(SolrRequest<?> request, int retryCount, List<String> inputCollections)As this class doesn't watch external collections on the client side, there's a chance that the request will fail due to cached stale state, which means the state must be refreshed from ZK and retried.protected NamedList<Object>sendRequest(SolrRequest<?> request, List<String> inputCollections)voidsetCollectionCacheTTl(int seconds)Deprecated.voidsetDefaultCollection(String collection)Deprecated.voidsetParallelCacheRefreshes(int n)Deprecated.voidsetParser(ResponseParser processor)Deprecated.useCloudHttp2SolrClient.BuilderinsteadvoidsetRequestWriter(RequestWriter requestWriter)Deprecated.useCloudHttp2SolrClient.BuilderinsteadvoidsetRetryExpiryTime(int secs)Deprecated.protected abstract booleanwasCommError(Throwable t)- 
Methods inherited from class org.apache.solr.client.solrj.SolrClientadd, add, add, add, add, add, add, add, add, add, addBean, addBean, addBean, addBean, addBeans, addBeans, addBeans, addBeans, addBeans, addBeans, commit, commit, commit, commit, commit, commit, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteByQuery, deleteByQuery, deleteByQuery, deleteByQuery, getBinder, getById, getById, getById, getById, getById, getById, getById, getById, getContext, getDefaultCollection, optimize, optimize, optimize, optimize, optimize, optimize, ping, ping, query, query, query, query, queryAndStreamResponse, queryAndStreamResponse, queryAndStreamResponse, request, rollback, rollback
 
- 
 
- 
- 
- 
Field Detail- 
STATE_VERSIONpublic static final String STATE_VERSION - See Also:
- Constant Field Values
 
 - 
retryExpiryTimeNanoprotected long retryExpiryTimeNano 
 - 
locksprotected volatile Object[] locks 
 - 
collectionStateCacheprotected final org.apache.solr.client.solrj.impl.CloudSolrClient.StateCache collectionStateCache 
 
- 
 - 
Method Detail- 
setRetryExpiryTime@Deprecated public void setRetryExpiryTime(int secs) Deprecated.This is the time to wait to refetch the state after getting the same state version from ZKsecs 
 - 
setCollectionCacheTTl@Deprecated public void setCollectionCacheTTl(int seconds) Deprecated.Sets the cache ttl for DocCollection Objects cached.- Parameters:
- seconds- ttl value in seconds
 
 - 
getLbClientprotected abstract LBSolrClient getLbClient() 
 - 
getClusterStateProviderpublic abstract ClusterStateProvider getClusterStateProvider() 
 - 
getClusterState@Deprecated public ClusterState getClusterState() Deprecated.problematic as a 'get' method, since one implementation will do a remote request each time this is called, potentially return lots of data that isn't even needed.
 - 
wasCommErrorprotected abstract boolean wasCommError(Throwable t) 
 - 
closepublic void close() throws IOException- Throws:
- IOException
 
 - 
getParserpublic ResponseParser getParser() 
 - 
setParser@Deprecated public void setParser(ResponseParser processor) Deprecated.useCloudHttp2SolrClient.BuilderinsteadNote: This setter method is not thread-safe.- Parameters:
- processor- Default Response Parser chosen to parse the response if the parser were not specified as part of the request.
- See Also:
- SolrRequest.getResponseParser()
 
 - 
getRequestWriterpublic RequestWriter getRequestWriter() 
 - 
setRequestWriter@Deprecated public void setRequestWriter(RequestWriter requestWriter) Deprecated.useCloudHttp2SolrClient.BuilderinsteadChoose theRequestWriterto use.Note: This setter method is not thread-safe. 
 - 
setDefaultCollection@Deprecated public void setDefaultCollection(String collection) Deprecated.Sets the default collection for request.
 - 
isParallelUpdatespublic boolean isParallelUpdates() Gets whether direct updates are sent in parallel
 - 
connect@Deprecated public void connect() Deprecated.CallClusterStateProvider.getLiveNodes()instead.Connect to the zookeeper ensemble. This is an optional method that may be used to force a connection before any other requests are sent.
 - 
connect@Deprecated public void connect(long duration, TimeUnit timeUnit) throws TimeoutException, InterruptedException Deprecated.Connect to a cluster. If the cluster is not ready, retry connection up to a given timeout.- Parameters:
- duration- the timeout
- timeUnit- the units of the timeout
- Throws:
- TimeoutException- if the cluster is not ready after the timeout
- InterruptedException- if the wait is interrupted
 
 - 
getRouteExceptionprotected CloudSolrClient.RouteException getRouteException(SolrException.ErrorCode serverError, NamedList<Throwable> exceptions, Map<String,? extends LBSolrClient.Req> routes) 
 - 
createRoutesprotected Map<String,? extends LBSolrClient.Req> createRoutes(UpdateRequest updateRequest, ModifiableSolrParams routableParams, DocCollection col, DocRouter router, Map<String,List<String>> urlMap, String routeField) 
 - 
condenseResponseprotected <T extends CloudSolrClient.RouteResponse<?>> T condenseResponse(NamedList<?> response, int timeMillis, Supplier<T> supplier) 
 - 
condenseResponsepublic CloudSolrClient.RouteResponse condenseResponse(NamedList<?> response, int timeMillis) 
 - 
requestpublic NamedList<Object> request(SolrRequest<?> request, String collection) throws SolrServerException, IOException Description copied from class:SolrClientExecute a request against a Solr server for a given collection- Specified by:
- requestin class- SolrClient
- Parameters:
- request- the request to execute
- collection- the collection to execute the request against
- Returns:
- a NamedListcontaining the response from the server
- Throws:
- SolrServerException- if there is an error on the server
- IOException- If there is a low-level I/O error.
 
 - 
requestWithRetryOnStaleStateprotected NamedList<Object> requestWithRetryOnStaleState(SolrRequest<?> request, int retryCount, List<String> inputCollections) throws SolrServerException, IOException As this class doesn't watch external collections on the client side, there's a chance that the request will fail due to cached stale state, which means the state must be refreshed from ZK and retried.- Throws:
- SolrServerException
- IOException
 
 - 
sendRequestprotected NamedList<Object> sendRequest(SolrRequest<?> request, List<String> inputCollections) throws SolrServerException, IOException - Throws:
- SolrServerException
- IOException
 
 - 
isUpdatesToLeaderspublic boolean isUpdatesToLeaders() If true, this client has been configured such that it will generally prefer to sendIsUpdateRequestrequests to a shard leader, if and only ifIsUpdateRequest.isSendToLeaders()is also true. If false, then this client has been configured to obey normal routing preferences when dealing withIsUpdateRequestrequests.- See Also:
- isDirectUpdatesToLeadersOnly()
 
 - 
isDirectUpdatesToLeadersOnlypublic boolean isDirectUpdatesToLeadersOnly() If true, this client has been configured such that "direct updates" will only be sent to the current leader of the corresponding shard, and will not be retried with other replicas. This method has no effect ifisUpdatesToLeaders()orIsUpdateRequest.isSendToLeaders()returns false.A "direct update" is any update that can be sent directly to a single shard, and does not need to be broadcast to every shard. (Example: document updates or "delete by id" when using the default router; non-direct updates are things like commits and "delete by query"). NOTE: If a single UpdateRequestcontains multiple "direct updates" for different shards, this client may break the request up and merge the responses.- Returns:
- true if direct updates are sent to shard leaders only
 
 - 
setParallelCacheRefreshes@Deprecated public void setParallelCacheRefreshes(int n) Deprecated.If caches are expired they are refreshed after acquiring a lock. use this to set the number of locks
 - 
objectListprotected static Object[] objectList(int n) 
 - 
getDocCollectionprotected DocCollection getDocCollection(String collection, Integer expectedVersion) throws SolrException - Throws:
- SolrException
 
 - 
getMinAchievedReplicationFactorpublic int getMinAchievedReplicationFactor(String collection, NamedList<?> resp) Useful for determining the minimum achieved replication factor across all shards involved in processing an update request, typically useful for gauging the replication factor of a batch.
 - 
getShardReplicationFactorpublic Map<String,Integer> getShardReplicationFactor(String collection, NamedList<?> resp) Walks the NamedList response after performing an update request looking for the replication factor that was achieved in each shard involved in the request. For single doc updates, there will be only one shard in the return value.
 
- 
 
-