2 * Copyright © 2017 HPE, 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.netvirt.statistics;
10 import javax.annotation.PostConstruct;
11 import javax.annotation.PreDestroy;
12 import javax.inject.Inject;
13 import javax.inject.Singleton;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
16 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
17 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.StatisticsService;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 public class StatisticsProvider {
26 private static final Logger LOG = LoggerFactory.getLogger(StatisticsProvider.class);
28 private final DataBroker dataBroker;
29 private final IInterfaceManager interfaceManager;
30 private final RpcProviderRegistry rpcProviderRegistry;
31 private final IMdsalApiManager mdsalApiManager;
32 private final IdManagerService idManagerService;
33 private final CounterRetriever counterRetriever;
34 private CountersServiceInterfaceListener csil;
37 public StatisticsProvider(final DataBroker dataBroker, final RpcProviderRegistry rpcProviderRegistry,
38 CounterRetriever counterRetriever, IInterfaceManager interfaceManager, IMdsalApiManager mdsalApiManager,
39 IdManagerService idManagerService) {
40 this.dataBroker = dataBroker;
41 this.interfaceManager = interfaceManager;
42 this.rpcProviderRegistry = rpcProviderRegistry;
43 this.mdsalApiManager = mdsalApiManager;
44 this.counterRetriever = counterRetriever;
45 this.idManagerService = idManagerService;
50 LOG.info("{} start", getClass().getSimpleName());
51 StatisticsImpl statisticsImpl =
52 new StatisticsImpl(dataBroker, counterRetriever, interfaceManager, mdsalApiManager, idManagerService);
53 rpcProviderRegistry.addRpcImplementation(StatisticsService.class, statisticsImpl);
54 csil = new CountersServiceInterfaceListener(dataBroker, statisticsImpl);
58 public void destroy() {
59 LOG.info("{} close", getClass().getSimpleName());