001/*
002 * jPOS Project [http://jpos.org]
003 * Copyright (C) 2000-2026 jPOS Software SRL
004 *
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jpos.transaction;
020
021import org.jpos.q2.QBeanSupportMBean;
022import java.util.Date;
023
024/**
025 * JMX management interface exposing the TransactionManager's queue counters
026 * and TPS (transactions-per-second) metrics.
027 */
028@SuppressWarnings("unused")
029public interface TransactionManagerMBean extends QBeanSupportMBean {
030    /**
031     * Returns the current head index of the transaction queue.
032     *
033     * @return queue head index
034     */
035    long getHead();
036    /**
037     * Returns the current tail index of the transaction queue.
038     *
039     * @return queue tail index
040     */
041    long getTail();
042    /**
043     * Returns the number of in-flight transactions ({@code tail - head}).
044     *
045     * @return outstanding transaction count
046     */
047    int getOutstandingTransactions();
048    /**
049     * Returns the number of session threads currently processing transactions.
050     *
051     * @return live session count
052     */
053    int getActiveSessions();
054    /**
055     * Returns the configured maximum number of concurrent session threads.
056     *
057     * @return maximum session count
058     */
059    int getMaxSessions();
060    /**
061     * Returns a human-readable summary of TPS statistics.
062     *
063     * @return TPS snapshot suitable for diagnostics
064     */
065    String getTPSAsString();
066    /**
067     * Returns the average transactions-per-second since the last reset.
068     *
069     * @return mean TPS
070     */
071    float getTPSAvg();
072    /**
073     * Returns the peak transactions-per-second observed since the last reset.
074     *
075     * @return peak TPS
076     */
077    int getTPSPeak();
078    /**
079     * Returns the wall-clock instant at which {@link #getTPSPeak()} was reached.
080     *
081     * @return timestamp of the TPS peak, or {@code null} if not yet observed
082     */
083    Date getTPSPeakWhen();
084    /**
085     * Returns the elapsed time in milliseconds covered by the current TPS window.
086     *
087     * @return elapsed window in milliseconds
088     */
089    long getTPSElapsed();
090    /** Resets the TPS counters and start time. */
091    void resetTPS();
092}