Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class NamespaceResources extends BaseResources<Policies> {

private static final String POLICIES_READONLY_FLAG_PATH = "/admin/flags/policies-readonly";
private static final String NAMESPACE_BASE_PATH = "/namespace";

private static final String BUNDLE_DATA_BASE_PATH = "/loadbalance/bundle-data";
public NamespaceResources(MetadataStore localStore, MetadataStore configurationStore, int operationTimeoutSec) {
super(configurationStore, Policies.class, operationTimeoutSec);
this.configurationStore = configurationStore;
Expand Down Expand Up @@ -281,4 +281,39 @@ public CompletableFuture<Void> clearPartitionedTopicMetadataAsync(NamespaceName
return completableFuture;
}
}


// clear resource of `/loadbalance/bundle-data/{tenant}/{namespace}/` for zk-node
public CompletableFuture<Void> deleteBundleDataAsync(NamespaceName ns) {
final String namespaceBundlePath = joinPath(BUNDLE_DATA_BASE_PATH, ns.toString());
CompletableFuture<Void> future = new CompletableFuture<Void>();
deleteRecursiveAsync(this, namespaceBundlePath).whenComplete((ignore, ex) -> {
if (ex instanceof MetadataStoreException.NotFoundException) {
future.complete(null);
} else if (ex != null) {
future.completeExceptionally(ex);
} else {
future.complete(null);
}
});

return future;
}

// clear resource of `/loadbalance/bundle-data/{tenant}/` for zk-node
public CompletableFuture<Void> deleteBundleDataTenantAsync(String tenant) {
final String tenantBundlePath = joinPath(BUNDLE_DATA_BASE_PATH, tenant);
CompletableFuture<Void> future = new CompletableFuture<Void>();
deleteRecursiveAsync(this, tenantBundlePath).whenComplete((ignore, ex) -> {
if (ex instanceof MetadataStoreException.NotFoundException) {
future.complete(null);
} else if (ex != null) {
future.completeExceptionally(ex);
} else {
future.complete(null);
}
});

return future;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ protected CompletableFuture<Void> internalClearZkSources() {
// z-node can be deleted now
.thenCompose(ignore -> namespaceResources().deletePoliciesAsync(namespaceName))
// clear z-node of local policies
.thenCompose(ignore -> getLocalPolicies().deleteLocalPoliciesAsync(namespaceName));
.thenCompose(ignore -> getLocalPolicies().deleteLocalPoliciesAsync(namespaceName))
// clear /loadbalance/bundle-data
.thenCompose(ignore -> namespaceResources().deleteBundleDataAsync(namespaceName));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ protected void internalDeleteTenant(AsyncResponse asyncResponse, String tenant)
.clearTenantPersistence(tenant))
.thenCompose(ignore -> pulsar().getPulsarResources().getNamespaceResources()
.deleteTenantAsync(tenant))
.thenCompose(ignore -> pulsar().getPulsarResources().getNamespaceResources()
.deleteBundleDataTenantAsync(tenant))
.whenComplete((ignore, ex) -> {
if (ex != null) {
log.error("[{}] Failed to delete tenant {}", clientAppId(), tenant, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,9 @@ public void testDeleteTenant() throws Exception {
assertFalse(admin.tenants().getTenants().contains(tenant));

final String managedLedgersPath = "/managed-ledgers/" + tenant;
final String bundleDataPath = "/loadbalance/bundle-data/" + tenant;
assertFalse(pulsar.getLocalMetadataStore().exists(managedLedgersPath).join());
assertFalse(pulsar.getLocalMetadataStore().exists(bundleDataPath).join());
}

@Test
Expand Down Expand Up @@ -1355,6 +1357,9 @@ public void testDeleteNamespace() throws Exception {

final String managedLedgersPath = "/managed-ledgers/" + namespace;
assertFalse(pulsar.getLocalMetadataStore().exists(managedLedgersPath).join());

final String bundleDataPath = "/loadbalance/bundle-data/" + namespace;
assertFalse(pulsar.getLocalMetadataStore().exists(bundleDataPath).join());
}

@Test
Expand Down