class ConnectionFlow extends Object
Modifier and Type | Field and Description |
---|---|
private ClientToProxyConnection |
clientConnection |
private Object |
connectLock |
private ConnectionFlowStep |
currentStep |
private ProxyToServerConnection |
serverConnection |
private Queue<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 . |
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 . |
(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 this flow. |
private Queue<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 then(ConnectionFlowStep step)
ConnectionFlowStep
to this flow.step
- void read(Object msg)
ProxyToServerConnection
are passed to this method, which passes
it on to ConnectionFlowStep.read(ConnectionFlow, Object)
for the
current ConnectionFlowStep
.msg
- 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)
LOG
- void succeed()
ProxyToServerConnection
that we succeeded.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–2017 LittleShoot. All rights reserved.