Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14050545
D17564.id42251.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D17564.id42251.diff
View Options
diff --git a/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php b/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php
--- a/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php
+++ b/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php
@@ -505,7 +505,7 @@
array $data, $method = 'GET') {
$uri = $host->getURI($path);
- $data = json_encode($data);
+ $data = phutil_json_encode($data);
$future = new HTTPSFuture($uri, $data);
if ($method != 'GET') {
$future->setMethod($method);
diff --git a/src/infrastructure/cluster/search/PhabricatorMySQLSearchHost.php b/src/infrastructure/cluster/search/PhabricatorMySQLSearchHost.php
--- a/src/infrastructure/cluster/search/PhabricatorMySQLSearchHost.php
+++ b/src/infrastructure/cluster/search/PhabricatorMySQLSearchHost.php
@@ -24,6 +24,15 @@
return 'mysql';
}
+ public function getHealthRecord() {
+ if (!$this->healthRecord) {
+ $ref = PhabricatorDatabaseRef::getMasterDatabaseRefForApplication(
+ 'search');
+ $this->healthRecord = $ref->getHealthRecord();
+ }
+ return $this->healthRecord;
+ }
+
public function getConnectionStatus() {
PhabricatorDatabaseRef::queryAll();
$ref = PhabricatorDatabaseRef::getMasterDatabaseRefForApplication('search');
diff --git a/src/infrastructure/cluster/search/PhabricatorSearchHost.php b/src/infrastructure/cluster/search/PhabricatorSearchHost.php
--- a/src/infrastructure/cluster/search/PhabricatorSearchHost.php
+++ b/src/infrastructure/cluster/search/PhabricatorSearchHost.php
@@ -13,7 +13,6 @@
protected $disabled;
protected $host;
protected $port;
- protected $hostRefs = array();
const STATUS_OKAY = 'okay';
const STATUS_FAIL = 'fail';
@@ -121,43 +120,4 @@
abstract public function getConnectionStatus();
- public static function reindexAbstractDocument(
- PhabricatorSearchAbstractDocument $doc) {
-
- $services = self::getAllServices();
- $indexed = 0;
- foreach (self::getWritableHostForEachService() as $host) {
- $host->getEngine()->reindexAbstractDocument($doc);
- $indexed++;
- }
- if ($indexed == 0) {
- throw new PhabricatorClusterNoHostForRoleException('write');
- }
- }
-
- public static function executeSearch(PhabricatorSavedQuery $query) {
- $services = self::getAllServices();
- foreach ($services as $service) {
- $hosts = $service->getAllHostsForRole('read');
- // try all hosts until one succeeds
- foreach ($hosts as $host) {
- $last_exception = null;
- try {
- $res = $host->getEngine()->executeSearch($query);
- // return immediately if we get results without an exception
- $host->didHealthCheck(true);
- return $res;
- } catch (Exception $ex) {
- // try each server in turn, only throw if none succeed
- $last_exception = $ex;
- $host->didHealthCheck(false);
- }
- }
- }
- if ($last_exception) {
- throw $last_exception;
- }
- return $res;
- }
-
}
diff --git a/src/infrastructure/cluster/search/PhabricatorSearchService.php b/src/infrastructure/cluster/search/PhabricatorSearchService.php
--- a/src/infrastructure/cluster/search/PhabricatorSearchService.php
+++ b/src/infrastructure/cluster/search/PhabricatorSearchService.php
@@ -46,6 +46,7 @@
public function setConfig($config) {
$this->config = $config;
+ $this->setRoles(idx($config, 'roles', array()));
if (!isset($config['hosts'])) {
$config['hosts'] = array(
@@ -67,15 +68,6 @@
return $this->config;
}
- public function setDisabled($disabled) {
- $this->disabled = $disabled;
- return $this;
- }
-
- public function getDisabled() {
- return $this->disabled;
- }
-
public static function getConnectionStatusMap() {
return array(
self::STATUS_OKAY => array(
@@ -100,7 +92,7 @@
}
public function hasRole($role) {
- return isset($this->roles[$role]) && $this->roles[$role] === true;
+ return isset($this->roles[$role]) && $this->roles[$role] !== false;
}
public function setRoles(array $roles) {
@@ -160,6 +152,12 @@
* @return PhabricatorSearchHost[]
*/
public function getAllHostsForRole($role) {
+ // if the role is explicitly set to false at the top level, then all hosts
+ // have the role disabled.
+ if (idx($this->config, $role) === false) {
+ return array();
+ }
+
$hosts = array();
foreach ($this->hosts as $host) {
if ($host->hasRole($role)) {
@@ -225,8 +223,11 @@
PhabricatorSearchAbstractDocument $doc) {
$indexed = 0;
foreach (self::getAllServices() as $service) {
- $service->getEngine()->reindexAbstractDocument($doc);
- $indexed++;
+ $hosts = $service->getAllHostsForRole('write');
+ if (count($hosts)) {
+ $service->getEngine()->reindexAbstractDocument($doc);
+ $indexed++;
+ }
}
if ($indexed == 0) {
throw new PhabricatorClusterNoHostForRoleException('write');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 7:05 PM (1 d, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6715106
Default Alt Text
D17564.id42251.diff (5 KB)
Attached To
Mode
D17564: Address some New Search Configuration Errata
Attached
Detach File
Event Timeline
Log In to Comment