2 * Copyright IBM Corporation, 2013. 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
9 package org.opendaylight.controller.md.statistics.manager;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerImpl;
13 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
15 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
16 import org.osgi.framework.BundleContext;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 import com.google.common.annotations.VisibleForTesting;
23 * Statistics Manager Activator
25 * OSGi bundle activator
28 public class StatisticsManagerActivator extends AbstractBindingAwareProvider {
30 private final static Logger LOG = LoggerFactory.getLogger(StatisticsManagerActivator.class);
32 /* TODO move it to ConfigSubsystem */
33 private static final long DEFAULT_MIN_REQUEST_NET_MONITOR_INTERVAL = 3000L;
34 private static final int MAX_NODES_FOR_COLLECTOR = 16;
36 private StatisticsManager statsProvider;
39 public void onSessionInitiated(final ProviderContext session) {
40 LOG.info("StatisticsManagerActivator initialization.");
42 final DataBroker dataBroker = session.getSALService(DataBroker.class);
43 final NotificationProviderService notifService =
44 session.getSALService(NotificationProviderService.class);
45 statsProvider = new StatisticsManagerImpl(dataBroker, MAX_NODES_FOR_COLLECTOR);
46 statsProvider.start(notifService, session, DEFAULT_MIN_REQUEST_NET_MONITOR_INTERVAL);
47 LOG.info("StatisticsManagerActivator started successfully.");
49 catch (final Exception e) {
50 LOG.error("Unexpected error by initialization of StatisticsManagerActivator", e);
56 StatisticsManager getStatisticManager() {
61 protected void stopImpl(final BundleContext context) {
62 if (statsProvider != null) {
64 statsProvider.close();
66 catch (final Exception e) {
67 LOG.error("Unexpected error by stopping StatisticsManagerActivator", e);
71 LOG.info("StatisticsManagerActivator stoped.");