Top Description Fields Constructors Methods
org.apache.sshd.common.channel

public Class RemoteWindow

extends Window
Class Inheritance
Imports
java.net.SocketTimeoutException, java.time.Duration, .Instant, java.util.Objects, java.util.function.Predicate, org.apache.sshd.common.PropertyResolver, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.apache.sshd.common.util.buffer.BufferUtils

A Window reflecting this side's view of the peer's LocalWindow. A RemoteWindow is initialized when the peer announces its packet and window sizes in the initial message exchange when opening a channel. Whenever this side wants to send data, it checks whether the remote window has still enough space; if not, it sends only as much data as possible. When data is sent, the remote window size is reduced by the number of data bytes sent. When the window size drops to zero, no data is sent at all, and this side will have to wait for an SSH_MSG_CHANNEL_WINDOW_ADJUST message from the peer, which will increase the available window size again.
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private static final Predicate<Window>
SPACE_AVAILABLE_PREDICATE

Default Predicate used to test if space became available

Inherited from org.apache.sshd.common.channel.Window:
lock

Constructor Summary

AccessConstructor and Description
public
RemoteWindow(Channel channel, boolean isClient)

Method Summary

Modifier and TypeMethod and Description
public void
public void
expand(long increment)

public void
init(long
the initial window size
size
,
long
the peer's advertised maximum packet size
packetSize
,
PropertyResolver
{@PropertyResolver } to access properties
resolver
)

Overrides org.apache.sshd.common.channel.Window.init.

Initializes the RemoteWindow with the packet and window sizes received from the peer.

public void
waitAndConsume(long
Size of data to consume
len
,
long
Max. time (millis) to wait for enough data to become available
maxWaitTime
)

Waits for enough data to become available to consume the specified size

public void
waitAndConsume(long
Size of data to consume
len
,
Duration
Max. time to wait for enough data to become available
maxWaitTime
)

Waits for enough data to become available to consume the specified size

protected void
waitForCondition(Predicate<? super Window>
The Predicate to check if the condition has been satisfied - the argument to the predicate is this reference
predicate
,
Duration
Max. time to wait for the condition to be satisfied
maxWaitTime
)

Waits up to a specified amount of time for a condition to be satisfied and signaled via the lock

Note

assumes that lock is acquired when this method is called.

public long

Returns:

Amount of available data - always positive
waitForSpace
(long
Max. time (millis) to wait for space to become available
maxWaitTime
)

Waits until some data becomes available or timeout expires

public long

Returns:

Amount of available data - always positive
waitForSpace
(Duration
Max. time to wait for space to become available
maxWaitTime
)

Waits until some data becomes available or timeout expires

Inherited from org.apache.sshd.common.channel.Window:
checkInitializedclosegetChannelgetMaxSizegetPacketSizegetSizeisOpenlargerThantoStringupdateSize

Field Detail

SPACE_AVAILABLE_PREDICATEback to summary
private static final Predicate<Window> SPACE_AVAILABLE_PREDICATE

Default Predicate used to test if space became available

Constructor Detail

RemoteWindowback to summary
public RemoteWindow(Channel channel, boolean isClient)

Method Detail

consumeback to summary
public void consume(long len)

Implements abstract org.apache.sshd.common.channel.Window.consume.

Annotations
@Override
expandback to summary
public void expand(long increment)
initback to summary
public void init(long size, long packetSize, PropertyResolver resolver)

Overrides org.apache.sshd.common.channel.Window.init.

Initializes the RemoteWindow with the packet and window sizes received from the peer.

Parameters
size:long

the initial window size

packetSize:long

the peer's advertised maximum packet size

resolver:PropertyResolver

{@PropertyResolver } to access properties

Annotations
@Override
waitAndConsumeback to summary
public void waitAndConsume(long len, long maxWaitTime) throws InterruptedException, WindowClosedException, SocketTimeoutException

Waits for enough data to become available to consume the specified size

Parameters
len:long

Size of data to consume

maxWaitTime:long

Max. time (millis) to wait for enough data to become available

Exceptions
InterruptedException:
If interrupted while waiting
WindowClosedException:
If window closed while waiting
SocketTimeoutException:
If timeout expired before enough data became available
See Also
waitForCondition(Predicate, Duration), consume(long)
waitAndConsumeback to summary
public void waitAndConsume(long len, Duration maxWaitTime) throws InterruptedException, WindowClosedException, SocketTimeoutException

Waits for enough data to become available to consume the specified size

Parameters
len:long

Size of data to consume

maxWaitTime:Duration

Max. time to wait for enough data to become available

Exceptions
InterruptedException:
If interrupted while waiting
WindowClosedException:
If window closed while waiting
SocketTimeoutException:
If timeout expired before enough data became available
See Also
waitForCondition(Predicate, Duration), consume(long)
waitForConditionback to summary
protected void waitForCondition(Predicate<? super Window> predicate, Duration maxWaitTime) throws WindowClosedException, InterruptedException, SocketTimeoutException

Waits up to a specified amount of time for a condition to be satisfied and signaled via the lock

Note

assumes that lock is acquired when this method is called.

Parameters
predicate:Predicate<? super Window>

The Predicate to check if the condition has been satisfied - the argument to the predicate is this reference

maxWaitTime:Duration

Max. time to wait for the condition to be satisfied

Exceptions
WindowClosedException:
If window closed while waiting
InterruptedException:
If interrupted while waiting
SocketTimeoutException:
If timeout expired before condition was satisfied
See Also
isOpen()
waitForSpaceback to summary
public long waitForSpace(long maxWaitTime) throws InterruptedException, WindowClosedException, SocketTimeoutException

Waits until some data becomes available or timeout expires

Parameters
maxWaitTime:long

Max. time (millis) to wait for space to become available

Returns:long

Amount of available data - always positive

Exceptions
InterruptedException:
If interrupted while waiting
WindowClosedException:
If window closed while waiting
SocketTimeoutException:
If timeout expired before space became available
See Also
waitForCondition(Predicate, Duration)
waitForSpaceback to summary
public long waitForSpace(Duration maxWaitTime) throws InterruptedException, WindowClosedException, SocketTimeoutException

Waits until some data becomes available or timeout expires

Parameters
maxWaitTime:Duration

Max. time to wait for space to become available

Returns:long

Amount of available data - always positive

Exceptions
InterruptedException:
If interrupted while waiting
WindowClosedException:
If window closed while waiting
SocketTimeoutException:
If timeout expired before space became available
See Also
waitForCondition(Predicate, Duration)