r66883 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66882‎ | r66883 | r66884 >
Date:17:56, 25 May 2010
Author:maxsem
Status:deferred
Tags:
Comment:
Cassie: add support for multi-server configurations
Modified paths:
  • /trunk/extensions/Cassandra/Cassandra.php (modified) (history)
  • /trunk/extensions/Cassandra/Cassandra_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Cassandra/Cassandra_body.php
@@ -81,10 +81,17 @@
8282 }
8383
8484 private function connect( $cluster ) {
85 - global $wgCassandraPort;
 85+ global $wgCassandraPort, $wgCassandraClusters;
8686
8787 $cluster = str_replace( 'cassandra://', '', $cluster );
88 - list( $host, $this->keyspace ) = explode( '/', $cluster );
 88+ list( $cluster, $this->keyspace ) = explode( '/', $cluster );
 89+
 90+ if ( isset( $wgCassandraClusters[$cluster] ) ) {
 91+ $hosts = $wgCassandraClusters[$cluster];
 92+ $host = $hosts[mt_rand( 0, count( $hosts ) - 1 )];
 93+ } else {
 94+ $host = $cluster;
 95+ }
8996
9097 try {
9198 $this->socket = new TSocket( $host, $wgCassandraPort );
Index: trunk/extensions/Cassandra/Cassandra.php
@@ -36,6 +36,14 @@
3737 // in Cassandra's storage-conf.xml
3838 $wgCassandraPort = 9160;
3939
 40+// Mapping of cluster names to lists of server IPs
 41+// Example:
 42+// $wgCassandraClusters = array(
 43+// 'foo' => array( '192.168.1.1', '192.168.1.2', ),
 44+// 'bar' => array( 'somehostname' ),
 45+// );
 46+$wgCassandraClusters = array();
 47+
4048 // String prepended to saved key names, can be used to distinct between
4149 // different wikis, etc. Does not affect the already saved revisions.
4250 $wgCassandraKeyPrefix = $wgDBname;

Status & tagging log