public class GoogleCloudStorageReadChannel extends Object implements SeekableReadableByteChannel
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BACKOFF_INITIAL_INTERVAL_MILLIS |
static int |
DEFAULT_BACKOFF_MAX_ELAPSED_TIME_MILLIS |
static int |
DEFAULT_BACKOFF_MAX_INTERVAL_MILLIS |
static double |
DEFAULT_BACKOFF_MULTIPLIER |
static double |
DEFAULT_BACKOFF_RANDOMIZATION_FACTOR |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this channel.
|
boolean |
isOpen()
Tells whether this channel is open.
|
protected InputStream |
openStreamAndSetSize(long newPosition)
Opens the underlying stream, sets its position to the given value and sets size based on
stream content size.
|
long |
position()
Returns this channel's current position.
|
SeekableReadableByteChannel |
position(long newPosition)
Sets this channel's position.
|
int |
read(ByteBuffer buffer)
Reads from this channel and stores read data in the given buffer.
|
void |
setMaxRetries(int maxRetries)
Sets the number of times to automatically retry by re-opening the underlying readChannel
whenever an exception occurs while reading from it.
|
protected void |
setSize(long size)
Sets size of this channel to the given value.
|
long |
size()
Returns size of the object to which this channel is connected.
|
protected void |
validatePosition(long newPosition)
Validates that the given position is valid for this channel.
|
public static final int DEFAULT_BACKOFF_INITIAL_INTERVAL_MILLIS
public static final double DEFAULT_BACKOFF_RANDOMIZATION_FACTOR
public static final double DEFAULT_BACKOFF_MULTIPLIER
public static final int DEFAULT_BACKOFF_MAX_INTERVAL_MILLIS
public static final int DEFAULT_BACKOFF_MAX_ELAPSED_TIME_MILLIS
public void setMaxRetries(int maxRetries)
public int read(ByteBuffer buffer) throws IOException
read in interface ReadableByteChannelbuffer - buffer to read data intoIOException - on IO errorpublic boolean isOpen()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelIOException - on IO errorpublic long position()
throws IOException
position in interface SeekableReadableByteChannelIOExceptionpublic SeekableReadableByteChannel position(long newPosition) throws IOException
position in interface SeekableReadableByteChannelnewPosition - the new position, counting the number of bytes from the beginning.FileNotFoundException - if the underlying object does not exist.IOException - on IO errorpublic long size()
throws IOException
size in interface SeekableReadableByteChannelIOException - on IO errorprotected void setSize(long size)
protected void validatePosition(long newPosition)
protected InputStream openStreamAndSetSize(long newPosition) throws IOException
newPosition - position to seek into the new stream.IOException - on IO errorCopyright © 2015. All rights reserved.