本文整理汇总了PHP中LoadBalancer::getServerCount方法的典型用法代码示例。如果您正苦于以下问题:PHP LoadBalancer::getServerCount方法的具体用法?PHP LoadBalancer::getServerCount怎么用?PHP LoadBalancer::getServerCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoadBalancer
的用法示例。
在下文中一共展示了LoadBalancer::getServerCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shutdownLB
/**
* Notify the ChronologyProtector that the LoadBalancer is about to shut
* down. Saves replication positions.
*
* @param LoadBalancer $lb
* @return void
*/
public function shutdownLB(LoadBalancer $lb)
{
if (session_id() == '' || $lb->getServerCount() <= 1) {
return;
// don't start a session; don't bother with non-replicated setups
}
$masterName = $lb->getServerName(0);
if (isset($this->shutdownPositions[$masterName])) {
return;
// already done
}
// Only save the position if writes have been done on the connection
$db = $lb->getAnyOpenConnection(0);
$info = $lb->parentInfo();
if (!$db || !$db->doneWrites()) {
wfDebug(__METHOD__ . ": LB {$info['id']}, no writes done\n");
return;
}
$pos = $db->getMasterPos();
wfDebug(__METHOD__ . ": LB {$info['id']} has master pos {$pos}\n");
$this->shutdownPositions[$masterName] = $pos;
}
示例2: shutdownLB
/**
* Notify the ChronologyProtector that the LoadBalancer is about to shut
* down. Saves replication positions.
*
* @param LoadBalancer $lb
* @return void
*/
public function shutdownLB(LoadBalancer $lb)
{
if (!$this->enabled || $lb->getServerCount() <= 1) {
return;
// non-replicated setup or disabled
}
$info = $lb->parentInfo();
$masterName = $lb->getServerName($lb->getWriterIndex());
// Only save the position if writes have been done on the connection
$db = $lb->getAnyOpenConnection($lb->getWriterIndex());
if (!$db || !$db->doneWrites()) {
wfDebugLog('replication', __METHOD__ . ": LB {$info['id']}, no writes done\n");
return;
// nothing to do
}
$pos = $db->getMasterPos();
wfDebugLog('replication', __METHOD__ . ": LB {$info['id']} has master pos {$pos}\n");
$this->shutdownPositions[$masterName] = $pos;
}
示例3: shutdownLB
/**
* Notify the ChronologyProtector that the LoadBalancer is about to shut
* down. Saves replication positions.
*
* @param LoadBalancer $lb
*/
function shutdownLB($lb)
{
if (session_id() != '' && $lb->getServerCount() > 1) {
$masterName = $lb->getServerName(0);
if (!isset($this->shutdownPos[$masterName])) {
$pos = $lb->getMasterPos();
$info = $lb->parentInfo();
wfDebug(__METHOD__ . ": LB " . $info['id'] . " has master pos {$pos}\n");
$this->shutdownPos[$masterName] = $pos;
}
}
}