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;
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 ThreadExecutorStatsMXBeanImpl notificationExecutorStatsBean;
25 private final ThreadExecutorStatsMXBeanImpl dataStoreExecutorStatsBean;
26 private final QueuedNotificationManagerMXBeanImpl notificationManagerStatsBean;
28 public InMemoryDataStoreStats(String mBeanType, QueuedNotificationManager<?, ?> manager,
29 ExecutorService dataStoreExecutor) {
31 this.notificationManagerStatsBean = new QueuedNotificationManagerMXBeanImpl(manager,
32 "notification-manager", mBeanType, null);
33 notificationManagerStatsBean.registerMBean();
35 this.notificationExecutorStatsBean = new ThreadExecutorStatsMXBeanImpl(manager.getExecutor(),
36 "notification-executor", mBeanType, null);
37 this.notificationExecutorStatsBean.registerMBean();
39 this.dataStoreExecutorStatsBean = new ThreadExecutorStatsMXBeanImpl(dataStoreExecutor,
40 "data-store-executor", mBeanType, null);
41 this.dataStoreExecutorStatsBean.registerMBean();
45 public void close() throws Exception {
46 if(notificationExecutorStatsBean != null) {
47 notificationExecutorStatsBean.unregisterMBean();
50 if(dataStoreExecutorStatsBean != null) {
51 dataStoreExecutorStatsBean.unregisterMBean();
54 if(notificationManagerStatsBean != null) {
55 notificationManagerStatsBean.unregisterMBean();