nevzheng commented on code in PR #12133:
URL: https://github.com/apache/gravitino/pull/12133#discussion_r3651959772
##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -586,58 +613,75 @@ public void start() {
public void shutdown() {
LOG.info("Shutting down Gravitino Environment...");
- if (entityStore != null) {
- try {
- entityStore.close();
- } catch (Exception e) {
- LOG.warn("Failed to close EntityStore.", e);
+ try {
Review Comment:
issue: Wrapping the entire existing shutdown sequence in `try`/`finally`
creates a large diff in unrelated component lifecycle code and gives KMS
cleanup a stronger failure guarantee than the other components currently
receive. Please leave the existing shutdown flow unchanged and close the
registry once at the end. A holistic always-close lifecycle refactor should be
separate.
##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -207,7 +210,13 @@ public void initializeBaseComponents(Config config) {
this.config = config;
FileFetcher.get().initialize(config.get(Configs.BLOCK_UNSAFE_REMOTE_URI));
this.manageFullComponents = false;
- initBaseComponents();
+ this.kmsClientRegistry = new KmsClientRegistry(config);
+ try {
Review Comment:
suggestion: Can we simplify how `KmsClientRegistry` is added to
`GravitinoEnv`? Registering one owned component now duplicates `try`/`catch`
rollback blocks in both initialization paths, which feels disproportionate and
unlike the nearby component initialization. Please keep the lifecycle change
consistent with the existing environment pattern and minimize KMS-specific
control flow.
##########
core/src/main/java/org/apache/gravitino/encryption/kms/KmsConfig.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * 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.gravitino.encryption.kms;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.gravitino.Config;
+
+final class KmsConfig {
+
+ static final String KMS_CONFIG_PREFIX = "gravitino.kms.";
+ static final String KMS_SOURCES = KMS_CONFIG_PREFIX + "sources";
+
+ private static final String SOURCES = "sources";
+ private static final String SOURCE_PREFIX = "source.";
+ private static final String API = "api";
+ private static final Pattern SOURCE_NAME_PATTERN =
Pattern.compile("[A-Za-z0-9][A-Za-z0-9_-]*");
+ private static final Pattern SOURCE_PROPERTY_PATTERN =
Review Comment:
suggestion: Can we simplify this parser? The grammar is only `sources` plus
`source.<name>.<property>`, but the regex-based structural parsing and multiple
passes make it harder to follow. Please keep the small source-name validation,
parse hierarchical keys with `startsWith`/`indexOf`/`substring`, and build each
source property map in one pass while preserving malformed and unlisted-key
checks.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]