Class Apache_Solr_Service_Balancer

Description

Reference Implementation for using multiple Solr services in a distribution. Functionality

includes: routing of read / write operations failover (on selection) for multiple read servers

Located in /Service/Balancer.php (line 48)


	
			
Variable Summary
Method Summary
static string escape (string $value)
static string escapePhrase (string $value)
static string phrase (string $value)
Apache_Solr_Service_Balancer __construct ([array $readableServices = array()], [array $writeableServices = array()])
Apache_Solr_Response add (string $rawPost)
Apache_Solr_Response addDocument (Apache_Solr_Document $document, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true])
Apache_Solr_Response addDocuments (array $documents, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true])
void addReadService (mixed $service)
void addWriteService (mixed $service)
Apache_Solr_Response commit ([ $optimize = true], [boolean $waitFlush = true], [boolean $waitSearcher = true], [ $timeout = 3600])
Apache_Solr_Response delete (string $rawPost)
Apache_Solr_Response deleteById (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true])
Apache_Solr_Response deleteByQuery (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true])
Apache_Solr_Response optimize ([boolean $waitFlush = true], [boolean $waitSearcher = true])
void removeReadService (mixed $service)
void removeWriteService (mixed $service)
Apache_Solr_Response search (string $query, [int $offset = 0], [int $limit = 10], [array $params = array()])
void setCreateDocuments ( $createDocuments)
void setReadPingTimeout ( $timeout)
void setUseBackoff ( $enable)
void setWritePingTimeout ( $timeout)
string _getServiceId (string $host, integer $port, string $path)
Apache_Solr_Service _selectReadService ([ $forceSelect = false])
Apache_Solr_Service _selectWriteService ([ $forceSelect = false])
Apache_Solr_Service _selectWriteServiceSafe ([ $forceSelect = false])
Variables
mixed $_backoffEscalation = 2.0 (line 64)
  • access: protected
mixed $_backoffLimit = 600 (line 63)
  • access: protected
mixed $_createDocuments = true (line 50)
  • access: protected
mixed $_currentReadService = null (line 55)
  • access: protected
mixed $_currentWriteService = null (line 56)
  • access: protected
mixed $_defaultBackoff = 2.0 (line 65)
  • access: protected
mixed $_readableServices = array() (line 52)
  • access: protected
mixed $_readPingTimeout = 2 (line 58)
  • access: protected
mixed $_useBackoff = false (line 62)
  • access: protected
mixed $_writeableServices = array() (line 53)
  • access: protected
mixed $_writePingTimeout = 4 (line 59)
  • access: protected
Methods
static escape (line 75)

Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.

NOTE: inside a phrase fewer characters need escaped, use Apache_Solr_Service::escapePhrase() instead

  • access: public
static string escape (string $value)
  • string $value
static escapePhrase (line 86)

Escape a value meant to be contained in a phrase for special query characters

  • access: public
static string escapePhrase (string $value)
  • string $value
static phrase (line 97)

Convenience function for creating phrase syntax from a value

  • access: public
static string phrase (string $value)
  • string $value
Constructor __construct (line 108)

Constructor. Takes arrays of read and write service instances or descriptions

  • access: public
Apache_Solr_Service_Balancer __construct ([array $readableServices = array()], [array $writeableServices = array()])
  • array $readableServices
  • array $writeableServices
add (line 466)

Raw Add Method. Takes a raw post body and sends it to the update service. Post body should be a complete and well formed "add" xml document.

  • throws: Exception If an error occurs during the service call
  • access: public
Apache_Solr_Response add (string $rawPost)
  • string $rawPost
addDocument (line 501)

Add a Solr Document to the index

  • throws: Exception If an error occurs during the service call
  • access: public
Apache_Solr_Response addDocument (Apache_Solr_Document $document, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true])
  • Apache_Solr_Document $document
  • boolean $allowDups
  • boolean $overwritePending
  • boolean $overwriteCommitted
addDocuments (line 536)

Add an array of Solr Documents to the index all at once

  • throws: Exception If an error occurs during the service call
  • access: public
Apache_Solr_Response addDocuments (array $documents, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true])
  • array $documents: Should be an array of Apache_Solr_Document instances
  • boolean $allowDups
  • boolean $overwritePending
  • boolean $overwriteCommitted
addReadService (line 159)

Adds a service instance or service descriptor (if it is already not added)

  • throws: Exception If service descriptor is not valid
  • access: public
void addReadService (mixed $service)
  • mixed $service
addWriteService (line 227)

Adds a service instance or service descriptor (if it is already not added)

  • throws: Exception If service descriptor is not valid
  • access: public
void addWriteService (mixed $service)
  • mixed $service
commit (line 570)

Send a commit command. Will be synchronous unless both wait parameters are set to false.

  • throws: Exception If an error occurs during the service call
  • access: public
Apache_Solr_Response commit ([ $optimize = true], [boolean $waitFlush = true], [boolean $waitSearcher = true], [ $timeout = 3600])
  • boolean $waitFlush
  • boolean $waitSearcher
  • $optimize
  • $timeout
delete (line 603)

Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be a complete and well formed "delete" xml document

  • throws: Exception If an error occurs during the service call
  • access: public
Apache_Solr_Response delete (string $rawPost)
  • string $rawPost
deleteById (line 637)

Create a delete document based on document ID

  • throws: Exception If an error occurs during the service call
  • access: public
Apache_Solr_Response deleteById (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true])
  • string $id
  • boolean $fromPending
  • boolean $fromCommitted
deleteByQuery (line 671)

Create a delete document based on a query and submit it

  • throws: Exception If an error occurs during the service call
  • access: public
Apache_Solr_Response deleteByQuery (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true])
  • string $rawQuery
  • boolean $fromPending
  • boolean $fromCommitted
getCreateDocuments (line 452)
  • access: public
void getCreateDocuments ()
optimize (line 705)

Send an optimize command. Will be synchronous unless both wait parameters are set to false.

  • throws: Exception If an error occurs during the service call
  • access: public
Apache_Solr_Response optimize ([boolean $waitFlush = true], [boolean $waitSearcher = true])
  • boolean $waitFlush
  • boolean $waitSearcher
removeReadService (line 189)

Removes a service instance or descriptor from the available services

  • throws: Exception If service descriptor is not valid
  • access: public
void removeReadService (mixed $service)
  • mixed $service
removeWriteService (line 257)

Removes a service instance or descriptor from the available services

  • throws: Exception If service descriptor is not valid
  • access: public
void removeWriteService (mixed $service)
  • mixed $service
search (line 740)

Simple Search interface

  • throws: Exception If an error occurs during the service call
  • access: public
Apache_Solr_Response search (string $query, [int $offset = 0], [int $limit = 10], [array $params = array()])
  • string $query: The raw query string
  • int $offset: The starting offset for result documents
  • int $limit: The maximum number of result documents to return
  • array $params: key / value pairs for query parameters, use arrays for multivalued parameters
setCreateDocuments (line 441)
  • access: public
void setCreateDocuments ( $createDocuments)
  • $createDocuments
setReadPingTimeout (line 123)
  • access: public
void setReadPingTimeout ( $timeout)
  • $timeout
setUseBackoff (line 133)
  • access: public
void setUseBackoff ( $enable)
  • $enable
setWritePingTimeout (line 128)
  • access: public
void setWritePingTimeout ( $timeout)
  • $timeout
_getServiceId (line 146)

Generates a service ID

  • access: protected
string _getServiceId (string $host, integer $port, string $path)
  • string $host
  • integer $port
  • string $path
_selectReadService (line 295)

Iterate through available read services and select the first with a ping that satisfies configured timeout restrictions (or the default)

  • throws: Exception If there are no read services that meet requirements
  • access: protected
Apache_Solr_Service _selectReadService ([ $forceSelect = false])
  • $forceSelect
_selectWriteService (line 343)

Iterate through available write services and select the first with a ping that satisfies configured timeout restrictions (or the default)

  • throws: Exception If there are no write services that meet requirements
  • access: protected
Apache_Solr_Service _selectWriteService ([ $forceSelect = false])
  • $forceSelect
_selectWriteServiceSafe (line 399)

Iterate through available write services and select the first with a ping

that satisfies configured timeout restrictions (or the default). The timeout period will increase until a connection is made or the limit is reached. This will allow for increased reliability with heavily loaded server(s).

  • throws: Exception If there are no write services that meet requirements
  • access: protected
Apache_Solr_Service _selectWriteServiceSafe ([ $forceSelect = false])
  • $forceSelect

Documentation generated on Wed, 11 Mar 2009 17:34:13 -0400 by phpDocumentor 1.4.2