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

com.despegar.jdbc.galera.utils.PoolNameHelper 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.utils;

import com.google.common.base.Optional;

public class PoolNameHelper {

    public static final String DEFAULT_POOL_PREFIX_NAME = "hikari-pool";
    public static final String STATUS_POOL_PREFIX_NAME = "status-";

    /**
     * Because of errors when hikari pool name have ':' character, we remove the last part of the node name (:port).
     *
     * @param node it has the following pattern "host:port"
     */
    public static String nodeNameWithoutPort(String node) {
        return node.split(":")[0];
    }

    public static String getFullPoolName(Optional poolName, String node) {
        return poolName.or(DEFAULT_POOL_PREFIX_NAME) + "." + nodeNameWithoutPort(node);
    }

    public static String getFullStatusPoolName(Optional poolName, String node) {
        return STATUS_POOL_PREFIX_NAME + getFullPoolName(poolName, node);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy