All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.despegar.jdbc.galera.metrics.HikariMetrics Maven / Gradle / Ivy

Go to download

A simple Java client for MariaDB Galera Cluster and Percona XtraDB Cluster. It is designed to be an alternative to connect JVM app to MariaDB/Percona galera nodes without HAProxy

There is a newer version: 1.0.20
Show newest version
package com.despegar.jdbc.galera.metrics;

import com.google.common.base.Optional;

/**
 * HikariCP exposes the following metrics:
 * 1) waitPercentile95      It shows how long requesting threads to getConnection() are waiting for a connection (or timeout exception) from the pool.
 * 2) usagePercentile95     It shows how long each connection is used before being returned to the pool. This is the "out of pool" or "in-use" time.
 * 3) totalConnections      This value indicates the total number of connections in the pool.
 * 4) idleConnections       This value indicates the number of idle connections in the pool.
 * 5) activeConnections     This value indicates the number of the number of active (in - use) connections in the pool.
 * 6) waitingForConnections This value indicates the number of threads awaiting connections from the pool.
 */
public class HikariMetrics {

    private Optional waitPercentile95;
    private Optional usagePercentile95;
    private Optional totalConnections;
    private Optional idleConnections;
    private Optional activeConnections;
    private Optional waitingForConnections;

    private HikariMetrics(Builder builder) {
        this.waitPercentile95 = builder.waitPercentile95;
        this.usagePercentile95 = builder.usagePercentile95;
        this.totalConnections = builder.totalConnections;
        this.activeConnections = builder.activeConnections;
        this.idleConnections = builder.idleConnections;
        this.waitingForConnections = builder.waitingForConnections;
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public Optional getWaitPercentile95() {
        return waitPercentile95;
    }

    public Optional getUsagePercentile95() {
        return usagePercentile95;
    }

    public Optional getTotalConnections() {
        return totalConnections;
    }

    public Optional getIdleConnections() {
        return idleConnections;
    }

    public Optional getActiveConnections() {
        return activeConnections;
    }

    public Optional getWaitingForConnections() {
        return waitingForConnections;
    }

    public static final class Builder {
        private Optional waitPercentile95;
        private Optional usagePercentile95;
        private Optional totalConnections;
        private Optional idleConnections;
        private Optional activeConnections;
        private Optional waitingForConnections;

        private Builder() {
        }

        public Builder waitPercentile95(Optional waitPercentile95) {
            this.waitPercentile95 = waitPercentile95;
            return this;
        }

        public Builder usagePercentile95(Optional usagePercentile95) {
            this.usagePercentile95 = usagePercentile95;
            return this;
        }

        public Builder totalConnections(Optional totalConnections) {
            this.totalConnections = totalConnections;
            return this;
        }

        public Builder idleConnections(Optional idleConnections) {
            this.idleConnections = idleConnections;
            return this;
        }

        public Builder activeConnections(Optional activeConnections) {
            this.activeConnections = activeConnections;
            return this;
        }

        public Builder waitingForConnections(Optional waitingForConnections) {
            this.waitingForConnections = waitingForConnections;
            return this;
        }

        public HikariMetrics build() {
            return new HikariMetrics(this);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy