BUG-3219: Handle EchoRequests directly in ConnectionAdapter 54/20654/7
authorRobert Varga <rovarga@cisco.com>
Mon, 18 May 2015 15:18:41 +0000 (17:18 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 18 May 2015 23:53:13 +0000 (01:53 +0200)
If we have an OutboundQueueManager, we should short-cut handling of echo
request messages in the plugin itself. Perform exectly that.

Change-Id: If4090d02e521c2da5914545bf3e887bd265c54a0
Signed-off-by: Robert Varga <rovarga@cisco.com>
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java

index 91f4ceb1f9dd4854c95b4f2b34c359f16c019731..77fa66188a2176dc41af0678c839ce501695c7bf 100644 (file)
@@ -280,7 +280,11 @@ public class ConnectionAdapterImpl implements ConnectionFacade {
                 systemListener.onSwitchIdleEvent((SwitchIdleEvent) message);
                 // OpenFlow messages
             } else if (message instanceof EchoRequestMessage) {
-                messageListener.onEchoRequestMessage((EchoRequestMessage) message);
+                if (outputManager != null) {
+                    outputManager.onEchoRequest((EchoRequestMessage) message);
+                } else {
+                    messageListener.onEchoRequestMessage((EchoRequestMessage) message);
+                }
                 statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
             } else if (message instanceof ErrorMessage) {
                 // Send only unmatched errors
index a4d3f9746928dba8e7953db7923754a576a59957..766abe6a1d5bd0b3944acab9b24a6505f24e30fe 100644 (file)
@@ -20,6 +20,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -450,4 +453,9 @@ final class OutboundQueueManager<T extends OutboundQueueHandler> extends Channel
     public String toString() {
         return String.format("Channel %s queue [flushing=%s]", parent.getChannel(), flushScheduled.get());
     }
+
+    void onEchoRequest(final EchoRequestMessage message) {
+        final EchoReplyInput reply = new EchoReplyInputBuilder().setData(message.getData()).setVersion(message.getVersion()).setXid(message.getXid()).build();
+        parent.getChannel().writeAndFlush(reply);
+    }
 }