-
Couldn't load subscription status.
- Fork 497
[Draft] support overriding autoscaling scaling realizer via plugins #1020
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package org.apache.flink.autoscaler.realizer; | ||
|
|
||
| import org.apache.flink.core.plugin.Plugin; | ||
|
|
||
| /* Flink Autoscaler Scaling Realizer */ | ||
| public interface FlinkAutoscalerScalingRealizer extends Plugin, ScalingRealizer {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package org.apache.flink.kubernetes.operator.utils; | ||
|
|
||
| import org.apache.flink.configuration.ConfigConstants; | ||
| import org.apache.flink.core.plugin.PluginUtils; | ||
| import org.apache.flink.kubernetes.operator.config.FlinkConfigManager; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| public class PluginDiscoveryUtils { | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(PluginDiscoveryUtils.class); | ||
|
|
||
| public static <T> Set<T> discoverResources( | ||
| FlinkConfigManager configManager, Class<T> resourceClass) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think keeping this generic, will be beneficial for future changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Open to ideas |
||
| var conf = configManager.getDefaultConfig(); | ||
|
|
||
| Set<T> resources = new HashSet<>(); | ||
|
|
||
| PluginUtils.createPluginManagerFromRootFolder(conf) | ||
| .load(resourceClass) | ||
| .forEachRemaining( | ||
| resource -> { | ||
| LOG.info( | ||
| "Discovered resource from plugin directory [{}]: {}.", | ||
| System.getenv() | ||
| .getOrDefault( | ||
| ConfigConstants.ENV_FLINK_PLUGINS_DIR, | ||
| ConfigConstants.DEFAULT_FLINK_PLUGINS_DIRS), | ||
| resource.getClass().getName()); | ||
| resources.add(resource); | ||
| }); | ||
|
|
||
| return resources; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses the scaling realizer from plugins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this assumes 1 scaling realizer, I'll harden this