Path: blob/master/src/infrastructure/cluster/search/PhabricatorSearchHost.php
13450 views
<?php12abstract class PhabricatorSearchHost3extends Phobject {45const KEY_REFS = 'cluster.search.refs';6const KEY_HEALTH = 'cluster.search.health';78protected $engine;9protected $healthRecord;10protected $roles = array();1112protected $disabled;13protected $host;14protected $port;1516const STATUS_OKAY = 'okay';17const STATUS_FAIL = 'fail';1819public function __construct(PhabricatorFulltextStorageEngine $engine) {20$this->engine = $engine;21}2223public function setDisabled($disabled) {24$this->disabled = $disabled;25return $this;26}2728public function getDisabled() {29return $this->disabled;30}3132/**33* @return PhabricatorFulltextStorageEngine34*/35public function getEngine() {36return $this->engine;37}3839public function isWritable() {40return $this->hasRole('write');41}4243public function isReadable() {44return $this->hasRole('read');45}4647public function hasRole($role) {48return isset($this->roles[$role]) && $this->roles[$role] === true;49}5051public function setRoles(array $roles) {52foreach ($roles as $role => $val) {53$this->roles[$role] = $val;54}55return $this;56}5758public function getRoles() {59$roles = array();60foreach ($this->roles as $key => $val) {61if ($val) {62$roles[$key] = $val;63}64}65return $roles;66}6768public function setPort($value) {69$this->port = $value;70return $this;71}7273public function getPort() {74return $this->port;75}7677public function setHost($value) {78$this->host = $value;79return $this;80}8182public function getHost() {83return $this->host;84}858687public function getHealthRecordCacheKey() {88$host = $this->getHost();89$port = $this->getPort();90$key = self::KEY_HEALTH;9192return "{$key}({$host}, {$port})";93}9495/**96* @return PhabricatorClusterServiceHealthRecord97*/98public function getHealthRecord() {99if (!$this->healthRecord) {100$this->healthRecord = new PhabricatorClusterServiceHealthRecord(101$this->getHealthRecordCacheKey());102}103return $this->healthRecord;104}105106public function didHealthCheck($reachable) {107$record = $this->getHealthRecord();108$should_check = $record->getShouldCheck();109110if ($should_check) {111$record->didHealthCheck($reachable);112}113}114115/**116* @return string[] Get a list of fields to show in the status overview UI117*/118abstract public function getStatusViewColumns();119120abstract public function getConnectionStatus();121122}123124125