Skip to content

Rename classes in transactional persistence package #1197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
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 @@ -42,7 +42,7 @@
import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
import org.apache.polaris.core.persistence.BasePolarisMetaStoreManagerTest;
import org.apache.polaris.core.persistence.PolarisTestMetaStoreManager;
import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl;
import org.apache.polaris.core.persistence.transactional.TransactionalMetaStoreManagerImpl;
import org.apache.polaris.jpa.models.ModelPrincipalSecrets;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -104,7 +104,7 @@ protected PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() {
new PolarisEclipseLinkMetaStoreSessionImpl(
store, Mockito.mock(), () -> "realm", null, "polaris", RANDOM_SECRETS);
return new PolarisTestMetaStoreManager(
new PolarisMetaStoreManagerImpl(),
new TransactionalMetaStoreManagerImpl(),
new PolarisCallContext(
session,
diagServices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.apache.polaris.core.persistence.dao.entity.BaseResult;
import org.apache.polaris.core.persistence.dao.entity.EntityResult;
import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl;
import org.apache.polaris.core.persistence.transactional.TransactionalMetaStoreManagerImpl;
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
import org.apache.polaris.core.storage.cache.StorageCredentialCache;
import org.slf4j.Logger;
Expand Down Expand Up @@ -92,7 +92,7 @@ protected PrincipalSecretsGenerator secretsGenerator(
* into the existing realm-based setup flow.
*/
protected PolarisMetaStoreManager createNewMetaStoreManager() {
return new PolarisMetaStoreManagerImpl();
return new TransactionalMetaStoreManagerImpl();
}

private void initializeForRealm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@
* and retrieve all Polaris metadata
*/
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
public class PolarisMetaStoreManagerImpl extends BaseMetaStoreManager {
private static final Logger LOGGER = LoggerFactory.getLogger(PolarisMetaStoreManagerImpl.class);
public class TransactionalMetaStoreManagerImpl extends BaseMetaStoreManager {
private static final Logger LOGGER =
LoggerFactory.getLogger(TransactionalMetaStoreManagerImpl.class);

/**
* A version of BaseMetaStoreManager::persistNewEntity but instead of calling the one-shot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.apache.polaris.core.entity.PolarisPrincipalSecrets;

/** Implements a simple in-memory store for Polaris, using tree-map */
public class PolarisTreeMapStore {
public class TreeMapMetaStore {

/** Slice of data, simple KV store. */
public class Slice<T> {
Expand Down Expand Up @@ -68,7 +68,7 @@ public String buildKey(T value) {
* @param key key for that value
*/
public T read(String key) {
PolarisTreeMapStore.this.ensureReadTr();
TreeMapMetaStore.this.ensureReadTr();
T value = this.slice.getOrDefault(key, null);
return (value != null) ? this.copyRecord.apply(value) : null;
}
Expand All @@ -79,7 +79,7 @@ public T read(String key) {
* @param prefix key prefix
*/
public List<T> readRange(String prefix) {
PolarisTreeMapStore.this.ensureReadTr();
TreeMapMetaStore.this.ensureReadTr();
// end of the key
String endKey =
prefix.substring(0, prefix.length() - 1)
Expand All @@ -95,7 +95,7 @@ public List<T> readRange(String prefix) {
* @param value value to write
*/
public void write(T value) {
PolarisTreeMapStore.this.ensureReadWriteTr();
TreeMapMetaStore.this.ensureReadWriteTr();
T valueToWrite = (value != null) ? this.copyRecord.apply(value) : null;
String key = this.buildKey(valueToWrite);
// write undo if needs be
Expand All @@ -111,7 +111,7 @@ public void write(T value) {
* @param key key for the record to remove
*/
public void delete(String key) {
PolarisTreeMapStore.this.ensureReadWriteTr();
TreeMapMetaStore.this.ensureReadWriteTr();
if (slice.containsKey(key)) {
// write undo if needs be
if (!this.undoSlice.containsKey(key)) {
Expand All @@ -127,15 +127,15 @@ public void delete(String key) {
* @param prefix key prefix for the record to remove
*/
public void deleteRange(String prefix) {
PolarisTreeMapStore.this.ensureReadWriteTr();
TreeMapMetaStore.this.ensureReadWriteTr();
List<T> elements = this.readRange(prefix);
for (T element : elements) {
this.delete(element);
}
}

void deleteAll() {
PolarisTreeMapStore.this.ensureReadWriteTr();
TreeMapMetaStore.this.ensureReadWriteTr();
slice.clear();
undoSlice.clear();
}
Expand All @@ -151,7 +151,7 @@ public void delete(T value) {

/** Rollback all changes made to this slice since transaction started */
private void rollback() {
PolarisTreeMapStore.this.ensureReadWriteTr();
TreeMapMetaStore.this.ensureReadWriteTr();
undoSlice.forEach(
(key, value) -> {
if (value == null) {
Expand Down Expand Up @@ -217,7 +217,7 @@ public boolean isWrite() {
*
* @param diagnostics diagnostic services
*/
public PolarisTreeMapStore(@Nonnull PolarisDiagnostics diagnostics) {
public TreeMapMetaStore(@Nonnull PolarisDiagnostics diagnostics) {

// the entities slice
this.sliceEntities =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
import org.apache.polaris.core.storage.PolarisStorageIntegration;
import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;

public class PolarisTreeMapMetaStoreSessionImpl extends AbstractTransactionalPersistence {
public class TreeMapTransactionalPersistenceImpl extends AbstractTransactionalPersistence {

// the TreeMap store to use
private final PolarisTreeMapStore store;
private final TreeMapMetaStore store;
private final PolarisStorageIntegrationProvider storageIntegrationProvider;
private final PrincipalSecretsGenerator secretsGenerator;

public PolarisTreeMapMetaStoreSessionImpl(
@Nonnull PolarisTreeMapStore store,
public TreeMapTransactionalPersistenceImpl(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a concept of MetaStoreSession any more, better to remove it.

@Nonnull TreeMapMetaStore store,
@Nonnull PolarisStorageIntegrationProvider storageIntegrationProvider,
@Nonnull PrincipalSecretsGenerator secretsGenerator) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
import org.apache.polaris.core.persistence.cache.EntityCache;
import org.apache.polaris.core.persistence.cache.EntityCacheByNameKey;
import org.apache.polaris.core.persistence.cache.EntityCacheLookupResult;
import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore;
import org.apache.polaris.core.persistence.transactional.TransactionalMetaStoreManagerImpl;
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
import org.apache.polaris.core.persistence.transactional.TreeMapMetaStore;
import org.apache.polaris.core.persistence.transactional.TreeMapTransactionalPersistenceImpl;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
Expand All @@ -48,7 +48,7 @@ public class EntityCacheTest {
private final PolarisDiagnostics diagServices;

// the entity store, use treemap implementation
private final PolarisTreeMapStore store;
private final TreeMapMetaStore store;

// to interact with the metastore
private final TransactionalPersistence metaStore;
Expand Down Expand Up @@ -86,10 +86,10 @@ public class EntityCacheTest {
*/
public EntityCacheTest() {
diagServices = new PolarisDefaultDiagServiceImpl();
store = new PolarisTreeMapStore(diagServices);
metaStore = new PolarisTreeMapMetaStoreSessionImpl(store, Mockito.mock(), RANDOM_SECRETS);
store = new TreeMapMetaStore(diagServices);
metaStore = new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS);
callCtx = new PolarisCallContext(metaStore, diagServices);
metaStoreManager = new PolarisMetaStoreManagerImpl();
metaStoreManager = new TransactionalMetaStoreManagerImpl();

// bootstrap the mata store with our test schema
tm = new PolarisTestMetaStoreManager(metaStoreManager, callCtx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
import org.apache.polaris.core.PolarisDiagnostics;
import org.apache.polaris.core.config.PolarisConfigurationStore;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore;
import org.apache.polaris.core.persistence.transactional.TreeMapMetaStore;
import org.apache.polaris.core.persistence.transactional.TreeMapTransactionalPersistenceImpl;
import org.mockito.Mockito;

public class PolarisTreeMapAtomicOperationMetaStoreManagerTest
extends BasePolarisMetaStoreManagerTest {
@Override
public PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() {
PolarisDiagnostics diagServices = new PolarisDefaultDiagServiceImpl();
PolarisTreeMapStore store = new PolarisTreeMapStore(diagServices);
TreeMapMetaStore store = new TreeMapMetaStore(diagServices);
PolarisCallContext callCtx =
new PolarisCallContext(
new PolarisTreeMapMetaStoreSessionImpl(store, Mockito.mock(), RANDOM_SECRETS),
new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS),
diagServices,
new PolarisConfigurationStore() {},
timeSource.withZone(ZoneId.systemDefault()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@
import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
import org.apache.polaris.core.PolarisDiagnostics;
import org.apache.polaris.core.config.PolarisConfigurationStore;
import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore;
import org.apache.polaris.core.persistence.transactional.TransactionalMetaStoreManagerImpl;
import org.apache.polaris.core.persistence.transactional.TreeMapMetaStore;
import org.apache.polaris.core.persistence.transactional.TreeMapTransactionalPersistenceImpl;
import org.mockito.Mockito;

public class PolarisTreeMapMetaStoreManagerTest extends BasePolarisMetaStoreManagerTest {
@Override
public PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() {
PolarisDiagnostics diagServices = new PolarisDefaultDiagServiceImpl();
PolarisTreeMapStore store = new PolarisTreeMapStore(diagServices);
TreeMapMetaStore store = new TreeMapMetaStore(diagServices);
PolarisCallContext callCtx =
new PolarisCallContext(
new PolarisTreeMapMetaStoreSessionImpl(store, Mockito.mock(), RANDOM_SECRETS),
new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS),
diagServices,
new PolarisConfigurationStore() {},
timeSource.withZone(ZoneId.systemDefault()));

return new PolarisTestMetaStoreManager(new PolarisMetaStoreManagerImpl(), callCtx);
return new PolarisTestMetaStoreManager(new TransactionalMetaStoreManagerImpl(), callCtx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
import org.apache.polaris.core.persistence.resolver.Resolver;
import org.apache.polaris.core.persistence.resolver.ResolverPath;
import org.apache.polaris.core.persistence.resolver.ResolverStatus;
import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore;
import org.apache.polaris.core.persistence.transactional.TransactionalMetaStoreManagerImpl;
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
import org.apache.polaris.core.persistence.transactional.TreeMapMetaStore;
import org.apache.polaris.core.persistence.transactional.TreeMapTransactionalPersistenceImpl;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
Expand All @@ -65,7 +65,7 @@ public class ResolverTest {
private final PolarisDiagnostics diagServices;

// the entity store, use treemap implementation
private final PolarisTreeMapStore store;
private final TreeMapMetaStore store;

// to interact with the metastore
private final TransactionalPersistence metaStore;
Expand Down Expand Up @@ -118,10 +118,10 @@ public class ResolverTest {
*/
public ResolverTest() {
diagServices = new PolarisDefaultDiagServiceImpl();
store = new PolarisTreeMapStore(diagServices);
metaStore = new PolarisTreeMapMetaStoreSessionImpl(store, Mockito.mock(), RANDOM_SECRETS);
store = new TreeMapMetaStore(diagServices);
metaStore = new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS);
callCtx = new PolarisCallContext(metaStore, diagServices);
metaStoreManager = new PolarisMetaStoreManagerImpl();
metaStoreManager = new TransactionalMetaStoreManagerImpl();

// bootstrap the mata store with our test schema
tm = new PolarisTestMetaStoreManager(metaStoreManager, callCtx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
import org.apache.polaris.core.persistence.PolarisObjectMapperUtil;
import org.apache.polaris.core.persistence.dao.entity.BaseResult;
import org.apache.polaris.core.persistence.dao.entity.ScopedCredentialsResult;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore;
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
import org.apache.polaris.core.persistence.transactional.TreeMapMetaStore;
import org.apache.polaris.core.persistence.transactional.TreeMapTransactionalPersistenceImpl;
import org.apache.polaris.core.storage.PolarisCredentialProperty;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.RepeatedTest;
Expand All @@ -64,10 +64,10 @@ public StorageCredentialCacheTest() {
// diag services
PolarisDiagnostics diagServices = new PolarisDefaultDiagServiceImpl();
// the entity store, use treemap implementation
PolarisTreeMapStore store = new PolarisTreeMapStore(diagServices);
TreeMapMetaStore store = new TreeMapMetaStore(diagServices);
// to interact with the metastore
TransactionalPersistence metaStore =
new PolarisTreeMapMetaStoreSessionImpl(store, Mockito.mock(), RANDOM_SECRETS);
new TreeMapTransactionalPersistenceImpl(store, Mockito.mock(), RANDOM_SECRETS);
callCtx = new PolarisCallContext(metaStore, diagServices);
metaStoreManager = Mockito.mock(PolarisMetaStoreManager.class);
storageCredentialCache = new StorageCredentialCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl;
import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore;
import org.apache.polaris.core.persistence.transactional.TransactionalPersistence;
import org.apache.polaris.core.persistence.transactional.TreeMapMetaStore;
import org.apache.polaris.core.persistence.transactional.TreeMapTransactionalPersistenceImpl;
import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;
import org.apache.polaris.service.context.RealmContextConfiguration;

@ApplicationScoped
@Identifier("in-memory")
public class InMemoryPolarisMetaStoreManagerFactory
extends LocalPolarisMetaStoreManagerFactory<PolarisTreeMapStore> {
extends LocalPolarisMetaStoreManagerFactory<TreeMapMetaStore> {

private final PolarisStorageIntegrationProvider storageIntegration;
private final Set<String> bootstrappedRealms = new HashSet<>();
Expand All @@ -64,17 +64,17 @@ public void onStartup(RealmContextConfiguration realmContextConfiguration) {
}

@Override
protected PolarisTreeMapStore createBackingStore(@Nonnull PolarisDiagnostics diagnostics) {
return new PolarisTreeMapStore(diagnostics);
protected TreeMapMetaStore createBackingStore(@Nonnull PolarisDiagnostics diagnostics) {
return new TreeMapMetaStore(diagnostics);
}

@Override
protected TransactionalPersistence createMetaStoreSession(
@Nonnull PolarisTreeMapStore store,
@Nonnull TreeMapMetaStore store,
@Nonnull RealmContext realmContext,
@Nullable RootCredentialsSet rootCredentialsSet,
@Nonnull PolarisDiagnostics diagnostics) {
return new PolarisTreeMapMetaStoreSessionImpl(
return new TreeMapTransactionalPersistenceImpl(
store, storageIntegration, secretsGenerator(realmContext, rootCredentialsSet));
}

Expand Down