org.apache.solr.client.solrj.impl
Class CloudSolrServer

java.lang.Object
  extended by org.apache.solr.client.solrj.SolrServer
      extended by org.apache.solr.client.solrj.impl.CloudSolrServer
All Implemented Interfaces:
Serializable

public class CloudSolrServer
extends SolrServer

SolrJ client class to communicate with SolrCloud. Instances of this class communicate with Zookeeper to discover Solr endpoints for SolrCloud collections, and then use the LBHttpSolrServer to issue requests. This class assumes the id field for your documents is called 'id' - if this is not the case, you must set the right name with setIdField(String).

See Also:
Serialized Form

Nested Class Summary
static class CloudSolrServer.RouteException
           
static class CloudSolrServer.RouteResponse
           
 
Constructor Summary
CloudSolrServer(String zkHost)
           
CloudSolrServer(String zkHost, boolean updatesToLeaders)
           
CloudSolrServer(String zkHost, LBHttpSolrServer lbServer)
           
CloudSolrServer(String zkHost, LBHttpSolrServer lbServer, boolean updatesToLeaders)
           
 
Method Summary
 CloudSolrServer.RouteResponse condenseResponse(NamedList response, long timeMillis)
           
 void connect()
          Connect to the zookeeper ensemble.
 String getDefaultCollection()
          Gets the default collection for request
 String getIdField()
           
 LBHttpSolrServer getLbServer()
           
 ResponseParser getParser()
           
 RequestWriter getRequestWriter()
           
 ZkStateReader getZkStateReader()
           
 boolean isUpdatesToLeaders()
           
 NamedList<Object> request(SolrRequest request)
          SolrServer implementations need to implement how a request is actually processed
 void setDefaultCollection(String collection)
          Sets the default collection for request
 void setIdField(String idField)
           
 void setParallelUpdates(boolean parallelUpdates)
           
 void setParser(ResponseParser processor)
          Note: This setter method is not thread-safe.
 void setRequestWriter(RequestWriter requestWriter)
           
 void setZkClientTimeout(int zkClientTimeout)
          Set the timeout to the zookeeper ensemble in ms
 void setZkConnectTimeout(int zkConnectTimeout)
          Set the connect timeout to the zookeeper ensemble in ms
 void shutdown()
          Release allocated resources.
 
Methods inherited from class org.apache.solr.client.solrj.SolrServer
add, add, add, add, addBean, addBean, addBeans, addBeans, commit, commit, commit, deleteById, deleteById, deleteById, deleteById, deleteByQuery, deleteByQuery, getBinder, optimize, optimize, optimize, ping, query, query, queryAndStreamResponse, rollback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CloudSolrServer

public CloudSolrServer(String zkHost)
Parameters:
zkHost - The client endpoint of the zookeeper quorum containing the cloud state, in the form HOST:PORT.

CloudSolrServer

public CloudSolrServer(String zkHost,
                       boolean updatesToLeaders)
                throws MalformedURLException
Throws:
MalformedURLException

CloudSolrServer

public CloudSolrServer(String zkHost,
                       LBHttpSolrServer lbServer)
Parameters:
zkHost - The client endpoint of the zookeeper quorum containing the cloud state, in the form HOST:PORT.
lbServer - LBHttpSolrServer instance for requests.

CloudSolrServer

public CloudSolrServer(String zkHost,
                       LBHttpSolrServer lbServer,
                       boolean updatesToLeaders)
Parameters:
zkHost - The client endpoint of the zookeeper quorum containing the cloud state, in the form HOST:PORT.
lbServer - LBHttpSolrServer instance for requests.
updatesToLeaders - sends updates only to leaders - defaults to true
Method Detail

getParser

public ResponseParser getParser()

setParser

public void setParser(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 RequestWriter getRequestWriter()

setRequestWriter

public void setRequestWriter(RequestWriter requestWriter)

getZkStateReader

public ZkStateReader getZkStateReader()

setIdField

public void setIdField(String idField)
Parameters:
idField - the field to route documents on.

getIdField

public String getIdField()
Returns:
the field that updates are routed on.

setDefaultCollection

public void setDefaultCollection(String collection)
Sets the default collection for request


getDefaultCollection

public String getDefaultCollection()
Gets the default collection for request


setZkConnectTimeout

public void setZkConnectTimeout(int zkConnectTimeout)
Set the connect timeout to the zookeeper ensemble in ms


setZkClientTimeout

public void setZkClientTimeout(int zkClientTimeout)
Set the timeout to the zookeeper ensemble in ms


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.


setParallelUpdates

public void setParallelUpdates(boolean parallelUpdates)

condenseResponse

public CloudSolrServer.RouteResponse condenseResponse(NamedList response,
                                                      long timeMillis)

request

public NamedList<Object> request(SolrRequest request)
                          throws SolrServerException,
                                 IOException
Description copied from class: SolrServer
SolrServer implementations need to implement how a request is actually processed

Specified by:
request in class SolrServer
Throws:
SolrServerException
IOException

shutdown

public void shutdown()
Description copied from class: SolrServer
Release allocated resources.

Specified by:
shutdown in class SolrServer

getLbServer

public LBHttpSolrServer getLbServer()

isUpdatesToLeaders

public boolean isUpdatesToLeaders()


Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.