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