MediaWiki
REL1_39
ILoadBalancer.php
Go to the documentation of this file.
1
<?php
20
namespace
Wikimedia\Rdbms
;
21
77
interface
ILoadBalancer
{
79
public
const
DB_REPLICA
= -1;
84
public
const
DB_PRIMARY
= -2;
85
86
// phpcs:disable MediaWiki.Usage.DeprecatedConstantUsage.DB_MASTER
91
public
const
DB_MASTER
=
self::DB_PRIMARY
;
92
// phpcs:enable MediaWiki.Usage.DeprecatedConstantUsage.DB_MASTER
93
95
public
const
DOMAIN_ANY
=
''
;
97
public
const
GROUP_GENERIC
=
''
;
98
100
public
const
CONN_TRX_AUTOCOMMIT
= 1;
102
public
const
CONN_SILENCE_ERRORS
= 2;
104
public
const
CONN_INTENT_WRITABLE
= 4;
106
public
const
CONN_REFRESH_READ_ONLY
= 8;
107
122
public
function
getClusterName
(): string;
123
131
public
function
getLocalDomainID
(): string;
132
138
public
function
resolveDomainID
( $domain ): string;
139
146
public
function
redefineLocalDomain
( $domain );
147
158
public
function
setTempTablesOnlyMode
( $value, $domain );
159
174
public
function
getReaderIndex
( $group =
false
, $domain =
false
);
175
189
public
function
waitFor
( $pos );
190
201
public
function
waitForAll
( $pos, $timeout =
null
);
202
217
public
function
getAnyOpenConnection
( $i, $flags = 0 );
218
269
public
function
getConnection
( $i, $groups = [], $domain =
false
, $flags = 0 );
270
291
public
function
getServerConnection
( $i, $domain, $flags = 0 );
292
297
public
function
reuseConnection
(
IDatabase
$conn );
298
303
public
function
reuseConnectionInternal
(
IDatabase
$conn );
304
313
public
function
getConnectionRef
( $i, $groups = [], $domain =
false
, $flags = 0 ):
IDatabase
;
314
323
public
function
getConnectionInternal
( $i, $groups = [], $domain =
false
, $flags = 0 ):
IDatabase
;
324
341
public
function
getLazyConnectionRef
( $i, $groups = [], $domain =
false
, $flags = 0 ):
IDatabase
;
342
361
public
function
getMaintenanceConnectionRef
( $i, $groups = [], $domain =
false
, $flags = 0 ):
DBConnRef
;
362
368
public
function
getWriterIndex
();
369
375
public
function
getServerCount
();
376
386
public
function
hasReplicaServers
();
387
407
public
function
hasStreamingReplicaServers
();
408
415
public
function
getServerName
( $i ): string;
416
424
public
function
getServerInfo
( $i );
425
433
public
function
getServerType
( $i );
434
442
public
function
getServerAttributes
( $i );
443
451
public
function
getPrimaryPos
();
452
468
public
function
getReplicaResumePos
();
469
478
public
function
closeConnection
(
IDatabase
$conn );
479
484
public
function
hasPrimaryConnection
();
485
491
public
function
hasPrimaryChanges
();
492
499
public
function
explicitTrxActive
();
500
506
public
function
lastPrimaryChangeTimestamp
();
507
516
public
function
hasOrMadeRecentPrimaryChanges
( $age =
null
);
517
523
public
function
getLaggedReplicaMode
( $domain =
false
);
524
533
public
function
laggedReplicaUsed
();
534
540
public
function
getReadOnlyReason
( $domain =
false
);
541
545
public
function
pingAll
();
546
557
public
function
getMaxLag
( $domain =
false
);
558
569
public
function
getLagTimes
( $domain =
false
);
570
584
public
function
waitForPrimaryPos
(
IDatabase
$conn, $pos =
false
, $timeout = 10 );
585
593
public
function
setTransactionListener
( $name, callable $callback =
null
);
594
607
public
function
setTableAliases
( array $aliases );
608
621
public
function
setIndexAliases
( array $aliases );
622
631
public
function
setDomainAliases
( array $aliases );
632
}
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\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition
IDatabase.php:39
Wikimedia\Rdbms\ILoadBalancer
Create and track the database connections and transactions for a given database cluster.
Definition
ILoadBalancer.php:77
Wikimedia\Rdbms\ILoadBalancer\getClusterName
getClusterName()
Get the logical name of the database cluster.
Wikimedia\Rdbms\ILoadBalancer\reuseConnection
reuseConnection(IDatabase $conn)
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:104
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\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:97
Wikimedia\Rdbms\ILoadBalancer\getMaxLag
getMaxLag( $domain=false)
Get the name and lag time of the most-lagged replica server.
Wikimedia\Rdbms\ILoadBalancer\waitFor
waitFor( $pos)
Set the primary position to reach before the next generic group DB query.
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\reuseConnectionInternal
reuseConnectionInternal(IDatabase $conn)
Wikimedia\Rdbms\ILoadBalancer\getReaderIndex
getReaderIndex( $group=false, $domain=false)
Get the specific server index of the reader connection for a given group.
Wikimedia\Rdbms\ILoadBalancer\waitForPrimaryPos
waitForPrimaryPos(IDatabase $conn, $pos=false, $timeout=10)
Wait for a replica DB to reach a specified primary position.
Wikimedia\Rdbms\ILoadBalancer\getLaggedReplicaMode
getLaggedReplicaMode( $domain=false)
Wikimedia\Rdbms\ILoadBalancer\DOMAIN_ANY
const DOMAIN_ANY
Domain specifier when no specific database needs to be selected.
Definition
ILoadBalancer.php:95
Wikimedia\Rdbms\ILoadBalancer\DB_REPLICA
const DB_REPLICA
Request a replica DB connection.
Definition
ILoadBalancer.php:79
Wikimedia\Rdbms\ILoadBalancer\CONN_TRX_AUTOCOMMIT
const CONN_TRX_AUTOCOMMIT
DB handle should have DBO_TRX disabled and the caller will leave it as such.
Definition
ILoadBalancer.php:100
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
Return null on connection failure instead of throwing an exception.
Definition
ILoadBalancer.php:102
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 primary server.
Wikimedia\Rdbms\ILoadBalancer\setDomainAliases
setDomainAliases(array $aliases)
Convert certain database domains to alternative ones.
Wikimedia\Rdbms\ILoadBalancer\laggedReplicaUsed
laggedReplicaUsed()
Checks whether the database for generic connections this request was both:
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\CONN_REFRESH_READ_ONLY
const CONN_REFRESH_READ_ONLY
Bypass and update any server-side read-only mode state cache.
Definition
ILoadBalancer.php:106
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\getLazyConnectionRef
getLazyConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Get a lazy-connecting database handle for a server index.
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:91
Wikimedia\Rdbms\ILoadBalancer\DB_PRIMARY
const DB_PRIMARY
Request a primary, write-enabled DB connection.
Definition
ILoadBalancer.php:84
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\getLagTimes
getLagTimes( $domain=false)
Get an estimate of replication lag (in seconds) for each server.
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\waitForAll
waitForAll( $pos, $timeout=null)
Set the primary wait position and wait for ALL replica DBs to catch up to it.
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 Fri Dec 20 2024 15:34:43 for MediaWiki by
1.10.0