Remove unused routedRpcRegistration
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / OpendaylightFlowStatisticsServiceImpl.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 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.api.openflow.device.TranslatorLibrary;
14 import org.opendaylight.openflowplugin.api.openflow.statistics.compatibility.Delegator;
15 import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerAggregateFlowMultipartService;
16 import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerAggregateFlowMultipartService;
17 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
29 import org.opendaylight.yangtools.yang.common.RpcResult;
30
31 public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService,
32                                                               Delegator<OpendaylightFlowStatisticsService> {
33
34     private final SingleLayerAggregateFlowMultipartService singleLayerService;
35     private final MultiLayerAggregateFlowMultipartService multiLayerService;
36     private OpendaylightFlowStatisticsService delegate;
37
38     public static OpendaylightFlowStatisticsServiceImpl createWithOook(final RequestContextStack requestContextStack,
39                                                                        final DeviceContext deviceContext,
40                                                                        final ConvertorExecutor convertorExecutor) {
41         return new OpendaylightFlowStatisticsServiceImpl(requestContextStack,
42                                                          deviceContext,
43                                                          deviceContext.oook(),
44                                                          convertorExecutor);
45     }
46
47     public OpendaylightFlowStatisticsServiceImpl(final RequestContextStack requestContextStack,
48                                                  final DeviceContext deviceContext,
49                                                  final TranslatorLibrary translatorLibrary,
50                                                  final ConvertorExecutor convertorExecutor) {
51         singleLayerService = new SingleLayerAggregateFlowMultipartService(requestContextStack, deviceContext);
52         multiLayerService = new MultiLayerAggregateFlowMultipartService(requestContextStack, deviceContext,
53             convertorExecutor, translatorLibrary);
54     }
55
56     @Override
57     public void setDelegate(OpendaylightFlowStatisticsService delegate) {
58         this.delegate = delegate;
59     }
60
61     /**
62      * Get aggregate statistics.
63      *
64      * @deprecated provided for Be-release as backward compatibility relic.
65      */
66     @Override
67     @Deprecated
68     public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>
69         getAggregateFlowStatisticsFromFlowTableForAllFlows(
70                 final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
71         if (delegate != null) {
72             return delegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
73         } else {
74             throw new IllegalAccessError("no delegate available - service is currently out of order");
75         }
76     }
77
78     @Override
79     public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>
80         getAggregateFlowStatisticsFromFlowTableForGivenMatch(
81                 final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
82         return singleLayerService.canUseSingleLayerSerialization()
83             ? singleLayerService.handleAndReply(input)
84             : multiLayerService.handleAndReply(input);
85     }
86
87     /**
88      * Get flow statistics.
89      *
90      * @deprecated provided for Be-release as backward compatibility relic.
91      */
92     @Override
93     @Deprecated
94     public ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
95             final GetAllFlowStatisticsFromFlowTableInput input) {
96         if (delegate != null) {
97             return delegate.getAllFlowStatisticsFromFlowTable(input);
98         } else {
99             throw new IllegalAccessError("no delegate available - service is currently out of order");
100         }
101     }
102
103     /**
104      * Get flow statistics.
105      *
106      * @deprecated provided for Be-release as backward compatibility relic.
107      */
108     @Override
109     @Deprecated
110     public ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>
111         getAllFlowsStatisticsFromAllFlowTables(final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
112         if (delegate != null) {
113             return delegate.getAllFlowsStatisticsFromAllFlowTables(input);
114         } else {
115             throw new IllegalAccessError("no delegate available - service is currently out of order");
116         }
117     }
118
119     /**
120      * Get flow statistics.
121      *
122      * @deprecated provided for Be-release as backward compatibility relic.
123      */
124     @Override
125     @Deprecated
126     public ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
127             final GetFlowStatisticsFromFlowTableInput input) {
128         if (delegate != null) {
129             return delegate.getFlowStatisticsFromFlowTable(input);
130         } else {
131             throw new IllegalAccessError("no delegate available - service is currently out of order");
132         }
133     }
134 }