public function Apache_Solr_Service_Balancer::addWriteService in Apache Solr Search 5
Adds a service instance or service descriptor (if it is already not added)
Parameters
mixed $service:
Throws
Exception If service descriptor is not valid
1 call to Apache_Solr_Service_Balancer::addWriteService()
- Apache_Solr_Service_Balancer::__construct in SolrPhpClient/
Apache/ Solr/ Service/ Balancer.php - Constructor. Takes arrays of read and write service instances or descriptions
File
- SolrPhpClient/
Apache/ Solr/ Service/ Balancer.php, line 210
Class
- 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
Code
public function addWriteService($service) {
if ($service instanceof Apache_Solr_Service) {
$id = $this
->_getServiceId($service
->getHost(), $service
->getPort(), $service
->getPath());
$this->_writeableServices[$id] = $service;
}
else {
if (is_array($service)) {
if (isset($service['host']) && isset($service['port']) && isset($service['path'])) {
$id = $this
->_getServiceId((string) $service['host'], (int) $service['port'], (string) $service['path']);
$this->_writeableServices[$id] = $service;
}
else {
throw new Exception('A Writeable Service description array does not have all required elements of host, port, and path');
}
}
}
}