From: Michal Polkorab Date: Mon, 11 Jan 2016 21:28:52 +0000 (+0100) Subject: Bug 4942 - Barrier send condition updated X-Git-Tag: release/beryllium~9 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=6a499f9932f6965ce84e97e98d2cd188482e8327;p=openflowjava.git Bug 4942 - Barrier send condition updated - fixes uncovered case - if a barrier was scheduled and another barrier was sent due to exceeded "maxNonBarrierMessages", then we would cancel / not enqueue the scheduled barrier because of "sinceLast" time - this time is lower than "maxBarrierNanos" Change-Id: I86f1be2ac0dc76241523ee3b6e6bf12bec90889e Signed-off-by: Michal Polkorab (cherry picked from commit 62c0db21eb5d45415011647427ba9f7a0dc69302) --- diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 90db23da..1769face 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -86,16 +86,11 @@ final class OutboundQueueManager extends return; } - final long now = System.nanoTime(); - final long sinceLast = now - lastBarrierNanos; - if (sinceLast >= maxBarrierNanos) { - LOG.debug("Last barrier at {} now {}, elapsed {}", lastBarrierNanos, now, sinceLast); - // FIXME: we should be tracking requests/responses instead of this - if (nonBarrierMessages == 0) { - LOG.trace("No messages written since last barrier, not issuing one"); - } else { - scheduleBarrierMessage(); - } + if (currentQueue.isBarrierNeeded()) { + LOG.trace("Sending a barrier message"); + scheduleBarrierMessage(); + } else { + LOG.trace("Barrier not needed, not issuing one"); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java index a9876d99..cafd114c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -51,12 +51,24 @@ final class StackedOutboundQueue extends AbstractStackedOutboundQueue { } Long reserveBarrierIfNeeded() { + if (isBarrierNeeded()) { + return reserveEntry(); + } + return null; + } + + /** + * Checks if Barrier Request is the last message enqueued. If not, one needs + * to be scheduled in order to collect data about previous messages. + * @return true if last enqueued message is Barrier Request, false otherwise + */ + boolean isBarrierNeeded() { final long bXid = barrierXid; final long fXid = firstSegment.getBaseXid() + flushOffset; if (bXid >= fXid) { LOG.debug("Barrier found at XID {} (currently at {})", bXid, fXid); - return null; + return false; } - return reserveEntry(); + return true; } }