Error-resilient Solr_Configure
Self-heals in case the solr data directory is missing, by unloading and re-creating the core.
This commit is contained in:
parent
d9af3c1b43
commit
8486eebd0e
|
@ -159,17 +159,23 @@ class Solr_Configure extends BuildTask {
|
|||
|
||||
foreach ($indexes as $index => $instance) {
|
||||
$indexName = $instance->getIndexName();
|
||||
$instanceDir = $indexName;
|
||||
if ($remote) $instanceDir = "$remote/$instanceDir";
|
||||
|
||||
if ($service->coreIsActive($indexName)) {
|
||||
echo "Reloading configuration...";
|
||||
$service->coreReload($indexName);
|
||||
echo "done\n";
|
||||
} else {
|
||||
echo "Creating configuration...";
|
||||
$instanceDir = $indexName;
|
||||
if ($remote) {
|
||||
$instanceDir = "$remote/$instanceDir";
|
||||
try {
|
||||
if ($service->coreIsActive($indexName)) {
|
||||
echo "Reloading configuration...";
|
||||
$service->coreReload($indexName);
|
||||
echo "done\n";
|
||||
} else {
|
||||
echo "Creating configuration...";
|
||||
$service->coreCreate($indexName, $instanceDir);
|
||||
echo "done\n";
|
||||
}
|
||||
} catch(Apache_Solr_HttpTransportException $e) {
|
||||
// Can happen when the directory is missing
|
||||
echo "Failed reload, falling back to unloading and creating configuration...";
|
||||
$service->coreUnload($indexName, $instanceDir);
|
||||
$service->coreCreate($indexName, $instanceDir);
|
||||
echo "done\n";
|
||||
}
|
||||
|
|
|
@ -43,6 +43,13 @@ class SolrService extends Apache_Solr_Service {
|
|||
return $this->coreCommand('RELOAD', $core);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Apache_Solr_Response
|
||||
*/
|
||||
public function coreUnload($core) {
|
||||
return $this->coreCommand('UNLOAD', $core);
|
||||
}
|
||||
|
||||
protected $_serviceCache = array();
|
||||
|
||||
public function serviceForCore($core) {
|
||||
|
|
Loading…
Reference in New Issue