Package org.postgresql.hostchooser
Class GlobalHostStatusTracker
- java.lang.Object
-
- org.postgresql.hostchooser.GlobalHostStatusTracker
-
public class GlobalHostStatusTracker extends java.lang.ObjectKeeps track of HostSpec targets in a global map.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classGlobalHostStatusTracker.HostSpecStatus
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<HostSpec,GlobalHostStatusTracker.HostSpecStatus>hostStatusMapprivate static ResourceLocklock
-
Constructor Summary
Constructors Constructor Description GlobalHostStatusTracker()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static java.util.List<HostSpec>getCandidateHosts(HostSpec[] hostSpecs, HostRequirement targetServerType, long hostRecheckMillis)Returns a list of candidate hosts that have the required targetServerType.static voidreportHostStatus(HostSpec hostSpec, HostStatus hostStatus)Store the actual observed host status.
-
-
-
Field Detail
-
hostStatusMap
private static final java.util.Map<HostSpec,GlobalHostStatusTracker.HostSpecStatus> hostStatusMap
-
lock
private static final ResourceLock lock
-
-
Method Detail
-
reportHostStatus
public static void reportHostStatus(HostSpec hostSpec, HostStatus hostStatus)
Store the actual observed host status.- Parameters:
hostSpec- The host whose status is known.hostStatus- Latest known status for the host.
-
getCandidateHosts
static java.util.List<HostSpec> getCandidateHosts(HostSpec[] hostSpecs, HostRequirement targetServerType, long hostRecheckMillis)
Returns a list of candidate hosts that have the required targetServerType.- Parameters:
hostSpecs- The potential list of hosts.targetServerType- The required target server type.hostRecheckMillis- How stale information is allowed.- Returns:
- candidate hosts to connect to.
-
-