4199186dcdf8ce83b24736a9f53ab8c0db101efa
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / OpendaylightGroupStatisticsServiceImpl.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.group.statistics.rev131111.GetAllGroupStatisticsInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
25 import org.opendaylight.yangtools.yang.common.RpcResult;
26
27 public class OpendaylightGroupStatisticsServiceImpl implements OpendaylightGroupStatisticsService {
28     private final AllGroupsStatsService allGroups;
29     private final GroupDescriptionService groupDesc;
30     private final GroupFeaturesService groupFeat;
31     private final GroupStatsService groupStats;
32     private final NotificationPublishService notificationPublishService;
33
34     public OpendaylightGroupStatisticsServiceImpl(final RequestContextStack requestContextStack,
35                                                   final DeviceContext deviceContext,
36                                                   final AtomicLong compatibilityXidSeed,
37                                                   final NotificationPublishService notificationPublishService,
38                                                   final ConvertorExecutor convertorExecutor) {
39         this.notificationPublishService = notificationPublishService;
40         allGroups =
41                 new AllGroupsStatsService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
42         groupDesc = new GroupDescriptionService(requestContextStack,
43                                                 deviceContext,
44                                                 compatibilityXidSeed,
45                                                 convertorExecutor);
46         groupFeat = new GroupFeaturesService(requestContextStack, deviceContext, compatibilityXidSeed);
47         groupStats = new GroupStatsService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
48     }
49
50     @Override
51     public ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(
52             final GetAllGroupStatisticsInput input) {
53         return allGroups.handleAndNotify(input, notificationPublishService);
54     }
55
56     @Override
57     public ListenableFuture<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(
58             final GetGroupDescriptionInput input) {
59         return groupDesc.handleAndNotify(input, notificationPublishService);
60     }
61
62     @Override
63     public ListenableFuture<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
64         return groupFeat.handleAndNotify(input, notificationPublishService);
65     }
66
67     @Override
68     public ListenableFuture<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(
69             final GetGroupStatisticsInput input) {
70         return groupStats.handleAndNotify(input, notificationPublishService);
71     }
72 }