Ability to set the blobs table name for any server in an external cluster. This would allow, for example, the merging of all external storage for a large wikipedia dump into a single database, with "clusters" distinguished by table name.
This commit is contained in:
parent
baf7fdc2d2
commit
af47b8260c
5 changed files with 44 additions and 3 deletions
|
|
@ -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 ===
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
Loading…
Reference in a new issue