Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
### Deprecations

- The configuration option `polaris.rate-limiter.token-bucket.window` is no longer supported and should be removed.
- `PolarisConfigurationStore` has been deprecated for removal.

### Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.polaris.core.PolarisCallContext;
import org.apache.polaris.core.config.PolarisConfigurationStore;
import org.apache.polaris.core.config.RealmConfigurationSource;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.CatalogEntity;
import org.apache.polaris.core.entity.PolarisBaseEntity;
Expand Down Expand Up @@ -101,7 +101,7 @@ public class TestCatalogMaintenance {
@Inject MaintenanceService maintenance;
@Inject MutableMonotonicClock mutableMonotonicClock;

@Inject PolarisConfigurationStore configurationStore;
@Inject RealmConfigurationSource configurationSource;
@Inject CacheBackend cacheBackend;
@Inject RealmPersistenceFactory realmPersistenceFactory;

Expand Down Expand Up @@ -139,7 +139,7 @@ public void catalogMaintenance() {

var manager = metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext);
var session = metaStoreManagerFactory.getOrCreateSession(realmContext);
var callCtx = new PolarisCallContext(realmContext, session, configurationStore);
var callCtx = new PolarisCallContext(realmContext, session, configurationSource);

var persistence =
realmPersistenceFactory.newBuilder().realmId(realmId).skipDecorators().build();
Expand Down Expand Up @@ -455,7 +455,7 @@ private void checkEntities(String step, List<PolarisBaseEntity> entities) {

var manager = metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext);
var session = metaStoreManagerFactory.getOrCreateSession(realmContext);
var callCtx = new PolarisCallContext(realmContext, session, configurationStore);
var callCtx = new PolarisCallContext(realmContext, session, configurationSource);

for (var e : entities) {
var result =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.UUID;
import org.apache.iceberg.catalog.Namespace;
import org.apache.polaris.core.PolarisCallContext;
import org.apache.polaris.core.config.PolarisConfigurationStore;
import org.apache.polaris.core.config.RealmConfigurationSource;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.NamespaceEntity;
import org.apache.polaris.core.entity.PolarisBaseEntity;
Expand Down Expand Up @@ -70,7 +70,7 @@ public class TestNoSqlMetaStoreManager extends BasePolarisMetaStoreManagerTest {
@Identifier("nosql")
MetaStoreManagerFactory metaStoreManagerFactory;

@Inject PolarisConfigurationStore configurationStore;
@Inject RealmConfigurationSource configurationSource;
@Inject MonotonicClock monotonicClock;

String realmId;
Expand All @@ -91,7 +91,7 @@ protected PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() {
var manager = metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext);
var session = metaStoreManagerFactory.getOrCreateSession(realmContext);

var callCtx = new PolarisCallContext(realmContext, session, configurationStore);
var callCtx = new PolarisCallContext(realmContext, session, configurationSource);

return new PolarisTestMetaStoreManager(manager, callCtx, startTime, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.List;
import java.util.UUID;
import org.apache.polaris.core.PolarisCallContext;
import org.apache.polaris.core.config.PolarisConfigurationStore;
import org.apache.polaris.core.config.RealmConfigurationSource;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.PolarisGrantRecord;
import org.apache.polaris.core.persistence.BaseResolverTest;
Expand All @@ -48,7 +48,7 @@ public class TestNoSqlResolver extends BaseResolverTest {
@Identifier("nosql")
MetaStoreManagerFactory metaStoreManagerFactory;

@Inject PolarisConfigurationStore configurationStore;
@Inject RealmConfigurationSource configurationSource;
@Inject MonotonicClock monotonicClock;

PolarisMetaStoreManager metaStoreManager;
Expand All @@ -73,7 +73,7 @@ protected PolarisCallContext callCtx() {
metaStoreManager = metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext);
var session = metaStoreManagerFactory.getOrCreateSession(realmContext);

callCtx = new PolarisCallContext(realmContext, session, configurationStore);
callCtx = new PolarisCallContext(realmContext, session, configurationSource);

tm = new PolarisTestMetaStoreManager(metaStoreManager, callCtx, startTime, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.time.Clock;
import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
import org.apache.polaris.core.PolarisDiagnostics;
import org.apache.polaris.core.config.PolarisConfigurationStore;
import org.apache.polaris.core.config.RealmConfigurationSource;
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
import org.apache.polaris.core.storage.PolarisStorageIntegration;
import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;
Expand All @@ -44,8 +44,8 @@ PolarisStorageIntegration<T> getStorageIntegrationForConfig(
}

@Produces
PolarisConfigurationStore producePolarisConfigurationStore() {
return new PolarisConfigurationStore() {};
RealmConfigurationSource produceRealmConfigurationSource() {
return RealmConfigurationSource.EMPTY_CONFIG;
}

@Produces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package org.apache.polaris.core;

import jakarta.annotation.Nonnull;
import org.apache.polaris.core.config.PolarisConfigurationStore;
import org.apache.polaris.core.config.RealmConfig;
import org.apache.polaris.core.config.RealmConfigImpl;
import org.apache.polaris.core.config.RealmConfigurationSource;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.persistence.BasePersistence;
Expand All @@ -34,23 +34,36 @@ public class PolarisCallContext implements CallContext {

// meta store which is used to persist Polaris entity metadata
private final BasePersistence metaStore;
private final PolarisConfigurationStore configurationStore;
private final RealmConfigurationSource configurationSource;
private final RealmContext realmContext;
private final RealmConfig realmConfig;

/**
* @deprecated Use {@link PolarisCallContext#PolarisCallContext(RealmContext, BasePersistence,
* RealmConfigurationSource)}.
*/
@SuppressWarnings("removal")
@Deprecated(forRemoval = true)
public PolarisCallContext(
@Nonnull RealmContext realmContext,
@Nonnull BasePersistence metaStore,
@Nonnull PolarisConfigurationStore configurationStore) {
@Nonnull org.apache.polaris.core.config.PolarisConfigurationStore configurationStore) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: avoiding imports because IntelliJ warns about deprecation on the import statement and that warning cannot be suppressed 🤷

Copy link
Member

Choose a reason for hiding this comment

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

IntelliJ warns about deprecation on the import statement

This is strange, because that Java 8 legacy was removed via JEP 211.

this(realmContext, metaStore, configurationStore::getConfiguration);
}

public PolarisCallContext(
@Nonnull RealmContext realmContext,
@Nonnull BasePersistence metaStore,
@Nonnull RealmConfigurationSource configurationSource) {
this.realmContext = realmContext;
this.metaStore = metaStore;
this.configurationStore = configurationStore;
this.realmConfig = new RealmConfigImpl(this.configurationStore, this.realmContext);
this.configurationSource = configurationSource;
this.realmConfig = new RealmConfigImpl(this.configurationSource, this.realmContext);
}

public PolarisCallContext(
@Nonnull RealmContext realmContext, @Nonnull BasePersistence metaStore) {
this(realmContext, metaStore, new PolarisConfigurationStore() {});
this(realmContext, metaStore, RealmConfigurationSource.EMPTY_CONFIG);
}

public BasePersistence getMetaStore() {
Expand Down Expand Up @@ -81,6 +94,6 @@ public PolarisCallContext copy() {
// copy of the RealmContext to ensure the access during the task executor.
String realmId = this.realmContext.getRealmIdentifier();
RealmContext realmContext = () -> realmId;
return new PolarisCallContext(realmContext, this.metaStore, this.configurationStore);
return new PolarisCallContext(realmContext, this.metaStore, this.configurationSource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
*/
package org.apache.polaris.core.config;

import com.google.common.base.Preconditions;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.CatalogEntity;
Expand All @@ -32,7 +29,11 @@
/**
* Dynamic configuration store used to retrieve runtime parameters, which may vary by realm or by
* request.
*
* @deprecated Use {@link RealmConfig} instead.
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated(forRemoval = true)
public interface PolarisConfigurationStore {
Logger LOGGER = LoggerFactory.getLogger(PolarisConfigurationStore.class);

Expand All @@ -58,35 +59,10 @@ public interface PolarisConfigurationStore {
* @return the current value or the supplied default value
* @param <T> the type of the configuration value
*/
@SuppressWarnings("removal")
default <T> @Nonnull T getConfiguration(
@Nonnull RealmContext realmContext, String configName, @Nonnull T defaultValue) {
Preconditions.checkNotNull(defaultValue, "Cannot pass null as a default value");
T configValue = getConfiguration(realmContext, configName);
return configValue != null ? configValue : defaultValue;
}

/**
* In some cases, we may extract a value that doesn't match the expected type for a config. This
* method can be used to attempt to force-cast it using `String.valueOf`
*/
private <T> @Nonnull T tryCast(PolarisConfiguration<T> config, Object value) {
if (value == null) {
return config.defaultValue();
}

if (config.defaultValue() instanceof Boolean) {
return config.cast(Boolean.valueOf(String.valueOf(value)));
} else if (config.defaultValue() instanceof Integer) {
return config.cast(Integer.valueOf(String.valueOf(value)));
} else if (config.defaultValue() instanceof Long) {
return config.cast(Long.valueOf(String.valueOf(value)));
} else if (config.defaultValue() instanceof Double) {
return config.cast(Double.valueOf(String.valueOf(value)));
} else if (config.defaultValue() instanceof List<?>) {
return config.cast(new ArrayList<>((List<?>) value));
} else {
return config.cast(value);
}
return asRealmConfig(realmContext).getConfig(configName, defaultValue);
}

/**
Expand All @@ -99,8 +75,7 @@ public interface PolarisConfigurationStore {
*/
default <T> @Nonnull T getConfiguration(
@Nonnull RealmContext realmContext, PolarisConfiguration<T> config) {
T result = getConfiguration(realmContext, config.key(), config.defaultValue());
return tryCast(config, result);
return asRealmConfig(realmContext).getConfig(config);
}

/**
Expand Down Expand Up @@ -138,26 +113,10 @@ public interface PolarisConfigurationStore {
@Nonnull RealmContext realmContext,
@Nonnull Map<String, String> catalogProperties,
PolarisConfiguration<T> config) {
if (config.hasCatalogConfig() || config.hasCatalogConfigUnsafe()) {
String propertyValue = null;
if (config.hasCatalogConfig()) {
propertyValue = catalogProperties.get(config.catalogConfig());
}
if (propertyValue == null) {
if (config.hasCatalogConfigUnsafe()) {
propertyValue = catalogProperties.get(config.catalogConfigUnsafe());
}
if (propertyValue != null) {
LOGGER.warn(
String.format(
"Deprecated config %s is in use and will be removed in a future version",
config.catalogConfigUnsafe()));
}
}
if (propertyValue != null) {
return tryCast(config, propertyValue);
}
}
return getConfiguration(realmContext, config);
return asRealmConfig(realmContext).getConfig(config, catalogProperties);
}

private RealmConfig asRealmConfig(RealmContext realmContext) {
return new RealmConfigImpl(this::getConfiguration, realmContext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface RealmConfig {
* @return the current value set for the configuration key, or null if not set
* @deprecated Use typed {@link #getConfig(PolarisConfiguration)} instead.
*/
@Deprecated
@Deprecated(forRemoval = true)
<T> @Nullable T getConfig(String configName);

/**
Expand All @@ -44,7 +44,9 @@ public interface RealmConfig {
* @param configName the name of the configuration key to check
* @param defaultValue the default value if the configuration key has no value
* @return the current value or the supplied default value
* @deprecated Use typed {@link #getConfig(PolarisConfiguration)} instead.
*/
@Deprecated(forRemoval = true)
<T> T getConfig(String configName, T defaultValue);

/**
Expand Down
Loading