Class TenantRepository
java.lang.Object
com.yahoo.vespa.config.server.tenant.TenantRepository
This component will monitor the set of tenants in the config server by watching in ZooKeeper.
It will set up Tenant objects accordingly, which will manage the config sessions per tenant.
This class will read the preexisting set of tenants from ZooKeeper at startup. (For now it will also
create a default tenant since that will be used for APIs that do no know about tenants or have not yet
implemented support for it).
This instance is called from two different threads, the http handler threads and the zookeeper watcher threads.
To create or delete a tenant, the handler calls
addTenant(com.yahoo.config.provision.TenantName)
and deleteTenant(com.yahoo.config.provision.TenantName)
methods.
This will delete shared state from zookeeper, and return, so it does not mean a tenant is immediately deleted.
Once a tenant is deleted from zookeeper, the zookeeper watcher thread will get notified on all config servers, and
shutdown and delete any per-configserver state.- Author:
- Vegard Havdal, Ulf Lilleengen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.yahoo.config.provision.TenantName
-
Constructor Summary
ConstructorsConstructorDescriptionTenantRepository
(HostRegistry hostRegistry, com.yahoo.vespa.curator.Curator curator, Metrics metrics, com.yahoo.concurrent.StripedExecutor<com.yahoo.config.provision.TenantName> zkApplicationWatcherExecutor, com.yahoo.concurrent.StripedExecutor<com.yahoo.config.provision.TenantName> zkSessionWatcherExecutor, FileDistributionFactory fileDistributionFactory, com.yahoo.vespa.flags.FlagSource flagSource, ExecutorService zkCacheExecutor, com.yahoo.container.jdisc.secretstore.SecretStore secretStore, HostProvisionerProvider hostProvisionerProvider, com.yahoo.cloud.config.ConfigserverConfig configserverConfig, ConfigServerDB configServerDB, com.yahoo.config.provision.Zone zone, Clock clock, ModelFactoryRegistry modelFactoryRegistry, com.yahoo.config.model.api.ConfigDefinitionRepo configDefinitionRepo, ConfigActivationListener configActivationListener, TenantListener tenantListener, com.yahoo.cloud.config.ZookeeperServerConfig zookeeperServerConfig, com.yahoo.config.model.api.OnnxModelCost onnxModelCost, List<com.yahoo.config.model.api.EndpointCertificateSecretStore> endpointCertificateSecretStores) TenantRepository
(HostRegistry hostRegistry, com.yahoo.vespa.curator.Curator curator, Metrics metrics, com.yahoo.vespa.flags.FlagSource flagSource, com.yahoo.container.jdisc.secretstore.SecretStore secretStore, HostProvisionerProvider hostProvisionerProvider, com.yahoo.cloud.config.ConfigserverConfig configserverConfig, ConfigServerDB configServerDB, com.yahoo.config.provision.Zone zone, ModelFactoryRegistry modelFactoryRegistry, com.yahoo.config.model.api.ConfigDefinitionRepo configDefinitionRepo, ConfigActivationListener configActivationListener, TenantListener tenantListener, com.yahoo.cloud.config.ZookeeperServerConfig zookeeperServerConfig, FileDirectory fileDirectory, com.yahoo.config.model.api.OnnxModelCost onnxModelCost, com.yahoo.component.provider.ComponentRegistry<com.yahoo.config.model.api.EndpointCertificateSecretStore> endpointCertificateSecretStores) Creates a new tenant repository -
Method Summary
Modifier and TypeMethodDescriptionaddTenant
(com.yahoo.config.provision.TenantName tenantName) protected void
bootstrapTenant
(com.yahoo.config.provision.TenantName tenantName) boolean
checkThatTenantExists
(com.yahoo.config.provision.TenantName tenant) void
close()
void
createAndWriteTenantMetaData
(Tenant tenant) com.yahoo.transaction.Transaction
createWriteTenantMetaDataTransaction
(TenantMetaData tenantMetaData) Returns a default (compatibility with single tenant config requests) tenantvoid
deleteTenant
(com.yahoo.config.provision.TenantName name) Removes the given tenant from ZooKeeper and filesystem.Set<com.yahoo.config.provision.TenantName>
static com.yahoo.path.Path
getApplicationsPath
(com.yahoo.config.provision.TenantName tenantName) Gets zookeeper path for application data for a tenantstatic com.yahoo.path.Path
com.yahoo.vespa.curator.Curator
static com.yahoo.path.Path
getLocksPath
(com.yahoo.config.provision.TenantName tenantName) Gets zookeeper path for locks for a tenant's applications.static com.yahoo.path.Path
getSessionsPath
(com.yahoo.config.provision.TenantName tenantName) Gets zookeeper path for session data for a tenantgetTenant
(com.yahoo.config.provision.TenantName tenantName) Returns the tenant with the given name, ornull
if this does not exist.getTenantMetaData
(Tenant tenant) static com.yahoo.path.Path
getTenantPath
(com.yahoo.config.provision.TenantName tenantName) Gets zookeeper path for tenant datastatic String
logPre
(com.yahoo.config.provision.ApplicationId app) A helper to format a log preamble for messages with a tenant and app idstatic String
logPre
(com.yahoo.config.provision.TenantName tenant) A helper to format a log preamble for messages with a tenantreadCreatedTimeFromZooKeeper
(com.yahoo.config.provision.TenantName tenantName)
-
Field Details
-
HOSTED_VESPA_TENANT
public static final com.yahoo.config.provision.TenantName HOSTED_VESPA_TENANT
-
-
Constructor Details
-
TenantRepository
@Inject public TenantRepository(HostRegistry hostRegistry, com.yahoo.vespa.curator.Curator curator, Metrics metrics, com.yahoo.vespa.flags.FlagSource flagSource, com.yahoo.container.jdisc.secretstore.SecretStore secretStore, HostProvisionerProvider hostProvisionerProvider, com.yahoo.cloud.config.ConfigserverConfig configserverConfig, ConfigServerDB configServerDB, com.yahoo.config.provision.Zone zone, ModelFactoryRegistry modelFactoryRegistry, com.yahoo.config.model.api.ConfigDefinitionRepo configDefinitionRepo, ConfigActivationListener configActivationListener, TenantListener tenantListener, com.yahoo.cloud.config.ZookeeperServerConfig zookeeperServerConfig, FileDirectory fileDirectory, com.yahoo.config.model.api.OnnxModelCost onnxModelCost, com.yahoo.component.provider.ComponentRegistry<com.yahoo.config.model.api.EndpointCertificateSecretStore> endpointCertificateSecretStores) Creates a new tenant repository -
TenantRepository
public TenantRepository(HostRegistry hostRegistry, com.yahoo.vespa.curator.Curator curator, Metrics metrics, com.yahoo.concurrent.StripedExecutor<com.yahoo.config.provision.TenantName> zkApplicationWatcherExecutor, com.yahoo.concurrent.StripedExecutor<com.yahoo.config.provision.TenantName> zkSessionWatcherExecutor, FileDistributionFactory fileDistributionFactory, com.yahoo.vespa.flags.FlagSource flagSource, ExecutorService zkCacheExecutor, com.yahoo.container.jdisc.secretstore.SecretStore secretStore, HostProvisionerProvider hostProvisionerProvider, com.yahoo.cloud.config.ConfigserverConfig configserverConfig, ConfigServerDB configServerDB, com.yahoo.config.provision.Zone zone, Clock clock, ModelFactoryRegistry modelFactoryRegistry, com.yahoo.config.model.api.ConfigDefinitionRepo configDefinitionRepo, ConfigActivationListener configActivationListener, TenantListener tenantListener, com.yahoo.cloud.config.ZookeeperServerConfig zookeeperServerConfig, com.yahoo.config.model.api.OnnxModelCost onnxModelCost, List<com.yahoo.config.model.api.EndpointCertificateSecretStore> endpointCertificateSecretStores)
-
-
Method Details
-
addTenant
-
createAndWriteTenantMetaData
-
createWriteTenantMetaDataTransaction
public com.yahoo.transaction.Transaction createWriteTenantMetaDataTransaction(TenantMetaData tenantMetaData) -
getTenantMetaData
-
bootstrapTenant
protected void bootstrapTenant(com.yahoo.config.provision.TenantName tenantName) -
readCreatedTimeFromZooKeeper
-
defaultTenant
Returns a default (compatibility with single tenant config requests) tenant- Returns:
- default tenant
-
deleteTenant
public void deleteTenant(com.yahoo.config.provision.TenantName name) Removes the given tenant from ZooKeeper and filesystem. Assumes that tenant exists.- Parameters:
name
- name of the tenant
-
logPre
A helper to format a log preamble for messages with a tenant and app id- Parameters:
app
- the app- Returns:
- the log string
-
logPre
A helper to format a log preamble for messages with a tenant- Parameters:
tenant
- tenant- Returns:
- the log string
-
close
public void close() -
checkThatTenantExists
public boolean checkThatTenantExists(com.yahoo.config.provision.TenantName tenant) -
getTenant
Returns the tenant with the given name, ornull
if this does not exist. -
getAllTenantNames
-
getAllTenants
-
getTenantPath
public static com.yahoo.path.Path getTenantPath(com.yahoo.config.provision.TenantName tenantName) Gets zookeeper path for tenant data- Parameters:
tenantName
- tenant name- Returns:
- a
Path
to the zookeeper data for a tenant
-
getSessionsPath
public static com.yahoo.path.Path getSessionsPath(com.yahoo.config.provision.TenantName tenantName) Gets zookeeper path for session data for a tenant- Parameters:
tenantName
- tenant name- Returns:
- a
Path
to the zookeeper sessions data for a tenant
-
getApplicationsPath
public static com.yahoo.path.Path getApplicationsPath(com.yahoo.config.provision.TenantName tenantName) Gets zookeeper path for application data for a tenant- Parameters:
tenantName
- tenant name- Returns:
- a
Path
to the zookeeper application data for a tenant
-
getLocksPath
public static com.yahoo.path.Path getLocksPath(com.yahoo.config.provision.TenantName tenantName) Gets zookeeper path for locks for a tenant's applications. This is never cleaned, but shouldn't be a problem. -
getBarriersPath
public static com.yahoo.path.Path getBarriersPath() -
getCurator
public com.yahoo.vespa.curator.Curator getCurator() -
hostProvisionerProvider
-