コード例 #1
0
 /**
  * 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;
 }