public class TenantProvisionerService extends Object
Modifier and Type | Method and Description |
---|---|
void |
bootstrapTenant(String tenantId) |
void |
deleteProvisioner(String provisionerId)
Delete the given provisioner, queueing a job to reassign its workers to different provisioners.
|
void |
deleteTenantByName(String name)
Delete the given tenant.
|
Collection<Provisioner> |
getAllProvisioners()
Get an immutable collection of all provisioners for external display, with tenant ids mapped to tenant names.
|
Collection<TenantSpecification> |
getAllTenantSpecifications()
Get an unmodifiable collection of all tenant specifications.
|
Provisioner |
getProvisioner(String provisionerId)
Get the provisioner for the given id for external display, with tenant ids mapped to tenant names,
or null if none exists.
|
TenantSpecification |
getTenantSpecification(String name)
Get a tenant specification by tenant name.
|
void |
handleHeartbeat(String provisionerId,
ProvisionerHeartbeat heartbeat)
Handle the heartbeat of a provisioner, updating the last heartbeat time of the provisioner and updating the number
of live workers running on the provisioner for each tenant it is responsible for.
|
void |
rebalanceTenantWorkers(String tenantId)
Rebalance workers for the tenant across the provisioners.
|
boolean |
satisfiesTenantQuotas(String tenantId,
int additionalClusters,
int additionalNodes)
Verify that tenant cluster and node quotas would not be exceeded if the given number of additional clusters and
nodes would be added.
|
boolean |
satisfiesTenantQuotas(Tenant tenant,
int additionalClusters,
int additionalNodes)
Verify that tenant cluster and node quotas would not be exceeded if the given number of additional clusters and
nodes would be added.
|
void |
syncResources(Account account)
Get a snapshot of what plugin resources are slated to be active on the provisioners that are running workers
for the given account, and push those resources to the provisioners.
|
void |
timeoutProvisioners(long timeoutTs)
Delete and reassign workers for provisioners that have not sent a heartbeat since the given timestamp in
milliseconds.
|
void |
writeProvisioner(Provisioner provisioner)
Write a provisioner, and queue jobs to rebalance workers for all tenants in the system.
|
String |
writeTenantSpecification(TenantSpecification tenantSpecification)
Write the tenant to the store and balance the tenant workers across provisioners.
|
public Collection<TenantSpecification> getAllTenantSpecifications() throws IOException
IOException
public TenantSpecification getTenantSpecification(String name) throws IOException
name
- Name of the tenant to getIOException
public Collection<Provisioner> getAllProvisioners() throws IOException
IOException
public Provisioner getProvisioner(String provisionerId) throws IOException
provisionerId
- Id of the provisioner to getIOException
public String writeTenantSpecification(TenantSpecification tenantSpecification) throws IOException, CapacityException, QuotaException
tenantSpecification
- Tenant to writeIOException
- if there was an exception persisting the tenantCapacityException
- if there is not enough capacity to support all tenant workersQuotaException
- if a tenant quota would be violated by the changepublic boolean satisfiesTenantQuotas(String tenantId, int additionalClusters, int additionalNodes) throws IOException
tenantId
- Id of the tenant to verify quotas foradditionalClusters
- Number of clusters that would be addedadditionalNodes
- Number of nodes that would be addedIOException
public boolean satisfiesTenantQuotas(Tenant tenant, int additionalClusters, int additionalNodes) throws IOException
tenant
- Tenant to verify quotas foradditionalClusters
- Number of clusters that would be addedadditionalNodes
- Number of nodes that would be addedIOException
public void deleteTenantByName(String name) throws IllegalStateException, IOException
name
- Name of the tenant to deleteIllegalStateException
- if the tenant has one or more assigned workersIOException
- if there was an exception persisting the deletionpublic void deleteProvisioner(String provisionerId) throws IOException
provisionerId
- Id of the provisioner to deleteIOException
public void handleHeartbeat(String provisionerId, ProvisionerHeartbeat heartbeat) throws IOException, MissingEntityException
provisionerId
- Id of the provisioner that sent the heartbeatheartbeat
- The heartbeat containing live worker informationIOException
- if there was an exception persisting the dataMissingEntityException
- if there is no provisioner for the given idpublic void writeProvisioner(Provisioner provisioner) throws IOException
provisioner
- Provisioner to writeIOException
public void rebalanceTenantWorkers(String tenantId) throws IOException, CapacityException
tenantId
- Id of the tenant whose workers need to be rebalancedCapacityException
- if there is not enough capacity to rebalance tenant workersIOException
- if there was an exception persisting the worker rebalancepublic void syncResources(Account account) throws IOException
account
- Account to syncIOException
public void timeoutProvisioners(long timeoutTs) throws IOException
timeoutTs
- Timestamp in milliseconds to use as a cut off for deleting provisioners.IOException
public void bootstrapTenant(String tenantId) throws IOException, IllegalAccessException
IOException
IllegalAccessException
Copyright © 2013-2016 Cask Data, Inc. Licensed under the Apache License, Version 2.0.