24 return 'external-domains';
28 return [
'VirtualDomains',
'services' ];
33 $status = $this->createVirtualDomains();
34 $status->merge( $this->createExternalStoreDomains() );
43 private function createVirtualDomains() {
44 $status = Status::newGood();
45 foreach ( $this->getVirtualDomains() as $virtualDomain ) {
46 if ( !$this->shouldDoShared()
47 && $this->lbFactory->isSharedVirtualDomain( $virtualDomain )
49 $status->warning(
'config-skip-shared-domain', $virtualDomain );
53 if ( $this->lbFactory->isLocalDomain( $virtualDomain ) ) {
57 $lb = $this->lbFactory->getLoadBalancer( $virtualDomain );
58 $realDomainId = $this->lbFactory->getMappedDomain( $virtualDomain );
59 $status->merge( $this->maybeCreateDomain( $lb, $realDomainId ) );
65 private function createExternalStoreDomains() {
66 $status = Status::newGood();
67 $localDomainId = $this->lbFactory->getLocalDomainID();
68 foreach ( $this->esFactory->getWriteBaseUrls() as
$url ) {
69 $store = $this->esFactory->getStoreForUrl(
$url );
71 $cluster = $store->getClusterForUrl(
$url );
72 if ( $cluster ===
null ) {
73 throw new \RuntimeException(
"Invalid store url \"$url\"" );
75 $lb = $this->lbFactory->getExternalLB( $cluster );
76 $domainId = $store->getDomainIdForCluster( $cluster );
77 if ( $domainId !==
false && $domainId !== $localDomainId && !$this->shouldDoShared() ) {
79 $status->warning(
'config-skip-shared-domain',
"$cluster/$domainId" );
82 $status->merge( $this->maybeCreateDomain( $lb, $domainId ) );
84 $conn = $lb->getMaintenanceConnectionRef(
DB_PRIMARY, [], $domainId );
85 $conn->setSchemaVars( $this->
getContext()->getSchemaVars() );
86 if ( !$conn->tableExists( $store->getTable( $cluster ) ) ) {
87 $store->initializeTable( $cluster );
104 private function maybeCreateDomain( $lb, $domainId ) {
105 $databaseCreator = $this->getDatabaseCreator();
106 if ( $domainId ===
false ) {
107 $domainId = $this->lbFactory->getLocalDomainID();
109 $database = DatabaseDomain::newFromId( $domainId )->getDatabase();
110 if ( !$databaseCreator->existsInLoadBalancer( $lb, $database ) ) {
111 return $databaseCreator->createInLoadBalancer( $lb, $database );
113 return Status::newGood();
121 private function shouldDoShared() {
122 return (
bool)$this->getOption(
'Shared' );