## 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 49)

Class Constant Summary
SVN_ID = '$Id: Balancer.php 15 2009-08-04 17:53:08Z donovan.jimenez $'
SVN_REVISION = '$Revision: 15 $'
Variable Summary
mixed $_backoffEscalation
mixed $_backoffLimit
mixed $_createDocuments
mixed $_currentReadService
mixed $_currentWriteService
mixed $_defaultBackoff
mixed $_readableServices
mixed $_readPingTimeout
mixed $_useBackoff
mixed $_writeableServices
mixed $_writePingTimeout
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])
void getCreateDocuments ()
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 75)

- access: protected

mixed $_backoffLimit = 600 (line 74)

- access: protected

mixed $_createDocuments = true (line 61)

- access: protected

mixed $_currentReadService = null (line 66)

- access: protected

mixed $_currentWriteService = null (line 67)

- access: protected

mixed $_defaultBackoff = 2.0 (line 76)

- access: protected

mixed $_readableServices = array() (line 63)

- access: protected

mixed $_readPingTimeout = 2 (line 69)

- access: protected

mixed $_useBackoff = false (line 73)

- access: protected

mixed $_writeableServices = array() (line 64)

- access: protected

mixed $_writePingTimeout = 4 (line 70)

- access: protected

Methods
static escape (line 86)

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 97)

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 108)

Convenience function for creating phrase syntax from a value

- access: public

static string phrase (string $value)

- string $value

Constructor __construct (line 119)

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 477)

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 512)

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 547)

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 170)

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 238)

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 581)

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 614)

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 648)

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 682)

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 463)

- access: public

void getCreateDocuments ()
optimize (line 716)

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 200)

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 268)

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 751)

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 452)

- access: public

void setCreateDocuments ( $createDocuments)

- $createDocuments

setReadPingTimeout (line 134)

- access: public

void setReadPingTimeout ( $timeout)

- $timeout

setUseBackoff (line 144)

- access: public

void setUseBackoff ( $enable)

- $enable

setWritePingTimeout (line 139)

- access: public

void setWritePingTimeout ( $timeout)

- $timeout

_getServiceId (line 157)

Generates a service ID

- access: protected

string _getServiceId (string $host, integer $port, string $path)

- string $host
- integer $port
- string $path

_selectReadService (line 306)

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 354)

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 410)

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

Class Constants
SVN_ID = '$Id: Balancer.php 15 2009-08-04 17:53:08Z donovan.jimenez $' (line 59)

SVN ID meta data for this class

SVN_REVISION = '$Revision: 15 $' (line 54)

SVN Revision meta data for this class

Documentation generated on Mon, 09 Nov 2009 18:15:41 -0500 by phpDocumentor 1.4.2