csviri commented on code in PR #239:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/239#discussion_r880205818
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/controller/FlinkDeploymentController.java:
##########
@@ -152,26 +160,71 @@ private void handleDeploymentFailed(FlinkDeployment
flinkApp, DeploymentFailedEx
}
@Override
- public List<EventSource>
prepareEventSources(EventSourceContext<FlinkDeployment> ctx) {
- if (effectiveNamespaces.isEmpty()) {
- return
List.of(OperatorUtils.createJmDepInformerEventSource(kubernetesClient));
- } else {
- return effectiveNamespaces.stream()
- .map(ns ->
OperatorUtils.createJmDepInformerEventSource(kubernetesClient, ns))
- .collect(Collectors.toList());
- }
+ public Map<String, EventSource> prepareEventSources(
+ EventSourceContext<FlinkDeployment> context) {
+
+ return EventSourceInitializer.nameEventSources(
+ getSessionJobInformerEventSource(context),
+ getFlinkDeploymentInformerEventSource(context));
+ }
+
+ private InformerEventSource<Deployment, FlinkDeployment>
getFlinkDeploymentInformerEventSource(
+ EventSourceContext<FlinkDeployment> context) {
+ final String labelSelector =
+ Map.of(
+ Constants.LABEL_TYPE_KEY,
+ Constants.LABEL_TYPE_NATIVE_TYPE,
+ Constants.LABEL_COMPONENT_KEY,
+ Constants.LABEL_COMPONENT_JOB_MANAGER)
+ .entrySet().stream()
+ .map(Object::toString)
+ .collect(Collectors.joining(","));
+
+ var configuration =
+ InformerConfiguration.from(Deployment.class, context)
+ .withLabelSelector(labelSelector)
+
.withSecondaryToPrimaryMapper(Mappers.fromLabel(Constants.LABEL_APP_KEY))
+ .withNamespacesInheritedFromController(context)
+ .followNamespaceChanges(true)
+ .build();
+
+ return new InformerEventSource<>(configuration, context);
}
- @VisibleForTesting
- public void setEffectiveNamespaces(Set<String> effectiveNamespaces) {
- this.effectiveNamespaces = effectiveNamespaces;
+ private InformerEventSource<FlinkSessionJob, FlinkDeployment>
getSessionJobInformerEventSource(
+ EventSourceContext<FlinkDeployment> context) {
+
+ final SecondaryToPrimaryMapper<FlinkSessionJob>
secondaryToPrimaryMapper =
+ sessionJob ->
+ context.getPrimaryCache()
Review Comment:
Now additional indexer is supported for this, so there is no need to
traverse the list of objects, see:
https://github.com/java-operator-sdk/java-operator-sdk/blob/5afdecd3a00b2a5d1c0e6170f4c942bda3126dc8/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java#L124-L124
--
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]