This is an automated email from the ASF dual-hosted git repository. snazy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push: new 04e65af4f Use injected PolarisDiagnostics in MetaStoreManagerFactory impls (#2251) 04e65af4f is described below commit 04e65af4f8052459b8bea04f6274684278c3660a Author: Christopher Lambert <xn...@gmx.de> AuthorDate: Wed Aug 6 19:51:03 2025 +0200 Use injected PolarisDiagnostics in MetaStoreManagerFactory impls (#2251) --- .../relational/jdbc/JdbcMetaStoreManagerFactory.java | 9 ++++----- .../persistence/LocalPolarisMetaStoreManagerFactory.java | 8 +++----- .../InMemoryAtomicOperationMetaStoreManagerFactory.java | 5 +++-- .../InMemoryPolarisMetaStoreManagerFactory.java | 3 ++- .../org/apache/polaris/service/task/TaskExecutorImpl.java | 2 +- .../apache/polaris/service/admin/PolarisAuthzTestBase.java | 5 +++-- .../apache/polaris/service/entity/CatalogEntityTest.java | 14 +++++++------- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java b/persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java index 83da6009b..ca2294882 100644 --- a/persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java +++ b/persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java @@ -30,7 +30,6 @@ import java.util.Optional; import java.util.function.Supplier; import javax.sql.DataSource; import org.apache.polaris.core.PolarisCallContext; -import org.apache.polaris.core.PolarisDefaultDiagServiceImpl; import org.apache.polaris.core.PolarisDiagnostics; import org.apache.polaris.core.config.RealmConfig; import org.apache.polaris.core.context.RealmContext; @@ -68,8 +67,8 @@ public class JdbcMetaStoreManagerFactory implements MetaStoreManagerFactory { final Map<String, PolarisMetaStoreManager> metaStoreManagerMap = new HashMap<>(); final Map<String, EntityCache> entityCacheMap = new HashMap<>(); final Map<String, Supplier<BasePersistence>> sessionSupplierMap = new HashMap<>(); - protected final PolarisDiagnostics diagServices = new PolarisDefaultDiagServiceImpl(); + @Inject PolarisDiagnostics diagnostics; @Inject PolarisStorageIntegrationProvider storageIntegrationProvider; @Inject Instance<DataSource> dataSource; @Inject RelationalJdbcConfiguration relationalJdbcConfiguration; @@ -176,7 +175,7 @@ public class JdbcMetaStoreManagerFactory implements MetaStoreManagerFactory { PolarisMetaStoreManager metaStoreManager = getOrCreateMetaStoreManager(realmContext); BasePersistence session = getOrCreateSession(realmContext); - PolarisCallContext callContext = new PolarisCallContext(realmContext, session, diagServices); + PolarisCallContext callContext = new PolarisCallContext(realmContext, session, diagnostics); BaseResult result = metaStoreManager.purge(callContext); results.put(realm, result); @@ -233,7 +232,7 @@ public class JdbcMetaStoreManagerFactory implements MetaStoreManagerFactory { metaStoreManagerMap.get(realmContext.getRealmIdentifier()); BasePersistence metaStore = sessionSupplierMap.get(realmContext.getRealmIdentifier()).get(); PolarisCallContext polarisContext = - new PolarisCallContext(realmContext, metaStore, diagServices); + new PolarisCallContext(realmContext, metaStore, diagnostics); Optional<PrincipalEntity> preliminaryRootPrincipal = metaStoreManager.findRootPrincipal(polarisContext); @@ -268,7 +267,7 @@ public class JdbcMetaStoreManagerFactory implements MetaStoreManagerFactory { metaStoreManagerMap.get(realmContext.getRealmIdentifier()); BasePersistence metaStore = sessionSupplierMap.get(realmContext.getRealmIdentifier()).get(); PolarisCallContext polarisContext = - new PolarisCallContext(realmContext, metaStore, diagServices); + new PolarisCallContext(realmContext, metaStore, diagnostics); Optional<PrincipalEntity> rootPrincipal = metaStoreManager.findRootPrincipal(polarisContext); if (rootPrincipal.isEmpty()) { diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java index 43f6774b7..925fcd955 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.Optional; import java.util.function.Supplier; import org.apache.polaris.core.PolarisCallContext; -import org.apache.polaris.core.PolarisDefaultDiagServiceImpl; import org.apache.polaris.core.PolarisDiagnostics; import org.apache.polaris.core.config.RealmConfig; import org.apache.polaris.core.context.RealmContext; @@ -53,7 +52,6 @@ public abstract class LocalPolarisMetaStoreManagerFactory<StoreType> final Map<String, EntityCache> entityCacheMap = new HashMap<>(); final Map<String, StoreType> backingStoreMap = new HashMap<>(); final Map<String, Supplier<TransactionalPersistence>> sessionSupplierMap = new HashMap<>(); - protected final PolarisDiagnostics diagServices = new PolarisDefaultDiagServiceImpl(); private static final Logger LOGGER = LoggerFactory.getLogger(LocalPolarisMetaStoreManagerFactory.class); @@ -128,7 +126,7 @@ public abstract class LocalPolarisMetaStoreManagerFactory<StoreType> PolarisMetaStoreManager metaStoreManager = getOrCreateMetaStoreManager(realmContext); TransactionalPersistence session = getOrCreateSession(realmContext); - PolarisCallContext callContext = new PolarisCallContext(realmContext, session, diagServices); + PolarisCallContext callContext = new PolarisCallContext(realmContext, session, diagnostics); BaseResult result = metaStoreManager.purge(callContext); results.put(realm, result); @@ -184,7 +182,7 @@ public abstract class LocalPolarisMetaStoreManagerFactory<StoreType> metaStoreManagerMap.get(realmContext.getRealmIdentifier()); BasePersistence metaStore = sessionSupplierMap.get(realmContext.getRealmIdentifier()).get(); PolarisCallContext polarisContext = - new PolarisCallContext(realmContext, metaStore, diagServices); + new PolarisCallContext(realmContext, metaStore, diagnostics); Optional<PrincipalEntity> preliminaryRootPrincipal = metaStoreManager.findRootPrincipal(polarisContext); @@ -219,7 +217,7 @@ public abstract class LocalPolarisMetaStoreManagerFactory<StoreType> metaStoreManagerMap.get(realmContext.getRealmIdentifier()); BasePersistence metaStore = sessionSupplierMap.get(realmContext.getRealmIdentifier()).get(); PolarisCallContext polarisContext = - new PolarisCallContext(realmContext, metaStore, diagServices); + new PolarisCallContext(realmContext, metaStore, diagnostics); Optional<PrincipalEntity> rootPrincipal = metaStoreManager.findRootPrincipal(polarisContext); if (rootPrincipal.isEmpty()) { diff --git a/runtime/service/src/main/java/org/apache/polaris/service/persistence/InMemoryAtomicOperationMetaStoreManagerFactory.java b/runtime/service/src/main/java/org/apache/polaris/service/persistence/InMemoryAtomicOperationMetaStoreManagerFactory.java index 3f0b1a355..274848091 100644 --- a/runtime/service/src/main/java/org/apache/polaris/service/persistence/InMemoryAtomicOperationMetaStoreManagerFactory.java +++ b/runtime/service/src/main/java/org/apache/polaris/service/persistence/InMemoryAtomicOperationMetaStoreManagerFactory.java @@ -35,8 +35,9 @@ import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider; public class InMemoryAtomicOperationMetaStoreManagerFactory extends InMemoryPolarisMetaStoreManagerFactory { - public InMemoryAtomicOperationMetaStoreManagerFactory() { - super(null, null); + @SuppressWarnings("unused") // Required by CDI + protected InMemoryAtomicOperationMetaStoreManagerFactory() { + this(null, null); } @Inject diff --git a/runtime/service/src/main/java/org/apache/polaris/service/persistence/InMemoryPolarisMetaStoreManagerFactory.java b/runtime/service/src/main/java/org/apache/polaris/service/persistence/InMemoryPolarisMetaStoreManagerFactory.java index 0febc2cae..becc569d9 100644 --- a/runtime/service/src/main/java/org/apache/polaris/service/persistence/InMemoryPolarisMetaStoreManagerFactory.java +++ b/runtime/service/src/main/java/org/apache/polaris/service/persistence/InMemoryPolarisMetaStoreManagerFactory.java @@ -46,7 +46,8 @@ public class InMemoryPolarisMetaStoreManagerFactory private final PolarisStorageIntegrationProvider storageIntegration; private final Set<String> bootstrappedRealms = new HashSet<>(); - public InMemoryPolarisMetaStoreManagerFactory() { + @SuppressWarnings("unused") // Required by CDI + protected InMemoryPolarisMetaStoreManagerFactory() { this(null, null); } diff --git a/runtime/service/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java b/runtime/service/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java index 87109ed54..62d66003e 100644 --- a/runtime/service/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java +++ b/runtime/service/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java @@ -66,7 +66,7 @@ public class TaskExecutorImpl implements TaskExecutor { @Nullable private final Tracer tracer; @SuppressWarnings("unused") // Required by CDI - public TaskExecutorImpl() { + protected TaskExecutorImpl() { this(null, null, null, null, null); } diff --git a/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java b/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java index b3ed3ed59..8e169d3c5 100644 --- a/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java +++ b/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java @@ -461,8 +461,9 @@ public abstract class PolarisAuthzTestBase { public static class TestPolarisCallContextCatalogFactory extends PolarisCallContextCatalogFactory { - public TestPolarisCallContextCatalogFactory() { - super(null, null, null, null, null, null); + @SuppressWarnings("unused") // Required by CDI + protected TestPolarisCallContextCatalogFactory() { + this(null, null, null, null, null, null); } @Inject diff --git a/runtime/service/src/test/java/org/apache/polaris/service/entity/CatalogEntityTest.java b/runtime/service/src/test/java/org/apache/polaris/service/entity/CatalogEntityTest.java index a7f55e4c4..c04ea78d9 100644 --- a/runtime/service/src/test/java/org/apache/polaris/service/entity/CatalogEntityTest.java +++ b/runtime/service/src/test/java/org/apache/polaris/service/entity/CatalogEntityTest.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.stream.Stream; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.PolarisDefaultDiagServiceImpl; +import org.apache.polaris.core.PolarisDiagnostics; import org.apache.polaris.core.admin.model.AwsStorageConfigInfo; import org.apache.polaris.core.admin.model.AzureStorageConfigInfo; import org.apache.polaris.core.admin.model.Catalog; @@ -36,6 +37,7 @@ 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.BasePersistence; import org.apache.polaris.core.persistence.MetaStoreManagerFactory; import org.apache.polaris.service.persistence.InMemoryPolarisMetaStoreManagerFactory; import org.assertj.core.api.Assertions; @@ -49,18 +51,16 @@ import org.junit.jupiter.params.provider.ValueSource; public class CatalogEntityTest { private static final ObjectMapper MAPPER = new ObjectMapper(); + private final PolarisDiagnostics diagnostics = new PolarisDefaultDiagServiceImpl(); private CallContext callContext; @BeforeEach public void setup() { - MetaStoreManagerFactory metaStoreManagerFactory = new InMemoryPolarisMetaStoreManagerFactory(); RealmContext realmContext = () -> "realm"; - PolarisCallContext polarisCallContext = - new PolarisCallContext( - realmContext, - metaStoreManagerFactory.getOrCreateSession(realmContext), - new PolarisDefaultDiagServiceImpl()); - this.callContext = polarisCallContext; + MetaStoreManagerFactory metaStoreManagerFactory = + new InMemoryPolarisMetaStoreManagerFactory(null, diagnostics); + BasePersistence metaStore = metaStoreManagerFactory.getOrCreateSession(realmContext); + this.callContext = new PolarisCallContext(realmContext, metaStore, diagnostics); } @ParameterizedTest