Class ModifiedCloudSolrClient
- java.lang.Object
-
- org.apache.solr.client.solrj.SolrClient
-
- org.apache.manifoldcf.agents.output.solr.ModifiedCloudSolrClient
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Serializable,java.lang.AutoCloseable
- Direct Known Subclasses:
ModifiedCloudHttp2SolrClient
public abstract class ModifiedCloudSolrClient extends org.apache.solr.client.solrj.SolrClient- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classModifiedCloudSolrClient.BuilderConstructsCloudSolrClientinstances from provided configuration.static classModifiedCloudSolrClient.RouteExceptionstatic classModifiedCloudSolrClient.RouteResponse<T extends ModifiedLBSolrClient.Req>
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.manifoldcf.agents.output.solr.ModifiedCloudSolrClient.StateCachecollectionStateCachestatic java.lang.StringSTATE_VERSION
-
Constructor Summary
Constructors Modifier Constructor Description protectedModifiedCloudSolrClient(boolean updatesToLeaders, boolean parallelUpdates, boolean directUpdatesToLeadersOnly)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()ModifiedCloudSolrClient.RouteResponsecondenseResponse(org.apache.solr.common.util.NamedList<?> response, int timeMillis)protected <T extends ModifiedCloudSolrClient.RouteResponse<?>>
TcondenseResponse(org.apache.solr.common.util.NamedList<?> response, int timeMillis, java.util.function.Supplier<T> supplier)voidconnect()Connect to the zookeeper ensemble.voidconnect(long duration, java.util.concurrent.TimeUnit timeUnit)Connect to a cluster.protected java.util.Map<java.lang.String,? extends ModifiedLBSolrClient.Req>createRoutes(ModifiedUpdateRequest updateRequest, org.apache.solr.common.params.ModifiableSolrParams routableParams, org.apache.solr.common.cloud.DocCollection col, org.apache.solr.common.cloud.DocRouter router, java.util.Map<java.lang.String,java.util.List<java.lang.String>> urlMap, java.lang.String routeField)org.apache.solr.common.cloud.ClusterStategetClusterState()abstract org.apache.solr.client.solrj.impl.ClusterStateProvidergetClusterStateProvider()java.lang.StringgetDefaultCollection()Gets the default collection for requestprotected org.apache.solr.common.cloud.DocCollectiongetDocCollection(java.lang.String collection, java.lang.Integer expectedVersion)protected abstract ModifiedLBSolrClientgetLbClient()intgetMinAchievedReplicationFactor(java.lang.String collection, org.apache.solr.common.util.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.org.apache.solr.client.solrj.ResponseParsergetParser()org.apache.solr.client.solrj.request.RequestWritergetRequestWriter()protected ModifiedCloudSolrClient.RouteExceptiongetRouteException(org.apache.solr.common.SolrException.ErrorCode serverError, org.apache.solr.common.util.NamedList<java.lang.Throwable> exceptions, java.util.Map<java.lang.String,? extends ModifiedLBSolrClient.Req> routes)java.util.Map<java.lang.String,java.lang.Integer>getShardReplicationFactor(java.lang.String collection, org.apache.solr.common.util.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()booleanisParallelUpdates()Gets whether direct updates are sent in parallelbooleanisUpdatesToLeaders()protected static java.util.ArrayList<java.lang.Object>objectList(int n)org.apache.solr.common.util.NamedList<java.lang.Object>request(org.apache.solr.client.solrj.SolrRequest<?> request, java.lang.String collection)protected org.apache.solr.common.util.NamedList<java.lang.Object>requestWithRetryOnStaleState(org.apache.solr.client.solrj.SolrRequest<?> request, int retryCount, java.util.List<java.lang.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 org.apache.solr.common.util.NamedList<java.lang.Object>sendRequest(org.apache.solr.client.solrj.SolrRequest<?> request, java.util.List<java.lang.String> inputCollections)voidsetCollectionCacheTTl(int seconds)Sets the cache ttl for DocCollection Objects cached.voidsetDefaultCollection(java.lang.String collection)Sets the default collection for requestvoidsetParallelCacheRefreshes(int n)If caches are expired they are refreshed after acquiring a lock.voidsetParser(org.apache.solr.client.solrj.ResponseParser processor)Note: This setter method is not thread-safe.voidsetRequestWriter(org.apache.solr.client.solrj.request.RequestWriter requestWriter)voidsetRetryExpiryTime(int secs)This is the time to wait to refetch the state after getting the same state version from ZKprotected abstract booleanwasCommError(java.lang.Throwable t)-
Methods inherited from class org.apache.solr.client.solrj.SolrClient
add, 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, optimize, optimize, optimize, optimize, optimize, optimize, ping, ping, query, query, query, query, queryAndStreamResponse, queryAndStreamResponse, queryAndStreamResponse, request, rollback, rollback
-
-
-
-
Field Detail
-
STATE_VERSION
public static final java.lang.String STATE_VERSION
- See Also:
- Constant Field Values
-
collectionStateCache
protected final org.apache.manifoldcf.agents.output.solr.ModifiedCloudSolrClient.StateCache collectionStateCache
-
-
Method Detail
-
setRetryExpiryTime
public void setRetryExpiryTime(int secs)
This is the time to wait to refetch the state after getting the same state version from ZKsecs
-
setCollectionCacheTTl
public void setCollectionCacheTTl(int seconds)
Sets the cache ttl for DocCollection Objects cached.- Parameters:
seconds- ttl value in seconds
-
getLbClient
protected abstract ModifiedLBSolrClient getLbClient()
-
getClusterStateProvider
public abstract org.apache.solr.client.solrj.impl.ClusterStateProvider getClusterStateProvider()
-
getClusterState
public org.apache.solr.common.cloud.ClusterState getClusterState()
-
wasCommError
protected abstract boolean wasCommError(java.lang.Throwable t)
-
close
public void close() throws java.io.IOException- Throws:
java.io.IOException
-
getParser
public org.apache.solr.client.solrj.ResponseParser getParser()
-
setParser
public void setParser(org.apache.solr.client.solrj.ResponseParser processor)
Note: 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()
-
getRequestWriter
public org.apache.solr.client.solrj.request.RequestWriter getRequestWriter()
-
setRequestWriter
public void setRequestWriter(org.apache.solr.client.solrj.request.RequestWriter requestWriter)
-
setDefaultCollection
public void setDefaultCollection(java.lang.String collection)
Sets the default collection for request
-
getDefaultCollection
public java.lang.String getDefaultCollection()
Gets the default collection for request
-
isParallelUpdates
public boolean isParallelUpdates()
Gets whether direct updates are sent in parallel
-
connect
public void connect()
Connect to the zookeeper ensemble. This is an optional method that may be used to force a connect before any other requests are sent.
-
connect
public void connect(long duration, java.util.concurrent.TimeUnit timeUnit) throws java.util.concurrent.TimeoutException, java.lang.InterruptedExceptionConnect to a cluster. If the cluster is not ready, retry connection up to a given timeout.- Parameters:
duration- the timeouttimeUnit- the units of the timeout- Throws:
java.util.concurrent.TimeoutException- if the cluster is not ready after the timeoutjava.lang.InterruptedException- if the wait is interrupted
-
getRouteException
protected ModifiedCloudSolrClient.RouteException getRouteException(org.apache.solr.common.SolrException.ErrorCode serverError, org.apache.solr.common.util.NamedList<java.lang.Throwable> exceptions, java.util.Map<java.lang.String,? extends ModifiedLBSolrClient.Req> routes)
-
createRoutes
protected java.util.Map<java.lang.String,? extends ModifiedLBSolrClient.Req> createRoutes(ModifiedUpdateRequest updateRequest, org.apache.solr.common.params.ModifiableSolrParams routableParams, org.apache.solr.common.cloud.DocCollection col, org.apache.solr.common.cloud.DocRouter router, java.util.Map<java.lang.String,java.util.List<java.lang.String>> urlMap, java.lang.String routeField)
-
condenseResponse
protected <T extends ModifiedCloudSolrClient.RouteResponse<?>> T condenseResponse(org.apache.solr.common.util.NamedList<?> response, int timeMillis, java.util.function.Supplier<T> supplier)
-
condenseResponse
public ModifiedCloudSolrClient.RouteResponse condenseResponse(org.apache.solr.common.util.NamedList<?> response, int timeMillis)
-
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:
requestin classorg.apache.solr.client.solrj.SolrClient- Throws:
org.apache.solr.client.solrj.SolrServerExceptionjava.io.IOException
-
requestWithRetryOnStaleState
protected org.apache.solr.common.util.NamedList<java.lang.Object> requestWithRetryOnStaleState(org.apache.solr.client.solrj.SolrRequest<?> request, int retryCount, java.util.List<java.lang.String> inputCollections) throws org.apache.solr.client.solrj.SolrServerException, java.io.IOExceptionAs 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:
org.apache.solr.client.solrj.SolrServerExceptionjava.io.IOException
-
sendRequest
protected org.apache.solr.common.util.NamedList<java.lang.Object> sendRequest(org.apache.solr.client.solrj.SolrRequest<?> request, java.util.List<java.lang.String> inputCollections) throws org.apache.solr.client.solrj.SolrServerException, java.io.IOException- Throws:
org.apache.solr.client.solrj.SolrServerExceptionjava.io.IOException
-
isUpdatesToLeaders
public boolean isUpdatesToLeaders()
-
isDirectUpdatesToLeadersOnly
public boolean isDirectUpdatesToLeadersOnly()
- Returns:
- true if direct updates are sent to shard leaders only
-
setParallelCacheRefreshes
public void setParallelCacheRefreshes(int n)
If caches are expired they are refreshed after acquiring a lock. use this to set the number of locks
-
objectList
protected static java.util.ArrayList<java.lang.Object> objectList(int n)
-
getDocCollection
protected org.apache.solr.common.cloud.DocCollection getDocCollection(java.lang.String collection, java.lang.Integer expectedVersion) throws org.apache.solr.common.SolrException- Throws:
org.apache.solr.common.SolrException
-
getMinAchievedReplicationFactor
public int getMinAchievedReplicationFactor(java.lang.String collection, org.apache.solr.common.util.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.
-
getShardReplicationFactor
public java.util.Map<java.lang.String,java.lang.Integer> getShardReplicationFactor(java.lang.String collection, org.apache.solr.common.util.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.
-
-