From f300dc870df800fae1699ce675ef57fbd8c0307a Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Mon, 24 Nov 2025 09:30:02 +0100 Subject: [PATCH] NoSQL: Prepare admin-tool No functional changes. 1. Refactor the configuration property to a configuration type. 2. Make `BaseCommand` suitable for non-meta-store-factory use cases. --- .../apache/polaris/admintool/BaseCommand.java | 6 +--- .../admintool/BaseMetaStoreCommand.java | 26 ++++++++++++++++ .../polaris/admintool/BootstrapCommand.java | 2 +- .../polaris/admintool/PolarisAdminTool.java | 2 +- .../polaris/admintool/PurgeCommand.java | 2 +- .../admintool/config/AdminToolProducers.java | 7 +++-- .../QuarkusPersistenceConfiguration.java | 31 +++++++++++++++++++ 7 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 runtime/admin/src/main/java/org/apache/polaris/admintool/BaseMetaStoreCommand.java create mode 100644 runtime/admin/src/main/java/org/apache/polaris/admintool/config/QuarkusPersistenceConfiguration.java diff --git a/runtime/admin/src/main/java/org/apache/polaris/admintool/BaseCommand.java b/runtime/admin/src/main/java/org/apache/polaris/admintool/BaseCommand.java index c56fe97169..00c8f7e01b 100644 --- a/runtime/admin/src/main/java/org/apache/polaris/admintool/BaseCommand.java +++ b/runtime/admin/src/main/java/org/apache/polaris/admintool/BaseCommand.java @@ -18,9 +18,7 @@ */ package org.apache.polaris.admintool; -import jakarta.inject.Inject; import java.util.concurrent.Callable; -import org.apache.polaris.core.persistence.MetaStoreManagerFactory; import picocli.CommandLine.Model.CommandSpec; import picocli.CommandLine.Spec; @@ -30,7 +28,5 @@ public abstract class BaseCommand implements Callable { public static final int EXIT_CODE_BOOTSTRAP_ERROR = 3; public static final int EXIT_CODE_PURGE_ERROR = 4; - @Inject MetaStoreManagerFactory metaStoreManagerFactory; - - @Spec CommandSpec spec; + @Spec protected CommandSpec spec; } diff --git a/runtime/admin/src/main/java/org/apache/polaris/admintool/BaseMetaStoreCommand.java b/runtime/admin/src/main/java/org/apache/polaris/admintool/BaseMetaStoreCommand.java new file mode 100644 index 0000000000..5a28b54799 --- /dev/null +++ b/runtime/admin/src/main/java/org/apache/polaris/admintool/BaseMetaStoreCommand.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.admintool; + +import jakarta.inject.Inject; +import org.apache.polaris.core.persistence.MetaStoreManagerFactory; + +public abstract class BaseMetaStoreCommand extends BaseCommand { + @Inject protected MetaStoreManagerFactory metaStoreManagerFactory; +} diff --git a/runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java b/runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java index bfa59fab8d..82d92f4e18 100644 --- a/runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java +++ b/runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java @@ -33,7 +33,7 @@ name = "bootstrap", mixinStandardHelpOptions = true, description = "Bootstraps realms and root principal credentials.") -public class BootstrapCommand extends BaseCommand { +public class BootstrapCommand extends BaseMetaStoreCommand { @CommandLine.Mixin InputOptions inputOptions; diff --git a/runtime/admin/src/main/java/org/apache/polaris/admintool/PolarisAdminTool.java b/runtime/admin/src/main/java/org/apache/polaris/admintool/PolarisAdminTool.java index 2cb03f07c6..66ddaf0547 100644 --- a/runtime/admin/src/main/java/org/apache/polaris/admintool/PolarisAdminTool.java +++ b/runtime/admin/src/main/java/org/apache/polaris/admintool/PolarisAdminTool.java @@ -32,7 +32,7 @@ BootstrapCommand.class, PurgeCommand.class, }) -public class PolarisAdminTool extends BaseCommand { +public class PolarisAdminTool extends BaseMetaStoreCommand { @Override public Integer call() { diff --git a/runtime/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java b/runtime/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java index 600ae0b1a5..772d311d6b 100644 --- a/runtime/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java +++ b/runtime/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java @@ -26,7 +26,7 @@ name = "purge", mixinStandardHelpOptions = true, description = "Purge realms and all associated entities.") -public class PurgeCommand extends BaseCommand { +public class PurgeCommand extends BaseMetaStoreCommand { @CommandLine.Option( names = {"-r", "--realm"}, diff --git a/runtime/admin/src/main/java/org/apache/polaris/admintool/config/AdminToolProducers.java b/runtime/admin/src/main/java/org/apache/polaris/admintool/config/AdminToolProducers.java index e6251b2c88..28a43a6c37 100644 --- a/runtime/admin/src/main/java/org/apache/polaris/admintool/config/AdminToolProducers.java +++ b/runtime/admin/src/main/java/org/apache/polaris/admintool/config/AdminToolProducers.java @@ -32,15 +32,16 @@ import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo; import org.apache.polaris.core.storage.PolarisStorageIntegration; import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider; -import org.eclipse.microprofile.config.inject.ConfigProperty; public class AdminToolProducers { @Produces public MetaStoreManagerFactory metaStoreManagerFactory( - @ConfigProperty(name = "polaris.persistence.type") String persistenceType, + QuarkusPersistenceConfiguration persistenceConfiguration, @Any Instance metaStoreManagerFactories) { - return metaStoreManagerFactories.select(Identifier.Literal.of(persistenceType)).get(); + return metaStoreManagerFactories + .select(Identifier.Literal.of(persistenceConfiguration.type())) + .get(); } @Produces diff --git a/runtime/admin/src/main/java/org/apache/polaris/admintool/config/QuarkusPersistenceConfiguration.java b/runtime/admin/src/main/java/org/apache/polaris/admintool/config/QuarkusPersistenceConfiguration.java new file mode 100644 index 0000000000..9e1960d78a --- /dev/null +++ b/runtime/admin/src/main/java/org/apache/polaris/admintool/config/QuarkusPersistenceConfiguration.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.admintool.config; + +import io.smallrye.config.ConfigMapping; + +@ConfigMapping(prefix = "polaris.persistence") +public interface QuarkusPersistenceConfiguration { + + /** + * The type of the persistence to use. Must be a registered {@link + * org.apache.polaris.core.persistence.MetaStoreManagerFactory} identifier. + */ + String type(); +}