class ConnectionFlow extends Object
| Modifier and Type | Field and Description |
|---|---|
private ClientToProxyConnection |
clientConnection |
private Object |
connectLock |
private ConnectionFlowStep |
currentStep |
private ProxyToServerConnection |
serverConnection |
private Deque<ConnectionFlowStep> |
steps |
private boolean |
suppressInitialRequest |
| Constructor and Description |
|---|
ConnectionFlow(ClientToProxyConnection clientConnection,
ProxyToServerConnection serverConnection,
Object connectLock)
Construct a new
ConnectionFlow for the given client and server
connections. |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
advance()
Advances the flow.
|
private void |
doProcessCurrentStep(ProxyConnectionLogger LOG)
Does the work of processing the current step, checking the result and
handling success/failure.
|
(package private) void |
fail()
Like
fail(Throwable) but with no cause. |
(package private) void |
fail(Throwable cause)
Called when the flow fails at some
ConnectionFlowStep. |
(package private) ConnectionFlow |
first(ConnectionFlowStep step)
Add a
ConnectionFlowStep to the beginning of this flow. |
private ProxyProtocolMessage |
getHAProxyMessage(InetSocketAddress clientAddress,
InetSocketAddress remoteAddress) |
private void |
notifyThreadsWaitingForConnection()
Once we've finished recording our connection and written our initial
request, we can notify anyone who is waiting on the connection that it's
okay to proceed.
|
private void |
processCurrentStep()
Process the current
ConnectionFlowStep. |
(package private) void |
read(Object msg)
While we're in the process of connecting, any messages read by the
ProxyToServerConnection are passed to this method, which passes
it on to ConnectionFlowStep.read(ConnectionFlow, Object) for the
current ConnectionFlowStep. |
private void |
relayProxyInformation() |
(package private) void |
start()
Starts the connection flow, notifying the
ClientToProxyConnection
that we've started. |
(package private) void |
succeed()
Called when the flow is complete and successful.
|
(package private) ConnectionFlow |
then(ConnectionFlowStep step)
Add a
ConnectionFlowStep to the end of this flow. |
private Deque<ConnectionFlowStep> steps
private final ClientToProxyConnection clientConnection
private final ProxyToServerConnection serverConnection
private volatile ConnectionFlowStep currentStep
private volatile boolean suppressInitialRequest
private final Object connectLock
ConnectionFlow(ClientToProxyConnection clientConnection, ProxyToServerConnection serverConnection, Object connectLock)
ConnectionFlow for the given client and server
connections.clientConnection - serverConnection - connectLock - an object that's shared by ConnectionFlow and
ProxyToServerConnection and that is used for
synchronizing the reader and writer threads that are both
involved during the establishing of a connection.ConnectionFlow first(ConnectionFlowStep step)
ConnectionFlowStep to the beginning of this flow.ConnectionFlow then(ConnectionFlowStep step)
ConnectionFlowStep to the end of this flow.void read(Object msg)
ProxyToServerConnection are passed to this method, which passes
it on to ConnectionFlowStep.read(ConnectionFlow, Object) for the
current ConnectionFlowStep.void start()
ClientToProxyConnection
that we've started.void advance()
Advances the flow. advance() will be called until we're either
out of steps, or a step has failed.
private void processCurrentStep()
Process the current ConnectionFlowStep. With each step, we:
ProxyConnection to the
value of ConnectionFlowStep.getState()ConnectionFlowStep.execute()Future returned by
ConnectionFlowStep.execute(), check the success.ConnectionFlowStep.onSuccess(ConnectionFlow).fail(), stopping the connection
flowprivate void doProcessCurrentStep(ProxyConnectionLogger LOG)
void succeed()
ProxyToServerConnection that we succeeded.private void relayProxyInformation()
private ProxyProtocolMessage getHAProxyMessage(InetSocketAddress clientAddress, InetSocketAddress remoteAddress)
void fail(Throwable cause)
ConnectionFlowStep.
Disconnects the ProxyToServerConnection and informs the
ClientToProxyConnection that our connection failed.void fail()
fail(Throwable) but with no cause.private void notifyThreadsWaitingForConnection()
Copyright © 2009–2021. All rights reserved.