Skip to content

Commit

Permalink
Update metastoreManager default back to in-memory
Browse files Browse the repository at this point in the history
  • Loading branch information
aihuaxu committed Aug 25, 2024
1 parent d947e98 commit 9f936a3
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@
import io.polaris.core.monitor.PolarisMetricRegistry;
import io.polaris.core.storage.PolarisStorageIntegrationProvider;
import io.polaris.core.storage.cache.StorageCredentialCache;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -210,21 +208,6 @@ public void setStorageIntegrationProvider(PolarisStorageIntegrationProvider stor
return rotatedSecrets;
}

@TestOnly
public void bootstrapRealmAndPrintCredentials(String realmId) {
Map<String, PolarisMetaStoreManager.PrincipalSecretsResult> results =
this.bootstrapRealms(Collections.singletonList(realmId));
PolarisMetaStoreManager.PrincipalSecretsResult principalSecrets = results.get(realmId);

String msg =
String.format(
"realm: %1s root principal credentials: %2s:%3s",
realmId,
principalSecrets.getPrincipalSecrets().getPrincipalClientId(),
principalSecrets.getPrincipalSecrets().getMainSecret());
System.out.println(msg);
}

/**
* In this method we check if Service was bootstrapped for a given realm, i.e. that all the
* entities were created (root principal, root principal role, etc) If service was not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import java.net.URL;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -288,7 +289,7 @@ public void run(PolarisApplicationConfig configuration, Environment environment)
// different processes
// and in-memory state will be lost b/w invocation of bootstrap command and running a server
if (metaStoreManagerFactory instanceof InMemoryPolarisMetaStoreManagerFactory) {
metaStoreManagerFactory.getOrCreateMetaStoreManager(configuration::getDefaultRealm);
metaStoreManagerFactory.bootstrapRealms(List.of(configuration.getDefaultRealm()));
}

LOGGER.info("Server started successfully.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void before() {
PolarisTreeMapStore backingStore = new PolarisTreeMapStore(diagServices);
InMemoryPolarisMetaStoreManagerFactory managerFactory =
new InMemoryPolarisMetaStoreManagerFactory();
managerFactory.bootstrapRealmAndPrintCredentials(realmContext.getRealmIdentifier());
managerFactory.bootstrapRealms(List.of(realmContext.getRealmIdentifier()));
managerFactory.setStorageIntegrationProvider(
new PolarisStorageIntegrationProviderImpl(Mockito::mock));
PolarisMetaStoreManager metaStoreManager =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void before() {
PolarisStorageIntegrationProvider storageIntegrationProvider = Mockito.mock();
InMemoryPolarisMetaStoreManagerFactory managerFactory =
new InMemoryPolarisMetaStoreManagerFactory();
managerFactory.bootstrapRealmAndPrintCredentials(realmContext.getRealmIdentifier());
managerFactory.bootstrapRealms(List.of(realmContext.getRealmIdentifier()));
managerFactory.setStorageIntegrationProvider(storageIntegrationProvider);
metaStoreManager = managerFactory.getOrCreateMetaStoreManager(realmContext);
Map<String, Object> configMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void before() {
RealmContext realmContext = () -> "realm";
InMemoryPolarisMetaStoreManagerFactory managerFactory =
new InMemoryPolarisMetaStoreManagerFactory();
managerFactory.bootstrapRealmAndPrintCredentials(realmContext.getRealmIdentifier());
managerFactory.bootstrapRealms(List.of(realmContext.getRealmIdentifier()));
managerFactory.setStorageIntegrationProvider(
new PolarisStorageIntegrationProviderImpl(Mockito::mock));
PolarisMetaStoreManager metaStoreManager =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.polaris.service.persistence.InMemoryPolarisMetaStoreManagerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Executors;
Expand All @@ -54,7 +55,7 @@ class ManifestFileCleanupTaskHandlerTest {
void setUp() {
metaStoreManagerFactory = new InMemoryPolarisMetaStoreManagerFactory();
realmContext = () -> "realmName";
metaStoreManagerFactory.bootstrapRealmAndPrintCredentials(realmContext.getRealmIdentifier());
metaStoreManagerFactory.bootstrapRealms(List.of(realmContext.getRealmIdentifier()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TableCleanupTaskHandlerTest {
void setUp() {
metaStoreManagerFactory = new InMemoryPolarisMetaStoreManagerFactory();
realmContext = () -> "realmName";
metaStoreManagerFactory.bootstrapRealmAndPrintCredentials(realmContext.getRealmIdentifier());
metaStoreManagerFactory.bootstrapRealms(List.of(realmContext.getRealmIdentifier()));
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ public void beforeAll(ExtensionContext extensionContext) throws Exception {
metaStoreManagerFactory = config.getMetaStoreManagerFactory();

if (metaStoreManagerFactory instanceof LocalPolarisMetaStoreManagerFactory msmf) {
((LocalPolarisMetaStoreManagerFactory) metaStoreManagerFactory)
.bootstrapRealmAndPrintCredentials(realm);
metaStoreManagerFactory.bootstrapRealms(List.of(realm));

StsClient mockSts = Mockito.mock(StsClient.class);
Mockito.when(mockSts.assumeRole(Mockito.isA(AssumeRoleRequest.class)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ featureConfiguration:
- AZURE

metaStoreManager:
# type: in-memory
type: in-memory
# type: remote
# url: http://sdp-devvm-mcollado:8080
type: eclipse-link # uncomment to use eclipse-link as metastore
persistence-unit: polaris
# type: eclipse-link # uncomment to use eclipse-link as metastore
# persistence-unit: polaris

oauth2:
type: default
Expand Down

0 comments on commit 9f936a3

Please sign in to comment.