Merge "Remove old ProfilerOutputUdp class"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 22 Oct 2015 07:10:31 +0000 (07:10 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 22 Oct 2015 07:10:31 +0000 (07:10 +0000)
includes/deferred/LinksUpdate.php
includes/jobqueue/JobQueueRedis.php
includes/libs/MapCacheLRU.php
includes/libs/ProcessCacheLRU.php

index b96fa46..5a7efca 100644 (file)
@@ -992,7 +992,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                return array(
                        'wiki' => $this->mDb->getWikiID(),
                        'job'  => new JobSpecification(
-                               'refreshLinks',
+                               'refreshLinksPrioritized',
                                array(
                                        'prioritize' => true,
                                        // Reuse the parser cache if it was saved
index 002fe0d..1e957c2 100644 (file)
@@ -218,14 +218,15 @@ class JobQueueRedis extends JobQueue {
                                        $failed += count( $itemBatch );
                                }
                        }
-                       if ( $failed > 0 ) {
-                               wfDebugLog( 'JobQueueRedis', "Could not insert {$failed} {$this->type} job(s)." );
-
-                               throw new RedisException( "Could not insert {$failed} {$this->type} job(s)." );
-                       }
                        JobQueue::incrStats( 'inserts', $this->type, count( $items ) );
+                       JobQueue::incrStats( 'inserts_actual', $pushed );
                        JobQueue::incrStats( 'dupe_inserts', $this->type,
                                count( $items ) - $failed - $pushed );
+                       if ( $failed > 0 ) {
+                               $err = "Could not insert {$failed} {$this->type} job(s).";
+                               wfDebugLog( 'JobQueueRedis', $err );
+                               throw new RedisException( $err );
+                       }
                } catch ( RedisException $e ) {
                        $this->throwRedisException( $conn, $e );
                }
index a0230be..a49eb01 100644 (file)
@@ -39,11 +39,11 @@ class MapCacheLRU {
 
        /**
         * @param int $maxKeys Maximum number of entries allowed (min 1).
-        * @throws Exception When $maxCacheKeys is not an int or =< 0.
+        * @throws Exception When $maxCacheKeys is not an int or not above zero.
         */
        public function __construct( $maxKeys ) {
                Assert::parameterType( 'integer', $maxKeys, '$maxKeys' );
-               Assert::parameter( $maxKeys >= 1, '$maxKeys', 'must be >= 1' );
+               Assert::parameter( $maxKeys > 0, '$maxKeys', 'must be above zero' );
 
                $this->maxCacheKeys = $maxKeys;
        }
@@ -59,7 +59,7 @@ class MapCacheLRU {
         */
        public function set( $key, $value ) {
                if ( array_key_exists( $key, $this->cache ) ) {
-                       $this->ping( $key ); // push to top
+                       $this->ping( $key );
                } elseif ( count( $this->cache ) >= $this->maxCacheKeys ) {
                        reset( $this->cache );
                        $evictKey = key( $this->cache );
@@ -87,12 +87,11 @@ class MapCacheLRU {
         * @return mixed
         */
        public function get( $key ) {
-               if ( array_key_exists( $key, $this->cache ) ) {
-                       $this->ping( $key ); // push to top
-                       return $this->cache[$key];
-               } else {
+               if ( !array_key_exists( $key, $this->cache ) ) {
                        return null;
                }
+               $this->ping( $key );
+               return $this->cache[$key];
        }
 
        /**
index b55ff9d..eec31ce 100644 (file)
@@ -55,7 +55,7 @@ class ProcessCacheLRU {
         */
        public function set( $key, $prop, $value ) {
                if ( isset( $this->cache[$key] ) ) {
-                       $this->ping( $key ); // push to top
+                       $this->ping( $key );
                } elseif ( count( $this->cache ) >= $this->maxCacheKeys ) {
                        reset( $this->cache );
                        $evictKey = key( $this->cache );
@@ -94,13 +94,11 @@ class ProcessCacheLRU {
         * @return mixed
         */
        public function get( $key, $prop ) {
-               if ( isset( $this->cache[$key][$prop] ) ) {
-                       // push to top
-                       $this->ping( $key );
-                       return $this->cache[$key][$prop];
-               } else {
+               if ( !isset( $this->cache[$key][$prop] ) ) {
                        return null;
                }
+               $this->ping( $key );
+               return $this->cache[$key][$prop];
        }
 
        /**
@@ -130,7 +128,7 @@ class ProcessCacheLRU {
         */
        public function resize( $maxKeys ) {
                Assert::parameterType( 'integer', $maxKeys, '$maxKeys' );
-               Assert::parameter( $maxKeys >= 1, '$maxKeys', 'must be >= 1' );
+               Assert::parameter( $maxKeys > 0, '$maxKeys', 'must be above zero' );
 
                $this->maxCacheKeys = $maxKeys;
                while ( count( $this->cache ) > $this->maxCacheKeys ) {