X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Fcore%2Finternal%2FSynchronousMessage.java;h=bb94d4b3186e73235c736aa8b2f8f78f5ecaf3dc;hp=4737d4cea9c1b95333f9c3d5ff2e5410ea392552;hb=1bad1b7ca9a87f9e1d32cfcf5a181354fc378ad4;hpb=e326757873804be369d20efd0b54467871094c06 diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SynchronousMessage.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SynchronousMessage.java index 4737d4cea9..bb94d4b318 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SynchronousMessage.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SynchronousMessage.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -18,15 +17,15 @@ import org.openflow.protocol.OFError; import org.openflow.protocol.OFMessage; /** - * Implements the synchronous message send to a switch - * It sends the requested message to the switch followed by a barrier request message - * It returns the result once it gets the reply from the switch or after a timeout - * If the protocol does not dictate the switch to reply the processing status for a particular message - * the barrier request forces the switch to reply saying whether or not the message processing was - * successful for messages sent to the switch up to this point - * - * - * + * This class implements synchronous operations on message send to a switch. If + * syncRequest is set to true, it sends the requested message to the switch + * followed by a Barrier request message. It returns the result once it gets the + * reply from the switch or after a timeout. If the protocol does not dictate + * the switch to reply the processing status for a particular message, the + * Barrier request forces the switch to reply saying whether or not the message + * processing was successful for messages sent to the switch up to this point. + * If syncRequest is false, it simply skips the message send and just waits for + * the response back. */ public class SynchronousMessage implements Callable { private ISwitch sw; @@ -34,21 +33,30 @@ public class SynchronousMessage implements Callable { private OFMessage syncMsg; protected CountDownLatch latch; private Object result; + private boolean syncRequest; - public SynchronousMessage(ISwitch sw, Integer xid, OFMessage msg) { + public SynchronousMessage(ISwitch sw, Integer xid, OFMessage msg, + boolean syncRequest) { this.sw = sw; this.xid = xid; syncMsg = msg; latch = new CountDownLatch(1); result = null; + this.syncRequest = syncRequest; } @Override public Object call() throws Exception { - sw.asyncSend(syncMsg, xid); - if (!(syncMsg instanceof OFBarrierRequest)) { - OFBarrierRequest barrierMsg = new OFBarrierRequest(); - sw.asyncSend(barrierMsg, xid); + /* + * Send out message only if syncRequest is set to true. Otherwise, just + * wait for the Barrier response back. + */ + if (syncRequest) { + sw.asyncSend(syncMsg, xid); + if (!(syncMsg instanceof OFBarrierRequest)) { + OFBarrierRequest barrierMsg = new OFBarrierRequest(); + sw.asyncSend(barrierMsg, xid); + } } latch.await(); return result;