Skip to content

Commit 88db62e

Browse files
committed
Request-scoped PolarisMetaStoreManager
the `PolarisMetaStoreManager` interface methods all take a `PolarisCallContext` parameter because they need access to `PolarisCallContext.getMetaStore` aka the persistence session. also occasionally the `RealmContext` and `RealmConfig` is needed. this means `PolarisMetaStoreManager` is only usable within a request-scope. `MetaStoreManagerFactory.getOrCreateMetaStoreManager` impls suggests that there needs to be one shared `PolarisMetaStoreManager` instance per realm. however if we look at the `PolarisMetaStoreManager` impls (`AtomicOperationMetaStoreManager` and `TransactionalMetaStoreManagerImpl`) we can see that they dont have any state themselves, the fields only reference application-scoped collaborators. those 2 observations combined mean that in order to reduce the dependency on `PolarisCallContext` the `PolarisMetaStoreManager` has to become request-scoped. note that if custom implementations would need any state sharing for a realm, they are still free to do so in their custom `MetaStoreManagerFactory` implementations, as they can initialize the request-scoped `PolarisMetaStoreManager` with whatever data they need. when `PolarisMetaStoreManager` is request-scoped the `getOrCreateSession` method also becomes a private implementation detail of the `MetaStoreManagerFactory`. the `EntityCache` / `InMemoryEntityCache` however can no longer operate on a single `PolarisMetaStoreManager` and the one from the request needs to be passed as a parameter in all the methods now.
1 parent 62a1e70 commit 88db62e

File tree

79 files changed

+1366
-2755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1366
-2755
lines changed

persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/EclipseLinkPolarisMetaStoreManagerFactory.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.nio.file.Path;
2727
import java.time.Clock;
2828
import org.apache.polaris.core.PolarisDiagnostics;
29+
import org.apache.polaris.core.config.PolarisConfigurationStore;
2930
import org.apache.polaris.core.context.RealmContext;
3031
import org.apache.polaris.core.persistence.LocalPolarisMetaStoreManagerFactory;
3132
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
@@ -48,12 +49,13 @@ public class EclipseLinkPolarisMetaStoreManagerFactory
4849

4950
@SuppressWarnings("unused") // Required by CDI
5051
protected EclipseLinkPolarisMetaStoreManagerFactory() {
51-
this(null, null);
52+
this(null, null, null);
5253
}
5354

5455
@Inject
55-
protected EclipseLinkPolarisMetaStoreManagerFactory(Clock clock, PolarisDiagnostics diagnostics) {
56-
super(clock, diagnostics);
56+
protected EclipseLinkPolarisMetaStoreManagerFactory(
57+
Clock clock, PolarisDiagnostics diagnostics, PolarisConfigurationStore configurationStore) {
58+
super(clock, diagnostics, configurationStore);
5759
}
5860

5961
@Override

persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreSessionImpl.java

Lines changed: 38 additions & 80 deletions
Large diffs are not rendered by default.

persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@
3232
import java.nio.file.Path;
3333
import java.util.Objects;
3434
import java.util.stream.Stream;
35-
import org.apache.polaris.core.PolarisCallContext;
3635
import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
3736
import org.apache.polaris.core.PolarisDiagnostics;
38-
import org.apache.polaris.core.context.RealmContext;
3937
import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
4038
import org.apache.polaris.core.persistence.BasePolarisMetaStoreManagerTest;
4139
import org.apache.polaris.core.persistence.PolarisTestMetaStoreManager;
@@ -83,14 +81,13 @@ static void prepareConfFiles(@TempDir Path archiveDir) throws IOException {
8381
protected PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() {
8482
PolarisDiagnostics diagServices = new PolarisDefaultDiagServiceImpl();
8583
PolarisEclipseLinkStore store = new PolarisEclipseLinkStore(diagServices);
86-
RealmContext realmContext = () -> "realm";
8784
PolarisEclipseLinkMetaStoreSessionImpl session =
8885
new PolarisEclipseLinkMetaStoreSessionImpl(
8986
diagServices, store, Mockito.mock(), realmContext, null, "polaris", RANDOM_SECRETS);
9087
TransactionalMetaStoreManagerImpl metaStoreManager =
91-
new TransactionalMetaStoreManagerImpl(clock, diagServices);
92-
PolarisCallContext callCtx = new PolarisCallContext(realmContext, session);
93-
return new PolarisTestMetaStoreManager(metaStoreManager, callCtx);
88+
new TransactionalMetaStoreManagerImpl(
89+
clock, diagServices, realmContext, realmConfig, () -> session);
90+
return new PolarisTestMetaStoreManager(metaStoreManager);
9491
}
9592

9693
@ParameterizedTest

0 commit comments

Comments
 (0)