5e00bce0b2c93449b411acf68cd3945705c42d11
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / OpendaylightMeterStatisticsServiceImpl.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 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.openflow.md.core.sal.convertor.ConvertorExecutor;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
25 import org.opendaylight.yangtools.yang.common.RpcResult;
26
27 public class OpendaylightMeterStatisticsServiceImpl implements OpendaylightMeterStatisticsService {
28     private final AllMeterConfigStatsService allMeterConfig;
29     private final AllMeterStatsService allMeterStats;
30     private final MeterFeaturesService meterFeatures;
31     private final MeterStatsService meterStats;
32     private final NotificationPublishService notificationPublishService;
33
34     public OpendaylightMeterStatisticsServiceImpl(final RequestContextStack requestContextStack,
35                                                   final DeviceContext deviceContext,
36                                                   final AtomicLong compatibilityXidSeed,
37                                                   final NotificationPublishService notificationPublishService,
38                                                   final ConvertorExecutor convertorExecutor) {
39         this.notificationPublishService = notificationPublishService;
40
41         allMeterConfig = new AllMeterConfigStatsService(requestContextStack,
42                                                         deviceContext,
43                                                         compatibilityXidSeed,
44                                                         convertorExecutor);
45         allMeterStats = new AllMeterStatsService(requestContextStack,
46                                                  deviceContext,
47                                                  compatibilityXidSeed,
48                                                  convertorExecutor);
49         meterFeatures = new MeterFeaturesService(requestContextStack, deviceContext, compatibilityXidSeed);
50         meterStats = new MeterStatsService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
51     }
52
53     @Override
54     public ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
55             final GetAllMeterConfigStatisticsInput input) {
56         return allMeterConfig.handleAndNotify(input, notificationPublishService);
57     }
58
59     @Override
60     public ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(
61                                                                       final GetAllMeterStatisticsInput input) {
62         return allMeterStats.handleAndNotify(input, notificationPublishService);
63     }
64
65     @Override
66     public ListenableFuture<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(final GetMeterFeaturesInput input) {
67         return meterFeatures.handleAndNotify(input, notificationPublishService);
68     }
69
70     @Override
71     public ListenableFuture<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(
72             final GetMeterStatisticsInput input) {
73         return meterStats.handleAndNotify(input, notificationPublishService);
74     }
75 }