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.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;
31 public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService,
32 Delegator<OpendaylightFlowStatisticsService> {
34 private final SingleLayerAggregateFlowMultipartService singleLayerService;
35 private final MultiLayerAggregateFlowMultipartService multiLayerService;
36 private OpendaylightFlowStatisticsService delegate;
38 public static OpendaylightFlowStatisticsServiceImpl createWithOook(final RequestContextStack requestContextStack,
39 final DeviceContext deviceContext,
40 final ConvertorExecutor convertorExecutor) {
41 return new OpendaylightFlowStatisticsServiceImpl(requestContextStack,
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);
57 public void setDelegate(OpendaylightFlowStatisticsService delegate) {
58 this.delegate = delegate;
62 * Get aggregate statistics.
64 * @deprecated provided for Be-release as backward compatibility relic.
68 public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>
69 getAggregateFlowStatisticsFromFlowTableForAllFlows(
70 final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
71 if (delegate != null) {
72 return delegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
74 throw new IllegalAccessError("no delegate available - service is currently out of order");
79 public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>
80 getAggregateFlowStatisticsFromFlowTableForGivenMatch(
81 final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
82 return singleLayerService.canUseSingleLayerSerialization()
83 ? singleLayerService.handleAndReply(input)
84 : multiLayerService.handleAndReply(input);
88 * Get flow statistics.
90 * @deprecated provided for Be-release as backward compatibility relic.
94 public ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
95 final GetAllFlowStatisticsFromFlowTableInput input) {
96 if (delegate != null) {
97 return delegate.getAllFlowStatisticsFromFlowTable(input);
99 throw new IllegalAccessError("no delegate available - service is currently out of order");
104 * Get flow statistics.
106 * @deprecated provided for Be-release as backward compatibility relic.
110 public ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>
111 getAllFlowsStatisticsFromAllFlowTables(final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
112 if (delegate != null) {
113 return delegate.getAllFlowsStatisticsFromAllFlowTables(input);
115 throw new IllegalAccessError("no delegate available - service is currently out of order");
120 * Get flow statistics.
122 * @deprecated provided for Be-release as backward compatibility relic.
126 public ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
127 final GetFlowStatisticsFromFlowTableInput input) {
128 if (delegate != null) {
129 return delegate.getFlowStatisticsFromFlowTable(input);
131 throw new IllegalAccessError("no delegate available - service is currently out of order");