Merge "Change StatisticsContext"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / OpendaylightFlowTableStatisticsServiceImpl.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.impl.statistics.services;
9
10 import java.util.concurrent.Future;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
13 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
14 import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
15 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
24 import org.opendaylight.yangtools.yang.common.RpcResult;
25
26 public final class OpendaylightFlowTableStatisticsServiceImpl extends AbstractSimpleService<GetFlowTablesStatisticsInput, GetFlowTablesStatisticsOutput> implements
27         OpendaylightFlowTableStatisticsService {
28
29     public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
30         super(requestContextStack, deviceContext, GetFlowTablesStatisticsOutput.class);
31     }
32
33     @Override
34     public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
35             final GetFlowTablesStatisticsInput input) {
36         return handleServiceCall(input);
37     }
38
39     @Override
40     protected OfHeader buildRequest(final Xid xid, final GetFlowTablesStatisticsInput input) {
41         // Create multipart request body for fetch all the group stats
42         final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
43         final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
44         multipartRequestTableBuilder.setEmpty(true);
45         multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
46
47         // Set request body to main multipart request
48         final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
49                 MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
50
51         mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
52
53         return mprInput.build();
54     }
55 }