private function getCacheKey(array $serverIndexes) { sort($serverIndexes); // Lag is per-server, not per-DB, so key on the master DB name return $this->srvCache->makeGlobalKey('lag-times', self::VERSION, $this->parent->getServerName($this->parent->getWriterIndex()), implode('-', $serverIndexes)); }
/** * Clean up the connection when out of scope */ function __destruct() { if ($this->conn !== null) { $this->lb->reuseConnection($this->conn); } }
/** * Notify the ChronologyProtector that the ILoadBalancer is about to shut * down. Saves replication positions. * * @param ILoadBalancer $lb * @return void */ public function shutdownLB(ILoadBalancer $lb) { if (!$this->enabled) { return; // not enabled } elseif (!$lb->hasOrMadeRecentMasterChanges(INF)) { // Only save the position if writes have been done on the connection return; } $masterName = $lb->getServerName($lb->getWriterIndex()); if ($lb->getServerCount() > 1) { $pos = $lb->getMasterPos(); $this->logger->info(__METHOD__ . ": LB for '{$masterName}' has pos {$pos}\n"); $this->shutdownPositions[$masterName] = $pos; } else { $this->logger->info(__METHOD__ . ": DB '{$masterName}' touched\n"); } $this->shutdownTouchDBs[$masterName] = 1; }
/** * @param ILoadBalancer $lb */ protected function initLoadBalancer(ILoadBalancer $lb) { if ($this->trxRoundId !== false) { $lb->beginMasterChanges($this->trxRoundId); // set DBO_TRX } }