public interface ClientChannel extends Channel, StreamingChannel, ClientSessionHolder
AttributeRepository.AttributeKey<T>
StreamingChannel.Streaming
CHANNEL_EXEC, CHANNEL_SHELL, CHANNEL_SUBSYSTEM
EMPTY
NONE
Modifier and Type | Method and Description |
---|---|
IoInputStream |
getAsyncErr() |
IoOutputStream |
getAsyncIn() |
IoInputStream |
getAsyncOut() |
Set<ClientChannelEvent> |
getChannelState() |
String |
getChannelType() |
default ClientSession |
getClientSession() |
String |
getExitSignal() |
Integer |
getExitStatus() |
InputStream |
getInvertedErr()
Obtains an
InputStream to read received SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA data directly
from the channel. |
OutputStream |
getInvertedIn()
Obtains an
OutputStream to send data directly to the remote end of the channel. |
InputStream |
getInvertedOut()
Obtains an
InputStream to read received SshConstants.SSH_MSG_CHANNEL_DATA data directly from the
channel. |
OpenFuture |
open() |
void |
setErr(OutputStream err)
Sets an output stream for the channel to write received
SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA data
to. |
void |
setIn(InputStream in)
Sets an
InputStream that will be read by this channel and forwarded to the remote channel. |
void |
setOut(OutputStream out)
Sets an output stream for the channel to write received
SshConstants.SSH_MSG_CHANNEL_DATA data to. |
void |
setRedirectErrorStream(boolean redirectErrorStream)
Defines whether to redirect the error stream into the output stream; has no effect if
setErr(OutputStream) has also been called by the time the channel is opened. |
static void |
validateCommandExitStatusCode(String command,
Integer exitStatus)
Makes sure remote command exit status has been provided and it is zero
|
default Set<ClientChannelEvent> |
waitFor(Collection<ClientChannelEvent> mask,
Duration timeout)
Waits until any of the specified events in the mask is signaled
|
Set<ClientChannelEvent> |
waitFor(Collection<ClientChannelEvent> mask,
long timeout)
Waits until any of the specified events in the mask is signaled
|
addRequestHandler, addRequestHandlers, getLocalWindow, getRecipient, getRemoteWindow, getRequestHandlers, handleChannelRegistrationResult, handleChannelUnregistration, handleClose, handleData, handleEof, handleExtendedData, handleFailure, handleOpenFailure, handleOpenSuccess, handleRequest, handleSuccess, handleWindowAdjust, init, isEofSignalled, isInitialized, open, removeRequestHandler, removeRequestHandlers, resolveAttribute, resolveAttribute, writePacket
getSession, getSessionContext
getChannelId
addChannelListener, getChannelListenerProxy, removeChannelListener
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty, isEmpty
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
attributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePair
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolver
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
getStreaming, setStreaming
default ClientSession getClientSession()
getClientSession
in interface ClientSessionHolder
ClientSession
usedString getChannelType()
IoOutputStream getAsyncIn()
IoInputStream getAsyncOut()
IoInputStream getAsyncErr()
OutputStream getInvertedIn()
OutputStream
to send data directly to the remote end of the channel. This can be used instead
of using setIn(InputStream)
method and having the channel polling for data in that stream.
When the channel closes, it will close
the returned stream.
This method should be called only after the channel has been opened.
OutputStream
for sending data, or null
if an input stream was set via
setIn(InputStream)
setIn(InputStream)
InputStream getInvertedOut()
InputStream
to read received SshConstants.SSH_MSG_CHANNEL_DATA
data directly from the
channel. This is an alternative to setOut(OutputStream)
. If the error stream is redirected to the output
stream via setRedirectErrorStream(true)
, this stream will also receive
SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA
data.
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 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.
InputStream
for reading received data, or null
if an output stream was set via
setOut(OutputStream)
setOut(OutputStream)
,
setRedirectErrorStream(boolean)
InputStream getInvertedErr()
InputStream
to read received SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA
data directly
from the channel. This is an alternative to setErr(OutputStream)
. If the error stream is redirected to
the output stream via setRedirectErrorStream(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.
InputStream
for reading received data, or null
if an output stream was set via
setErr(OutputStream)
setErr(OutputStream)
,
setRedirectErrorStream(boolean)
void setIn(InputStream in)
InputStream
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 EOF on the stream is reached. It is recommended to use the
getInvertedIn()
method instead and write data directly.
The stream must be set before the channel is opened. When the channel closes, it will close
the given stream.
in
- an InputStream
to be polled and forwardedgetInvertedIn()
void setOut(OutputStream out)
SshConstants.SSH_MSG_CHANNEL_DATA
data to. For
remote command execution, this is typically the remote command's stdout
. If the error stream is
redirected to the output stream via setRedirectErrorStream(true)
, this
stream will also receive SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA
data.
The stream must be set before the channel is opened. When the channel closes, it will close
the 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 InputStream
obtained via getInvertedOut()
.
out
- the OutputStream
getInvertedOut()
,
setRedirectErrorStream(boolean)
void setErr(OutputStream err)
SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA
data
to. For remote command execution, this is typically the remote command's stderr
.
The stream must be set before the channel is opened. When the channel closes, it will close
the 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 InputStream
obtained via getInvertedErr()
. (Or it might forward the data to
the output stream if setRedirectErrorStream(true)
is set.)
err
- the OutputStream
getInvertedErr()
,
setRedirectErrorStream(boolean)
void setRedirectErrorStream(boolean redirectErrorStream)
setErr(OutputStream)
has also been called by the time the channel is opened.redirectErrorStream
- whether to redirect the error stream to the output stream.OpenFuture open() throws IOException
IOException
Set<ClientChannelEvent> getChannelState()
waitFor(Collection, long)
Set<ClientChannelEvent> waitFor(Collection<ClientChannelEvent> mask, long timeout)
mask
- The ClientChannelEvent
s masktimeout
- The timeout to wait (msec.) - if non-positive then foreverClientChannelEvent.TIMEOUT
if timeout expired before
the expected event was signaleddefault Set<ClientChannelEvent> waitFor(Collection<ClientChannelEvent> mask, Duration timeout)
mask
- The ClientChannelEvent
s masktimeout
- The timeout to wait - if null then foreverClientChannelEvent.TIMEOUT
if timeout expired before
the expected event was signaledInteger getExitStatus()
null
if not signaledString getExitSignal()
null
if not signaledstatic void validateCommandExitStatusCode(String command, Integer exitStatus) throws RemoteException
command
- The command string - used only for exception textexitStatus
- The exit status valueRemoteException
- If exitStatus is null
or non-zeroCopyright © 2008–2024 The Apache Software Foundation. All rights reserved.