0f324cbfd76a4fdf750b78b25f30322c8a26eaac
[controller.git] / opendaylight / md-sal / sal-common-util / src / main / java / org / opendaylight / controller / md / sal / common / util / jmx / QueuedNotificationManagerMXBeanImpl.java
1 /*
2  * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.md.sal.common.util.jmx;
10
11 import com.google.common.base.Preconditions;
12 import java.util.List;
13 import org.opendaylight.yangtools.util.concurrent.ListenerNotificationQueueStats;
14 import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
15
16 /**
17  * Implementation of the QueuedNotificationManagerMXBean interface.
18  *
19  * <p>
20  * This class is not intended for use outside of MD-SAL and its part of private
21  * implementation (still exported as public to be reused across MD-SAL implementation
22  * components) and may be removed in subsequent
23  * releases.
24  *
25  * @author Thomas Pantelis
26  */
27 public class QueuedNotificationManagerMXBeanImpl extends AbstractMXBean
28                                                  implements QueuedNotificationManagerMXBean {
29
30     private final QueuedNotificationManager<?,?> manager;
31
32     public QueuedNotificationManagerMXBeanImpl(QueuedNotificationManager<?,?> manager,
33             String beanName, String beanType, String beanCategory) {
34         super(beanName, beanType, beanCategory);
35         this.manager = Preconditions.checkNotNull(manager);
36     }
37
38     @Override
39     public List<ListenerNotificationQueueStats> getCurrentListenerQueueStats() {
40         return manager.getListenerNotificationQueueStats();
41     }
42
43     @Override
44     public int getMaxListenerQueueSize() {
45         return manager.getMaxQueueCapacity();
46     }
47
48     public QueuedNotificationManagerStats toQueuedNotificationManagerStats() {
49         return new QueuedNotificationManagerStats(getMaxListenerQueueSize(), getCurrentListenerQueueStats());
50     }
51 }