2 * Copyright (c) 2014 Brocade Communications Systems, 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
9 package org.opendaylight.controller.md.sal.dom.store.impl.jmx;
11 import java.util.concurrent.ExecutorService;
12 import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
13 import org.opendaylight.controller.md.sal.common.util.jmx.QueuedNotificationManagerMXBeanImpl;
14 import org.opendaylight.controller.md.sal.common.util.jmx.ThreadExecutorStatsMXBeanImpl;
15 import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
18 * Wrapper class for data store MXbeans.
20 * @author Thomas Pantelis
22 public class InMemoryDataStoreStats implements AutoCloseable {
24 private final AbstractMXBean notificationExecutorStatsBean;
25 private final AbstractMXBean dataStoreExecutorStatsBean;
26 private final QueuedNotificationManagerMXBeanImpl notificationManagerStatsBean;
28 public InMemoryDataStoreStats(final String mBeanType, final QueuedNotificationManager<?, ?> manager,
29 final ExecutorService dataStoreExecutor) {
31 notificationManagerStatsBean = new QueuedNotificationManagerMXBeanImpl(manager,
32 "notification-manager", mBeanType, null);
33 notificationManagerStatsBean.registerMBean();
35 notificationExecutorStatsBean = ThreadExecutorStatsMXBeanImpl.create(manager.getExecutor(),
36 "notification-executor", mBeanType, null);
37 if (notificationExecutorStatsBean != null) {
38 notificationExecutorStatsBean.registerMBean();
41 dataStoreExecutorStatsBean = ThreadExecutorStatsMXBeanImpl.create(dataStoreExecutor,
42 "data-store-executor", mBeanType, null);
43 if (dataStoreExecutorStatsBean != null) {
44 dataStoreExecutorStatsBean.registerMBean();
49 public void close() throws Exception {
50 if(notificationExecutorStatsBean != null) {
51 notificationExecutorStatsBean.unregisterMBean();
54 if(dataStoreExecutorStatsBean != null) {
55 dataStoreExecutorStatsBean.unregisterMBean();
58 if(notificationManagerStatsBean != null) {
59 notificationManagerStatsBean.unregisterMBean();