You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "adutra (via GitHub)" <gi...@apache.org> on 2025/01/27 17:40:48 UTC

[PR] MetaStoreManagerFactory API improvements [polaris]

adutra opened a new pull request, #889:
URL: https://github.com/apache/polaris/pull/889

   This PR brings a few improvements to `MetaStoreManagerFactory` API:
   
   - use `RealmId` consistently rather than a `String`.
   - make the `purgeRealms` method return the purge results.
   
   This PR also touches a few places that are indirectly affected by this change:
   
   - Realm context configuration (see QuarkusRealmContextConfiguration)
   - Purge and Bootstrap commands in the admin tool
   
   These changes are a prerequisite for #878 and #887.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on PR #889:
URL: https://github.com/apache/polaris/pull/889#issuecomment-2618938915

   @collado-mike @eric-maynard @snazy 
   
   Since the mailing list discussion around RealmId is still ongoing, and given that you raised concerns about using `RealmId` as map keys or set elements:
   
   Would it be better for you if we keep using String ids in the bootstrap/purge parts of the `MetaStoreManagerFactory` API?
   
   I think I could make it work. The only change I really need to keep working on #887 is that `purgeRealms` should return the purge results.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory: make purgeRealms() return purge results [polaris]

Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1942033766


##########
quarkus/admin/src/main/java/org/apache/polaris/admintool/RealmIdConverter.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.polaris.core.context.RealmId;
+import picocli.CommandLine.ITypeConverter;
+
+public class RealmIdConverter implements ITypeConverter<RealmId> {

Review Comment:
   I see, and what does _that_ do?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931048685


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java:
##########
@@ -96,37 +97,40 @@ private void initializeForRealm(
   }
 
   @Override
-  public synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
-      List<String> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
-    Map<String, PrincipalSecretsResult> results = new HashMap<>();
-
-    for (String realm : realms) {
-      RealmId realmId = RealmId.newRealmId(realm);
-      if (!metaStoreManagerMap.containsKey(realmId.id())) {
-        initializeForRealm(realmId, credentialsBootstrap);
+  public synchronized Map<RealmId, PrincipalSecretsResult> bootstrapRealms(
+      List<RealmId> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
+    Map<RealmId, PrincipalSecretsResult> results = new HashMap<>();
+
+    for (RealmId realm : realms) {
+      if (!metaStoreManagerMap.containsKey(realm.id())) {
+        initializeForRealm(realm, credentialsBootstrap);
         PrincipalSecretsResult secretsResult =
             bootstrapServiceAndCreatePolarisPrincipalForRealm(
-                realmId, metaStoreManagerMap.get(realmId.id()));
-        results.put(realmId.id(), secretsResult);
+                realm, metaStoreManagerMap.get(realm.id()));
+        results.put(ImmutableRealmId.copyOf(realm), secretsResult);

Review Comment:
   why copying? it's immutable



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on PR #889:
URL: https://github.com/apache/polaris/pull/889#issuecomment-2621076623

   > Would it be better for you if we keep using String ids in the bootstrap/purge parts of the `MetaStoreManagerFactory` API?
   
   WFM


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931139504


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java:
##########
@@ -96,37 +97,40 @@ private void initializeForRealm(
   }
 
   @Override
-  public synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
-      List<String> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
-    Map<String, PrincipalSecretsResult> results = new HashMap<>();
-
-    for (String realm : realms) {
-      RealmId realmId = RealmId.newRealmId(realm);
-      if (!metaStoreManagerMap.containsKey(realmId.id())) {
-        initializeForRealm(realmId, credentialsBootstrap);
+  public synchronized Map<RealmId, PrincipalSecretsResult> bootstrapRealms(
+      List<RealmId> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
+    Map<RealmId, PrincipalSecretsResult> results = new HashMap<>();
+
+    for (RealmId realm : realms) {
+      if (!metaStoreManagerMap.containsKey(realm.id())) {
+        initializeForRealm(realm, credentialsBootstrap);
         PrincipalSecretsResult secretsResult =
             bootstrapServiceAndCreatePolarisPrincipalForRealm(
-                realmId, metaStoreManagerMap.get(realmId.id()));
-        results.put(realmId.id(), secretsResult);
+                realm, metaStoreManagerMap.get(realm.id()));
+        results.put(ImmutableRealmId.copyOf(realm), secretsResult);

Review Comment:
   It's `RequestScoped`, so I think it can get lost.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "collado-mike (via GitHub)" <gi...@apache.org>.
collado-mike commented on PR #889:
URL: https://github.com/apache/polaris/pull/889#issuecomment-2627864884

   > Would it be better for you if we keep using String ids in the bootstrap/purge parts of the `MetaStoreManagerFactory` API?
   
   I certainly like typed keys over String keys, but my worry is that it will be too easy to make mistakes. If it was a POJO, I'd say use the typed key, but I don't think people should have to wonder about whether a Realm passed in as a method argument was originally a CDI bean or if it's safe to use.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory: make purgeRealms() return purge results [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra merged PR #889:
URL: https://github.com/apache/polaris/pull/889


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931242636


##########
quarkus/admin/src/main/java/org/apache/polaris/admintool/RealmIdConverter.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.polaris.core.context.RealmId;
+import picocli.CommandLine.ITypeConverter;
+
+public class RealmIdConverter implements ITypeConverter<RealmId> {

Review Comment:
   It's used by Picocli to automatically convert Strings to RealmId. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory: make purgeRealms() return purge results [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1942419966


##########
quarkus/admin/src/main/java/org/apache/polaris/admintool/RealmIdConverter.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.polaris.core.context.RealmId;
+import picocli.CommandLine.ITypeConverter;
+
+public class RealmIdConverter implements ITypeConverter<RealmId> {

Review Comment:
   It's removed anyways.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931139944


##########
quarkus/admin/src/main/java/org/apache/polaris/admintool/RealmIdConverter.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.polaris.core.context.RealmId;
+import picocli.CommandLine.ITypeConverter;
+
+public class RealmIdConverter implements ITypeConverter<RealmId> {

Review Comment:
   This class seems like it does nothing



##########
quarkus/service/src/main/java/org/apache/polaris/service/quarkus/context/RealmIdConverter.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.service.quarkus.context;
+
+import org.apache.polaris.core.context.RealmId;
+import org.eclipse.microprofile.config.spi.Converter;
+
+public class RealmIdConverter implements Converter<RealmId> {

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931140759


##########
service/common/src/main/java/org/apache/polaris/service/persistence/InMemoryPolarisMetaStoreManagerFactory.java:
##########
@@ -95,25 +95,25 @@ public synchronized PolarisMetaStoreManager getOrCreateMetaStoreManager(RealmId
   public synchronized Supplier<PolarisMetaStoreSession> getOrCreateSessionSupplier(
       RealmId realmId) {
     if (!bootstrappedRealms.contains(realmId.id())) {
-      bootstrapRealmsAndPrintCredentials(List.of(realmId.id()));
+      bootstrapRealmsAndPrintCredentials(List.of(realmId));
     }
     return super.getOrCreateSessionSupplier(realmId);
   }
 
-  private void bootstrapRealmsAndPrintCredentials(List<String> realms) {
+  private void bootstrapRealmsAndPrintCredentials(List<RealmId> realms) {
     PolarisCredentialsBootstrap credentialsBootstrap =
         PolarisCredentialsBootstrap.fromEnvironment();
-    Map<String, PrincipalSecretsResult> results =
+    Map<RealmId, PrincipalSecretsResult> results =
         this.bootstrapRealms(realms, credentialsBootstrap);
-    bootstrappedRealms.addAll(realms);
 
-    for (String realmId : realms) {
-      PrincipalSecretsResult principalSecrets = results.get(realmId);
+    for (RealmId realm : results.keySet()) {
+      bootstrappedRealms.add(realm.id());

Review Comment:
   Shouldn't this use `RealmId` not `String`, so we don't need to call `id()`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931241311


##########
service/common/src/main/java/org/apache/polaris/service/persistence/InMemoryPolarisMetaStoreManagerFactory.java:
##########
@@ -95,25 +95,25 @@ public synchronized PolarisMetaStoreManager getOrCreateMetaStoreManager(RealmId
   public synchronized Supplier<PolarisMetaStoreSession> getOrCreateSessionSupplier(
       RealmId realmId) {
     if (!bootstrappedRealms.contains(realmId.id())) {
-      bootstrapRealmsAndPrintCredentials(List.of(realmId.id()));
+      bootstrapRealmsAndPrintCredentials(List.of(realmId));
     }
     return super.getOrCreateSessionSupplier(realmId);
   }
 
-  private void bootstrapRealmsAndPrintCredentials(List<String> realms) {
+  private void bootstrapRealmsAndPrintCredentials(List<RealmId> realms) {
     PolarisCredentialsBootstrap credentialsBootstrap =
         PolarisCredentialsBootstrap.fromEnvironment();
-    Map<String, PrincipalSecretsResult> results =
+    Map<RealmId, PrincipalSecretsResult> results =
         this.bootstrapRealms(realms, credentialsBootstrap);
-    bootstrappedRealms.addAll(realms);
 
-    for (String realmId : realms) {
-      PrincipalSecretsResult principalSecrets = results.get(realmId);
+    for (RealmId realm : results.keySet()) {
+      bootstrappedRealms.add(realm.id());

Review Comment:
   See my previous comment: CDI beans as map keys or set elements would have surprising effects here, notably containsKey() and addAll() wouldn't work as expected. We would need to copy the RealmId each time to be sure. In the end I think it's not worth it since these maps and collections are not public. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on PR #889:
URL: https://github.com/apache/polaris/pull/889#issuecomment-2628930064

   Alright, I reverted the map key changes and went back to String keys.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931822241


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java:
##########
@@ -96,37 +97,40 @@ private void initializeForRealm(
   }
 
   @Override
-  public synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
-      List<String> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
-    Map<String, PrincipalSecretsResult> results = new HashMap<>();
-
-    for (String realm : realms) {
-      RealmId realmId = RealmId.newRealmId(realm);
-      if (!metaStoreManagerMap.containsKey(realmId.id())) {
-        initializeForRealm(realmId, credentialsBootstrap);
+  public synchronized Map<RealmId, PrincipalSecretsResult> bootstrapRealms(
+      List<RealmId> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
+    Map<RealmId, PrincipalSecretsResult> results = new HashMap<>();
+
+    for (RealmId realm : realms) {
+      if (!metaStoreManagerMap.containsKey(realm.id())) {
+        initializeForRealm(realm, credentialsBootstrap);
         PrincipalSecretsResult secretsResult =
             bootstrapServiceAndCreatePolarisPrincipalForRealm(
-                realmId, metaStoreManagerMap.get(realmId.id()));
-        results.put(realmId.id(), secretsResult);
+                realm, metaStoreManagerMap.get(realm.id()));
+        results.put(ImmutableRealmId.copyOf(realm), secretsResult);

Review Comment:
   @eric-maynard @adutra fair point. However, the realm-IDs here are parameters for bootstrap?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931243363


##########
quarkus/service/src/main/java/org/apache/polaris/service/quarkus/context/RealmIdConverter.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.service.quarkus.context;
+
+import org.apache.polaris.core.context.RealmId;
+import org.eclipse.microprofile.config.spi.Converter;
+
+public class RealmIdConverter implements Converter<RealmId> {

Review Comment:
   Same but this one is used by Quarkus / MicroProfile. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory: make purgeRealms() return purge results [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on PR #889:
URL: https://github.com/apache/polaris/pull/889#issuecomment-2676251880

   Rebased again.
   
   @snazy @collado-mike @eric-maynard can an I have another review please?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931917661


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java:
##########
@@ -96,37 +97,40 @@ private void initializeForRealm(
   }
 
   @Override
-  public synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
-      List<String> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
-    Map<String, PrincipalSecretsResult> results = new HashMap<>();
-
-    for (String realm : realms) {
-      RealmId realmId = RealmId.newRealmId(realm);
-      if (!metaStoreManagerMap.containsKey(realmId.id())) {
-        initializeForRealm(realmId, credentialsBootstrap);
+  public synchronized Map<RealmId, PrincipalSecretsResult> bootstrapRealms(
+      List<RealmId> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
+    Map<RealmId, PrincipalSecretsResult> results = new HashMap<>();
+
+    for (RealmId realm : realms) {
+      if (!metaStoreManagerMap.containsKey(realm.id())) {
+        initializeForRealm(realm, credentialsBootstrap);
         PrincipalSecretsResult secretsResult =
             bootstrapServiceAndCreatePolarisPrincipalForRealm(
-                realmId, metaStoreManagerMap.get(realmId.id()));
-        results.put(realmId.id(), secretsResult);
+                realm, metaStoreManagerMap.get(realm.id()));
+        results.put(ImmutableRealmId.copyOf(realm), secretsResult);

Review Comment:
   Unfortunately the `bootstrapRealms` method can be called both from a bootstrap command (in which case `RealmId` is not a CDI proxy) and from "regular" server code (in which case it is a proxy). (The "regular" path only happens with the in-memory metastore though.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "collado-mike (via GitHub)" <gi...@apache.org>.
collado-mike commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931553575


##########
quarkus/admin/src/main/java/org/apache/polaris/admintool/RealmIdConverter.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.polaris.core.context.RealmId;
+import picocli.CommandLine.ITypeConverter;
+
+public class RealmIdConverter implements ITypeConverter<RealmId> {

Review Comment:
   Javadoc comments are extremely helpful for people ramping up on the frameworks being used here



##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java:
##########
@@ -96,37 +97,40 @@ private void initializeForRealm(
   }
 
   @Override
-  public synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
-      List<String> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
-    Map<String, PrincipalSecretsResult> results = new HashMap<>();
-
-    for (String realm : realms) {
-      RealmId realmId = RealmId.newRealmId(realm);
-      if (!metaStoreManagerMap.containsKey(realmId.id())) {
-        initializeForRealm(realmId, credentialsBootstrap);
+  public synchronized Map<RealmId, PrincipalSecretsResult> bootstrapRealms(
+      List<RealmId> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
+    Map<RealmId, PrincipalSecretsResult> results = new HashMap<>();
+
+    for (RealmId realm : realms) {
+      if (!metaStoreManagerMap.containsKey(realm.id())) {
+        initializeForRealm(realm, credentialsBootstrap);
         PrincipalSecretsResult secretsResult =
             bootstrapServiceAndCreatePolarisPrincipalForRealm(
-                realmId, metaStoreManagerMap.get(realmId.id()));
-        results.put(realmId.id(), secretsResult);
+                realm, metaStoreManagerMap.get(realm.id()));
+        results.put(ImmutableRealmId.copyOf(realm), secretsResult);

Review Comment:
   I worry that this is an extremely easy mistake to make. I dislike proxies for this and other reasons. A person has to have a lot of context in their head before they do simple things like add keys to maps.



##########
quarkus/service/src/main/java/org/apache/polaris/service/quarkus/context/RealmIdConverter.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.service.quarkus.context;
+
+import org.apache.polaris.core.context.RealmId;
+import org.eclipse.microprofile.config.spi.Converter;
+
+public class RealmIdConverter implements Converter<RealmId> {

Review Comment:
   Same re: javadoc comments



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory API improvements [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #889:
URL: https://github.com/apache/polaris/pull/889#discussion_r1931237540


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java:
##########
@@ -96,37 +97,40 @@ private void initializeForRealm(
   }
 
   @Override
-  public synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
-      List<String> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
-    Map<String, PrincipalSecretsResult> results = new HashMap<>();
-
-    for (String realm : realms) {
-      RealmId realmId = RealmId.newRealmId(realm);
-      if (!metaStoreManagerMap.containsKey(realmId.id())) {
-        initializeForRealm(realmId, credentialsBootstrap);
+  public synchronized Map<RealmId, PrincipalSecretsResult> bootstrapRealms(
+      List<RealmId> realms, PolarisCredentialsBootstrap credentialsBootstrap) {
+    Map<RealmId, PrincipalSecretsResult> results = new HashMap<>();
+
+    for (RealmId realm : realms) {
+      if (!metaStoreManagerMap.containsKey(realm.id())) {
+        initializeForRealm(realm, credentialsBootstrap);
         PrincipalSecretsResult secretsResult =
             bootstrapServiceAndCreatePolarisPrincipalForRealm(
-                realmId, metaStoreManagerMap.get(realmId.id()));
-        results.put(realmId.id(), secretsResult);
+                realm, metaStoreManagerMap.get(realm.id()));
+        results.put(ImmutableRealmId.copyOf(realm), secretsResult);

Review Comment:
   It's potentially a CDI bean, and these are poor choices as map keys: the CDI specs do not say anything about how CDI proxies should handle equals() and hashCode(). Such beans can have surprising effects when put in a set or a map. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MetaStoreManagerFactory: make purgeRealms() return purge results [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on PR #889:
URL: https://github.com/apache/polaris/pull/889#issuecomment-2633617023

   PR rebased. 
   
   With the revert from `RealmId` back to `RealmContext`, the scope of this PR faded to almost nothing. Indeed, `RealmContext` is even worse than `RealmId` as a map key or set element, because all its instances are just lambdas, and thus do not have any strong contract for `equals()` and `hashCode()`. It is therefore really a bad idea to use those in _any_ collection.
   
   The new scope of this PR is now focused around making the `purgeRealms` method return the purge results.
   
   @snazy @collado-mike @eric-maynard can an I have another review please?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org