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 )
52 if ( $this->lbFactory->isLocalDomain( $virtualDomain ) ) {
56 $lb = $this->lbFactory->getLoadBalancer( $virtualDomain );
57 $realDomainId = $this->lbFactory->getMappedDomain( $virtualDomain );
58 $status->merge( $this->maybeCreateDomain( $lb, $realDomainId ) );
64 private function createExternalStoreDomains() {
65 $status = Status::newGood();
66 foreach ( $this->esFactory->getWriteBaseUrls() as
$url ) {
67 $store = $this->esFactory->getStoreForUrl(
$url );
69 $cluster = $store->getClusterForUrl(
$url );
70 if ( $cluster ===
null ) {
71 throw new \RuntimeException(
"Invalid store url \"$url\"" );
73 $lb = $this->lbFactory->getExternalLB( $cluster );
74 $domainId = $store->getDomainIdForCluster( $cluster );
75 if ( $domainId !==
false && !$this->shouldDoShared() ) {
79 $status->merge( $this->maybeCreateDomain( $lb, $domainId ) );
81 $conn = $lb->getMaintenanceConnectionRef(
DB_PRIMARY, [], $domainId );
82 $conn->setSchemaVars( $this->
getContext()->getSchemaVars() );
83 if ( !$conn->tableExists( $store->getTable( $cluster ) ) ) {
84 $store->initializeTable( $cluster );
101 private function maybeCreateDomain( $lb, $domainId ) {
102 $databaseCreator = $this->getDatabaseCreator();
103 if ( $domainId ===
false ) {
104 $domainId = $this->lbFactory->getLocalDomainID();
106 $database = DatabaseDomain::newFromId( $domainId )->getDatabase();
107 if ( !$databaseCreator->existsInLoadBalancer( $lb, $database ) ) {
108 return $databaseCreator->createInLoadBalancer( $lb, $database );
110 return Status::newGood();
118 private function shouldDoShared() {
119 return (
bool)$this->getOption(
'Shared' );