public class StandardSocketFactory extends java.lang.Object implements SocketFactory, SocketMetadata
SocketMetadata.Helper
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
host
The hostname to connect to
|
protected long |
loginTimeoutCheckTimestamp
Time when last Login Timeout check occurred
|
protected int |
loginTimeoutCountdown
The remaining login time in milliseconds.
|
protected int |
port
The port number to connect to
|
protected java.net.Socket |
rawSocket
The underlying TCP/IP socket to use
|
protected int |
socketTimeoutBackup
Backup original Socket timeout to be restored after handshake
|
static java.lang.String |
TCP_KEEP_ALIVE_DEFAULT_VALUE |
static java.lang.String |
TCP_KEEP_ALIVE_PROPERTY_NAME |
static java.lang.String |
TCP_NO_DELAY_DEFAULT_VALUE |
static java.lang.String |
TCP_NO_DELAY_PROPERTY_NAME |
static java.lang.String |
TCP_RCV_BUF_DEFAULT_VALUE |
static java.lang.String |
TCP_RCV_BUF_PROPERTY_NAME |
static java.lang.String |
TCP_SND_BUF_DEFAULT_VALUE |
static java.lang.String |
TCP_SND_BUF_PROPERTY_NAME |
static java.lang.String |
TCP_TRAFFIC_CLASS_DEFAULT_VALUE |
static java.lang.String |
TCP_TRAFFIC_CLASS_PROPERTY_NAME |
Constructor and Description |
---|
StandardSocketFactory() |
Modifier and Type | Method and Description |
---|---|
java.net.Socket |
afterHandshake()
Called by the driver after issuing the MySQL protocol handshake and
reading the results of the handshake.
|
java.net.Socket |
beforeHandshake()
Called by the driver before issuing the MySQL protocol handshake.
|
java.net.Socket |
connect(java.lang.String hostname,
int portNumber,
java.util.Properties props)
Creates a new socket using the given properties.
|
protected java.net.Socket |
createSocket(java.util.Properties props)
Create the raw socket.
|
protected int |
getRealTimeout(int expectedTimeout)
Validates the connection/socket timeout that must really be used.
|
boolean |
isLocallyConnected(ConnectionImpl conn) |
protected void |
resetLoginTimeCountdown()
Decrements elapsed time since last reset from login timeout count down.
|
public static final java.lang.String TCP_NO_DELAY_PROPERTY_NAME
public static final java.lang.String TCP_KEEP_ALIVE_DEFAULT_VALUE
public static final java.lang.String TCP_KEEP_ALIVE_PROPERTY_NAME
public static final java.lang.String TCP_RCV_BUF_PROPERTY_NAME
public static final java.lang.String TCP_SND_BUF_PROPERTY_NAME
public static final java.lang.String TCP_TRAFFIC_CLASS_PROPERTY_NAME
public static final java.lang.String TCP_RCV_BUF_DEFAULT_VALUE
public static final java.lang.String TCP_SND_BUF_DEFAULT_VALUE
public static final java.lang.String TCP_TRAFFIC_CLASS_DEFAULT_VALUE
public static final java.lang.String TCP_NO_DELAY_DEFAULT_VALUE
protected java.lang.String host
protected int port
protected java.net.Socket rawSocket
protected int loginTimeoutCountdown
protected long loginTimeoutCheckTimestamp
protected int socketTimeoutBackup
public java.net.Socket afterHandshake() throws java.net.SocketException, java.io.IOException
afterHandshake
in interface SocketFactory
java.net.SocketException
- if a socket error occursjava.io.IOException
- if an I/O error occurspublic java.net.Socket beforeHandshake() throws java.net.SocketException, java.io.IOException
beforeHandshake
in interface SocketFactory
java.net.SocketException
- if a socket error occursjava.io.IOException
- if an I/O error occursprotected java.net.Socket createSocket(java.util.Properties props)
props
- properties available to affect behavior during socket creation.public java.net.Socket connect(java.lang.String hostname, int portNumber, java.util.Properties props) throws java.net.SocketException, java.io.IOException
SocketFactory
com.mysql.jdbc.StandardSocketFactory
Implementing classes
are responsible for handling synchronization of this method (if needed).connect
in interface SocketFactory
hostname
- the hostname passed in the JDBC URL. It will be a single
hostname, as the driver parses multi-hosts (for failover) and
calls this method for each host connection attempt.portNumber
- the port number to connect to (if required).props
- properties passed to the driver via the URL and/or properties
instance.java.net.SocketException
- if a socket error occursjava.io.IOException
- if an I/O error occurscom.mysql.jdbc.SocketFactory#createSocket(Properties)
public boolean isLocallyConnected(ConnectionImpl conn) throws java.sql.SQLException
isLocallyConnected
in interface SocketMetadata
java.sql.SQLException
protected void resetLoginTimeCountdown() throws java.net.SocketException
java.net.SocketException
- If the login timeout is reached or exceeded.protected int getRealTimeout(int expectedTimeout)
expectedTimeout
- The timeout to validate.