Enum RemoteInputStream.Flag

    • Enum Constant Detail

      • GREEDY

        public static final RemoteInputStream.Flag GREEDY
        Set this flag to greedily drain the input stream wrapped in 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.

      • NOT_GREEDY

        public static final RemoteInputStream.Flag NOT_GREEDY
        A dummy flag to make it explicit that the particular use case prevents you from setting GREEDY flag. The lack of GREEDY flag incurs a considerable performance penalty, so when a developer chooses to do so, it's good to record that explicitly, hence this flag.

        public static final RemoteInputStream.Flag MANUAL_UNEXPORT
        If a Callable captures a 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.
    • Method Detail

      • values

        public static RemoteInputStream.Flag[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (RemoteInputStream.Flag c : RemoteInputStream.Flag.values())
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static RemoteInputStream.Flag valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        name - the name of the enum constant to be returned.
        the enum constant with the specified name
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null