Search in sources :

Example 1 with DeleteWatchEventFilter

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

the class KubernetesControllerFactory method getDeleteFilters.

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

Aggregations

DeleteWatchEventFilter (io.kubernetes.client.spring.extended.controller.annotation.DeleteWatchEventFilter)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