\Apache_Solr_Service_Balancer
Reference Implementation for using multiple Solr services in a distribution. Functionality includes: routing of read / write operations failover (on selection) for multiple read servers
Synopsis
class Apache_Solr_Service_Balancer
{
- // constants
- const SVN_REVISION = '$Revision$';
- const SVN_ID = '$Id$';
- const SVN_URL = '$HeadURL$';
- // members
- protected boolean $_createDocuments = true;
- protected array $_readableServices = ;
- protected array $_writeableServices = ;
- protected $_currentReadService = NULL;
- protected $_currentWriteService = NULL;
- protected integer $_readPingTimeout = 2;
- protected integer $_writePingTimeout = 4;
- protected boolean $_useBackoff = false;
- protected integer $_backoffLimit = 600;
- protected float $_backoffEscalation = 2.0;
- protected float $_defaultBackoff = 2.0;
- // methods
- public static string escape()
- public static string escapePhrase()
- public static string phrase()
- public void __construct()
- public void setReadPingTimeout()
- public void setWritePingTimeout()
- public void setUseBackoff()
- protected string _getServiceId()
- public void addReadService()
- public void removeReadService()
- public void addWriteService()
- public void removeWriteService()
- protected Apache_Solr_Service _selectReadService()
- protected Apache_Solr_Service _selectWriteService()
- protected Apache_Solr_Service _selectWriteServiceSafe()
- public void setCreateDocuments()
- public boolean getCreateDocuments()
- public Apache_Solr_Response add()
- public Apache_Solr_Response addDocument()
- public Apache_Solr_Response addDocuments()
- public Apache_Solr_Response commit()
- public Apache_Solr_Response delete()
- public Apache_Solr_Response deleteById()
- public Apache_Solr_Response deleteByMultipleIds()
- public Apache_Solr_Response deleteByQuery()
- public Apache_Solr_Response extract()
- public Apache_Solr_Response extractFromString()
- public Apache_Solr_Response optimize()
- public Apache_Solr_Response search()
Tasks
Line | Task |
---|---|
823+ | Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted. |
Constants
Name | Value |
---|---|
SVN_REVISION | '$Revision$' |
SVN_ID | '$Id$' |
SVN_URL | '$HeadURL$' |
Members
protected
- $_backoffEscalation
- $_backoffLimit
- $_createDocuments
- $_currentReadService
- $_currentWriteService
- $_defaultBackoff
- $_readPingTimeout
- $_readableServices
- $_useBackoff
- $_writePingTimeout
- $_writeableServices
Methods
protected
- _getServiceId() — Generates a service ID
- _selectReadService() — Iterate through available read services and select the first with a ping that satisfies configured timeout restrictions (or the default)
- _selectWriteService() — Iterate through available write services and select the first with a ping that satisfies configured timeout restrictions (or the default)
- _selectWriteServiceSafe() — 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).
public
- __construct() — Constructor. Takes arrays of read and write service instances or descriptions
- add() — 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.
- addDocument() — Add a Solr Document to the index
- addDocuments() — Add an array of Solr Documents to the index all at once
- addReadService() — Adds a service instance or service descriptor (if it is already not added)
- addWriteService() — Adds a service instance or service descriptor (if it is already not added)
- commit() — Send a commit command. Will be synchronous unless both wait parameters are set to false.
- delete() — 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
- deleteById() — Create a delete document based on document ID
- deleteByMultipleIds() — Create and post a delete document based on multiple document IDs.
- deleteByQuery() — Create a delete document based on a query and submit it
- escape() — Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
- escapePhrase() — Escape a value meant to be contained in a phrase for special query characters
- extract() — Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how to use Solr Cell and what parameters are available.
- extractFromString() — Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how to use Solr Cell and what parameters are available.
- getCreateDocuments() — Get the current state of teh create documents flag.
- optimize() — Send an optimize command. Will be synchronous unless both wait parameters are set to false.
- phrase() — Convenience function for creating phrase syntax from a value
- removeReadService() — Removes a service instance or descriptor from the available services
- removeWriteService() — Removes a service instance or descriptor from the available services
- search() — Simple Search interface
- setCreateDocuments() — Set the create documents flag. This determines whether {@link Apache_Solr_Response} objects will parse the response and create {@link Apache_Solr_Document} instances in place.
- setReadPingTimeout()
- setUseBackoff()
- setWritePingTimeout()