1 package org.opendaylight.controller.config.yang.md.sal.statistics_manager;
3 import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
4 import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerConfig;
5 import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerImpl;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
9 public class StatisticsManagerModule extends org.opendaylight.controller.config.yang.md.sal.statistics_manager.AbstractStatisticsManagerModule {
10 private final static Logger LOG = LoggerFactory.getLogger(StatisticsManagerModule.class);
12 private final static int MAX_NODES_FOR_COLLECTOR_DEFAULT = 16;
13 private final static int MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT = 3000;
15 private StatisticsManager statisticsManagerProvider;
17 public StatisticsManagerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
18 super(identifier, dependencyResolver);
21 public StatisticsManagerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final StatisticsManagerModule oldModule, final java.lang.AutoCloseable oldInstance) {
22 super(identifier, dependencyResolver, oldModule, oldInstance);
26 public void customValidation() {
27 // add custom validation form module attributes here.
31 public java.lang.AutoCloseable createInstance() {
32 LOG.info("StatisticsManager module initialization.");
33 final StatisticsManagerConfig config = createConfig();
34 statisticsManagerProvider = new StatisticsManagerImpl(getDataBrokerDependency(), config);
35 statisticsManagerProvider.start(getNotificationServiceDependency(), getRpcRegistryDependency());
36 LOG.info("StatisticsManager started successfully.");
37 return new AutoCloseable() {
39 public void close() throws Exception {
41 statisticsManagerProvider.close();
43 catch (final Exception e) {
44 LOG.error("Unexpected error by stopping StatisticsManager module", e);
46 LOG.info("StatisticsManager module stopped.");
51 public StatisticsManagerConfig createConfig() {
52 final StatisticsManagerConfig.StatisticsManagerConfigBuilder builder = StatisticsManagerConfig.builder();
53 if (getStatisticsManagerSettings() != null && getStatisticsManagerSettings().getMaxNodesForCollector() != null) {
54 builder.setMaxNodesForCollector(getStatisticsManagerSettings().getMaxNodesForCollector());
56 LOG.warn("Load the xml ConfigSubsystem input value fail! MaxNodesForCollector value is set to {} ",
57 MAX_NODES_FOR_COLLECTOR_DEFAULT);
58 builder.setMaxNodesForCollector(MAX_NODES_FOR_COLLECTOR_DEFAULT);
60 if (getStatisticsManagerSettings() != null &&
61 getStatisticsManagerSettings().getMinRequestNetMonitorInterval() != null) {
62 builder.setMinRequestNetMonitorInterval(getStatisticsManagerSettings().getMinRequestNetMonitorInterval());
64 LOG.warn("Load the xml CofnigSubsystem input value fail! MinRequestNetMonitorInterval value is set to {} ",
65 MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT);
66 builder.setMinRequestNetMonitorInterval(MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT);
68 return builder.build();