From: Robert Varga Date: Thu, 21 May 2015 12:57:48 +0000 (+0200) Subject: BUG-3219: Throw away message as soon as we send it out X-Git-Tag: release/beryllium~46 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=354c77b535184f0743baa30304d53bf2eea9c936;p=openflowjava.git BUG-3219: Throw away message as soon as we send it out In order to relieve pressure on memory, do not wait until the entire buffer is acknowledged, but clear the message as soon as we send it to the network. Change-Id: Ie64c1e0a011e1d1a1a0a98a21d9cc90642f81e6c Signed-off-by: Robert Varga (cherry picked from commit be5f0cac1babcfccc7209657f2541dd0818c5cb0) --- diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index 8b498579..48722dbb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -21,27 +21,30 @@ final class OutboundQueueEntry { private FutureCallback callback; private OfHeader message; private boolean completed; + private boolean barrier; private volatile boolean committed; void commit(final OfHeader message, final FutureCallback callback) { this.message = message; this.callback = callback; + this.barrier = message instanceof BarrierInput; // Volatile write, needs to be last committed = true; } void reset() { + barrier = false; callback = null; - message = null; completed = false; + message = null; // Volatile write, needs to be last committed = false; } boolean isBarrier() { - return message instanceof BarrierInput; + return barrier; } boolean isCommitted() { @@ -52,12 +55,14 @@ final class OutboundQueueEntry { return completed; } - OfHeader getMessage() { - return message; + OfHeader takeMessage() { + final OfHeader ret = message; + message = null; + return ret; } boolean complete(final OfHeader response) { - Preconditions.checkState(!completed, "Attempted to complete a completed message %s with response %s", message, response); + Preconditions.checkState(!completed, "Attempted to complete a completed message with response %s", response); // Multipart requests are special, we have to look at them to see // if there is something outstanding and adjust ourselves accordingly @@ -84,7 +89,7 @@ final class OutboundQueueEntry { callback.onFailure(cause); } } else { - LOG.warn("Ignoring failure {} for completed message {}", cause, message); + LOG.warn("Ignoring failure {} for completed message", cause); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index ab3340bf..2433637f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -234,7 +234,7 @@ final class OutboundQueueImpl implements OutboundQueue { return null; } - final OfHeader msg = entry.getMessage(); + final OfHeader msg = entry.takeMessage(); flushOffset++; if (msg != null) { return msg;