Decompose RPC implementation classes
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / GetAggregateFlowStatisticsFromFlowTableForGivenMatchImpl.java
1 /*
2  * Copyright (c) 2024 PANTHEON.tech, s.r.o. 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 com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
13 import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerAggregateFlowMultipartService;
14 import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerAggregateFlowMultipartService;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatch;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
20
21 public final class GetAggregateFlowStatisticsFromFlowTableForGivenMatchImpl
22         implements GetAggregateFlowStatisticsFromFlowTableForGivenMatch {
23     private final SingleLayerAggregateFlowMultipartService single;
24     private final MultiLayerAggregateFlowMultipartService multi;
25
26     public GetAggregateFlowStatisticsFromFlowTableForGivenMatchImpl(final RequestContextStack requestContextStack,
27             final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
28         single = new SingleLayerAggregateFlowMultipartService(requestContextStack, deviceContext);
29         multi = new MultiLayerAggregateFlowMultipartService(requestContextStack, deviceContext,
30             convertorExecutor, deviceContext.oook());
31     }
32
33     @Override
34     public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> invoke(
35             final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
36         return single.canUseSingleLayerSerialization() ? single.handleAndReply(input) : multi.handleAndReply(input);
37     }
38 }