public abstract class AbstractClientChannel extends AbstractChannel implements ClientChannel
AbstractChannel.GracefulChannelCloseable, AbstractChannel.GracefulState
AbstractCloseable.State
ClientChannel.Streaming
AttributeRepository.AttributeKey<T>
Modifier and Type | Field and Description |
---|---|
protected ChannelAsyncInputStream |
asyncErr |
protected ChannelAsyncOutputStream |
asyncIn |
protected ChannelAsyncInputStream |
asyncOut |
private java.lang.String |
channelType |
protected java.io.OutputStream |
err |
protected java.util.concurrent.atomic.AtomicReference<java.lang.String> |
exitSignalHolder |
protected java.util.concurrent.atomic.AtomicReference<java.lang.Integer> |
exitStatusHolder |
protected java.io.InputStream |
in |
protected java.io.InputStream |
invertedErr |
protected java.io.OutputStream |
invertedIn |
protected java.io.InputStream |
invertedOut |
protected java.util.concurrent.atomic.AtomicBoolean |
opened |
protected java.lang.String |
openFailureLang |
protected java.lang.String |
openFailureMsg |
protected int |
openFailureReason |
protected OpenFuture |
openFuture |
protected java.io.OutputStream |
out |
protected ClientChannel.Streaming |
streaming |
channelListenerProxy, channelListeners, eofReceived, eofSent, gracefulFuture, gracefulState, initialized, RESPONSE_BUFFER_GROWTH_FACTOR, service
closeFuture, futureLock, state
log
CHANNEL_EXEC, CHANNEL_SHELL, CHANNEL_SUBSYSTEM
EMPTY
NONE
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT
Modifier | Constructor and Description |
---|---|
protected |
AbstractClientChannel(java.lang.String type) |
protected |
AbstractClientChannel(java.lang.String type,
java.util.Collection<? extends RequestHandler<Channel>> handlers) |
Modifier and Type | Method and Description |
---|---|
protected void |
addChannelSignalRequestHandlers(EventNotifier<java.lang.String> notifier) |
protected abstract void |
doOpen() |
protected void |
doWriteData(byte[] data,
int off,
long len) |
protected void |
doWriteExtendedData(byte[] data,
int off,
long len) |
IoInputStream |
getAsyncErr() |
IoOutputStream |
getAsyncIn() |
IoInputStream |
getAsyncOut() |
java.util.Set<ClientChannelEvent> |
getChannelState() |
java.lang.String |
getChannelType() |
java.io.OutputStream |
getErr() |
java.lang.String |
getExitSignal() |
java.lang.Integer |
getExitStatus() |
java.io.InputStream |
getIn() |
protected Closeable |
getInnerCloseable() |
java.io.InputStream |
getInvertedErr() |
java.io.OutputStream |
getInvertedIn()
Access to an output stream to send data directly to the remote channel.
|
java.io.InputStream |
getInvertedOut() |
java.io.OutputStream |
getOut() |
ClientChannel.Streaming |
getStreaming() |
void |
handleOpenFailure(Buffer buffer)
For a client channel, this method will be called internally by the session when the server has rejected this
channel opening.
|
void |
handleOpenSuccess(int recipient,
long rwSize,
long packetSize,
Buffer buffer)
For a client channel, this method will be called internally by the session when the confirmation has been
received.
|
void |
handleWindowAdjust(Buffer buffer)
Invoked when
SSH_MSG_CHANNEL_WINDOW_ADJUST received |
OpenFuture |
open() |
OpenFuture |
open(int recipient,
long rwSize,
long packetSize,
Buffer buffer)
For a server channel, this method will actually open the channel
|
void |
setErr(java.io.OutputStream err) |
void |
setIn(java.io.InputStream in)
Set an input stream that will be read by this channel and forwarded to the remote channel.
|
void |
setOut(java.io.OutputStream out) |
void |
setStreaming(ClientChannel.Streaming streaming) |
protected <C extends java.util.Collection<ClientChannelEvent>> |
updateCurrentChannelState(C state) |
java.util.Set<ClientChannelEvent> |
waitFor(java.util.Collection<ClientChannelEvent> mask,
long timeout)
Waits until any of the specified events in the mask is signaled
|
addChannelListener, addPendingRequest, addRequestHandler, attributeKeys, clearAttributes, computeAttributeIfAbsent, configureWindow, getAttribute, getAttributesCount, getChannelListenerProxy, getChannelStreamPacketWriterResolver, getExecutorService, getId, getLocalWindow, getParentPropertyResolver, getProperties, getRecipient, getRemoteWindow, getRequestHandlers, getSession, handleChannelRequest, handleClose, handleData, handleEof, handleExtendedData, handleFailure, handleInternalRequest, handleRequest, handleSuccess, handleUnknownChannelRequest, init, invokeChannelSignaller, isEofSent, isEofSignalled, isInitialized, notifyStateChanged, notifyStateChanged, preClose, removeAttribute, removeChannelListener, removePendingRequest, removeRequestHandler, resolveChannelStreamPacketWriterResolver, sendEof, sendResponse, sendWindowAdjust, setAttribute, setChannelStreamPacketWriterResolver, setRecipient, signalChannelClosed, signalChannelClosed, signalChannelInitialized, signalChannelInitialized, signalChannelOpenFailure, signalChannelOpenFailure, signalChannelOpenSuccess, signalChannelOpenSuccess, toString, validateIncomingDataSize, writePacket
doCloseGracefully, doCloseImmediately
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListener
getSimplifiedLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getClientSession, validateCommandExitStatusCode, waitFor
addRequestHandler, addRequestHandlers, getId, getLocalWindow, getRecipient, getRemoteWindow, getRequestHandlers, handleClose, handleData, handleEof, handleExtendedData, handleFailure, handleRequest, handleSuccess, init, isEofSignalled, isInitialized, removeRequestHandler, removeRequestHandlers, resolveAttribute, resolveAttribute
getSession, getSessionContext
addChannelListener, getChannelListenerProxy, removeChannelListener
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
attributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePair
calculatePadLength, writePacket
getChannelStreamPacketWriterResolver, resolveChannelStreamPacketWriter, resolveChannelStreamPacketWriterResolver, setChannelStreamPacketWriterResolver
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
protected final java.util.concurrent.atomic.AtomicBoolean opened
protected ClientChannel.Streaming streaming
protected ChannelAsyncOutputStream asyncIn
protected ChannelAsyncInputStream asyncOut
protected ChannelAsyncInputStream asyncErr
protected java.io.InputStream in
protected java.io.OutputStream invertedIn
protected java.io.OutputStream out
protected java.io.InputStream invertedOut
protected java.io.OutputStream err
protected java.io.InputStream invertedErr
protected final java.util.concurrent.atomic.AtomicReference<java.lang.Integer> exitStatusHolder
protected final java.util.concurrent.atomic.AtomicReference<java.lang.String> exitSignalHolder
protected int openFailureReason
protected java.lang.String openFailureMsg
protected java.lang.String openFailureLang
protected OpenFuture openFuture
private final java.lang.String channelType
protected AbstractClientChannel(java.lang.String type)
protected AbstractClientChannel(java.lang.String type, java.util.Collection<? extends RequestHandler<Channel>> handlers)
protected void addChannelSignalRequestHandlers(EventNotifier<java.lang.String> notifier)
public java.lang.String getChannelType()
getChannelType
in interface ClientChannel
public ClientChannel.Streaming getStreaming()
getStreaming
in interface ClientChannel
public void setStreaming(ClientChannel.Streaming streaming)
setStreaming
in interface ClientChannel
public IoOutputStream getAsyncIn()
getAsyncIn
in interface ClientChannel
public IoInputStream getAsyncOut()
getAsyncOut
in interface ClientChannel
public IoInputStream getAsyncErr()
getAsyncErr
in interface ClientChannel
public java.io.OutputStream getInvertedIn()
ClientChannel
ClientChannel.setIn(java.io.InputStream)
method and having the channel polling for data in that stream.getInvertedIn
in interface ClientChannel
public java.io.InputStream getIn()
public void setIn(java.io.InputStream in)
ClientChannel
ClientChannel.getInvertedIn()
method instead and
write data directly.setIn
in interface ClientChannel
in
- an InputStream to be polled and forwardedpublic java.io.InputStream getInvertedOut()
getInvertedOut
in interface ClientChannel
public java.io.OutputStream getOut()
public void setOut(java.io.OutputStream out)
setOut
in interface ClientChannel
public java.io.InputStream getInvertedErr()
getInvertedErr
in interface ClientChannel
public java.io.OutputStream getErr()
public void setErr(java.io.OutputStream err)
setErr
in interface ClientChannel
protected Closeable getInnerCloseable()
getInnerCloseable
in class AbstractChannel
public java.util.Set<ClientChannelEvent> waitFor(java.util.Collection<ClientChannelEvent> mask, long timeout)
ClientChannel
waitFor
in interface ClientChannel
mask
- The ClientChannelEvent
s masktimeout
- The timeout to wait (msec.) - if non-positive then foreverClientChannelEvent.TIMEOUT
if timeout expired before
the expected event was signaledpublic java.util.Set<ClientChannelEvent> getChannelState()
getChannelState
in interface ClientChannel
ClientChannel.waitFor(Collection, long)
protected <C extends java.util.Collection<ClientChannelEvent>> C updateCurrentChannelState(C state)
public OpenFuture open() throws java.io.IOException
open
in interface ClientChannel
java.io.IOException
public OpenFuture open(int recipient, long rwSize, long packetSize, Buffer buffer)
Channel
recipient
- Recipient identifierrwSize
- Read/Write window size (uint32
)packetSize
- Preferred maximum packet size (uint32
)buffer
- Incoming Buffer
that triggered the call. Note: the buffer's read position is
exactly after the information that read to this call was decodedOpenFuture
for the channel open requestpublic void handleOpenSuccess(int recipient, long rwSize, long packetSize, Buffer buffer)
Channel
recipient
- Recipient identifierrwSize
- Read/Write window size (uint32
)packetSize
- Preferred maximum packet size (uint32
)buffer
- Incoming Buffer
that triggered the call. Note: the buffer's read position is
exactly after the information that read to this call was decodedprotected abstract void doOpen() throws java.io.IOException
java.io.IOException
public void handleOpenFailure(Buffer buffer)
Channel
buffer
- Incoming Buffer
that triggered the call. Note: the buffer's read position is
exactly after the information that read to this call was decodedprotected void doWriteData(byte[] data, int off, long len) throws java.io.IOException
doWriteData
in class AbstractChannel
java.io.IOException
protected void doWriteExtendedData(byte[] data, int off, long len) throws java.io.IOException
doWriteExtendedData
in class AbstractChannel
java.io.IOException
public void handleWindowAdjust(Buffer buffer) throws java.io.IOException
Channel
SSH_MSG_CHANNEL_WINDOW_ADJUST
receivedhandleWindowAdjust
in class AbstractChannel
buffer
- The rest of the message data Buffer
after decoding the channel identifiersjava.io.IOException
- If failed to handle the messagepublic java.lang.Integer getExitStatus()
getExitStatus
in interface ClientChannel
null
if not signaledpublic java.lang.String getExitSignal()
getExitSignal
in interface ClientChannel
null
if not signaled