Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/cluster/PhabricatorDatabaseRef.php
<?php | <?php | ||||
final class PhabricatorDatabaseRef | final class PhabricatorDatabaseRef | ||||
extends Phobject { | extends Phobject { | ||||
const STATUS_OKAY = 'okay'; | const STATUS_OKAY = 'okay'; | ||||
const STATUS_FAIL = 'fail'; | const STATUS_FAIL = 'fail'; | ||||
const STATUS_AUTH = 'auth'; | const STATUS_AUTH = 'auth'; | ||||
const STATUS_REPLICATION_CLIENT = 'replication-client'; | const STATUS_REPLICATION_CLIENT = 'replication-client'; | ||||
const REPLICATION_OKAY = 'okay'; | const REPLICATION_OKAY = 'okay'; | ||||
const REPLICATION_MASTER_REPLICA = 'master-replica'; | const REPLICATION_MASTER_REPLICA = 'master-replica'; | ||||
const REPLICATION_REPLICA_NONE = 'replica-none'; | const REPLICATION_REPLICA_NONE = 'replica-none'; | ||||
const REPLICATION_SLOW = 'replica-slow'; | const REPLICATION_SLOW = 'replica-slow'; | ||||
const REPLICATION_NOT_REPLICATING = 'not-replicating'; | const REPLICATION_NOT_REPLICATING = 'not-replicating'; | ||||
const KEY_HEALTH = 'cluster.db.health'; | |||||
const KEY_REFS = 'cluster.db.refs'; | const KEY_REFS = 'cluster.db.refs'; | ||||
const KEY_INDIVIDUAL = 'cluster.db.individual'; | const KEY_INDIVIDUAL = 'cluster.db.individual'; | ||||
private $host; | private $host; | ||||
private $port; | private $port; | ||||
private $user; | private $user; | ||||
private $pass; | private $pass; | ||||
private $disabled; | private $disabled; | ||||
▲ Show 20 Lines • Show All 459 Lines • ▼ Show 20 Lines | if ($should_check) { | ||||
// This does an implicit health update. | // This does an implicit health update. | ||||
$connection = $this->newManagementConnection(); | $connection = $this->newManagementConnection(); | ||||
$this->isReachable($connection); | $this->isReachable($connection); | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
private function getHealthRecordCacheKey() { | |||||
$host = $this->getHost(); | |||||
$port = $this->getPort(); | |||||
$key = self::KEY_HEALTH; | |||||
return "{$key}({$host}, {$port})"; | |||||
} | |||||
public function getHealthRecord() { | public function getHealthRecord() { | ||||
if (!$this->healthRecord) { | if (!$this->healthRecord) { | ||||
$this->healthRecord = new PhabricatorDatabaseHealthRecord($this); | $this->healthRecord = new PhabricatorClusterServiceHealthRecord( | ||||
$this->getHealthRecordCacheKey()); | |||||
} | } | ||||
return $this->healthRecord; | return $this->healthRecord; | ||||
} | } | ||||
public static function getActiveDatabaseRefs() { | public static function getActiveDatabaseRefs() { | ||||
$refs = array(); | $refs = array(); | ||||
foreach (self::getMasterDatabaseRefs() as $ref) { | foreach (self::getMasterDatabaseRefs() as $ref) { | ||||
▲ Show 20 Lines • Show All 219 Lines • Show Last 20 Lines |