Index: trunk/extensions/Cassandra/Cassandra_body.php |
— | — | @@ -81,10 +81,17 @@ |
82 | 82 | } |
83 | 83 | |
84 | 84 | private function connect( $cluster ) { |
85 | | - global $wgCassandraPort; |
| 85 | + global $wgCassandraPort, $wgCassandraClusters; |
86 | 86 | |
87 | 87 | $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 | + } |
89 | 96 | |
90 | 97 | try { |
91 | 98 | $this->socket = new TSocket( $host, $wgCassandraPort ); |
Index: trunk/extensions/Cassandra/Cassandra.php |
— | — | @@ -36,6 +36,14 @@ |
37 | 37 | // in Cassandra's storage-conf.xml |
38 | 38 | $wgCassandraPort = 9160; |
39 | 39 | |
| 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 | + |
40 | 48 | // String prepended to saved key names, can be used to distinct between |
41 | 49 | // different wikis, etc. Does not affect the already saved revisions. |
42 | 50 | $wgCassandraKeyPrefix = $wgDBname; |