com.despegar.jdbc.galera.utils.PoolNameHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of galera-java-client Show documentation
Show all versions of galera-java-client Show documentation
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
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);
}
}