BUG-3219: Throw away message as soon as we send it out 92/20892/1
authorRobert Varga <rovarga@cisco.com>
Thu, 21 May 2015 12:57:48 +0000 (14:57 +0200)
committerRobert Varga <rovarga@cisco.com>
Thu, 21 May 2015 12:59:10 +0000 (14:59 +0200)
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 <rovarga@cisco.com>
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java

index 8b498579eb79cdc99a786b0fb92f7ff147b9542f..48722dbbdd3d0db856fa83af27953b1e2dcc3e6a 100644 (file)
@@ -21,27 +21,30 @@ final class OutboundQueueEntry {
     private FutureCallback<OfHeader> callback;
     private OfHeader message;
     private boolean completed;
+    private boolean barrier;
     private volatile boolean committed;
 
     void commit(final OfHeader message, final FutureCallback<OfHeader> 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);
         }
     }
 
index ab3340bf36d5c45868fa3cd827d4fd9314f4db4c..2433637f1bbc72148c89dafec2d38965f76d6759 100644 (file)
@@ -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;