Skip to content

Commit 14f5305

Browse files
authored
NoSQL: Prepare admin-tool (#3134)
No functional changes. 1. Refactor the configuration property to a configuration type. 2. Make `BaseCommand` suitable for non-meta-store-factory use cases.
1 parent caf568e commit 14f5305

File tree

7 files changed

+65
-11
lines changed

7 files changed

+65
-11
lines changed

runtime/admin/src/main/java/org/apache/polaris/admintool/BaseCommand.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
*/
1919
package org.apache.polaris.admintool;
2020

21-
import jakarta.inject.Inject;
2221
import java.util.concurrent.Callable;
23-
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
2422
import picocli.CommandLine.Model.CommandSpec;
2523
import picocli.CommandLine.Spec;
2624

@@ -30,7 +28,5 @@ public abstract class BaseCommand implements Callable<Integer> {
3028
public static final int EXIT_CODE_BOOTSTRAP_ERROR = 3;
3129
public static final int EXIT_CODE_PURGE_ERROR = 4;
3230

33-
@Inject MetaStoreManagerFactory metaStoreManagerFactory;
34-
35-
@Spec CommandSpec spec;
31+
@Spec protected CommandSpec spec;
3632
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.admintool;
20+
21+
import jakarta.inject.Inject;
22+
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
23+
24+
public abstract class BaseMetaStoreCommand extends BaseCommand {
25+
@Inject protected MetaStoreManagerFactory metaStoreManagerFactory;
26+
}

runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
name = "bootstrap",
3434
mixinStandardHelpOptions = true,
3535
description = "Bootstraps realms and root principal credentials.")
36-
public class BootstrapCommand extends BaseCommand {
36+
public class BootstrapCommand extends BaseMetaStoreCommand {
3737

3838
@CommandLine.Mixin InputOptions inputOptions;
3939

runtime/admin/src/main/java/org/apache/polaris/admintool/PolarisAdminTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
BootstrapCommand.class,
3333
PurgeCommand.class,
3434
})
35-
public class PolarisAdminTool extends BaseCommand {
35+
public class PolarisAdminTool extends BaseMetaStoreCommand {
3636

3737
@Override
3838
public Integer call() {

runtime/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
name = "purge",
2727
mixinStandardHelpOptions = true,
2828
description = "Purge realms and all associated entities.")
29-
public class PurgeCommand extends BaseCommand {
29+
public class PurgeCommand extends BaseMetaStoreCommand {
3030

3131
@CommandLine.Option(
3232
names = {"-r", "--realm"},

runtime/admin/src/main/java/org/apache/polaris/admintool/config/AdminToolProducers.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@
3232
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
3333
import org.apache.polaris.core.storage.PolarisStorageIntegration;
3434
import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;
35-
import org.eclipse.microprofile.config.inject.ConfigProperty;
3635

3736
public class AdminToolProducers {
3837

3938
@Produces
4039
public MetaStoreManagerFactory metaStoreManagerFactory(
41-
@ConfigProperty(name = "polaris.persistence.type") String persistenceType,
40+
QuarkusPersistenceConfiguration persistenceConfiguration,
4241
@Any Instance<MetaStoreManagerFactory> metaStoreManagerFactories) {
43-
return metaStoreManagerFactories.select(Identifier.Literal.of(persistenceType)).get();
42+
return metaStoreManagerFactories
43+
.select(Identifier.Literal.of(persistenceConfiguration.type()))
44+
.get();
4445
}
4546

4647
@Produces
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.admintool.config;
20+
21+
import io.smallrye.config.ConfigMapping;
22+
23+
@ConfigMapping(prefix = "polaris.persistence")
24+
public interface QuarkusPersistenceConfiguration {
25+
26+
/**
27+
* The type of the persistence to use. Must be a registered {@link
28+
* org.apache.polaris.core.persistence.MetaStoreManagerFactory} identifier.
29+
*/
30+
String type();
31+
}

0 commit comments

Comments
 (0)