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 @@ -37,6 +37,7 @@
import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
import org.apache.polaris.core.PolarisDiagnostics;
import org.apache.polaris.core.config.PolarisConfigurationStore;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
import org.apache.polaris.core.persistence.BasePolarisMetaStoreManagerTest;
import org.apache.polaris.core.persistence.PolarisTestMetaStoreManager;
Expand Down Expand Up @@ -84,12 +85,14 @@ static void prepareConfFiles(@TempDir Path archiveDir) throws IOException {
protected PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() {
PolarisDiagnostics diagServices = new PolarisDefaultDiagServiceImpl();
PolarisEclipseLinkStore store = new PolarisEclipseLinkStore(diagServices);
RealmContext realmContext = () -> "realm";
PolarisEclipseLinkMetaStoreSessionImpl session =
new PolarisEclipseLinkMetaStoreSessionImpl(
store, Mockito.mock(), () -> "realm", null, "polaris", RANDOM_SECRETS);
store, Mockito.mock(), realmContext, null, "polaris", RANDOM_SECRETS);
return new PolarisTestMetaStoreManager(
new TransactionalMetaStoreManagerImpl(),
new PolarisCallContext(
realmContext,
session,
diagServices,
new PolarisConfigurationStore() {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ public Map<String, BaseResult> purgeRealms(Iterable<String> realms) {
Map<String, BaseResult> results = new HashMap<>();

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
import org.apache.polaris.core.PolarisDiagnostics;
import org.apache.polaris.core.config.PolarisConfigurationStore;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.persistence.AtomicOperationMetaStoreManager;
import org.apache.polaris.core.persistence.BasePolarisMetaStoreManagerTest;
import org.apache.polaris.core.persistence.PolarisTestMetaStoreManager;
Expand Down Expand Up @@ -56,11 +57,17 @@ protected PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() {
e);
}

RealmContext realmContext = () -> "REALM";
JdbcBasePersistenceImpl basePersistence =
new JdbcBasePersistenceImpl(datasourceOperations, RANDOM_SECRETS, Mockito.mock(), "REALM");
new JdbcBasePersistenceImpl(
datasourceOperations,
RANDOM_SECRETS,
Mockito.mock(),
realmContext.getRealmIdentifier());
return new PolarisTestMetaStoreManager(
new AtomicOperationMetaStoreManager(),
new PolarisCallContext(
realmContext,
basePersistence,
diagServices,
new PolarisConfigurationStore() {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,6 @@ public PolarisCallContext(
this.clock = clock;
}

@Deprecated
public PolarisCallContext(
@Nonnull BasePersistence metaStore,
@Nonnull PolarisDiagnostics diagServices,
@Nonnull PolarisConfigurationStore configurationStore,
@Nonnull Clock clock) {
this.metaStore = metaStore;
this.diagServices = diagServices;
this.configurationStore = configurationStore;
this.clock = clock;
}

public PolarisCallContext(
@Nonnull RealmContext realmContext,
@Nonnull BasePersistence metaStore,
Expand All @@ -81,15 +69,6 @@ public PolarisCallContext(
this.clock = Clock.system(ZoneId.systemDefault());
}

@Deprecated
public PolarisCallContext(
@Nonnull BasePersistence metaStore, @Nonnull PolarisDiagnostics diagServices) {
this.metaStore = metaStore;
this.diagServices = diagServices;
this.configurationStore = new PolarisConfigurationStore() {};
this.clock = Clock.system(ZoneId.systemDefault());
}

public BasePersistence getMetaStore() {
return metaStore;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ public Map<String, BaseResult> purgeRealms(Iterable<String> realms) {
Map<String, BaseResult> results = new HashMap<>();

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() {
TreeMapMetaStore store = new TreeMapMetaStore(diagServices);
PolarisCallContext callCtx =
new PolarisCallContext(
() -> "testRealm",
new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS),
diagServices,
new PolarisConfigurationStore() {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() {
TreeMapMetaStore store = new TreeMapMetaStore(diagServices);
PolarisCallContext callCtx =
new PolarisCallContext(
() -> "testRealm",
new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS),
diagServices,
new PolarisConfigurationStore() {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected PolarisCallContext callCtx() {
TreeMapMetaStore store = new TreeMapMetaStore(diagServices);
TreeMapTransactionalPersistenceImpl metaStore =
new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS);
callCtx = new PolarisCallContext(metaStore, diagServices);
callCtx = new PolarisCallContext(() -> "testRealm", metaStore, diagServices);
}
return callCtx;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public InMemoryEntityCacheTest() {
diagServices = new PolarisDefaultDiagServiceImpl();
store = new TreeMapMetaStore(diagServices);
metaStore = new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS);
callCtx = new PolarisCallContext(metaStore, diagServices);
callCtx = new PolarisCallContext(() -> "testRealm", metaStore, diagServices);
metaStoreManager = new TransactionalMetaStoreManagerImpl();

// bootstrap the mata store with our test schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void testValidateAccessToLocationsWithWildcard() {
Map<String, Boolean> config = Map.of("ALLOW_WILDCARD_LOCATION", true);
PolarisCallContext polarisCallContext =
new PolarisCallContext(
() -> "testRealm",
Mockito.mock(),
new PolarisDefaultDiagServiceImpl(),
new PolarisConfigurationStore() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public StorageCredentialCacheTest() {
// to interact with the metastore
TransactionalPersistence metaStore =
new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS);
callCtx = new PolarisCallContext(metaStore, diagServices);
callCtx = new PolarisCallContext(() -> "testRealm", metaStore, diagServices);
metaStoreManager = Mockito.mock(PolarisMetaStoreManager.class);
storageCredentialCache = new StorageCredentialCache();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void setup() {
.build();
PolarisCallContext polarisCallContext =
new PolarisCallContext(
fakeServices.realmContext(),
fakeServices
.metaStoreManagerFactory()
.getOrCreateSessionSupplier(fakeServices.realmContext())
Expand Down Expand Up @@ -185,6 +186,7 @@ private PolarisCallContext setupCallContext(PolarisMetaStoreManager metaStoreMan
MetaStoreManagerFactory metaStoreManagerFactory = services.metaStoreManagerFactory();
RealmContext realmContext = services.realmContext();
return new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(),
services.polarisDiagnostics());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public void before(TestInfo testInfo) {

polarisContext =
new PolarisCallContext(
realmContext,
managerFactory.getOrCreateSessionSupplier(realmContext).get(),
diagServices,
configurationStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void testSuccessfulTokenGeneration() throws Exception {
final String scope = "PRINCIPAL_ROLE:TEST";

PolarisCallContext polarisCallContext =
new PolarisCallContext(null, null, configurationStore, null);
new PolarisCallContext(null, null, null, configurationStore, null);
PolarisMetaStoreManager metastoreManager = Mockito.mock(PolarisMetaStoreManager.class);
String mainSecret = "client-secret";
PolarisPrincipalSecrets principalSecrets =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class JWTSymmetricKeyGeneratorTest {
/** Sanity test to verify that we can generate a token */
@Test
public void testJWTSymmetricKeyGenerator() {
PolarisCallContext polarisCallContext = new PolarisCallContext(null, null, null, null);
PolarisCallContext polarisCallContext = new PolarisCallContext(null, null, null, null, null);
PolarisMetaStoreManager metastoreManager = Mockito.mock(PolarisMetaStoreManager.class);
String mainSecret = "test_secret";
String clientId = "test_client_id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public void before(TestInfo testInfo) {
userSecretsManager = userSecretsManagerFactory.getOrCreateUserSecretsManager(realmContext);
polarisContext =
new PolarisCallContext(
realmContext,
managerFactory.getOrCreateSessionSupplier(realmContext).get(),
diagServices,
configurationStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public void before(TestInfo testInfo) {
userSecretsManager = userSecretsManagerFactory.getOrCreateUserSecretsManager(realmContext);
polarisContext =
new PolarisCallContext(
realmContext,
managerFactory.getOrCreateSessionSupplier(realmContext).get(),
diagServices,
configurationStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public void before(TestInfo testInfo) {
userSecretsManager = userSecretsManagerFactory.getOrCreateUserSecretsManager(realmContext);
polarisContext =
new PolarisCallContext(
realmContext,
managerFactory.getOrCreateSessionSupplier(realmContext).get(),
diagServices,
configurationStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public void before(TestInfo testInfo) {
userSecretsManager = userSecretsManagerFactory.getOrCreateUserSecretsManager(realmContext);
polarisContext =
new PolarisCallContext(
realmContext,
managerFactory.getOrCreateSessionSupplier(realmContext).get(),
diagServices,
configurationStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public void before(TestInfo testInfo) {
realmContext = () -> realmName;
polarisContext =
new PolarisCallContext(
realmContext,
managerFactory.getOrCreateSessionSupplier(realmContext).get(),
diagServices,
configurationStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.polaris.core.admin.model.PolarisCatalog;
import org.apache.polaris.core.admin.model.StorageConfigInfo;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.CatalogEntity;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
import org.apache.polaris.service.persistence.InMemoryPolarisMetaStoreManagerFactory;
Expand All @@ -43,8 +44,10 @@ public class CatalogEntityTest {
@BeforeAll
public static void setup() {
MetaStoreManagerFactory metaStoreManagerFactory = new InMemoryPolarisMetaStoreManagerFactory();
RealmContext realmContext = () -> "realm";
PolarisCallContext polarisCallContext =
new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(() -> "realm").get(),
new PolarisDefaultDiagServiceImpl());
CallContext callContext = CallContext.of(() -> "realm", polarisCallContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ private void addTaskLocation(TaskEntity task) {
public void testMetadataFileCleanup() throws IOException {
PolarisCallContext polarisCallContext =
new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(),
new PolarisDefaultDiagServiceImpl());
CallContext callCtx = CallContext.of(realmContext, polarisCallContext);
Expand Down Expand Up @@ -205,6 +206,7 @@ public void close() {
public void testMetadataFileCleanupIfFileNotExist() throws IOException {
PolarisCallContext polarisCallContext =
new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(),
new PolarisDefaultDiagServiceImpl());
CallContext callCtx = CallContext.of(realmContext, polarisCallContext);
Expand Down Expand Up @@ -250,6 +252,7 @@ public void testMetadataFileCleanupIfFileNotExist() throws IOException {
public void testCleanupWithRetries() throws IOException {
PolarisCallContext polarisCallContext =
new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(),
new PolarisDefaultDiagServiceImpl());
CallContext callCtx = CallContext.of(realmContext, polarisCallContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private void addTaskLocation(TaskEntity task) {
public void testCleanupFileNotExists() throws IOException {
PolarisCallContext polarisCallContext =
new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(),
new PolarisDefaultDiagServiceImpl());
CallContext callCtx = CallContext.of(realmContext, polarisCallContext);
Expand Down Expand Up @@ -121,6 +122,7 @@ public void testCleanupFileNotExists() throws IOException {
public void testCleanupFileManifestExistsDataFilesDontExist() throws IOException {
PolarisCallContext polarisCallContext =
new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(),
new PolarisDefaultDiagServiceImpl());
CallContext callCtx = CallContext.of(realmContext, polarisCallContext);
Expand Down Expand Up @@ -150,6 +152,7 @@ public void testCleanupFileManifestExistsDataFilesDontExist() throws IOException
public void testCleanupFiles() throws IOException {
PolarisCallContext polarisCallContext =
new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(),
new PolarisDefaultDiagServiceImpl());
CallContext callCtx = CallContext.of(realmContext, polarisCallContext);
Expand Down Expand Up @@ -196,6 +199,7 @@ public void close() {
public void testCleanupFilesWithRetries() throws IOException {
PolarisCallContext polarisCallContext =
new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(),
new PolarisDefaultDiagServiceImpl());
CallContext callCtx = CallContext.of(realmContext, polarisCallContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void setup() {
QuarkusMock.installMockForType(realmContext, RealmContext.class);
PolarisCallContext polarisCallContext =
new PolarisCallContext(
realmContext,
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(),
diagServices,
configurationStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ private PolarisPrincipalSecrets fetchAdminSecrets() {
helper.metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
PolarisCallContext polarisContext =
new PolarisCallContext(
metaStoreSession, helper.diagServices, helper.configurationStore, helper.clock);
realmContext,
metaStoreSession,
helper.diagServices,
helper.configurationStore,
helper.clock);
try {
PolarisMetaStoreManager metaStoreManager =
helper.metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public RealmContext getRealmContext() {
@Override
public PolarisCallContext getPolarisCallContext() {
return new PolarisCallContext(
realmContext,
testServices
.metaStoreManagerFactory()
.getOrCreateSessionSupplier(realmContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void testEventsAreEmitted() {
BasePersistence bp = metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();

PolarisCallContext polarisCallCtx =
new PolarisCallContext(bp, testServices.polarisDiagnostics());
new PolarisCallContext(realmContext, bp, testServices.polarisDiagnostics());
CallContext callContext = CallContext.of(realmContext, polarisCallCtx);

// This task doesn't have a type so it won't be handle-able by a real handler. We register a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public RealmContext getRealmContext() {
@Override
public PolarisCallContext getPolarisCallContext() {
return new PolarisCallContext(
realmContext,
metaStoreSession,
polarisDiagnostics,
configurationStore,
Expand Down
Loading