Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaStoreManagerFactory: make purgeRealms() return purge results #889

Merged
merged 1 commit into from
Feb 28, 2025
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 @@ -21,7 +21,6 @@
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import org.apache.polaris.core.PolarisCallContext;
Expand Down Expand Up @@ -97,7 +96,7 @@ private void initializeForRealm(

@Override
public synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
List<String> realms, RootCredentialsSet rootCredentialsSet) {
Iterable<String> realms, RootCredentialsSet rootCredentialsSet) {
Map<String, PrincipalSecretsResult> results = new HashMap<>();

for (String realm : realms) {
Expand All @@ -111,23 +110,28 @@ public synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
}
}

return results;
return Map.copyOf(results);
}

@Override
public void purgeRealms(List<String> realms) {
public Map<String, BaseResult> purgeRealms(Iterable<String> realms) {
Map<String, BaseResult> results = new HashMap<>();

for (String realm : realms) {
PolarisMetaStoreManager metaStoreManager = getOrCreateMetaStoreManager(() -> realm);
PolarisMetaStoreSession session = getOrCreateSessionSupplier(() -> realm).get();

PolarisCallContext callContext = new PolarisCallContext(session, diagServices);
metaStoreManager.purge(callContext);
BaseResult result = metaStoreManager.purge(callContext);
results.put(realm, result);

storageCredentialCacheMap.remove(realm);
backingStoreMap.remove(realm);
sessionSupplierMap.remove(realm);
metaStoreManagerMap.remove(realm);
}

return Map.copyOf(results);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.polaris.core.persistence;

import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import org.apache.polaris.core.auth.PolarisSecretsManager.PrincipalSecretsResult;
Expand All @@ -39,8 +38,8 @@ public interface MetaStoreManagerFactory {
EntityCache getOrCreateEntityCache(RealmContext realmContext);

Map<String, PrincipalSecretsResult> bootstrapRealms(
List<String> realms, RootCredentialsSet rootCredentialsSet);
Iterable<String> realms, RootCredentialsSet rootCredentialsSet);

/** Purge all metadata for the realms provided */
void purgeRealms(List<String> realms);
Map<String, BaseResult> purgeRealms(Iterable<String> realms);
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import org.apache.polaris.core.entity.PolarisEntityType;
import org.apache.polaris.core.entity.PrincipalEntity;
import org.apache.polaris.core.entity.TaskEntity;
import org.apache.polaris.core.persistence.BaseResult;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
import org.apache.polaris.core.persistence.PolarisEntityManager;
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
Expand Down Expand Up @@ -345,12 +346,12 @@ public EntityCache getOrCreateEntityCache(RealmContext realmContext) {

@Override
public Map<String, PrincipalSecretsResult> bootstrapRealms(
List<String> realms, RootCredentialsSet rootCredentialsSet) {
Iterable<String> realms, RootCredentialsSet rootCredentialsSet) {
throw new NotImplementedException("Bootstrapping realms is not supported");
}

@Override
public void purgeRealms(List<String> realms) {
public Map<String, BaseResult> purgeRealms(Iterable<String> realms) {
throw new NotImplementedException("Purging realms is not supported");
}
};
Expand Down