3971f7f60b9c3f8584aab61b293147857aaa5350
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / OpendaylightPortStatisticsServiceImpl.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.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21
22 public class OpendaylightPortStatisticsServiceImpl implements OpendaylightPortStatisticsService {
23     private final AllPortStatsService allPortStats;
24     private final PortStatsService portStats;
25     private final NotificationPublishService notificationPublishService;
26
27     public OpendaylightPortStatisticsServiceImpl(final RequestContextStack requestContextStack,
28                                                  final DeviceContext deviceContext,
29                                                  final AtomicLong compatibilityXidSeed,
30                                                  final NotificationPublishService notificationPublishService) {
31         this.notificationPublishService = notificationPublishService;
32         allPortStats = new AllPortStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
33         portStats = new PortStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
34     }
35
36     @Override
37     public ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(
38             final GetAllNodeConnectorsStatisticsInput input) {
39         return allPortStats.handleAndNotify(input, notificationPublishService);
40     }
41
42     @Override
43     public ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
44             final GetNodeConnectorStatisticsInput input) {
45         return portStats.handleAndNotify(input, notificationPublishService);
46     }
47 }