Search in sources :

Example 11 with KubernetesObject

use of io.kubernetes.client.common.KubernetesObject in project java by kubernetes-client.

the class DeltaFIFO method queueActionLocked.

/**
 * queueActionLocked appends to the delta list for the object. Caller must hold the lock.
 */
private void queueActionLocked(DeltaType actionType, KubernetesObject obj) {
    String id = this.keyOf(obj);
    Deque<MutablePair<DeltaType, KubernetesObject>> deltas = items.get(id);
    if (deltas == null) {
        deltas = new LinkedList<>();
        deltas.add(new MutablePair(actionType, obj));
    } else {
        deltas.add(new MutablePair<DeltaType, KubernetesObject>(actionType, obj));
    }
    Deque<MutablePair<DeltaType, KubernetesObject>> combinedDeltaList = combineDeltas(deltas);
    boolean exist = items.containsKey(id);
    if (combinedDeltaList != null && combinedDeltaList.size() > 0) {
        if (!exist) {
            this.queue.add(id);
        }
        this.items.put(id, combinedDeltaList);
        notEmpty.signalAll();
    } else {
        this.items.remove(id);
    }
}
Also used : MutablePair(org.apache.commons.lang3.tuple.MutablePair) KubernetesObject(io.kubernetes.client.common.KubernetesObject)

Aggregations

KubernetesObject (io.kubernetes.client.common.KubernetesObject)11 MutablePair (org.apache.commons.lang3.tuple.MutablePair)4 KubectlException (io.kubernetes.client.extended.kubectl.exception.KubectlException)3 KubernetesListObject (io.kubernetes.client.common.KubernetesListObject)2 ApiException (io.kubernetes.client.openapi.ApiException)2 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)2 Deque (java.util.Deque)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 BeanCreationException (org.springframework.beans.factory.BeanCreationException)2 V1Patch (io.kubernetes.client.custom.V1Patch)1 Controller (io.kubernetes.client.extended.controller.Controller)1 ControllerBuilder (io.kubernetes.client.extended.controller.builder.ControllerBuilder)1 DefaultControllerBuilder (io.kubernetes.client.extended.controller.builder.DefaultControllerBuilder)1 Reconciler (io.kubernetes.client.extended.controller.reconciler.Reconciler)1 Request (io.kubernetes.client.extended.controller.reconciler.Request)1 DefaultRateLimitingQueue (io.kubernetes.client.extended.workqueue.DefaultRateLimitingQueue)1 RateLimitingQueue (io.kubernetes.client.extended.workqueue.RateLimitingQueue)1 WorkQueue (io.kubernetes.client.extended.workqueue.WorkQueue)1