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
8 package org.opendaylight.openflowplugin.impl.statistics.services;
10 import com.google.common.base.Function;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import java.util.concurrent.Future;
13 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
14 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
15 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
16 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
17 import org.opendaylight.openflowplugin.impl.services.CommonService;
18 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
19 import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
27 import org.opendaylight.yangtools.yang.common.RpcResult;
32 public class OpendaylightFlowTableStatisticsServiceImpl extends CommonService implements
33 OpendaylightFlowTableStatisticsService {
35 public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
36 super(requestContextStack, deviceContext);
40 public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
41 final GetFlowTablesStatisticsInput input) {
44 return handleServiceCall(new Function<RequestContext<GetFlowTablesStatisticsOutput>,
45 ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>>>() {
48 public ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>> apply(final RequestContext<GetFlowTablesStatisticsOutput> requestContext) {
50 // Create multipart request body for fetch all the group stats
51 final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
52 final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
53 multipartRequestTableBuilder.setEmpty(true);
54 multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
56 // Set request body to main multipart request
57 final Xid xid = requestContext.getXid();
58 final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
59 MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
61 mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
62 return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());