Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / poolcounter / PoolCounterRedis.php
index 5e8db07..5a15ddf 100644 (file)
@@ -18,6 +18,7 @@
  * @file
  * @author Aaron Schulz
  */
+use Psr\Log\LoggerInterface;
 
 /**
  * Version of PoolCounter that uses Redis
@@ -55,6 +56,8 @@ class PoolCounterRedis extends PoolCounter {
        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 */
@@ -87,6 +90,7 @@ class PoolCounterRedis extends PoolCounter {
 
                $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
@@ -107,7 +111,7 @@ class PoolCounterRedis extends PoolCounter {
                        $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;
                                }
@@ -151,6 +155,7 @@ class PoolCounterRedis extends PoolCounter {
 
                // @codingStandardsIgnoreStart Generic.Files.LineLength
                static $script =
+               /** @lang Lua */
 <<<LUA
                local kSlots,kSlotsNextRelease,kWakeup,kWaiting = unpack(KEYS)
                local rMaxWorkers,rExpiry,rSlot,rSlotTime,rAwakeAll,rTime = unpack(ARGV)
@@ -287,6 +292,7 @@ LUA;
         */
        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)
@@ -355,6 +361,7 @@ LUA;
         */
        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)