2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.access.client;
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import java.util.function.Consumer;
13 import org.opendaylight.controller.cluster.access.concepts.Request;
14 import org.opendaylight.controller.cluster.access.concepts.Response;
15 import org.opendaylight.yangtools.concepts.Immutable;
18 * Single entry in a {@link AbstractClientConnection}. Tracks the request, the associated callback and time when
19 * the request was first enqueued.
21 * @author Robert Varga
24 public class ConnectionEntry implements Immutable {
25 private final Consumer<Response<?, ?>> callback;
26 private final Request<?, ?> request;
27 private final long enqueuedTicks;
29 ConnectionEntry(final Request<?, ?> request, final Consumer<Response<?, ?>> callback, final long now) {
30 this.request = Preconditions.checkNotNull(request);
31 this.callback = Preconditions.checkNotNull(callback);
32 this.enqueuedTicks = now;
35 ConnectionEntry(final ConnectionEntry entry) {
36 this(entry.request, entry.callback, entry.enqueuedTicks);
39 public final Consumer<Response<?, ?>> getCallback() {
43 public final Request<?, ?> getRequest() {
47 public void complete(final Response<?, ?> response) {
48 callback.accept(response);
51 final long getEnqueuedTicks() {