Class AsyncCapableClientChannel
- 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
-
- org.apache.sshd.client.channel.AsyncCapableClientChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,ClientChannel,ClientSessionHolder,AttributeRepository,AttributeStore,Channel,ChannelIdentifier,ChannelListenerManager,StreamingChannel,ChannelStreamWriterResolver,ChannelStreamWriterResolverManager,Closeable,PropertyResolver,SessionContextHolder,SessionHolder<Session>,ExecutorServiceCarrier
- Direct Known Subclasses:
ChannelDirectTcpip,ChannelSession
public abstract class AsyncCapableClientChannel extends AbstractClientChannel
Channel that sets up asynchronous streams, and that pumps an input stream if set viaAbstractClientChannel.setIn(InputStream).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.sshd.common.channel.AbstractChannel
AbstractChannel.GracefulChannelCloseable, AbstractChannel.GracefulState, AbstractChannel.PacketValidator
-
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 java.util.concurrent.Future<?>pumperprotected CloseableExecutorServicepumperServiceprotected booleanwithErrorStream-
Fields inherited from class org.apache.sshd.client.channel.AbstractClientChannel
asyncErr, asyncIn, asyncOut, err, exitSignalHolder, exitStatusHolder, in, invertedErr, invertedIn, invertedOut, opened, openFailureLang, openFailureMsg, openFailureReason, openFuture, out, redirectErrorStream, streaming
-
Fields inherited from class org.apache.sshd.common.channel.AbstractChannel
channelListenerProxy, channelListeners, closeSignaled, DEFAULT_PACKET_VALIDATOR, 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 protectedAsyncCapableClientChannel(java.lang.String type, boolean withErrorStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseImmediately0()protected voiddoOpen()protected voiddoWriteExtendedData(byte[] data, int off, long len)IoInputStreamgetAsyncErr()java.io.OutputStreamgetErr()protected CloseablegetInnerCloseable()java.io.InputStreamgetInvertedErr()Obtains anInputStreamto read receivedSshConstants.SSH_MSG_CHANNEL_EXTENDED_DATAdata directly from the channel.protected voidpumpInputStream()protected intsecuredRead(java.io.InputStream in, int maxChunkSize, byte[] buf, int off, int len)voidsetErr(java.io.OutputStream err)Sets an output stream for the channel to write receivedSshConstants.SSH_MSG_CHANNEL_EXTENDED_DATAdata to.private <T> Tunsupported(java.util.function.Supplier<? extends T> err)-
Methods inherited from class org.apache.sshd.client.channel.AbstractClientChannel
addChannelSignalRequestHandlers, doWriteData, getAsyncIn, getAsyncOut, getChannelState, getChannelType, getExitSignal, getExitStatus, getIn, getInvertedIn, getInvertedOut, getOut, getStreaming, handleOpenFailure, handleOpenSuccess, handleWindowAdjust, isRedirectErrorStream, mayWrite, open, open, setIn, setOut, setRedirectErrorStream, setStreaming, updateCurrentChannelState, waitFor
-
Methods inherited from class org.apache.sshd.common.channel.AbstractChannel
addChannelListener, addPendingRequest, addRequestHandler, attributeKeys, clearAttributes, computeAttributeIfAbsent, configureWindow, getAttribute, getAttributesCount, getChannelId, getChannelListenerProxy, getChannelStreamWriterResolver, getExecutorService, getLocalWindow, getPacketValidator, 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, setPacketValidator, 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, 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.ChannelIdentifier
getChannelId
-
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
-
withErrorStream
protected final boolean withErrorStream
-
pumperService
protected CloseableExecutorService pumperService
-
pumper
protected java.util.concurrent.Future<?> pumper
-
-
Method Detail
-
unsupported
private <T> T unsupported(java.util.function.Supplier<? extends T> err)
-
getErr
public java.io.OutputStream getErr()
- Overrides:
getErrin classAbstractClientChannel
-
getAsyncErr
public IoInputStream getAsyncErr()
- Specified by:
getAsyncErrin interfaceClientChannel- Overrides:
getAsyncErrin classAbstractClientChannel
-
getInvertedErr
public java.io.InputStream getInvertedErr()
Description copied from interface:ClientChannelObtains anInputStreamto read receivedSshConstants.SSH_MSG_CHANNEL_EXTENDED_DATAdata directly from the channel. This is an alternative toClientChannel.setErr(OutputStream). If the error stream is redirected to the output stream viasetRedirectErrorStream(true), the returned stream will not receive any data and be always at EOF.When the channel closes, it will not close the returned stream. It is the caller's responsibility to close the returned stream if needed. Closing the stream while the channel is open may cause the channel to be closed forcibly if more data arrives. The stream remains open after the channel has closed, so that the caller can read the last arrived data even afterwards.
As with all external processes, the application should read this stream (unless it was redirected) to avoid that the channel blocks when the stream's buffer is full. The buffer size for the returned stream is bounded by the channel's local window size. If the caller does not read this stream, the channel will block once the local window is exhausted.
This method should be called only after the channel has been opened.
- Specified by:
getInvertedErrin interfaceClientChannel- Overrides:
getInvertedErrin classAbstractClientChannel- Returns:
- an
InputStreamfor reading received data, ornullif an output stream was set viaClientChannel.setErr(OutputStream) - See Also:
ClientChannel.setErr(OutputStream),ClientChannel.setRedirectErrorStream(boolean)
-
setErr
public void setErr(java.io.OutputStream err)
Description copied from interface:ClientChannelSets an output stream for the channel to write receivedSshConstants.SSH_MSG_CHANNEL_EXTENDED_DATAdata to. For remote command execution, this is typically the remote command'sstderr.The stream must be set before the channel is opened. When the channel closes, it will
closethe given stream.If no stream is set by the time the channel is opened, the channel will internally forward data to a stream that can be read via the
InputStreamobtained viaClientChannel.getInvertedErr(). (Or it might forward the data to the output stream ifsetRedirectErrorStream(true)is set.)- Specified by:
setErrin interfaceClientChannel- Overrides:
setErrin classAbstractClientChannel- Parameters:
err- theOutputStream- See Also:
ClientChannel.getInvertedErr(),ClientChannel.setRedirectErrorStream(boolean)
-
doWriteExtendedData
protected void doWriteExtendedData(byte[] data, int off, long len) throws java.io.IOException- Overrides:
doWriteExtendedDatain classAbstractClientChannel- Throws:
java.io.IOException
-
doOpen
protected void doOpen() throws java.io.IOException- Specified by:
doOpenin classAbstractClientChannel- Throws:
java.io.IOException
-
getInnerCloseable
protected Closeable getInnerCloseable()
- Overrides:
getInnerCloseablein classAbstractClientChannel
-
closeImmediately0
protected void closeImmediately0()
-
pumpInputStream
protected void pumpInputStream()
-
securedRead
protected int securedRead(java.io.InputStream in, int maxChunkSize, byte[] buf, int off, int len) throws java.io.IOException- Throws:
java.io.IOException
-
-