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
9 package org.opendaylight.openflowplugin.impl.services.sal;
11 import com.google.common.util.concurrent.Futures;
12 import java.util.Objects;
13 import java.util.concurrent.Future;
14 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
15 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
16 import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerGetAsyncConfigService;
17 import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerSetAsyncConfigService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.GetAsyncOutputBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.SalAsyncConfigService;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.SetAsyncInput;
23 import org.opendaylight.yangtools.yang.common.RpcResult;
24 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
26 public class SalAsyncConfigServiceImpl implements SalAsyncConfigService {
28 private final SingleLayerSetAsyncConfigService setAsyncConfigService;
29 private final SingleLayerGetAsyncConfigService getAsyncConfigService;
31 public SalAsyncConfigServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
32 setAsyncConfigService = new SingleLayerSetAsyncConfigService(requestContextStack, deviceContext);
33 getAsyncConfigService = new SingleLayerGetAsyncConfigService(requestContextStack, deviceContext);
37 public Future<RpcResult<Void>> setAsync(SetAsyncInput input) {
38 return setAsyncConfigService.handleServiceCall(input);
42 public Future<RpcResult<GetAsyncOutput>> getAsync(GetAsyncInput input) {
43 return Futures.transform(getAsyncConfigService.handleServiceCall(input), result ->
44 Objects.nonNull(result) && result.isSuccessful()
45 ? RpcResultBuilder.success(new GetAsyncOutputBuilder(result.getResult())).build()
46 : RpcResultBuilder.<GetAsyncOutput>failed().build());