Class CpcTenantLifecycleManager

java.lang.Object
io.confluent.kafka.cpc.multitenant.CpcTenantLifecycleManager

public class CpcTenantLifecycleManager extends Object
Manages the lifecycle of CPC tenants. A tenant's deletion date is the time at which it should be deleted: a tenant with no deletion date is active, a tenant whose deletion date is in the future is deactivated (but not yet deleted), and once the deletion date has passed the manager orchestrates resource cleanup (topics, ACLs, transactions).

State machine:

  ACTIVE → DEACTIVATED → DELETE_IN_PROGRESS → DELETED
             ↑              (deletion date reached)
             └── reactivation (deletion date removed)
  • Constructor Details

    • CpcTenantLifecycleManager

      public CpcTenantLifecycleManager(int deleteBatchSize, org.apache.kafka.common.utils.Time time)
  • Method Details

    • setAdminSupplierAndCreateClient

      public void setAdminSupplierAndCreateClient(Function<String, org.apache.kafka.clients.admin.Admin> adminClientSupplier)
      Sets the admin client supplier and attempts to create the admin client. Safe to call again later to retry creation.
    • createAdminClient

      public void createAdminClient()
      Tries to create the admin client via the configured supplier. No-op if already created; logs and silently fails if the supplier throws — caller is expected to retry.
    • updateTenantState

      public void updateTenantState(io.confluent.kafka.cpc.multitenant.CpcLogicalClusterMetadata lcm)
      Records the lifecycle state transition for a tenant based on its current metadata. Active tenants reset to ACTIVE; tenants with a deletion date transition to DEACTIVATED or DELETE_IN_PROGRESS depending on whether that deletion date is still in the future or has passed.
    • deleteTenants

      public void deleteTenants()
      Runs one pass of resource cleanup for all tenants currently in DELETE_IN_PROGRESS: aborts transactions, deletes topics, deletes ACLs. Tenants whose topics and ACLs are confirmed gone transition to DELETED. Designed to be called repeatedly on a fixed interval.
    • isClusterActive

      public boolean isClusterActive(String lcId)
      Returns true if the given tenant is tracked and in ACTIVE state. Unknown tenants return false.
    • deactivatedClusters

      public Set<String> deactivatedClusters()
      Returns the set of tenants currently in DEACTIVATED state.
    • deleteInProgressClusters

      public Set<String> deleteInProgressClusters()
      Returns the set of tenants currently in DELETE_IN_PROGRESS state.
    • fullyDeletedClusters

      public Set<String> fullyDeletedClusters()
      Returns the set of tenants currently in DELETED state.
    • close

      public void close()
      Shuts down the deletion executor and closes the admin client. Idempotent.