public class PartialPluginService extends java.lang.Object implements PluginService, CanReleaseResources, HostListProviderService, PluginManagerService
PluginService containing some methods that are not intended to be called. This class is intended to be used
by monitors, which require a PluginService, but are not expected to need or use some of the methods defined
by the PluginService interface. The methods that are not expected to be called will log a warning or throw an
UnsupportedOperationException when called.| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<HostSpec> |
allHosts |
protected @Nullable ConfigurationProfile |
configurationProfile |
protected ConnectionProviderManager |
connectionProviderManager |
protected HostSpec |
currentHostSpec |
protected Dialect |
dbDialect |
protected static long |
DEFAULT_HOST_AVAILABILITY_CACHE_EXPIRE_NANO |
protected java.lang.String |
driverProtocol |
protected @Nullable ExceptionHandler |
exceptionHandler |
protected ExceptionManager |
exceptionManager |
protected static CacheMap<java.lang.String,HostAvailability> |
hostAvailabilityExpiringCache |
protected HostListProvider |
hostListProvider |
protected HostSpec |
initialConnectionHostSpec |
protected boolean |
isInTransaction |
protected java.lang.String |
originalUrl |
protected ConnectionPluginManager |
pluginManager |
protected java.util.Properties |
props |
protected FullServicesContainer |
servicesContainer |
protected TargetDriverDialect |
targetDriverDialect |
| Constructor and Description |
|---|
PartialPluginService(@NonNull FullServicesContainer servicesContainer,
@NonNull ExceptionManager exceptionManager,
@NonNull java.util.Properties props,
@NonNull java.lang.String originalUrl,
@NonNull java.lang.String targetDriverProtocol,
@NonNull TargetDriverDialect targetDriverDialect,
@NonNull Dialect dbDialect,
@Nullable ConfigurationProfile configurationProfile) |
PartialPluginService(@NonNull FullServicesContainer servicesContainer,
@NonNull java.util.Properties props,
@NonNull java.lang.String originalUrl,
@NonNull java.lang.String targetDriverProtocol,
@NonNull TargetDriverDialect targetDriverDialect,
@NonNull Dialect dbDialect) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsStrategy(HostRole role,
java.lang.String strategy)
Returns a boolean indicating if the available
ConnectionProvider or
ConnectionPlugin instances support the selection of a host with the requested role and
strategy via PluginService.getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String). |
static void |
clearCache() |
protected java.util.EnumSet<NodeChangeOptions> |
compare(@NonNull HostSpec hostSpecA,
@NonNull HostSpec hostSpecB) |
java.sql.Connection |
connect(HostSpec hostSpec,
java.util.Properties props)
Establishes a connection to the given host using the given properties.
|
java.sql.Connection |
connect(HostSpec hostSpec,
java.util.Properties props,
@Nullable ConnectionPlugin pluginToSkip) |
void |
fillAliases(java.sql.Connection connection,
HostSpec hostSpec) |
java.sql.Connection |
forceConnect(HostSpec hostSpec,
java.util.Properties props)
Establishes a connection to the given host using the given properties.
|
java.sql.Connection |
forceConnect(HostSpec hostSpec,
java.util.Properties props,
@Nullable ConnectionPlugin pluginToSkip) |
void |
forceRefreshHostList() |
boolean |
forceRefreshHostList(boolean shouldVerifyWriter,
long timeoutMs)
Initiates a topology update.
|
void |
forceRefreshHostList(java.sql.Connection connection) |
java.util.List<HostSpec> |
getAllHosts()
Get host information for all hosts in the cluster.
|
ConnectionProvider |
getConnectionProvider()
Deprecated.
|
java.sql.Connection |
getCurrentConnection() |
HostSpec |
getCurrentHostSpec() |
Dialect |
getDialect() |
java.lang.String |
getDriverProtocol() |
HostListProvider |
getHostListProvider() |
HostRole |
getHostRole(java.sql.Connection conn)
Evaluates the host role of the given connection - either a writer or a reader.
|
java.util.List<HostSpec> |
getHosts()
Get host information for allowed hosts in the cluster.
|
HostSpecBuilder |
getHostSpecBuilder() |
HostSpec |
getHostSpecByStrategy(HostRole role,
java.lang.String strategy)
Selects a
HostSpec with the requested role from available hosts using the requested
strategy. |
HostSpec |
getHostSpecByStrategy(java.util.List<HostSpec> hosts,
HostRole role,
java.lang.String strategy)
Selects a
HostSpec with the requested role from available hosts using the requested
strategy. |
HostSpec |
getInitialConnectionHostSpec() |
java.lang.String |
getOriginalUrl() |
<T> T |
getPlugin(java.lang.Class<T> pluginClazz) |
java.util.Properties |
getProperties() |
@NonNull SessionStateService |
getSessionStateService() |
<T> T |
getStatus(@NonNull java.lang.Class<T> clazz,
boolean clusterBound) |
<T> T |
getStatus(@NonNull java.lang.Class<T> clazz,
java.lang.String key) |
TargetDriverDialect |
getTargetDriverDialect() |
java.lang.String |
getTargetName() |
TelemetryFactory |
getTelemetryFactory() |
HostSpec |
identifyConnection(java.sql.Connection connection) |
boolean |
isInTransaction() |
boolean |
isLoginException(java.lang.String sqlState) |
boolean |
isLoginException(java.lang.Throwable throwable)
The method determines whether provided throwable is about any login or authentication issues.
|
boolean |
isLoginException(java.lang.Throwable throwable,
@Nullable TargetDriverDialect targetDriverDialect) |
boolean |
isNetworkException(java.lang.String sqlState) |
boolean |
isNetworkException(java.lang.Throwable throwable)
The method determines whether provided throwable is about any network issues.
|
boolean |
isNetworkException(java.lang.Throwable throwable,
@Nullable TargetDriverDialect targetDriverDialect) |
boolean |
isPluginInUse(java.lang.Class<? extends ConnectionPlugin> pluginClazz) |
boolean |
isPooledConnectionProvider(HostSpec host,
java.util.Properties props) |
boolean |
isStaticHostListProvider() |
void |
refreshHostList() |
void |
refreshHostList(java.sql.Connection connection) |
void |
releaseResources()
An object that implements this interface should release all acquired resources assuming it may
be disposed at any time.
|
void |
setAllowedAndBlockedHosts(AllowedAndBlockedHosts allowedAndBlockedHosts)
Set the collection of hosts that should be allowed and/or blocked for connections.
|
void |
setAvailability(@NonNull java.util.Set<java.lang.String> hostAliases,
@NonNull HostAvailability availability) |
void |
setCurrentConnection(@NonNull java.sql.Connection connection,
@NonNull HostSpec hostSpec) |
java.util.EnumSet<NodeChangeOptions> |
setCurrentConnection(@NonNull java.sql.Connection connection,
@NonNull HostSpec hostSpec,
@Nullable ConnectionPlugin skipNotificationForThisPlugin)
Set a new internal connection.
|
void |
setHostListProvider(HostListProvider hostListProvider) |
void |
setInitialConnectionHostSpec(@NonNull HostSpec initialConnectionHostSpec) |
void |
setInTransaction(boolean inTransaction) |
<T> void |
setStatus(java.lang.Class<T> clazz,
T status,
boolean clusterBound) |
<T> void |
setStatus(java.lang.Class<T> clazz,
T status,
java.lang.String key) |
void |
updateDialect(@NonNull java.sql.Connection connection) |
protected static final long DEFAULT_HOST_AVAILABILITY_CACHE_EXPIRE_NANO
protected static final CacheMap<java.lang.String,HostAvailability> hostAvailabilityExpiringCache
protected final FullServicesContainer servicesContainer
protected final ConnectionPluginManager pluginManager
protected final java.util.Properties props
protected volatile HostListProvider hostListProvider
protected java.util.List<HostSpec> allHosts
protected HostSpec currentHostSpec
protected HostSpec initialConnectionHostSpec
protected boolean isInTransaction
protected final ExceptionManager exceptionManager
protected final @Nullable ExceptionHandler exceptionHandler
protected final java.lang.String originalUrl
protected final java.lang.String driverProtocol
protected TargetDriverDialect targetDriverDialect
protected Dialect dbDialect
protected final @Nullable ConfigurationProfile configurationProfile
protected final ConnectionProviderManager connectionProviderManager
public PartialPluginService(@NonNull FullServicesContainer servicesContainer, @NonNull java.util.Properties props, @NonNull java.lang.String originalUrl, @NonNull java.lang.String targetDriverProtocol, @NonNull TargetDriverDialect targetDriverDialect, @NonNull Dialect dbDialect)
public PartialPluginService(@NonNull FullServicesContainer servicesContainer, @NonNull ExceptionManager exceptionManager, @NonNull java.util.Properties props, @NonNull java.lang.String originalUrl, @NonNull java.lang.String targetDriverProtocol, @NonNull TargetDriverDialect targetDriverDialect, @NonNull Dialect dbDialect, @Nullable ConfigurationProfile configurationProfile)
public java.sql.Connection getCurrentConnection()
getCurrentConnection in interface HostListProviderServicegetCurrentConnection in interface PluginServicepublic HostSpec getCurrentHostSpec()
getCurrentHostSpec in interface HostListProviderServicegetCurrentHostSpec in interface PluginServicepublic void setInitialConnectionHostSpec(@NonNull HostSpec initialConnectionHostSpec)
setInitialConnectionHostSpec in interface HostListProviderServicepublic HostSpec getInitialConnectionHostSpec()
getInitialConnectionHostSpec in interface HostListProviderServicegetInitialConnectionHostSpec in interface PluginServicepublic java.lang.String getOriginalUrl()
getOriginalUrl in interface PluginServicepublic void setAllowedAndBlockedHosts(AllowedAndBlockedHosts allowedAndBlockedHosts)
PluginServicesetAllowedAndBlockedHosts in interface PluginServiceallowedAndBlockedHosts - An object defining the allowed and blocked sets of hosts.public boolean acceptsStrategy(HostRole role, java.lang.String strategy) throws java.sql.SQLException
PluginServiceConnectionProvider or
ConnectionPlugin instances support the selection of a host with the requested role and
strategy via PluginService.getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String).acceptsStrategy in interface PluginServicerole - the desired host rolestrategy - the strategy that should be used to pick a host (eg "random")ConnectionProvider or ConnectionPlugin instances
support the selection of a host with the requested role and strategy via
PluginService.getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String). Otherwise, return false.java.sql.SQLException - if there's an error processing this method.public HostSpec getHostSpecByStrategy(HostRole role, java.lang.String strategy) throws java.sql.SQLException
PluginServiceHostSpec with the requested role from available hosts using the requested
strategy. PluginService.acceptsStrategy(software.amazon.jdbc.HostRole, java.lang.String) should be called first to evaluate if the available
ConnectionProvider or ConnectionPlugin instances support the selection of a
host with the requested role and strategy.getHostSpecByStrategy in interface PluginServicerole - the desired role of the host - either a writer or a readerstrategy - the strategy that should be used to select a HostSpec from the
available hosts (eg "random")HostSpec with the requested rolejava.sql.SQLException - if the available ConnectionProvider or
ConnectionPlugin instances do not cannot find a
host matching the requested role or an error occurs while
selecting a hostpublic HostSpec getHostSpecByStrategy(java.util.List<HostSpec> hosts, HostRole role, java.lang.String strategy) throws java.sql.SQLException
PluginServiceHostSpec with the requested role from available hosts using the requested
strategy. PluginService.acceptsStrategy(software.amazon.jdbc.HostRole, java.lang.String) should be called first to evaluate if the available
ConnectionProvider or ConnectionPlugin instances support the selection of a
host with the requested role and strategy.getHostSpecByStrategy in interface PluginServicehosts - the list of HostSpec from which a HostSpec will be selected fromrole - the desired role of the host - either a writer or a readerstrategy - the strategy that should be used to select a HostSpec from the
available hosts (eg "random")HostSpec with the requested rolejava.sql.SQLException - if the available ConnectionProvider or
ConnectionPlugin instances do not cannot find a
host matching the requested role or an error occurs while
selecting a hostpublic HostRole getHostRole(java.sql.Connection conn) throws java.sql.SQLException
PluginServicegetHostRole in interface PluginServiceconn - a connection to the database instance whose role should be determinedjava.sql.SQLException - if there is a problem executing or processing the SQL query used to
determine the host role@Deprecated public ConnectionProvider getConnectionProvider()
getConnectionProvider in interface PluginServicepublic boolean isPooledConnectionProvider(HostSpec host, java.util.Properties props)
isPooledConnectionProvider in interface PluginServicepublic java.lang.String getDriverProtocol()
getDriverProtocol in interface PluginServicepublic void setCurrentConnection(@NonNull java.sql.Connection connection,
@NonNull HostSpec hostSpec)
throws java.sql.SQLException
setCurrentConnection in interface PluginServicejava.sql.SQLExceptionpublic java.util.EnumSet<NodeChangeOptions> setCurrentConnection(@NonNull java.sql.Connection connection, @NonNull HostSpec hostSpec, @Nullable ConnectionPlugin skipNotificationForThisPlugin) throws java.sql.SQLException
PluginServiceConnectionPlugin.notifyConnectionChanged(EnumSet) for more details. A plugin mentioned
in parameter skipNotificationForThisPlugin won't be receiving such notification.setCurrentConnection in interface PluginServiceconnection - the new internal connection.hostSpec - the host details for a new internal connection.skipNotificationForThisPlugin - A reference to a plugin that doesn't need to receive notification
about connection change. Usually, a plugin that initiates connection change
doesn't need to receive such notification and uses a pointer to
itself as a call parameter.java.sql.SQLException - if there's an error setting a current connection.protected java.util.EnumSet<NodeChangeOptions> compare(@NonNull HostSpec hostSpecA, @NonNull HostSpec hostSpecB)
public java.util.List<HostSpec> getAllHosts()
PluginServicegetAllHosts in interface PluginServicepublic java.util.List<HostSpec> getHosts()
PluginServicegetHosts in interface PluginServicepublic void setAvailability(@NonNull java.util.Set<java.lang.String> hostAliases,
@NonNull HostAvailability availability)
setAvailability in interface PluginServicepublic boolean isInTransaction()
isInTransaction in interface PluginServicepublic void setInTransaction(boolean inTransaction)
setInTransaction in interface PluginManagerServicepublic HostListProvider getHostListProvider()
getHostListProvider in interface HostListProviderServicegetHostListProvider in interface PluginServicepublic void refreshHostList()
throws java.sql.SQLException
refreshHostList in interface PluginServicejava.sql.SQLExceptionpublic void refreshHostList(java.sql.Connection connection)
throws java.sql.SQLException
refreshHostList in interface PluginServicejava.sql.SQLExceptionpublic void forceRefreshHostList()
throws java.sql.SQLException
forceRefreshHostList in interface PluginServicejava.sql.SQLExceptionpublic void forceRefreshHostList(java.sql.Connection connection)
throws java.sql.SQLException
forceRefreshHostList in interface PluginServicejava.sql.SQLExceptionpublic boolean forceRefreshHostList(boolean shouldVerifyWriter,
long timeoutMs)
throws java.sql.SQLException
PluginServiceforceRefreshHostList in interface PluginServiceshouldVerifyWriter - true, if a caller expects to get topology with the latest confirmed writertimeoutMs - timeout in msec to wait until topology gets refreshed and a new (or existing) writer is
confirmed (if shouldVerifyWriter has a value of true).java.sql.SQLException - if there was an error establishing a connection or fetching a topologypublic boolean isStaticHostListProvider()
isStaticHostListProvider in interface HostListProviderServicepublic void setHostListProvider(HostListProvider hostListProvider)
setHostListProvider in interface HostListProviderServicepublic java.sql.Connection connect(HostSpec hostSpec, java.util.Properties props) throws java.sql.SQLException
PluginServiceConnectionProvider has been set with
Driver.setCustomConnectionProvider(ConnectionProvider) and
ConnectionProvider.acceptsUrl(String, HostSpec, Properties) returns true for the
desired protocol, host, and properties, the connection will be created by the non-default
ConnectionProvider. Otherwise, the connection will be created by the default
ConnectionProvider. The default ConnectionProvider will be DriverConnectionProvider for
connections requested via the DriverManager and
DataSourceConnectionProvider for connections requested via an
AwsWrapperDataSource.connect in interface PluginServicehostSpec - the host details for the desired connectionprops - the connection propertiesConnection to the requested hostjava.sql.SQLException - if there was an error establishing a Connection to the requested
hostpublic java.sql.Connection connect(HostSpec hostSpec, java.util.Properties props, @Nullable ConnectionPlugin pluginToSkip) throws java.sql.SQLException
connect in interface PluginServicejava.sql.SQLExceptionpublic java.sql.Connection forceConnect(HostSpec hostSpec, java.util.Properties props) throws java.sql.SQLException
PluginServiceConnectionPlugin.connect(java.lang.String, software.amazon.jdbc.HostSpec, java.util.Properties, boolean, software.amazon.jdbc.JdbcCallable<java.sql.Connection, java.sql.SQLException>) in that the default ConnectionProvider will be used to
establish the connection even if a non-default ConnectionProvider has been set via
Driver.setCustomConnectionProvider(ConnectionProvider). The default ConnectionProvider will be
DriverConnectionProvider for connections requested via the
DriverManager and DataSourceConnectionProvider for connections
requested via an AwsWrapperDataSource.forceConnect in interface PluginServicehostSpec - the host details for the desired connectionprops - the connection propertiesConnection to the requested hostjava.sql.SQLException - if there was an error establishing a Connection to the requested
hostpublic java.sql.Connection forceConnect(HostSpec hostSpec, java.util.Properties props, @Nullable ConnectionPlugin pluginToSkip) throws java.sql.SQLException
forceConnect in interface PluginServicejava.sql.SQLExceptionpublic void releaseResources()
CanReleaseResourcesCalling this method does NOT mean that an object is disposing and there won't be any further calls. An object should keep its functional state after calling this method.
releaseResources in interface CanReleaseResourcespublic boolean isNetworkException(java.lang.Throwable throwable)
ExceptionHandlerisNetworkException in interface ExceptionHandlerthrowable - A throwable object to check.public boolean isNetworkException(java.lang.Throwable throwable,
@Nullable TargetDriverDialect targetDriverDialect)
isNetworkException in interface ExceptionHandlerpublic boolean isNetworkException(java.lang.String sqlState)
isNetworkException in interface ExceptionHandlerpublic boolean isLoginException(java.lang.Throwable throwable)
ExceptionHandlerisLoginException in interface ExceptionHandlerthrowable - A throwable object to check.public boolean isLoginException(java.lang.Throwable throwable,
@Nullable TargetDriverDialect targetDriverDialect)
isLoginException in interface ExceptionHandlerpublic boolean isLoginException(java.lang.String sqlState)
isLoginException in interface ExceptionHandlerpublic Dialect getDialect()
getDialect in interface HostListProviderServicegetDialect in interface PluginServicepublic TargetDriverDialect getTargetDriverDialect()
getTargetDriverDialect in interface PluginServicepublic void updateDialect(@NonNull java.sql.Connection connection)
updateDialect in interface PluginServicepublic HostSpec identifyConnection(java.sql.Connection connection) throws java.sql.SQLException
identifyConnection in interface PluginServicejava.sql.SQLExceptionpublic void fillAliases(java.sql.Connection connection,
HostSpec hostSpec)
throws java.sql.SQLException
fillAliases in interface PluginServicejava.sql.SQLExceptionpublic HostSpecBuilder getHostSpecBuilder()
getHostSpecBuilder in interface HostListProviderServicegetHostSpecBuilder in interface PluginServicepublic java.util.Properties getProperties()
getProperties in interface PluginServicepublic TelemetryFactory getTelemetryFactory()
getTelemetryFactory in interface PluginServicepublic java.lang.String getTargetName()
getTargetName in interface PluginServicepublic @NonNull SessionStateService getSessionStateService()
getSessionStateService in interface PluginServicepublic <T> T getPlugin(java.lang.Class<T> pluginClazz)
getPlugin in interface PluginServicepublic <T> void setStatus(java.lang.Class<T> clazz,
T status,
boolean clusterBound)
setStatus in interface PluginServicepublic <T> void setStatus(java.lang.Class<T> clazz,
T status,
java.lang.String key)
setStatus in interface PluginServicepublic <T> T getStatus(@NonNull java.lang.Class<T> clazz,
boolean clusterBound)
getStatus in interface PluginServicepublic <T> T getStatus(@NonNull java.lang.Class<T> clazz,
java.lang.String key)
getStatus in interface PluginServicepublic boolean isPluginInUse(java.lang.Class<? extends ConnectionPlugin> pluginClazz)
isPluginInUse in interface PluginServicepublic static void clearCache()