Class 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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.manifoldcf.agents.output.solr.ModifiedCloudSolrClient.StateCache collectionStateCache  
      static java.lang.String STATE_VERSION  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ModifiedCloudSolrClient​(boolean updatesToLeaders, boolean parallelUpdates, boolean directUpdatesToLeadersOnly)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      ModifiedCloudSolrClient.RouteResponse condenseResponse​(org.apache.solr.common.util.NamedList<?> response, int timeMillis)  
      protected <T extends ModifiedCloudSolrClient.RouteResponse<?>>
      T
      condenseResponse​(org.apache.solr.common.util.NamedList<?> response, int timeMillis, java.util.function.Supplier<T> supplier)  
      void connect()
      Connect to the zookeeper ensemble.
      void connect​(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.ClusterState getClusterState()  
      abstract org.apache.solr.client.solrj.impl.ClusterStateProvider getClusterStateProvider()  
      java.lang.String getDefaultCollection()
      Gets the default collection for request
      protected org.apache.solr.common.cloud.DocCollection getDocCollection​(java.lang.String collection, java.lang.Integer expectedVersion)  
      protected abstract ModifiedLBSolrClient getLbClient()  
      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.
      org.apache.solr.client.solrj.ResponseParser getParser()  
      org.apache.solr.client.solrj.request.RequestWriter getRequestWriter()  
      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)  
      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.
      boolean isDirectUpdatesToLeadersOnly()  
      boolean isParallelUpdates()
      Gets whether direct updates are sent in parallel
      boolean isUpdatesToLeaders()  
      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)  
      void setCollectionCacheTTl​(int seconds)
      Sets the cache ttl for DocCollection Objects cached.
      void setDefaultCollection​(java.lang.String collection)
      Sets the default collection for request
      void setParallelCacheRefreshes​(int n)
      If caches are expired they are refreshed after acquiring a lock.
      void setParser​(org.apache.solr.client.solrj.ResponseParser processor)
      Note: This setter method is not thread-safe.
      void setRequestWriter​(org.apache.solr.client.solrj.request.RequestWriter requestWriter)  
      void setRetryExpiryTime​(int secs)
      This is the time to wait to refetch the state after getting the same state version from ZK
      protected abstract boolean wasCommError​(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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • collectionStateCache

        protected final org.apache.manifoldcf.agents.output.solr.ModifiedCloudSolrClient.StateCache collectionStateCache
    • Constructor Detail

      • ModifiedCloudSolrClient

        protected ModifiedCloudSolrClient​(boolean updatesToLeaders,
                                          boolean parallelUpdates,
                                          boolean directUpdatesToLeadersOnly)
    • 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 ZK

        secs

      • setCollectionCacheTTl

        public void setCollectionCacheTTl​(int seconds)
        Sets the cache ttl for DocCollection Objects cached.
        Parameters:
        seconds - ttl value in seconds
      • 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.InterruptedException
        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:
        java.util.concurrent.TimeoutException - if the cluster is not ready after the timeout
        java.lang.InterruptedException - if the wait is interrupted
      • 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)
      • 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
      • 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.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:
        org.apache.solr.client.solrj.SolrServerException
        java.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.SolrServerException
        java.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.