-
Notifications
You must be signed in to change notification settings - Fork 462
Support shared RocksDB rate limiter in Fluss #2178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5c5bd6a
Support shared RocksDB rate limiter in Fluss
platinumhamburg 1717086
support generic flink procedure
platinumhamburg 83e7b14
fix flink procedure test case
platinumhamburg a1aeae3
refactor code
platinumhamburg 0b6f1c8
rebase merge conflict
platinumhamburg 8a3b7bb
improve document
platinumhamburg 90daef3
fix validation logic and unit test
platinumhamburg e5eeb03
improve document
platinumhamburg e3f0c6c
refactor code & fix document link
platinumhamburg 3081e71
fix document
platinumhamburg 8e88882
fix docs
wuchong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
fluss-common/src/main/java/org/apache/fluss/config/cluster/ConfigValidator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /* | ||
| * 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.fluss.config.cluster; | ||
|
|
||
| import org.apache.fluss.annotation.PublicEvolving; | ||
| import org.apache.fluss.exception.ConfigException; | ||
|
|
||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Validator for a single dynamic configuration key. | ||
| * | ||
| * <p>Unlike {@link ServerReconfigurable}, validators are stateless and only perform validation | ||
| * logic without requiring component instances. This allows coordinators to validate configurations | ||
| * for components they don't run (e.g., KvManager). | ||
| * | ||
| * <p>Example use case: CoordinatorServer needs to validate KV-related configurations even though it | ||
| * doesn't have a KvManager instance. A {@link ConfigValidator} can be registered on both | ||
| * CoordinatorServer (for validation) and TabletServer (for both validation and actual | ||
| * reconfiguration via {@link ServerReconfigurable}). | ||
| * | ||
| * <p>Each validator monitors a single configuration key. The validator will only be invoked when | ||
| * that specific key changes, improving validation efficiency. | ||
| * | ||
| * <p>This interface is designed to be stateless and thread-safe. Implementations should not rely on | ||
| * any mutable component state. | ||
| * | ||
| * <p><b>Type-safe validation:</b> The validator receives strongly-typed values that have already | ||
| * been parsed and validated for basic type correctness. This avoids redundant string parsing and | ||
| * allows validators to focus on business logic validation. | ||
| * | ||
| * @param <T> the type of the configuration value being validated | ||
| */ | ||
| @PublicEvolving | ||
| public interface ConfigValidator<T> { | ||
|
|
||
| /** | ||
| * Returns the configuration key this validator monitors. | ||
| * | ||
| * <p>The validator will only be invoked when this specific configuration key changes. This | ||
| * allows efficient filtering of validators and clear declaration of dependencies. | ||
| * | ||
| * @return the configuration key to monitor, must not be null or empty | ||
| */ | ||
| String configKey(); | ||
|
|
||
| /** | ||
| * Validates a configuration value change. | ||
| * | ||
| * <p>This method is called when the monitored configuration key changes. It should check | ||
| * whether the new value is valid, potentially considering the old value and validation rules. | ||
| * | ||
| * <p>The method should be stateless and deterministic - given the same old and new values, it | ||
| * should always produce the same validation result. | ||
| * | ||
| * @param oldValue the previous value of the configuration key, null if the key was not set | ||
| * before | ||
| * @param newValue the new value of the configuration key, null if the key is being deleted | ||
| * @throws ConfigException if the configuration change is invalid, with a descriptive error | ||
| * message explaining why the change cannot be applied | ||
| */ | ||
| void validate(@Nullable T oldValue, @Nullable T newValue) throws ConfigException; | ||
| } |
111 changes: 111 additions & 0 deletions
111
...link-common/src/main/java/org/apache/fluss/flink/procedure/GetClusterConfigProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /* | ||
| * 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.fluss.flink.procedure; | ||
|
|
||
| import org.apache.fluss.config.cluster.ConfigEntry; | ||
|
|
||
| import org.apache.flink.table.annotation.ArgumentHint; | ||
| import org.apache.flink.table.annotation.DataTypeHint; | ||
| import org.apache.flink.table.annotation.ProcedureHint; | ||
| import org.apache.flink.table.procedure.ProcedureContext; | ||
| import org.apache.flink.types.Row; | ||
|
|
||
| import javax.annotation.Nullable; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Procedure to get cluster configuration(s). | ||
| * | ||
| * <p>This procedure allows querying dynamic cluster configurations. It can retrieve: | ||
| * | ||
| * <ul> | ||
| * <li>A specific configuration key | ||
| * <li>All configurations (when key parameter is null or empty) | ||
| * </ul> | ||
| * | ||
| * <p>Usage examples: | ||
| * | ||
| * <pre> | ||
| * -- Get a specific configuration | ||
| * CALL sys.get_cluster_config('kv.rocksdb.shared-rate-limiter.bytes-per-sec'); | ||
| * | ||
| * -- Get all cluster configurations | ||
| * CALL sys.get_cluster_config(); | ||
| * </pre> | ||
| */ | ||
| public class GetClusterConfigProcedure extends ProcedureBase { | ||
|
|
||
| @ProcedureHint( | ||
| output = | ||
| @DataTypeHint( | ||
| "ROW<config_key STRING, config_value STRING, config_source STRING>")) | ||
| public Row[] call(ProcedureContext context) throws Exception { | ||
| return getConfigs(null); | ||
| } | ||
|
|
||
| @ProcedureHint( | ||
| argument = {@ArgumentHint(name = "config_key", type = @DataTypeHint("STRING"))}, | ||
| output = | ||
| @DataTypeHint( | ||
| "ROW<config_key STRING, config_value STRING, config_source STRING>")) | ||
| public Row[] call(ProcedureContext context, String configKey) throws Exception { | ||
| return getConfigs(configKey); | ||
| } | ||
|
|
||
| private Row[] getConfigs(@Nullable String configKey) throws Exception { | ||
| try { | ||
| // Get all cluster configurations | ||
| Collection<ConfigEntry> configs = admin.describeClusterConfigs().get(); | ||
|
|
||
| List<Row> results = new ArrayList<>(); | ||
|
|
||
| if (configKey == null || configKey.isEmpty()) { | ||
| // Return all configurations | ||
| for (ConfigEntry entry : configs) { | ||
| results.add( | ||
| Row.of( | ||
| entry.key(), | ||
| entry.value(), | ||
| entry.source() != null ? entry.source().name() : "UNKNOWN")); | ||
| } | ||
| } else { | ||
| // Find specific configuration | ||
| for (ConfigEntry entry : configs) { | ||
| if (entry.key().equals(configKey)) { | ||
| results.add( | ||
| Row.of( | ||
| entry.key(), | ||
| entry.value(), | ||
| entry.source() != null | ||
| ? entry.source().name() | ||
| : "UNKNOWN")); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return results.toArray(new Row[0]); | ||
|
|
||
| } catch (Exception e) { | ||
| throw new RuntimeException("Failed to get cluster config: " + e.getMessage(), e); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.