Ability to set the blobs table name for any server in an external cluster. This would...
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 29 Oct 2005 01:41:36 +0000 (01:41 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 29 Oct 2005 01:41:36 +0000 (01:41 +0000)
RELEASE-NOTES
includes/Database.php
includes/DefaultSettings.php
includes/ExternalStoreDB.php
includes/LoadBalancer.php

index 65a4d88..69b517f 100644 (file)
@@ -190,6 +190,7 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 3649) Remove obsolete, broken moveCustomMessages script
 * (bug 3291) 'last' diff link for last history line when not at end
 * Avoid numerous redundant latest-revision lookups in history
+* Ability to set the table name for external storage servers
 
 
 === Caveats ===
index 3d2f5c0..a4a889c 100644 (file)
@@ -62,6 +62,7 @@ class Database {
        var $mFlags;
        var $mTrxLevel = 0;
        var $mErrorCount = 0;
+       var $mLBInfo = array();
        /**#@-*/
 
 #------------------------------------------------------------------------------
@@ -130,6 +131,29 @@ class Database {
                return wfSetVar( $this->mErrorCount, $count );
        }
 
+       /**
+        * Properties passed down from the server info array of the load balancer
+        */
+       function getLBInfo( $name = NULL ) {
+               if ( is_null( $name ) ) {
+                       return $this->mLBInfo;
+               } else {
+                       if ( array_key_exists( $name, $this->mLBInfo ) ) {
+                               return $this->mLBInfo[$name];
+                       } else {
+                               return NULL;
+                       }
+               }
+       }
+
+       function setLBInfo( $name, $value = NULL ) {
+               if ( is_null( $value ) ) {
+                       $this->mLBInfo = $name;
+               } else {
+                       $this->mLBInfo[$name] = $value;
+               }
+       }
+
        /**#@+
         * Get function
         */
index a2eab9c..e395f98 100644 (file)
@@ -446,6 +446,12 @@ $wgSharedDB = null;
 #                   DBO_IGNORE -- ignore errors (not useful in LocalSettings.php)
 #                   DBO_NOBUFFER -- turn off buffering (not useful in LocalSettings.php)
 #
+#   max lag:     (optional) Maximum replication lag before a slave will taken out of rotation
+#   max threads: (optional) Maximum number of running threads
+#
+#   These and any other user-defined properties will be assigned to the mLBInfo member 
+#   variable of the Database object.
+#
 # Leave at false to use the single-server variables above
 $wgDBservers           = false;
 
index d07e23b..9623778 100644 (file)
@@ -54,6 +54,14 @@ class ExternalStoreDB {
                $lb =& $this->getLoadBalancer( $cluster );
                return $lb->getConnection( DB_MASTER );
        }               
+
+       function getTable( &$db ) {
+               $table = $db->getLBInfo( 'blobs table' );
+               if ( is_null( $table ) ) {
+                       $table = 'blobs';
+               }
+               return $table;
+       }
        
        function fetchFromURL($url) {
                global $wgExternalServers;
@@ -95,7 +103,7 @@ class ExternalStoreDB {
                wfDebug( "ExternalStoreDB::fetchBlob cache miss on $cacheID\n" );
                
                $dbr =& $this->getSlave( $cluster );
-               $ret = $dbr->selectField( 'blobs', 'blob_text', array( 'blob_id' => $id ) );
+               $ret = $dbr->selectField( $this->getTable( $dbr ), 'blob_text', array( 'blob_id' => $id ) );
                if( $itemID !== false ) {
                        // Unserialise object; caller extracts item
                        $ret = unserialize( $ret );
@@ -119,7 +127,7 @@ class ExternalStoreDB {
                $dbw =& $this->getMaster( $cluster );
 
                $id = $dbw->nextSequenceValue( 'blob_blob_id_seq' );
-               $dbw->insert( 'blobs', array( 'blob_id' => $id, 'blob_text' => $data ), $fname );
+               $dbw->insert( $this->getTable( $dbw ), array( 'blob_id' => $id, 'blob_text' => $data ), $fname );
                return "DB://$cluster/" . $dbw->insertId();
        }
 }
index aaa4d83..edc1fad 100644 (file)
@@ -438,7 +438,9 @@ class LoadBalancer {
                }
 
                # Create object
-               return new $class( $host, $user, $password, $dbname, 1, $flags );
+               $db = new $class( $host, $user, $password, $dbname, 1, $flags );
+               $db->setLBInfo( $server );
+               return $db;
        }
 
        function reportConnectionError( &$conn )