public class Cluster extends Object
| Constructor and Description |
|---|
Cluster(String urlIdentifier,
Properties properties) |
| Modifier and Type | Method and Description |
|---|---|
int |
checkClusterState()
Check each data nodes' validity of cluster,
use cached properties to tryConnect to each data nodes,
if cached properties is invalid, remove cached properties,
if state change to valid from invalid, quick load balancing start,
if state change to invalid from valid, clear cached connections of this node.
|
List<Integer> |
checkConnectionsValidity()
Check cached connections validity, and remove invalid connections.
|
boolean |
checkDnState(HostSpec hostSpec)
Check dn state by cached properties, and remove invalid properties.
|
int |
closeConnections()
Close connections from abandonedConnectionList.
|
int |
decrementCachedCreatingConnectionSize(HostSpec hostSpec)
CacheCreatingConnectionNum - 1;
|
boolean |
equals(Object o) |
int |
getCachedConnectionSize()
Get cached connection size.
|
ConnectionInfo |
getConnectionInfo(PgConnection connection)
Get connection info of the connection if exists.
|
int |
getMinReservedConPerCluster()
Get minReservedConPerCluster.
|
int |
getMinReservedConPerDatanode()
Get minReservedConPerDatanode.
|
int |
hashCode() |
int |
incrementCachedCreatingConnectionSize(HostSpec hostSpec)
CachedCreatingConnection + 1
|
boolean |
isEnableMinReservedConPerCluster()
Get enableMinReservedConPerCluster.
|
boolean |
isEnableMinReservedConPerDatanode()
Get enableMInReservedConPerDatanode.
|
static int |
parseMinReservedConPerCluster(Properties properties)
Parse minReservedConPerCluster, value range: [0, 100].
|
static int |
parseMinReservedConPerDatanode(Properties properties)
Parse minReservedConPerDatanode, value range: [0, 100].
|
void |
setConnection(PgConnection pgConnection,
Properties properties)
Add a new connection.
|
void |
setConnectionState(PgConnection pgConnection,
StatementCancelState state)
set connection state of cached connections if it exists.
|
void |
setProperties(Properties properties)
Set new properties if the user doesn't exist in cachedPropertiesList,
or update properties if exists.
|
List<HostSpec> |
sortDnsByLeastConn(List<HostSpec> hostSpecs)
Sort hostSpec list in ascending order by amount of connections.
|
public Cluster(String urlIdentifier, Properties properties) throws PSQLException
PSQLExceptionpublic void setConnectionState(PgConnection pgConnection, StatementCancelState state)
pgConnection - pgConnectionstate - new statepublic void setConnection(PgConnection pgConnection, Properties properties) throws PSQLException
pgConnection - pgConnectionproperties - propertiesPSQLExceptionpublic void setProperties(Properties properties)
properties - propertiespublic int decrementCachedCreatingConnectionSize(HostSpec hostSpec)
hostSpec - hostSpecpublic static int parseMinReservedConPerCluster(Properties properties) throws PSQLException
properties - propertiesPSQLException - minReservedConPerCluster parse failedpublic static int parseMinReservedConPerDatanode(Properties properties) throws PSQLException
properties - propertiesPSQLException - minReservedConPerDatanode parse failedpublic ConnectionInfo getConnectionInfo(PgConnection connection)
connection - connectionpublic List<HostSpec> sortDnsByLeastConn(List<HostSpec> hostSpecs)
hostSpecs - host specspublic int checkClusterState()
public boolean checkDnState(HostSpec hostSpec)
hostSpec - hostSpecpublic List<Integer> checkConnectionsValidity()
public int incrementCachedCreatingConnectionSize(HostSpec hostSpec)
hostSpec - hostSpecpublic int getMinReservedConPerCluster()
public boolean isEnableMinReservedConPerCluster()
public int getMinReservedConPerDatanode()
public boolean isEnableMinReservedConPerDatanode()
public int closeConnections()
public int getCachedConnectionSize()
Copyright © 2023 openGauss. All rights reserved.