Package org.apache.sshd.client.channel
Class AbstractClientChannel
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.util.closeable.IoBaseCloseable
-
- org.apache.sshd.common.util.closeable.AbstractCloseable
-
- org.apache.sshd.common.util.closeable.AbstractInnerCloseable
-
- org.apache.sshd.common.channel.AbstractChannel
-
- org.apache.sshd.client.channel.AbstractClientChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,ClientChannel,ClientSessionHolder,AttributeRepository,AttributeStore,Channel,ChannelListenerManager,StreamingChannel,ChannelStreamWriterResolver,ChannelStreamWriterResolverManager,Closeable,PropertyResolver,SessionContextHolder,SessionHolder<Session>,ExecutorServiceCarrier
- Direct Known Subclasses:
AgentForwardedChannel,ChannelDirectTcpip,ChannelForwardedX11,ChannelSession,TcpipClientChannel
public abstract class AbstractClientChannel extends AbstractChannel implements ClientChannel
TODO Add javadoc
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.sshd.common.channel.AbstractChannel
AbstractChannel.GracefulChannelCloseable, AbstractChannel.GracefulState
-
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
AbstractCloseable.State
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
AttributeRepository.AttributeKey<T>
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.channel.StreamingChannel
StreamingChannel.Streaming
-
-
Field Summary
Fields Modifier and Type Field Description protected ChannelAsyncInputStreamasyncErrprotected ChannelAsyncOutputStreamasyncInprotected ChannelAsyncInputStreamasyncOutprivate java.lang.StringchannelTypeprotected java.io.OutputStreamerrprotected java.util.concurrent.atomic.AtomicReference<java.lang.String>exitSignalHolderprotected java.util.concurrent.atomic.AtomicReference<java.lang.Integer>exitStatusHolderprotected java.io.InputStreaminprotected java.io.InputStreaminvertedErrprotected java.io.OutputStreaminvertedInprotected java.io.InputStreaminvertedOutprotected java.util.concurrent.atomic.AtomicBooleanopenedprotected java.lang.StringopenFailureLangprotected java.lang.StringopenFailureMsgprotected intopenFailureReasonprotected OpenFutureopenFutureprotected java.io.OutputStreamoutprotected StreamingChannel.Streamingstreaming-
Fields inherited from class org.apache.sshd.common.channel.AbstractChannel
channelListenerProxy, channelListeners, closeSignaled, eofReceived, eofSent, gracefulFuture, gracefulState, initialized, RESPONSE_BUFFER_GROWTH_FACTOR, service, unregisterSignaled
-
Fields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, state
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.channel.Channel
CHANNEL_EXEC, CHANNEL_SHELL, CHANNEL_SUBSYSTEM
-
Fields inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolver
NONE
-
Fields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractClientChannel(java.lang.String type)protectedAbstractClientChannel(java.lang.String type, java.util.Collection<? extends RequestHandler<Channel>> handlers)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddChannelSignalRequestHandlers(EventNotifier<java.lang.String> notifier)protected abstract voiddoOpen()protected voiddoWriteData(byte[] data, int off, long len)protected voiddoWriteExtendedData(byte[] data, int off, long len)IoInputStreamgetAsyncErr()IoOutputStreamgetAsyncIn()IoInputStreamgetAsyncOut()java.util.Set<ClientChannelEvent>getChannelState()java.lang.StringgetChannelType()java.io.OutputStreamgetErr()java.lang.StringgetExitSignal()java.lang.IntegergetExitStatus()java.io.InputStreamgetIn()protected CloseablegetInnerCloseable()java.io.InputStreamgetInvertedErr()java.io.OutputStreamgetInvertedIn()Access to an output stream to send data directly to the remote channel.java.io.InputStreamgetInvertedOut()java.io.OutputStreamgetOut()StreamingChannel.StreaminggetStreaming()voidhandleOpenFailure(Buffer buffer)For a client channel, this method will be called internally by the session when the server has rejected this channel opening.voidhandleOpenSuccess(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.voidhandleWindowAdjust(Buffer buffer)Invoked whenSSH_MSG_CHANNEL_WINDOW_ADJUSTreceivedOpenFutureopen()OpenFutureopen(int recipient, long rwSize, long packetSize, Buffer buffer)For a server channel, this method will actually open the channelvoidsetErr(java.io.OutputStream err)voidsetIn(java.io.InputStream in)Set an input stream that will be read by this channel and forwarded to the remote channel.voidsetOut(java.io.OutputStream out)voidsetStreaming(StreamingChannel.Streaming streaming)protected <C extends java.util.Collection<ClientChannelEvent>>
CupdateCurrentChannelState(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-
Methods inherited from class org.apache.sshd.common.channel.AbstractChannel
addChannelListener, addPendingRequest, addRequestHandler, attributeKeys, clearAttributes, computeAttributeIfAbsent, configureWindow, getAttribute, getAttributesCount, getChannelListenerProxy, getChannelStreamWriterResolver, getExecutorService, getId, getLocalWindow, getParentPropertyResolver, getProperties, getRecipient, getRemoteWindow, getRequestHandlers, getSession, handleChannelRegistrationResult, handleChannelRequest, handleChannelUnregistration, handleClose, handleData, handleEof, handleExtendedData, handleFailure, handleInternalRequest, handleRequest, handleSuccess, handleUnknownChannelRequest, init, invokeChannelSignaller, isEofSent, isEofSignalled, isInitialized, notifyStateChanged, notifyStateChanged, preClose, removeAttribute, removeChannelListener, removePendingRequest, removeRequestHandler, resolveChannelStreamWriterResolver, sendEof, sendResponse, sendWindowAdjust, setAttribute, setChannelStreamWriterResolver, setRecipient, signalChannelClosed, signalChannelClosed, signalChannelInitialized, signalChannelInitialized, signalChannelOpenFailure, signalChannelOpenFailure, signalChannelOpenSuccess, signalChannelOpenSuccess, toString, validateIncomingDataSize, writePacket
-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractInnerCloseable
doCloseGracefully, doCloseImmediately
-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListener
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.AttributeRepository
attributeKeys, getAttribute, getAttributesCount
-
Methods inherited from interface org.apache.sshd.common.AttributeStore
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
-
Methods inherited from interface org.apache.sshd.common.channel.Channel
addRequestHandler, addRequestHandlers, getId, getLocalWindow, getRecipient, getRemoteWindow, getRequestHandlers, handleChannelRegistrationResult, handleChannelUnregistration, handleClose, handleData, handleEof, handleExtendedData, handleFailure, handleRequest, handleSuccess, init, isEofSignalled, isInitialized, removeRequestHandler, removeRequestHandlers, resolveAttribute, writePacket
-
Methods inherited from interface org.apache.sshd.common.channel.ChannelListenerManager
addChannelListener, getChannelListenerProxy, removeChannelListener
-
Methods inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolverManager
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolver
-
Methods inherited from interface org.apache.sshd.client.channel.ClientChannel
getClientSession, waitFor
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
Methods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty
-
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSession, getSessionContext
-
-
-
-
Field Detail
-
opened
protected final java.util.concurrent.atomic.AtomicBoolean opened
-
streaming
protected StreamingChannel.Streaming streaming
-
asyncIn
protected ChannelAsyncOutputStream asyncIn
-
asyncOut
protected ChannelAsyncInputStream asyncOut
-
asyncErr
protected ChannelAsyncInputStream asyncErr
-
in
protected java.io.InputStream in
-
invertedIn
protected java.io.OutputStream invertedIn
-
out
protected java.io.OutputStream out
-
invertedOut
protected java.io.InputStream invertedOut
-
err
protected java.io.OutputStream err
-
invertedErr
protected java.io.InputStream invertedErr
-
exitStatusHolder
protected final java.util.concurrent.atomic.AtomicReference<java.lang.Integer> exitStatusHolder
-
exitSignalHolder
protected final java.util.concurrent.atomic.AtomicReference<java.lang.String> exitSignalHolder
-
openFailureReason
protected int openFailureReason
-
openFailureMsg
protected java.lang.String openFailureMsg
-
openFailureLang
protected java.lang.String openFailureLang
-
openFuture
protected OpenFuture openFuture
-
channelType
private final java.lang.String channelType
-
-
Constructor Detail
-
AbstractClientChannel
protected AbstractClientChannel(java.lang.String type)
-
AbstractClientChannel
protected AbstractClientChannel(java.lang.String type, java.util.Collection<? extends RequestHandler<Channel>> handlers)
-
-
Method Detail
-
addChannelSignalRequestHandlers
protected void addChannelSignalRequestHandlers(EventNotifier<java.lang.String> notifier)
-
getChannelType
public java.lang.String getChannelType()
- Specified by:
getChannelTypein interfaceClientChannel- Returns:
- The type of channel reported when it was created
-
getStreaming
public StreamingChannel.Streaming getStreaming()
- Specified by:
getStreamingin interfaceStreamingChannel
-
setStreaming
public void setStreaming(StreamingChannel.Streaming streaming)
- Specified by:
setStreamingin interfaceStreamingChannel
-
getAsyncIn
public IoOutputStream getAsyncIn()
- Specified by:
getAsyncInin interfaceClientChannel
-
getAsyncOut
public IoInputStream getAsyncOut()
- Specified by:
getAsyncOutin interfaceClientChannel
-
getAsyncErr
public IoInputStream getAsyncErr()
- Specified by:
getAsyncErrin interfaceClientChannel
-
getInvertedIn
public java.io.OutputStream getInvertedIn()
Description copied from interface:ClientChannelAccess to an output stream to send data directly to the remote channel. This can be used instead of usingClientChannel.setIn(java.io.InputStream)method and having the channel polling for data in that stream.- Specified by:
getInvertedInin interfaceClientChannel- Returns:
- an OutputStream to be used to send data
-
getIn
public java.io.InputStream getIn()
-
setIn
public void setIn(java.io.InputStream in)
Description copied from interface:ClientChannelSet an input stream that will be read by this channel and forwarded to the remote channel. Note that using such a stream will create an additional thread for pumping the stream which will only be able to end when that stream is actually closed or some data is read. It is recommended to use theClientChannel.getInvertedIn()method instead and write data directly.- Specified by:
setInin interfaceClientChannel- Parameters:
in- an InputStream to be polled and forwarded
-
getInvertedOut
public java.io.InputStream getInvertedOut()
- Specified by:
getInvertedOutin interfaceClientChannel
-
getOut
public java.io.OutputStream getOut()
-
setOut
public void setOut(java.io.OutputStream out)
- Specified by:
setOutin interfaceClientChannel
-
getInvertedErr
public java.io.InputStream getInvertedErr()
- Specified by:
getInvertedErrin interfaceClientChannel
-
getErr
public java.io.OutputStream getErr()
-
setErr
public void setErr(java.io.OutputStream err)
- Specified by:
setErrin interfaceClientChannel
-
getInnerCloseable
protected Closeable getInnerCloseable()
- Overrides:
getInnerCloseablein classAbstractChannel
-
waitFor
public java.util.Set<ClientChannelEvent> waitFor(java.util.Collection<ClientChannelEvent> mask, long timeout)
Description copied from interface:ClientChannelWaits until any of the specified events in the mask is signaled- Specified by:
waitForin interfaceClientChannel- Parameters:
mask- TheClientChannelEvents masktimeout- The timeout to wait (msec.) - if non-positive then forever- Returns:
- The actual signaled event - includes
ClientChannelEvent.TIMEOUTif timeout expired before the expected event was signaled
-
getChannelState
public java.util.Set<ClientChannelEvent> getChannelState()
- Specified by:
getChannelStatein interfaceClientChannel- Returns:
- A snapshot of the current channel state
- See Also:
ClientChannel.waitFor(Collection, long)
-
updateCurrentChannelState
protected <C extends java.util.Collection<ClientChannelEvent>> C updateCurrentChannelState(C state)
-
open
public OpenFuture open() throws java.io.IOException
- Specified by:
openin interfaceClientChannel- Throws:
java.io.IOException
-
open
public OpenFuture open(int recipient, long rwSize, long packetSize, Buffer buffer)
Description copied from interface:ChannelFor a server channel, this method will actually open the channel- Specified by:
openin interfaceChannel- Parameters:
recipient- Recipient identifierrwSize- Read/Write window size (uint32)packetSize- Preferred maximum packet size (uint32)buffer- IncomingBufferthat triggered the call. Note: the buffer's read position is exactly after the information that read to this call was decoded- Returns:
- An
OpenFuturefor the channel open request
-
handleOpenSuccess
public void handleOpenSuccess(int recipient, long rwSize, long packetSize, Buffer buffer)Description copied from interface:ChannelFor a client channel, this method will be called internally by the session when the confirmation has been received.- Specified by:
handleOpenSuccessin interfaceChannel- Parameters:
recipient- Recipient identifierrwSize- Read/Write window size (uint32)packetSize- Preferred maximum packet size (uint32)buffer- IncomingBufferthat triggered the call. Note: the buffer's read position is exactly after the information that read to this call was decoded
-
doOpen
protected abstract void doOpen() throws java.io.IOException- Throws:
java.io.IOException
-
handleOpenFailure
public void handleOpenFailure(Buffer buffer)
Description copied from interface:ChannelFor a client channel, this method will be called internally by the session when the server has rejected this channel opening.- Specified by:
handleOpenFailurein interfaceChannel- Parameters:
buffer- IncomingBufferthat triggered the call. Note: the buffer's read position is exactly after the information that read to this call was decoded
-
doWriteData
protected void doWriteData(byte[] data, int off, long len) throws java.io.IOException- Specified by:
doWriteDatain classAbstractChannel- Throws:
java.io.IOException
-
doWriteExtendedData
protected void doWriteExtendedData(byte[] data, int off, long len) throws java.io.IOException- Specified by:
doWriteExtendedDatain classAbstractChannel- Throws:
java.io.IOException
-
handleWindowAdjust
public void handleWindowAdjust(Buffer buffer) throws java.io.IOException
Description copied from interface:ChannelInvoked whenSSH_MSG_CHANNEL_WINDOW_ADJUSTreceived- Specified by:
handleWindowAdjustin interfaceChannel- Overrides:
handleWindowAdjustin classAbstractChannel- Parameters:
buffer- The rest of the message dataBufferafter decoding the channel identifiers- Throws:
java.io.IOException- If failed to handle the message
-
getExitStatus
public java.lang.Integer getExitStatus()
- Specified by:
getExitStatusin interfaceClientChannel- Returns:
- The signaled exit status via "exit-status" request -
nullif not signaled
-
getExitSignal
public java.lang.String getExitSignal()
- Specified by:
getExitSignalin interfaceClientChannel- Returns:
- The signaled exit signal via "exit-signal" -
nullif not signaled
-
-