0d5306faf7fbb4f479b8c63504ef40d5aca71c48
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / jmx / CommitStatsMXBeanImpl.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.dom.broker.impl.jmx;
10
11 import javax.annotation.Nonnull;
12 import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
13 import org.opendaylight.yangtools.util.DurationStatisticsTracker;
14
15 /**
16  * Implementation of the CommitStatsMXBean interface.
17  *
18  * @author Thomas Pantelis
19  */
20 public class CommitStatsMXBeanImpl extends AbstractMXBean implements CommitStatsMXBean {
21
22     private final DurationStatisticsTracker commitStatsTracker;
23
24     /**
25      * Constructor.
26      *
27      * @param commitStatsTracker the DurationStatsTracker used to obtain the stats.
28      * @param mBeanType mBeanType Used as the <code>type</code> property in the bean's ObjectName.
29      */
30     public CommitStatsMXBeanImpl(@Nonnull DurationStatisticsTracker commitStatsTracker,
31             @Nonnull String mBeanType) {
32         super("CommitStats", mBeanType, null);
33         this.commitStatsTracker = commitStatsTracker;
34     }
35
36     @Override
37     public long getTotalCommits() {
38         return commitStatsTracker.getTotalDurations();
39     }
40
41     @Override
42     public String getLongestCommitTime() {
43         return commitStatsTracker.getDisplayableLongestDuration();
44     }
45
46     @Override
47     public String getShortestCommitTime() {
48         return commitStatsTracker.getDisplayableShortestDuration();
49     }
50
51     @Override
52     public String getAverageCommitTime() {
53         return commitStatsTracker.getDisplayableAverageDuration();
54     }
55
56     @Override
57     public void clearStats() {
58         commitStatsTracker.reset();
59     }
60 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.