2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.util;
10 import com.google.common.util.concurrent.JdkFutureAdapters;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import java.util.concurrent.Future;
13 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
14 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
15 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
16 import org.opendaylight.openflowplugin.openflow.md.core.MessageFactory;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
24 public final class TaskUtil {
27 throw new AssertionError("TaskUtil is not expected to be instantiated.");
33 * @param messageService
34 * @return barrier response
36 public static RpcInputOutputTuple<BarrierInput, ListenableFuture<RpcResult<BarrierOutput>>> sendBarrier(SessionContext session,
37 SwitchConnectionDistinguisher cookie, IMessageDispatchService messageService) {
38 BarrierInput barrierInput = MessageFactory.createBarrier(
39 session.getFeatures().getVersion(), session.getNextXid());
40 Future<RpcResult<BarrierOutput>> barrierResult = messageService.barrier(barrierInput, cookie);
41 ListenableFuture<RpcResult<BarrierOutput>> output = JdkFutureAdapters.listenInPoolThread(barrierResult);
43 return new RpcInputOutputTuple<>(barrierInput, output);