+
+ /**
+ * Get the number of defined servers (not the number of open connections)
+ */
+ function getServerCount() {
+ return count( $this->mServers );
+ }
+
+ /**
+ * Save master pos to the session and to memcached, if the session exists
+ */
+ function saveMasterPos() {
+ global $wgSessionStarted;
+ if ( $wgSessionStarted && count( $this->mServers ) > 1 ) {
+ # If this entire request was served from a slave without opening a connection to the
+ # master (however unlikely that may be), then we can fetch the position from the slave.
+ if ( empty( $this->mConnections[0] ) ) {
+ $conn =& $this->getConnection( DB_SLAVE );
+ list( $file, $pos ) = $conn->getSlavePos();
+ wfDebug( "Saving master pos fetched from slave: $file $pos\n" );
+ } else {
+ $conn =& $this->getConnection( 0 );
+ list( $file, $pos ) = $conn->getMasterPos();
+ wfDebug( "Saving master pos: $file $pos\n" );
+ }
+ if ( $file !== false ) {
+ $_SESSION['master_log_file'] = $file;
+ $_SESSION['master_pos'] = $pos;
+ }
+ }
+ }
+
+ /**
+ * Loads the master pos from the session, waits for it if necessary
+ */
+ function loadMasterPos() {
+ if ( isset( $_SESSION['master_log_file'] ) && isset( $_SESSION['master_pos'] ) ) {
+ $this->waitFor( $_SESSION['master_log_file'], $_SESSION['master_pos'] );
+ }
+ }
+
+ /**
+ * Close all open connections
+ */
+ function closeAll() {
+ foreach( $this->mConnections as $i => $conn ) {
+ if ( $this->isOpen( $i ) ) {
+ $conn->close();
+ }
+ }
+ }
+
+ function commitAll() {
+ foreach( $this->mConnections as $i => $conn ) {
+ if ( $this->isOpen( $i ) ) {
+ $conn->immediateCommit();
+ }
+ }
+ }
+
+ function waitTimeout( $value = NULL ) {
+ return wfSetVar( $this->mWaitTimeout, $value );
+ }
+
+ function getLaggedSlaveMode() {
+ return $this->mLaggedSlaveMode;
+ }