* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @author Aaron Schulz
*/
+use Psr\Log\LoggerInterface;
/**
* Version of PoolCounter that uses Redis
protected $ring;
/** @var RedisConnectionPool */
protected $pool;
+ /** @var LoggerInterface */
+ protected $logger;
/** @var array (server label => host) map */
protected $serversByLabel;
/** @var string SHA-1 of the key */
parent::__construct( $conf, $type, $key );
$this->serversByLabel = $conf['servers'];
- $this->ring = new HashRing( array_fill_keys( array_keys( $conf['servers'] ), 100 ) );
+
+ $serverLabels = array_keys( $conf['servers'] );
+ $this->ring = new HashRing( array_fill_keys( $serverLabels, 10 ) );
$conf['redisConfig']['serializer'] = 'none'; // for use with Lua
$this->pool = RedisConnectionPool::singleton( $conf['redisConfig'] );
+ $this->logger = \MediaWiki\Logger\LoggerFactory::getInstance( 'redis' );
$this->keySha1 = sha1( $this->key );
$met = ini_get( 'max_execution_time' ); // usually 0 in CLI mode
$servers = $this->ring->getLocations( $this->key, 3 );
ArrayUtils::consistentHashSort( $servers, $this->key );
foreach ( $servers as $server ) {
- $conn = $this->pool->getConnection( $this->serversByLabel[$server] );
+ $conn = $this->pool->getConnection( $this->serversByLabel[$server], $this->logger );
if ( $conn ) {
break;
}
}
$conn = $status->value;
- // @codingStandardsIgnoreStart Generic.Files.LineLength
+ // phpcs:disable Generic.Files.LineLength
static $script =
+ /** @lang Lua */
<<<LUA
local kSlots,kSlotsNextRelease,kWakeup,kWaiting = unpack(KEYS)
local rMaxWorkers,rExpiry,rSlot,rSlotTime,rAwakeAll,rTime = unpack(ARGV)
end
return 1
LUA;
- // @codingStandardsIgnoreEnd
+ // phpcs:enable
try {
$conn->luaEval( $script,
*/
protected function initAndPopPoolSlotList( RedisConnRef $conn, $now ) {
static $script =
+ /** @lang Lua */
<<<LUA
local kSlots,kSlotsNextRelease,kSlotWaits = unpack(KEYS)
local rMaxWorkers,rMaxQueue,rTimeout,rExpiry,rSess,rTime = unpack(ARGV)
*/
protected function registerAcquisitionTime( RedisConnRef $conn, $slot, $now ) {
static $script =
+ /** @lang Lua */
<<<LUA
local kSlots,kSlotsNextRelease,kSlotWaits = unpack(KEYS)
local rSlot,rExpiry,rSess,rTime = unpack(ARGV)