Search in sources :

Example 1 with AddWatchEventFilter

use of io.kubernetes.client.spring.extended.controller.annotation.AddWatchEventFilter in project java by kubernetes-client.

the class KubernetesControllerFactory method getAddFilters.

private Map<Class, AddFilterAdaptor> getAddFilters(KubernetesReconcilerWatches watches, Reconciler reconciler) {
    Map<Class, AddFilterAdaptor> filters = new HashMap<>();
    Set<Method> allAnnotatedMethods = new HashSet<>();
    Set<Method> adoptedMethods = new HashSet<>();
    for (KubernetesReconcilerWatch watch : watches.value()) {
        for (Method method : reconciler.getClass().getMethods()) {
            AddWatchEventFilter annotation = method.getAnnotation(AddWatchEventFilter.class);
            if (annotation == null) {
                continue;
            }
            if (watch.apiTypeClass().equals(annotation.apiTypeClass())) {
                if (filters.containsKey(watch.apiTypeClass())) {
                    log.warn("Duplicated watch ADD event filter upon apiType {}", annotation.apiTypeClass());
                }
                filters.put(watch.apiTypeClass(), new AddFilterAdaptor(reconciler, method));
                adoptedMethods.add(method);
            }
            allAnnotatedMethods.add(method);
        }
    }
    allAnnotatedMethods.removeAll(adoptedMethods);
    if (allAnnotatedMethods.size() > 0) {
        log.warn("Dangling watch ADD event filters {}", StringUtils.join(allAnnotatedMethods, ","));
    }
    return filters;
}
Also used : AddWatchEventFilter(io.kubernetes.client.spring.extended.controller.annotation.AddWatchEventFilter) HashMap(java.util.HashMap) Method(java.lang.reflect.Method) KubernetesReconcilerWatch(io.kubernetes.client.spring.extended.controller.annotation.KubernetesReconcilerWatch) HashSet(java.util.HashSet)

Aggregations

AddWatchEventFilter (io.kubernetes.client.spring.extended.controller.annotation.AddWatchEventFilter)1 KubernetesReconcilerWatch (io.kubernetes.client.spring.extended.controller.annotation.KubernetesReconcilerWatch)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1