Skip to content

KAFKA-18894: Add KIP-877 support for ConfigProvider #14

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

Open
wants to merge 11 commits into
base: trunk
Choose a base branch
from

Conversation

arvi18
Copy link

@arvi18 arvi18 commented Apr 21, 2025

Add KIP-877 support for
ConfigProvider.

Cleanup: Collections.singletonMap() -> Map.of()

Jira: https://issues.apache.org/jira/browse/KAFKA-18894

Summary by CodeRabbit

  • New Features
    • Introduced a monitorable configuration provider with metric registration capabilities.
    • Enhanced worker and plugin systems to support monitorable config providers and associated metrics.
  • Bug Fixes
    • Improved integration of config providers with plugin and metric systems for more robust resource management.
  • Documentation
    • Expanded documentation for config providers, detailing metric registration and tagging.
  • Tests
    • Added and updated tests to verify monitorable config provider integration and metrics registration.
  • Refactor
    • Updated internal handling to use plugin wrappers for config providers throughout the configuration and worker systems.

@arvi18
Copy link
Author

arvi18 commented Apr 21, 2025

Thanks for this patch, please use ./gradlew spotlessApply fix build error

Copy link

coderabbitai bot commented Apr 21, 2025

Walkthrough

This set of changes refactors the handling of configuration providers in the Kafka codebase by introducing the use of Plugin<ConfigProvider> wrappers instead of directly managing ConfigProvider instances. This affects the instantiation, storage, usage, and closure of config providers across core classes and tests. The Plugins class now returns wrapped plugin instances, and all related consumers—including AbstractConfig, ConfigTransformer, WorkerConfigTransformer, and related tests—are updated to expect and operate on these plugin wrappers. Additionally, new documentation and a sample monitorable config provider are introduced, along with enhanced tests for metrics integration.

Changes

File(s) Change Summary
clients/src/main/java/org/apache/kafka/common/config/AbstractConfig.java
clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMakerConfig.java
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfigTransformer.java
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/Plugins.java
Refactored to use Plugin<ConfigProvider> wrappers instead of raw ConfigProvider instances for instantiation, storage, and closure. Updated method signatures, internal logic, and constructor parameters accordingly.
clients/src/main/java/org/apache/kafka/common/config/provider/ConfigProvider.java Extended JavaDoc to include guidance on metrics registration and automatic metric tagging for implementers. No code logic changes.
clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConfigTransformerTest.java
Updated tests to wrap config providers using Plugin.wrapInstance and switched to using Map.of for immutable maps. No changes to test logic or assertions.
clients/src/main/java/org/apache/kafka/common/config/provider/MonitorableConfigProvider.java Introduced a new stub implementation of a monitorable config provider that registers a static metric and implements both ConfigProvider and Monitorable interfaces.
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java Added a new test for monitorable config providers and metrics integration. Enhanced mocking to return wrapped plugin instances and included helper methods for metric assertion.
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginsTest.java Updated an existing test to unwrap plugin instances and added a new test for metrics integration with monitorable config providers. Introduced a custom provider class for testing.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client Code (e.g. Worker)
    participant Plugins as Plugins
    participant Plugin as Plugin<ConfigProvider>
    participant Provider as ConfigProvider

    Client->>Plugins: newConfigProvider(config, providerName, classLoader, metrics)
    Plugins->>Provider: Instantiate provider class
    Plugins->>Provider: Configure with parameters
    Plugins->>Provider: If Monitorable, call withPluginMetrics(metrics)
    Plugins->>Plugin: Plugin.wrapInstance(provider, metrics, ...)
    Plugins-->>Client: Return Plugin<ConfigProvider>

    Client->>Plugin: get() (when needed)
    Plugin-->>Client: Return ConfigProvider instance
    Client->>Provider: Use provider methods (e.g., get, close)
    Client->>Plugin: close() (on shutdown)
Loading

Poem

In the warren of configs, a new wrapper appears,
Plugins now cradle providers, allaying old fears.
With metrics and tags, each provider’s in view,
Monitorable bunnies, reporting what's true.
Tests hop along, checking metrics with care—
A garden of plugins, robust and aware!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.31.1)
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java (1)

109-109: This line still uses Collections.singletonMap instead of Map.of.

This line was not updated to use Map.of() like the other instances in the file.

-        ConfigTransformerResult result = configTransformer.transform(Collections.singletonMap(MY_KEY, null));
+        ConfigTransformerResult result = configTransformer.transform(Map.of(MY_KEY, null));
clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java (1)

98-105: Cache the provider instance once per loop iteration

Inside the inner loop we repeatedly call providerPlugin.get().
Although inexpensive, this does an AtomicReference#get() each time and clutters the hot path.
Grabbing the provider once makes the intent clearer and avoids redundant indirections:

-ConfigData configData = providerPlugin.get().get(path, keys);
+ConfigProvider provider = providerPlugin.get();
+ConfigData configData = provider.get(path, keys);

(NB: no functional change – purely readability & micro‑perf.)

connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfigTransformer.java (1)

100-102: Close the underlying providers, not just the plugin wrapper

Plugin already delegates close() to the wrapped object, so this works today, but
using the wrapper hides possible provider‑specific exceptions and makes stack‑traces
less obvious. Prefer closing the inner provider (and then the wrapper) or at least
logging the provider’s clazz() to aid debugging.

Not blocking – informational only.

clients/src/main/java/org/apache/kafka/common/config/AbstractConfig.java (2)

625-633: Pass the actual class‑loader to Plugin.wrapInstance

Plugin.wrapInstance(provider, null, CONFIG_PROVIDERS_CONFIG) records null
as the plugin’s class‑loader.
Some subsystems (e.g. metrics tagging and class‑loader leak detection) rely on
that field; keeping it null forfeits that information.

-Plugin<ConfigProvider> providerPlugin = Plugin.wrapInstance(provider, null, CONFIG_PROVIDERS_CONFIG);
+Plugin<ConfigProvider> providerPlugin = Plugin.wrapInstance(
+        provider,
+        provider.getClass().getClassLoader(),
+        CONFIG_PROVIDERS_CONFIG);

This is a one‑liner, keeps behaviour unchanged, and improves diagnostics.


550-560: Avoid double close when callers already shut the plugins

resolveConfigVariables closes every provider plugin immediately after use.
Higher‑level callers (e.g. WorkerConfigTransformer) also close the same
plugins in their own close() methods, which is safe but redundant.

Not urgent, yet trimming the extra Utils.closeQuietly here reduces log noise
and makes the lifecycle simpler.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed79212 and b92a2bb.

📒 Files selected for processing (12)
  • clients/src/main/java/org/apache/kafka/common/config/AbstractConfig.java (4 hunks)
  • clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java (3 hunks)
  • clients/src/main/java/org/apache/kafka/common/config/provider/ConfigProvider.java (1 hunks)
  • clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java (5 hunks)
  • clients/src/test/java/org/apache/kafka/common/config/provider/MonitorableConfigProvider.java (1 hunks)
  • connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMakerConfig.java (2 hunks)
  • connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java (1 hunks)
  • connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfigTransformer.java (3 hunks)
  • connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/Plugins.java (3 hunks)
  • connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConfigTransformerTest.java (5 hunks)
  • connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java (5 hunks)
  • connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginsTest.java (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMakerConfig.java (2)
clients/src/main/java/org/apache/kafka/common/internals/Plugin.java (1)
  • Plugin (33-92)
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/Plugins.java (1)
  • Plugins (59-696)
clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java (1)
clients/src/main/java/org/apache/kafka/common/internals/Plugin.java (1)
  • Plugin (33-92)
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConfigTransformerTest.java (1)
clients/src/main/java/org/apache/kafka/common/internals/Plugin.java (1)
  • Plugin (33-92)
clients/src/test/java/org/apache/kafka/common/config/provider/MonitorableConfigProvider.java (1)
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala (1)
  • withPluginMetrics (6299-6301)
🔇 Additional comments (29)
clients/src/main/java/org/apache/kafka/common/config/provider/ConfigProvider.java (1)

32-35: Documentation update for metrics support is clear and comprehensive.

The added JavaDoc clearly explains how to implement the Monitorable interface for enabling metrics in config providers. It also specifies the three tags that will be automatically added to all metrics registered by the config provider: config, class, and provider. This documentation complements the broader changes for KIP-877 support.

connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConfigTransformerTest.java (4)

19-21: Import for Plugin class added correctly.

The Plugin import is necessary for the new approach of wrapping config providers.


69-69: Config provider instance is now properly wrapped with Plugin.wrapInstance.

The test setup now correctly wraps the TestConfigProvider instance in a Plugin wrapper, which aligns with the broader implementation changes for KIP-877 support. The provider is properly wrapped with the "config.providers" category.


75-75: Collections.singletonMap replaced with Map.of.

This modernizes the code by using the newer, more concise Map.of() method instead of the older Collections.singletonMap().

Also applies to: 100-100, 115-115, 122-122


150-158: Collections.singletonMap replaced with Map.of in test data methods.

The implementation of the test data methods in TestConfigProvider has been updated to use the more modern Map.of() API, which is a good cleanup.

clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java (3)

20-20: Import for Plugin class added correctly.

The Plugin import is needed for the new approach of wrapping config providers.


49-49: Config provider instance is now properly wrapped with Plugin.wrapInstance.

The test setup now correctly wraps the TestConfigProvider instance in a Plugin wrapper, consistent with the implementation changes for KIP-877. The provider is properly wrapped with the "config.providers" category.


54-54: Collections.singletonMap replaced with Map.of in test methods.

This modernizes the code by using the newer, more concise Map.of() method instead of the older Collections.singletonMap().

Also applies to: 63-63, 72-72, 79-79, 86-86, 93-93, 102-102

connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMakerConfig.java (5)

26-26: Import for Plugin class added correctly.

The Plugin import is necessary for the new approach of wrapping config providers.


273-273: Updated map type to use Plugin wrappers.

The map type has been correctly updated from Map<String, ConfigProvider> to Map<String, Plugin<ConfigProvider>> to reflect the new design that uses plugin wrappers.


275-282: Updated to use the new Plugin-based ConfigProvider API.

The code has been updated to use the new signature of plugins.newConfigProvider() which now:

  1. Takes the provider name directly instead of a concatenated config key
  2. Adds the Plugins.ClassLoaderUsage.PLUGINS parameter
  3. Passes null for the metrics parameter (which is fine for this context)
  4. Returns a Plugin<ConfigProvider> wrapper that's stored in the map

This correctly implements the KIP-877 changes for ConfigProvider support.


283-283: Updated ConfigTransformer constructor to use plugins map.

The ConfigTransformer constructor is correctly updated to accept the map of Plugin-wrapped ConfigProviders.


285-285: Updated cleanup to close plugin wrappers.

The cleanup code now correctly closes the plugin wrappers instead of the raw providers. The Utils.closeQuietly method ensures that any exceptions during closure are properly handled.

connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/Plugins.java (3)

22-23: New imports for Plugin wrapping support

These imports are required for the KIP-877 implementation, which wraps ConfigProvider instances as Plugin objects to support metrics and lifecycle management.


632-633: Method signature and parameter changes to support KIP-877

The method now returns a Plugin<ConfigProvider> instead of a raw ConfigProvider and accepts a new Metrics parameter. The parameter was also renamed from providerPrefix to providerName for clarity, with the actual prefix being constructed inside the method.


649-649:

❌ Incorrect review comment

Add null check for metrics parameter

The metrics parameter can be null (as seen in tests), but there's no null check before using it in Plugin.wrapInstance(). This could lead to a NullPointerException if metrics is null in production code.

-        return Plugin.wrapInstance(plugin, metrics, WorkerConfig.CONFIG_PROVIDERS_CONFIG, Map.of("provider", providerName));
+        return Plugin.wrapInstance(plugin, metrics, WorkerConfig.CONFIG_PROVIDERS_CONFIG, Map.of("provider", providerName != null ? providerName : "unknown"));

Check if Plugin.wrapInstance handles null metrics gracefully:


🏁 Script executed:

#!/bin/bash
# Check if Plugin.wrapInstance handles null metrics
rg -A 5 -B 5 "wrapInstance" --glob "*.java"

Length of output: 42611


Plugin.wrapInstance already guards against null metrics
The wrapInstance implementation in clients/src/main/java/org/apache/kafka/common/internals/Plugin.java explicitly checks metrics != null before using it, so passing a null metrics parameter will not trigger a NullPointerException. The suggested diff is both unnecessary and addresses providerName rather than the metrics parameter.

No changes required.

Likely an incorrect or invalid review comment.

connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginsTest.java (4)

25-28: Add imports for monitorable config provider support

Added imports for the new MonitorableConfigProvider class and related metrics classes to test the KIP-877 implementation.


381-402: Updated test to handle Plugin-wrapped ConfigProvider

The test has been correctly updated to work with the new Plugin-wrapped ConfigProvider return type. Parameter renaming from providerPrefix to providerName aligns with the method signature change.


404-412: Test for metrics integration with config providers

This new test verifies an important aspect of KIP-877 - that the withPluginMetrics method is called after configuration when creating a config provider. This ensures metrics are properly registered.


810-816: Test implementation for monitorable config provider

The CustomMonitorableConfigProvider class provides a minimal implementation to verify that withPluginMetrics is called after configure. The assertion checks that the configured flag is true when withPluginMetrics is called.

clients/src/test/java/org/apache/kafka/common/config/provider/MonitorableConfigProvider.java (3)

19-28: Imports for the MonitorableConfigProvider implementation

The imports correctly include all the necessary classes for implementing both ConfigProvider and Monitorable interfaces.


29-38: Implementation of Monitorable interface

The class implements the Monitorable interface which is key for KIP-877. The withPluginMetrics method registers a simple metric with a constant value, which is sufficient for testing purposes.


40-57: ConfigProvider implementation

The ConfigProvider implementation is minimal but sufficient for testing. It tracks configuration state with the configured flag that is used by tests to verify the order of operations.

connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java (6)

40-46: New imports added for KIP-877 support.

These imports are necessary to support the new functionality for wrapping ConfigProviders in Plugin instances and monitoring them via metrics. This aligns with the KIP-877 implementation goal stated in the PR.


382-385: Modernized code with Map.of() instead of Collections.singletonMap().

Great update to use the more modern Map.of() method instead of Collections.singletonMap(), which aligns with the code cleanup goal mentioned in the PR objectives.


379-390: Updated mockFileConfigProvider to use Plugin wrapper.

The method now properly wraps the MockFileConfigProvider in a Plugin wrapper and correctly mocks the plugin system to expect a provider name and Metrics argument, returning the wrapped plugin instance. This change supports the KIP-877 implementation for ConfigProvider.


2904-2927: Added test for monitorable config providers with metrics integration.

This new test validates that the Worker correctly registers metrics for monitorable config providers. It properly sets up the configuration with two providers, mocks the plugin system to return wrapped instances with metrics, and verifies the expected metrics are registered in the worker's metrics registry.


2929-2935: Added helper method for constructing expected metric tags.

Clean implementation of a helper method to create the expected tags map with a consistent structure. This improves test readability and maintainability.


2937-2950: Added helper method for verifying metrics in the registry.

Well-implemented helper method that counts and asserts metrics in the worker's metrics registry that match the expected tags. The verification includes checking both the metric name and description against the expected values from MonitorableConfigProvider.

Comment on lines 210 to 223
private WorkerConfigTransformer initConfigTransformer() {
final List<String> providerNames = config.getList(WorkerConfig.CONFIG_PROVIDERS_CONFIG);
Map<String, ConfigProvider> providerMap = new HashMap<>();
Map<String, Plugin<ConfigProvider>> providerPluginMap = new HashMap<>();
for (String providerName : providerNames) {
ConfigProvider configProvider = plugins.newConfigProvider(
config,
WorkerConfig.CONFIG_PROVIDERS_CONFIG + "." + providerName,
ClassLoaderUsage.PLUGINS
Plugin<ConfigProvider> configProviderPlugin = plugins.newConfigProvider(
config,
providerName,
ClassLoaderUsage.PLUGINS,
metrics.metrics()
);
providerMap.put(providerName, configProvider);
providerPluginMap.put(providerName, configProviderPlugin);
}
return new WorkerConfigTransformer(this, providerMap);
return new WorkerConfigTransformer(this, providerPluginMap);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Guard against resource leaks when provider instantiation fails

plugins.newConfigProvider(...) may throw (e.g. bad class‑name, constructor error).
If that happens after a few providers are already created, those plugin instances stay open because initConfigTransformer() aborts before workerConfigTransformer is constructed and the close() call that normally releases them is never reached.

Consider wrapping the loop in a try/catch that closes any already‑created plugins before re‑throwing, e.g.:

Map<String, Plugin<ConfigProvider>> providerPluginMap = new HashMap<>();
try {
    for (String providerName : providerNames) {
        Plugin<ConfigProvider> configProviderPlugin = plugins.newConfigProvider(
            config, providerName, ClassLoaderUsage.PLUGINS, metrics.metrics());
        providerPluginMap.put(providerName, configProviderPlugin);
    }
} catch (Throwable t) {
+   providerPluginMap.values().forEach(p -> Utils.closeQuietly(p, "config provider plugin"));
    throw t;
}
return new WorkerConfigTransformer(this, Collections.unmodifiableMap(providerPluginMap));

This keeps the constructor exception‑safe and prevents dangling threads/metrics.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private WorkerConfigTransformer initConfigTransformer() {
final List<String> providerNames = config.getList(WorkerConfig.CONFIG_PROVIDERS_CONFIG);
Map<String, ConfigProvider> providerMap = new HashMap<>();
Map<String, Plugin<ConfigProvider>> providerPluginMap = new HashMap<>();
for (String providerName : providerNames) {
ConfigProvider configProvider = plugins.newConfigProvider(
config,
WorkerConfig.CONFIG_PROVIDERS_CONFIG + "." + providerName,
ClassLoaderUsage.PLUGINS
Plugin<ConfigProvider> configProviderPlugin = plugins.newConfigProvider(
config,
providerName,
ClassLoaderUsage.PLUGINS,
metrics.metrics()
);
providerMap.put(providerName, configProvider);
providerPluginMap.put(providerName, configProviderPlugin);
}
return new WorkerConfigTransformer(this, providerMap);
return new WorkerConfigTransformer(this, providerPluginMap);
}
private WorkerConfigTransformer initConfigTransformer() {
final List<String> providerNames = config.getList(WorkerConfig.CONFIG_PROVIDERS_CONFIG);
Map<String, Plugin<ConfigProvider>> providerPluginMap = new HashMap<>();
try {
for (String providerName : providerNames) {
Plugin<ConfigProvider> configProviderPlugin = plugins.newConfigProvider(
config,
providerName,
ClassLoaderUsage.PLUGINS,
metrics.metrics()
);
providerPluginMap.put(providerName, configProviderPlugin);
}
} catch (Throwable t) {
providerPluginMap.values().forEach(p ->
Utils.closeQuietly(p, "config provider plugin"));
throw t;
}
return new WorkerConfigTransformer(
this,
Collections.unmodifiableMap(providerPluginMap)
);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants