Skip to content

Commit 692602e

Browse files
authored
Generify MetaStoreManagerFactory.getOrCreateSessionSupplier (#1173)
No functional change. * Adjust the type parameter to the Persistence supplier to cover all possible implementation types. * Remove unnecessary fields from IcebergCatalogAdapter * Adjust types at call sites of `getOrCreateSessionSupplier`.
1 parent 495aea0 commit 692602e

File tree

6 files changed

+15
-22
lines changed

6 files changed

+15
-22
lines changed

polaris-core/src/main/java/org/apache/polaris/core/persistence/MetaStoreManagerFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525
import org.apache.polaris.core.persistence.cache.EntityCache;
2626
import org.apache.polaris.core.persistence.dao.entity.BaseResult;
2727
import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
28-
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
2928
import org.apache.polaris.core.storage.cache.StorageCredentialCache;
3029

3130
/** Configuration interface for configuring the {@link PolarisMetaStoreManager}. */
3231
public interface MetaStoreManagerFactory {
3332

3433
PolarisMetaStoreManager getOrCreateMetaStoreManager(RealmContext realmContext);
3534

36-
Supplier<TransactionalPersistence> getOrCreateSessionSupplier(RealmContext realmContext);
35+
Supplier<? extends BasePersistence> getOrCreateSessionSupplier(RealmContext realmContext);
3736

3837
StorageCredentialCache getOrCreateStorageCredentialCache(RealmContext realmContext);
3938

quarkus/service/src/main/java/org/apache/polaris/service/quarkus/config/QuarkusProducers.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
import org.apache.polaris.core.config.PolarisConfigurationStore;
4242
import org.apache.polaris.core.context.CallContext;
4343
import org.apache.polaris.core.context.RealmContext;
44+
import org.apache.polaris.core.persistence.BasePersistence;
4445
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
4546
import org.apache.polaris.core.persistence.PolarisEntityManager;
4647
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
47-
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
4848
import org.apache.polaris.core.storage.cache.StorageCredentialCache;
4949
import org.apache.polaris.service.auth.ActiveRolesProvider;
5050
import org.apache.polaris.service.auth.Authenticator;
@@ -113,7 +113,7 @@ public PolarisCallContext polarisCallContext(
113113
PolarisConfigurationStore configurationStore,
114114
MetaStoreManagerFactory metaStoreManagerFactory,
115115
Clock clock) {
116-
TransactionalPersistence metaStoreSession =
116+
BasePersistence metaStoreSession =
117117
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
118118
return new PolarisCallContext(metaStoreSession, diagServices, configurationStore, clock);
119119
}
@@ -220,7 +220,7 @@ public PolarisMetaStoreManager polarisMetaStoreManager(
220220

221221
@Produces
222222
@RequestScoped
223-
public TransactionalPersistence polarisMetaStoreSession(
223+
public BasePersistence polarisMetaStoreSession(
224224
RealmContext realmContext, MetaStoreManagerFactory metaStoreManagerFactory) {
225225
return metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
226226
}

quarkus/service/src/test/java/org/apache/polaris/service/quarkus/task/TableCleanupTaskHandlerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
import org.apache.polaris.core.entity.PolarisTaskConstants;
4949
import org.apache.polaris.core.entity.TableLikeEntity;
5050
import org.apache.polaris.core.entity.TaskEntity;
51+
import org.apache.polaris.core.persistence.BasePersistence;
5152
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
5253
import org.apache.polaris.core.persistence.PolarisResolvedPathWrapper;
53-
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
5454
import org.apache.polaris.core.storage.PolarisStorageActions;
5555
import org.apache.polaris.service.catalog.io.FileIOFactory;
5656
import org.apache.polaris.service.task.ManifestFileCleanupTaskHandler;
@@ -176,7 +176,7 @@ public void testTableCleanup() throws IOException {
176176

177177
@Test
178178
public void testTableCleanupHandlesAlreadyDeletedMetadata() throws IOException {
179-
TransactionalPersistence metaStoreSession =
179+
BasePersistence metaStoreSession =
180180
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
181181
FileIO fileIO =
182182
new InMemoryFileIO() {
@@ -230,7 +230,7 @@ public void close() {
230230

231231
@Test
232232
public void testTableCleanupDuplicatesTasksIfFileStillExists() throws IOException {
233-
TransactionalPersistence metaStoreSession =
233+
BasePersistence metaStoreSession =
234234
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
235235
FileIO fileIO =
236236
new InMemoryFileIO() {
@@ -346,7 +346,7 @@ public void close() {
346346

347347
@Test
348348
public void testTableCleanupMultipleSnapshots() throws IOException {
349-
TransactionalPersistence metaStoreSession =
349+
BasePersistence metaStoreSession =
350350
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
351351
FileIO fileIO = new InMemoryFileIO();
352352
TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", "schema1"), "table1");
@@ -491,7 +491,7 @@ public void testTableCleanupMultipleSnapshots() throws IOException {
491491

492492
@Test
493493
public void testTableCleanupMultipleMetadata() throws IOException {
494-
TransactionalPersistence metaStoreSession =
494+
BasePersistence metaStoreSession =
495495
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
496496
FileIO fileIO = new InMemoryFileIO();
497497
TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", "schema1"), "table1");

quarkus/service/src/test/java/org/apache/polaris/service/quarkus/test/PolarisIntegrationTestFixture.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
import org.apache.polaris.core.entity.PolarisEntitySubType;
4343
import org.apache.polaris.core.entity.PolarisEntityType;
4444
import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
45+
import org.apache.polaris.core.persistence.BasePersistence;
4546
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
4647
import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
4748
import org.apache.polaris.core.persistence.dao.entity.EntityResult;
48-
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
4949
import org.apache.polaris.service.persistence.InMemoryPolarisMetaStoreManagerFactory;
5050
import org.apache.polaris.service.quarkus.auth.TokenUtils;
5151
import org.junit.jupiter.api.TestInfo;
@@ -107,7 +107,7 @@ private PolarisPrincipalSecrets fetchAdminSecrets() {
107107
helper.realmContextResolver.resolveRealmContext(
108108
baseUri.toString(), "GET", "/", Map.of(REALM_PROPERTY_KEY, realm));
109109

110-
TransactionalPersistence metaStoreSession =
110+
BasePersistence metaStoreSession =
111111
helper.metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
112112
PolarisCallContext polarisContext =
113113
new PolarisCallContext(

service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@
6262
import org.apache.polaris.core.context.CallContext;
6363
import org.apache.polaris.core.context.RealmContext;
6464
import org.apache.polaris.core.entity.PolarisEntity;
65+
import org.apache.polaris.core.persistence.BasePersistence;
6566
import org.apache.polaris.core.persistence.PolarisEntityManager;
6667
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
6768
import org.apache.polaris.core.persistence.ResolvedPolarisEntity;
6869
import org.apache.polaris.core.persistence.resolver.Resolver;
6970
import org.apache.polaris.core.persistence.resolver.ResolverStatus;
70-
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
7171
import org.apache.polaris.service.catalog.api.IcebergRestCatalogApiService;
7272
import org.apache.polaris.service.catalog.api.IcebergRestConfigurationApiService;
7373
import org.apache.polaris.service.context.CallContextCatalogFactory;
@@ -125,9 +125,6 @@ public class IcebergCatalogAdapter
125125
private final CallContextCatalogFactory catalogFactory;
126126
private final PolarisEntityManager entityManager;
127127
private final PolarisMetaStoreManager metaStoreManager;
128-
private final TransactionalPersistence session;
129-
private final PolarisConfigurationStore configurationStore;
130-
private final PolarisDiagnostics diagnostics;
131128
private final PolarisAuthorizer polarisAuthorizer;
132129
private final IcebergCatalogPrefixParser prefixParser;
133130

@@ -138,7 +135,7 @@ public IcebergCatalogAdapter(
138135
CallContextCatalogFactory catalogFactory,
139136
PolarisEntityManager entityManager,
140137
PolarisMetaStoreManager metaStoreManager,
141-
TransactionalPersistence session,
138+
BasePersistence session,
142139
PolarisConfigurationStore configurationStore,
143140
PolarisDiagnostics diagnostics,
144141
PolarisAuthorizer polarisAuthorizer,
@@ -148,9 +145,6 @@ public IcebergCatalogAdapter(
148145
this.catalogFactory = catalogFactory;
149146
this.entityManager = entityManager;
150147
this.metaStoreManager = metaStoreManager;
151-
this.session = session;
152-
this.configurationStore = configurationStore;
153-
this.diagnostics = diagnostics;
154148
this.polarisAuthorizer = polarisAuthorizer;
155149
this.prefixParser = prefixParser;
156150

service/common/src/main/java/org/apache/polaris/service/context/DefaultCallContextResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import org.apache.polaris.core.config.PolarisConfigurationStore;
2929
import org.apache.polaris.core.context.CallContext;
3030
import org.apache.polaris.core.context.RealmContext;
31+
import org.apache.polaris.core.persistence.BasePersistence;
3132
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
32-
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
3333
import org.slf4j.Logger;
3434
import org.slf4j.LoggerFactory;
3535

@@ -64,7 +64,7 @@ public CallContext resolveCallContext(
6464
// pushed down for the metaStoreManagerFactory to inject Transactional-DB specific things
6565
// (including the MetaStoreSession" into the PolarisCallContext. The non-transactional
6666
// factories would then inject something else instead if needed.
67-
TransactionalPersistence metaStoreSession =
67+
BasePersistence metaStoreSession =
6868
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
6969
PolarisCallContext polarisContext =
7070
new PolarisCallContext(metaStoreSession, diagnostics, configurationStore, clock);

0 commit comments

Comments
 (0)