public static enum RemoteInputStream.Flag extends Enum<RemoteInputStream.Flag>
Enum Constant and Description |
---|
GREEDY
Set this flag to greedily drain the input stream wrapped in
RemoteInputStream
and send data to the other side. |
MANUAL_UNEXPORT
If a Callable captures a
RemoteInputStream on its way to the other wide,
RemoteInputStream gets unexported automatically when the callable returns. |
NOT_GREEDY
A dummy flag to make it explicit that the particular use case prevents you from
setting
GREEDY flag. |
Modifier and Type | Method and Description |
---|---|
static RemoteInputStream.Flag |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static RemoteInputStream.Flag[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final RemoteInputStream.Flag GREEDY
RemoteInputStream
and send data to the other side.
RemoteInputStream
is normally unbuffered, in the sense that it will
never attempt to read ahead and only read bytes that are explicitly requested via
InputStream.read(byte[], int, int)
methods (and other overloads.)
This is sometimes important, for example if you are going to pass InputStream to the other side, read specific amount of bytes from the other side, then come back to this side and keep reading.
But inability to read ahead means every RemoteInputStream.read(byte[], int, int)
call incurs
a remote roundtrip. A local buffering via BufferedInputStream
would help,
but you'd still block on a roundtrip whenever a buffer goes empty.
When this flag is set, it changes the underlying data transfer model of
RemoteInputStream
from pull to push. The side that created RemoteInputStream
will launch a thread and start proactively sending data to the other side.
The side that received RemoteInputStream
will buffer this content,
and so now RemoteInputStream.read(byte[], int, int)
will only block
when there's no data. In this way, it hides the network latency completely
when you send a large amount of data.
When communicating with earlier version of the remoting library on the other side, the channel falls back and behaves as if this flag was not specified.
public static final RemoteInputStream.Flag NOT_GREEDY
public static final RemoteInputStream.Flag MANUAL_UNEXPORT
RemoteInputStream
on its way to the other wide,
RemoteInputStream
gets unexported automatically when the callable returns.
If this flag is set, this will not happen, and the input stream must be explicitly closed
to get unexported.public static RemoteInputStream.Flag[] values()
for (RemoteInputStream.Flag c : RemoteInputStream.Flag.values()) System.out.println(c);
public static RemoteInputStream.Flag valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullCopyright © 2004–2022. All rights reserved.