MediaWiki
REL1_40
ILoadBalancer.php
Go to the documentation of this file.
1
<?php
20
namespace
Wikimedia\Rdbms
;
21
113
interface
ILoadBalancer
{
115
public
const
DB_REPLICA
= -1;
120
public
const
DB_PRIMARY
= -2;
121
122
// phpcs:disable MediaWiki.Usage.DeprecatedConstantUsage.DB_MASTER
127
public
const
DB_MASTER
=
self::DB_PRIMARY
;
128
// phpcs:enable MediaWiki.Usage.DeprecatedConstantUsage.DB_MASTER
129
131
public
const
DOMAIN_ANY
=
''
;
133
public
const
GROUP_GENERIC
=
''
;
134
136
public
const
CONN_UNTRACKED_GAUGE
= 1;
138
public
const
CONN_TRX_AUTOCOMMIT
= 2;
140
public
const
CONN_SILENCE_ERRORS
= 4;
142
public
const
CONN_INTENT_WRITABLE
= 8;
144
public
const
CONN_REFRESH_READ_ONLY
= 16;
145
164
public
function
getClusterName
(): string;
165
173
public
function
getLocalDomainID
(): string;
174
180
public
function
resolveDomainID
( $domain ): string;
181
188
public
function
redefineLocalDomain
( $domain );
189
200
public
function
setTempTablesOnlyMode
( $value, $domain );
201
215
public
function
getReaderIndex
( $group =
false
);
216
230
public
function
waitFor
(
DBPrimaryPos
$pos );
231
242
public
function
waitForAll
(
DBPrimaryPos
$pos, $timeout =
null
);
243
258
public
function
getAnyOpenConnection
( $i, $flags = 0 );
259
305
public
function
getConnection
( $i, $groups = [], $domain =
false
, $flags = 0 );
306
327
public
function
getServerConnection
( $i, $domain, $flags = 0 );
328
333
public
function
reuseConnection
(
IDatabase
$conn );
334
343
public
function
getConnectionRef
( $i, $groups = [], $domain =
false
, $flags = 0 ):
IDatabase
;
344
353
public
function
getConnectionInternal
( $i, $groups = [], $domain =
false
, $flags = 0 ):
IDatabase
;
354
373
public
function
getMaintenanceConnectionRef
( $i, $groups = [], $domain =
false
, $flags = 0 ):
DBConnRef
;
374
386
public
function
getWriterIndex
();
387
393
public
function
getServerCount
();
394
407
public
function
hasReplicaServers
();
408
425
public
function
hasStreamingReplicaServers
();
426
433
public
function
getServerName
( $i ): string;
434
442
public
function
getServerInfo
( $i );
443
451
public
function
getServerType
( $i );
452
460
public
function
getServerAttributes
( $i );
461
469
public
function
getPrimaryPos
();
470
487
public
function
getReplicaResumePos
();
488
497
public
function
closeConnection
(
IDatabase
$conn );
498
503
public
function
hasPrimaryConnection
();
504
510
public
function
hasPrimaryChanges
();
511
518
public
function
explicitTrxActive
();
519
525
public
function
lastPrimaryChangeTimestamp
();
526
535
public
function
hasOrMadeRecentPrimaryChanges
( $age =
null
);
536
543
public
function
laggedReplicaUsed
();
544
550
public
function
getReadOnlyReason
( $domain =
false
);
551
555
public
function
pingAll
();
556
566
public
function
getMaxLag
();
567
577
public
function
getLagTimes
();
578
590
public
function
waitForPrimaryPos
(
IDatabase
$conn );
591
599
public
function
setTransactionListener
( $name, callable $callback =
null
);
600
613
public
function
setTableAliases
( array $aliases );
614
627
public
function
setIndexAliases
( array $aliases );
628
637
public
function
setDomainAliases
( array $aliases );
638
}
Wikimedia\Rdbms\DBConnRef
Helper class used for automatically marking an IDatabase connection as reusable (once it no longer ma...
Definition
DBConnRef.php:29
Wikimedia\Rdbms\DBPrimaryPos
An object representing a primary or replica DB position in a replicated setup.
Definition
DBPrimaryPos.php:13
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition
IDatabase.php:36
Wikimedia\Rdbms\ILoadBalancer
This class is a delegate to ILBFactory for a given database cluster.
Definition
ILoadBalancer.php:113
Wikimedia\Rdbms\ILoadBalancer\getClusterName
getClusterName()
Get the name of the overall cluster of database servers managing the dataset.
Wikimedia\Rdbms\ILoadBalancer\reuseConnection
reuseConnection(IDatabase $conn)
Wikimedia\Rdbms\ILoadBalancer\getMaxLag
getMaxLag()
Get the name and lag time of the most-lagged replica server.
Wikimedia\Rdbms\ILoadBalancer\CONN_UNTRACKED_GAUGE
const CONN_UNTRACKED_GAUGE
Yield an untracked, low-timeout, autocommit-mode handle (to gauge server health)
Definition
ILoadBalancer.php:136
Wikimedia\Rdbms\ILoadBalancer\getConnection
getConnection( $i, $groups=[], $domain=false, $flags=0)
Get a lazy-connecting database handle for a specific or virtual (DB_PRIMARY/DB_REPLICA) server index.
Wikimedia\Rdbms\ILoadBalancer\CONN_INTENT_WRITABLE
const CONN_INTENT_WRITABLE
Caller is requesting the primary DB server for possibly writes.
Definition
ILoadBalancer.php:142
Wikimedia\Rdbms\ILoadBalancer\hasOrMadeRecentPrimaryChanges
hasOrMadeRecentPrimaryChanges( $age=null)
Check if this load balancer object had any recent or still pending writes issued against it by this P...
Wikimedia\Rdbms\ILoadBalancer\getLagTimes
getLagTimes()
Get an estimate of replication lag (in seconds) for each server.
Wikimedia\Rdbms\ILoadBalancer\getServerType
getServerType( $i)
Get the RDBMS type of the server with the specified index (e.g.
Wikimedia\Rdbms\ILoadBalancer\GROUP_GENERIC
const GROUP_GENERIC
The generic query group.
Definition
ILoadBalancer.php:133
Wikimedia\Rdbms\ILoadBalancer\getServerConnection
getServerConnection( $i, $domain, $flags=0)
Get a DB handle for a specific server index.
Wikimedia\Rdbms\ILoadBalancer\getReadOnlyReason
getReadOnlyReason( $domain=false)
Wikimedia\Rdbms\ILoadBalancer\getReplicaResumePos
getReplicaResumePos()
Get the highest DB replication position for chronology control purposes.
Wikimedia\Rdbms\ILoadBalancer\setTransactionListener
setTransactionListener( $name, callable $callback=null)
Set a callback via IDatabase::setTransactionListener() on all current and future primary connections ...
Wikimedia\Rdbms\ILoadBalancer\getReaderIndex
getReaderIndex( $group=false)
Get the specific server index of the reader connection for a given group.
Wikimedia\Rdbms\ILoadBalancer\waitForAll
waitForAll(DBPrimaryPos $pos, $timeout=null)
Set the primary wait position and wait for ALL replica DBs to catch up to it.
Wikimedia\Rdbms\ILoadBalancer\DOMAIN_ANY
const DOMAIN_ANY
Domain specifier when no specific database needs to be selected.
Definition
ILoadBalancer.php:131
Wikimedia\Rdbms\ILoadBalancer\DB_REPLICA
const DB_REPLICA
Request a replica DB connection.
Definition
ILoadBalancer.php:115
Wikimedia\Rdbms\ILoadBalancer\CONN_TRX_AUTOCOMMIT
const CONN_TRX_AUTOCOMMIT
Yield a tracked autocommit-mode handle (reuse existing ones)
Definition
ILoadBalancer.php:138
Wikimedia\Rdbms\ILoadBalancer\setTableAliases
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
Wikimedia\Rdbms\ILoadBalancer\redefineLocalDomain
redefineLocalDomain( $domain)
Close all connection and redefine the local domain for testing or schema creation.
Wikimedia\Rdbms\ILoadBalancer\CONN_SILENCE_ERRORS
const CONN_SILENCE_ERRORS
Yield null on connection failure instead of throwing an exception.
Definition
ILoadBalancer.php:140
Wikimedia\Rdbms\ILoadBalancer\setTempTablesOnlyMode
setTempTablesOnlyMode( $value, $domain)
Indicate whether the tables on this domain are only temporary tables for testing.
Wikimedia\Rdbms\ILoadBalancer\resolveDomainID
resolveDomainID( $domain)
Wikimedia\Rdbms\ILoadBalancer\getWriterIndex
getWriterIndex()
Get the specific server index of the "writer server".
Wikimedia\Rdbms\ILoadBalancer\setDomainAliases
setDomainAliases(array $aliases)
Convert certain database domains to alternative ones.
Wikimedia\Rdbms\ILoadBalancer\waitFor
waitFor(DBPrimaryPos $pos)
Set the primary position to reach before the next generic group DB query.
Wikimedia\Rdbms\ILoadBalancer\laggedReplicaUsed
laggedReplicaUsed()
Whether a highly "lagged" replica database connection was queried.
Wikimedia\Rdbms\ILoadBalancer\getServerCount
getServerCount()
Get the number of servers defined in configuration.
Wikimedia\Rdbms\ILoadBalancer\getLocalDomainID
getLocalDomainID()
Get the local (and default) database domain ID of connection handles.
Wikimedia\Rdbms\ILoadBalancer\getServerInfo
getServerInfo( $i)
Return the server configuration map for the server with the specified index.
Wikimedia\Rdbms\ILoadBalancer\waitForPrimaryPos
waitForPrimaryPos(IDatabase $conn)
Wait for a replica DB to reach a specified primary position.
Wikimedia\Rdbms\ILoadBalancer\CONN_REFRESH_READ_ONLY
const CONN_REFRESH_READ_ONLY
Bypass and update any server-side read-only mode state cache.
Definition
ILoadBalancer.php:144
Wikimedia\Rdbms\ILoadBalancer\getConnectionRef
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Wikimedia\Rdbms\ILoadBalancer\hasPrimaryChanges
hasPrimaryChanges()
Whether there are pending changes or callbacks in a transaction by this thread.
Wikimedia\Rdbms\ILoadBalancer\getPrimaryPos
getPrimaryPos()
Get the current primary replication position.
Wikimedia\Rdbms\ILoadBalancer\getMaintenanceConnectionRef
getMaintenanceConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Get a DB handle, suitable for migrations and schema changes, for a server index.
Wikimedia\Rdbms\ILoadBalancer\setIndexAliases
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
Wikimedia\Rdbms\ILoadBalancer\explicitTrxActive
explicitTrxActive()
Determine whether an explicit transaction is active on any open primary connection.
Wikimedia\Rdbms\ILoadBalancer\hasPrimaryConnection
hasPrimaryConnection()
Wikimedia\Rdbms\ILoadBalancer\lastPrimaryChangeTimestamp
lastPrimaryChangeTimestamp()
Get the timestamp of the latest write query done by this thread.
Wikimedia\Rdbms\ILoadBalancer\DB_MASTER
const DB_MASTER
Request a primary, write-enabled DB connection.
Definition
ILoadBalancer.php:127
Wikimedia\Rdbms\ILoadBalancer\DB_PRIMARY
const DB_PRIMARY
Request a primary, write-enabled DB connection.
Definition
ILoadBalancer.php:120
Wikimedia\Rdbms\ILoadBalancer\closeConnection
closeConnection(IDatabase $conn)
Close a connection.
Wikimedia\Rdbms\ILoadBalancer\getConnectionInternal
getConnectionInternal( $i, $groups=[], $domain=false, $flags=0)
Wikimedia\Rdbms\ILoadBalancer\hasReplicaServers
hasReplicaServers()
Whether there are any replica servers configured.
Wikimedia\Rdbms\ILoadBalancer\hasStreamingReplicaServers
hasStreamingReplicaServers()
Whether any replica servers use streaming replication from the primary server.
Wikimedia\Rdbms\ILoadBalancer\pingAll
pingAll()
Wikimedia\Rdbms\ILoadBalancer\getServerName
getServerName( $i)
Get the readable name of the server with the specified index.
Wikimedia\Rdbms\ILoadBalancer\getServerAttributes
getServerAttributes( $i)
Get basic attributes of the server with the specified index without connecting.
Wikimedia\Rdbms\ILoadBalancer\getAnyOpenConnection
getAnyOpenConnection( $i, $flags=0)
Get an existing DB handle to the given server index (on any domain)
Wikimedia\Rdbms
Definition
ChronologyProtector.php:20
includes
libs
rdbms
loadbalancer
ILoadBalancer.php
Generated on Thu Jun 27 2024 14:03:17 for MediaWiki by
1.10.0