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
8 package org.opendaylight.controller.cluster.databroker;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.CommitStatsMXBean;
12 import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
13 import org.opendaylight.yangtools.util.DurationStatisticsTracker;
16 * Implementation of the CommitStatsMXBean interface.
18 * @author Thomas Pantelis
20 final class CommitStatsMXBeanImpl extends AbstractMXBean implements CommitStatsMXBean {
21 private final DurationStatisticsTracker commitStatsTracker;
26 * @param commitStatsTracker the DurationStatsTracker used to obtain the stats.
27 * @param mbeantype mBeanType Used as the <code>type</code> property in the bean's ObjectName.
29 CommitStatsMXBeanImpl(final @NonNull DurationStatisticsTracker commitStatsTracker,
30 final @NonNull String mbeantype) {
31 super("CommitStats", mbeantype, null);
32 this.commitStatsTracker = commitStatsTracker;
36 public long getTotalCommits() {
37 return commitStatsTracker.getTotalDurations();
41 public String getLongestCommitTime() {
42 return commitStatsTracker.getDisplayableLongestDuration();
46 public String getShortestCommitTime() {
47 return commitStatsTracker.getDisplayableShortestDuration();
51 public String getAverageCommitTime() {
52 return commitStatsTracker.getDisplayableAverageDuration();
56 public void clearStats() {
57 commitStatsTracker.reset();