2 * Copyright (c) 2015 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
9 package org.opendaylight.openflowplugin.impl.util;
11 import com.google.common.util.concurrent.FutureCallback;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import com.google.common.util.concurrent.SettableFuture;
14 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
15 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
16 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
22 * Created by Martin Bobak <mbobak@cisco.com> on 18.5.2015.
24 public class StatisticsServiceUtil {
26 private StatisticsServiceUtil() {
27 throw new IllegalStateException("This class should not be instantiated");
30 public static <T> ListenableFuture<RpcResult<T>> getRpcResultListenableFuture(final Xid xid,
31 final MultipartRequestInput multipartRequestInput,
32 final DeviceContext deviceContext) {
33 final SettableFuture<RpcResult<T>> settableFuture = SettableFuture.create();
34 final OutboundQueue outboundQueue = deviceContext.getPrimaryConnectionContext().getOutboundQueueProvider();
35 outboundQueue.commitEntry(xid.getValue(), multipartRequestInput, new FutureCallback<OfHeader>() {
37 public void onSuccess(final OfHeader ofHeader) {
41 public void onFailure(final Throwable throwable) {
44 return settableFuture;