2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.impl.services.singlelayer;
10 import com.google.common.util.concurrent.Futures;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import com.google.common.util.concurrent.MoreExecutors;
13 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
14 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
15 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
16 import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.AsyncConfigMessage;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsync;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncInput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutputBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInputBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
24 import org.opendaylight.yangtools.yang.common.RpcResult;
25 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
27 public final class GetAsyncImpl extends AbstractSimpleService<GetAsyncInput, AsyncConfigMessage> implements GetAsync {
28 public GetAsyncImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
29 super(requestContextStack, deviceContext, AsyncConfigMessage.class);
33 public ListenableFuture<RpcResult<GetAsyncOutput>> invoke(final GetAsyncInput input) {
34 return Futures.transform(handleServiceCall(input), result ->
35 result != null && result.isSuccessful()
36 ? RpcResultBuilder.success(new GetAsyncOutputBuilder(result.getResult()).build()).build()
37 : RpcResultBuilder.<GetAsyncOutput>failed().build(),
38 MoreExecutors.directExecutor());
42 protected OfHeader buildRequest(final Xid xid, final GetAsyncInput input) {
43 return new GetAsyncInputBuilder().setVersion(getVersion()).setXid(xid.getValue()).build();