Merge "BUG-4118: Li:backward compatibility - rpcs - stats services"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / compatibility / OpendaylightFlowStatisticsServiceDelegateImpl.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.compatibility;
9
10 import java.util.concurrent.Future;
11 import java.util.concurrent.atomic.AtomicLong;
12 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
13 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
14 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
15 import org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsInTableService;
16 import org.opendaylight.openflowplugin.impl.statistics.services.AllFlowsInAllTablesService;
17 import org.opendaylight.openflowplugin.impl.statistics.services.AllFlowsInTableService;
18 import org.opendaylight.openflowplugin.impl.statistics.services.FlowsInTableService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
30 import org.opendaylight.yangtools.yang.common.RpcResult;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34 /**
35  * @author joe
36  */
37 public class OpendaylightFlowStatisticsServiceDelegateImpl implements OpendaylightFlowStatisticsService {
38
39     private static final Logger LOG = LoggerFactory.getLogger(OpendaylightFlowStatisticsServiceDelegateImpl.class);
40
41     private final AggregateFlowsInTableService aggregateFlowsInTable;
42     private final AllFlowsInAllTablesService allFlowsInAllTables;
43     private final AllFlowsInTableService allFlowsInTable;
44     private final FlowsInTableService flowsInTable;
45     private final NotificationPublishService notificationService;
46
47     public OpendaylightFlowStatisticsServiceDelegateImpl(final RequestContextStack requestContextStack,
48                                                          final DeviceContext deviceContext,
49                                                          final NotificationPublishService notificationService,
50                                                          final AtomicLong compatibilityXidSeed) {
51         this.notificationService = notificationService;
52         aggregateFlowsInTable = new AggregateFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
53         allFlowsInAllTables = new AllFlowsInAllTablesService(requestContextStack, deviceContext, compatibilityXidSeed);
54         allFlowsInTable = new AllFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
55         flowsInTable = new FlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
56     }
57
58     /**
59      * @deprecated this is the only method with real implementation provided, in delegate it makes no sense
60      */
61     @Override
62     @Deprecated
63     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
64             final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
65         throw new IllegalAccessError("unsupported by backward compatibility delegate service " +
66                 "- this rpc is always provided by default service implementation");
67     }
68
69     @Override
70     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
71             final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
72         return aggregateFlowsInTable.handleAndNotify(input, notificationService);
73     }
74
75     @Override
76     public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
77             final GetAllFlowStatisticsFromFlowTableInput input) {
78         return allFlowsInTable.handleAndNotify(input, notificationService);
79     }
80
81     @Override
82     public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
83             final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
84         return allFlowsInAllTables.handleAndNotify(input, notificationService);
85     }
86
87     @Override
88     public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
89             final GetFlowStatisticsFromFlowTableInput input) {
90         return flowsInTable.handleAndNotify(input, notificationService);
91     }
92 }