3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
12 import java.util.concurrent.Callable;
13 import java.util.concurrent.CountDownLatch;
15 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
16 import org.openflow.protocol.OFBarrierRequest;
17 import org.openflow.protocol.OFError;
18 import org.openflow.protocol.OFMessage;
21 * Implements the synchronous message send to a switch
22 * It sends the requested message to the switch followed by a barrier request message
23 * It returns the result once it gets the reply from the switch or after a timeout
24 * If the protocol does not dictate the switch to reply the processing status for a particular message
25 * the barrier request forces the switch to reply saying whether or not the message processing was
26 * successful for messages sent to the switch up to this point
31 public class SynchronousMessage implements Callable<Object> {
34 private OFMessage syncMsg;
35 protected CountDownLatch latch;
36 private Object result;
38 public SynchronousMessage(ISwitch sw, Integer xid, OFMessage msg) {
42 latch = new CountDownLatch(1);
47 public Object call() throws Exception {
48 sw.asyncSend(syncMsg, xid);
49 OFBarrierRequest barrierMsg = new OFBarrierRequest();
50 sw.asyncSend(barrierMsg, xid);
55 public Integer getXid() {
59 public void wakeup() {
60 this.latch.countDown();
63 public void wakeup(OFError e) {