Merge "Bug 1666: Fixing the clustering config file issue"
[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 java.util.List;
12
13 import org.opendaylight.yangtools.util.concurrent.ListenerNotificationQueueStats;
14 import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
15
16 import com.google.common.base.Preconditions;
17
18 /**
19  * Implementation of the QueuedNotificationManagerMXBean interface.
20  *
21  * <p>
22  * This class is not intended for use outside of MD-SAL and its part of private
23  * implementation (still exported as public to be reused across MD-SAL implementation
24  * components) and may be removed in subsequent
25  * releases.
26  *
27  * @author Thomas Pantelis
28  */
29 public class QueuedNotificationManagerMXBeanImpl extends AbstractMXBean
30                                                  implements QueuedNotificationManagerMXBean {
31
32     private final QueuedNotificationManager<?,?> manager;
33
34     public QueuedNotificationManagerMXBeanImpl( QueuedNotificationManager<?,?> manager,
35             String mBeanName, String mBeanType, String mBeanCategory ) {
36         super(mBeanName, mBeanType, mBeanCategory);
37         this.manager = Preconditions.checkNotNull( manager );
38     }
39
40     @Override
41     public List<ListenerNotificationQueueStats> getCurrentListenerQueueStats() {
42         return manager.getListenerNotificationQueueStats();
43     }
44
45     @Override
46     public int getMaxListenerQueueSize() {
47         return manager.getMaxQueueCapacity();
48     }
49
50     public QueuedNotificationManagerStats toQueuedNotificationManagerStats() {
51         return new QueuedNotificationManagerStats( getMaxListenerQueueSize(),
52                 getCurrentListenerQueueStats() );
53     }
54 }