27 return 'external-domains';
32 return [
'services' ];
37 $status = $this->createVirtualDomains();
38 $status->merge( $this->createExternalStoreDomains() );
47 private function createVirtualDomains():
Status {
48 $status =
Status::newGood();
50 foreach ( $virtualDomains as $virtualDomain ) {
51 if ( !$this->shouldDoShared()
52 && $this->lbFactory->isSharedVirtualDomain( $virtualDomain )
54 $status->warning(
'config-skip-shared-domain', $virtualDomain );
58 if ( $this->lbFactory->isLocalDomain( $virtualDomain ) ) {
62 $lb = $this->lbFactory->getLoadBalancer( $virtualDomain );
63 $realDomainId = $this->lbFactory->getMappedDomain( $virtualDomain );
64 $status->merge( $this->maybeCreateDomain( $lb, $realDomainId ) );
70 private function createExternalStoreDomains(): Status {
71 $status = Status::newGood();
72 $localDomainId = $this->lbFactory->getLocalDomainID();
73 foreach ( $this->esFactory->getWriteBaseUrls() as
$url ) {
74 $store = $this->esFactory->getStoreForUrl(
$url );
75 if ( $store instanceof ExternalStoreDB ) {
76 $cluster = $store->getClusterForUrl(
$url );
77 if ( $cluster ===
null ) {
78 throw new \RuntimeException(
"Invalid store url \"$url\"" );
80 $lb = $this->lbFactory->getExternalLB( $cluster );
81 $domainId = $store->getDomainIdForCluster( $cluster );
82 if ( $domainId !==
false && $domainId !== $localDomainId && !$this->shouldDoShared() ) {
84 $status->warning(
'config-skip-shared-domain',
"$cluster/$domainId" );
87 $status->merge( $this->maybeCreateDomain( $lb, $domainId ) );
89 $conn = $lb->getMaintenanceConnectionRef(
DB_PRIMARY, [], $domainId );
90 $conn->setSchemaVars( $this->
getContext()->getSchemaVars() );
91 if ( !$conn->tableExists( $store->getTable( $cluster ), __METHOD__ ) ) {
92 $store->initializeTable( $cluster );
109 private function maybeCreateDomain( $lb, $domainId ) {
110 $databaseCreator = $this->getDatabaseCreator();
111 if ( $domainId ===
false ) {
112 $domainId = $this->lbFactory->getLocalDomainID();
114 $database = DatabaseDomain::newFromId( $domainId )->getDatabase();
115 if ( !$databaseCreator->existsInLoadBalancer( $lb, $database ) ) {
116 return $databaseCreator->createInLoadBalancer( $lb, $database );
118 return Status::newGood();
126 private function shouldDoShared() {
127 return (
bool)$this->getOption(
'Shared' );