class ConnectionFlow extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
private ClientToProxyConnection |
clientConnection |
private Object |
connectLock |
private ConnectionFlowStep |
currentStep |
private ProxyToServerConnection |
serverConnection |
private Queue<ConnectionFlowStep> |
steps |
private boolean |
suppressInitialRequest |
| 构造器和说明 |
|---|
ConnectionFlow(ClientToProxyConnection clientConnection,
ProxyToServerConnection serverConnection,
Object connectLock)
Construct a new
ConnectionFlow for the given client and server connections. |
| 限定符和类型 | 方法和说明 |
|---|---|
(专用程序包) void |
advance()
Advances the flow.
|
private void |
doProcessCurrentStep(ProxyConnectionLogger logger)
Does the work of processing the current step, checking the result and handling success/failure.
|
(专用程序包) void |
fail()
Like
fail(Throwable) but with no cause. |
(专用程序包) 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. |
(专用程序包) 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. |
(专用程序包) void |
start()
Starts the connection flow, notifying the
ClientToProxyConnection that we've started. |
(专用程序包) void |
succeed()
Called when the flow is complete and successful.
|
(专用程序包) 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 - client connectionserverConnection - server connectionconnectLock - 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 - stepvoid read(Object msg)
ProxyToServerConnection are passed to
this method, which passes it on to ConnectionFlowStep.read(ConnectionFlow, Object) for the current
ConnectionFlowStep.msg - messagevoid 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 logger)
logger - 日志对象void succeed()
ProxyToServerConnection that we succeeded.void fail(Throwable cause)
ConnectionFlowStep. Disconnects the ProxyToServerConnection
and informs the ClientToProxyConnection that our connection failed.cause - errorvoid fail()
fail(Throwable) but with no cause.private void notifyThreadsWaitingForConnection()
Copyright © 2022 Zodiac. All rights reserved.