X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fclient%2FSequencedQueue.java;h=596e353c981f3d21d193c66795753233c40bb6eb;hp=5cf7873a4b95efadc64ba335dc3004aea9333bb4;hb=5fd8e6506248cc34da72281a1662612f6c2b2f9a;hpb=9b4f21460c6dcb10c381df631d064d05de16546c diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/SequencedQueue.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/SequencedQueue.java index 5cf7873a4b..596e353c98 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/SequencedQueue.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/SequencedQueue.java @@ -11,6 +11,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.base.Ticker; import com.google.common.base.Verify; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayDeque; import java.util.Iterator; import java.util.Optional; @@ -28,6 +29,8 @@ import org.slf4j.LoggerFactory; import scala.concurrent.duration.FiniteDuration; /* + * A queue that processes entries in sequence. + * * TODO: make this class and its users thread-safe. This will require some atomic state-keeping so that timeouts, * retries and enqueues work as expected. */ @@ -118,7 +121,7 @@ final class SequencedQueue { * 2) The request has been enqueued and transmitted, but the caller needs to schedule a new timer * 3) The request has been enqueued, but the caller needs to request resolution of backend information and that * process needs to complete before transmission occurs - * + *

* These options are covered via returning an {@link Optional}. The caller needs to examine it and decode * the scenarios above according to the following rules: * - if is null, the first case applies @@ -152,8 +155,14 @@ final class SequencedQueue { } // Ready to transmit - currentInflight.offer(e); - LOG.debug("Enqueued request {} to queue {}", request, this); + + if (currentInflight.offer(e)) { + LOG.debug("Enqueued request {} to queue {}", request, this); + } else { + // This shouldn't happen since the queue has unlimited capacity but check anyway to avoid FindBugs warning + // about checking return value. + LOG.warn("Fail to enqueued request {} to queue {}", request, this); + } e.retransmit(backend, nextTxSequence(), now); if (expectingTimer == null) { @@ -170,6 +179,8 @@ final class SequencedQueue { * - if a matching entry is not found, but it makes sense to keep looking at other queues, return null * - if a conflicting entry is encountered, indicating we should ignore this request, return an empty Optional */ + @SuppressFBWarnings(value = "NP_OPTIONAL_RETURN_NULL", + justification = "Returning null Optional is documented in the API contract.") private static Optional findMatchingEntry(final Queue queue, final ResponseEnvelope envelope) { // Try to find the request in a queue. Responses may legally come back in a different order, hence we need @@ -271,7 +282,8 @@ final class SequencedQueue { transmitEntries(pending, toSend); } - Optional setBackendInfo(final CompletionStage proof, final BackendInfo backend) { + Optional setBackendInfo(final CompletionStage proof, + final BackendInfo backend) { Preconditions.checkNotNull(backend); if (!proof.equals(backendProof)) { LOG.debug("Ignoring resolution {} while waiting for {}", proof, this.backendProof);