@NotThreadSafe public class SlicedMessageState<T> extends Object implements AutoCloseable
MessageSlicer| Constructor and Description |
|---|
SlicedMessageState(org.opendaylight.yangtools.concepts.Identifier identifier,
FileBackedOutputStream fileBackedStream,
int messageSliceSize,
int maxRetries,
T replyTarget,
Consumer<Throwable> onFailureCallback,
String logContext)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRetry()
Determines if the slicing can be retried.
|
void |
close() |
int |
getCurrentSliceIndex()
Returns the current slice index that has been sent.
|
org.opendaylight.yangtools.concepts.Identifier |
getIdentifier()
Returns the identifier of this instance.
|
int |
getLastSliceHashCode()
Returns the hash code of the last slice that was sent.
|
byte[] |
getNextSlice()
Reads and returns the next slice of data.
|
Consumer<Throwable> |
getOnFailureCallback()
Returns the callback to notify on failure.
|
T |
getReplyTarget()
Returns the user-defined target for sliced message replies.
|
int |
getTotalSlices()
Returns the total number of slices to send.
|
boolean |
isLastSlice(int index)
Determines if the given index is the last slice to send.
|
void |
reset()
Resets this instance to restart slicing from the beginning.
|
public SlicedMessageState(org.opendaylight.yangtools.concepts.Identifier identifier,
FileBackedOutputStream fileBackedStream,
int messageSliceSize,
int maxRetries,
T replyTarget,
Consumer<Throwable> onFailureCallback,
String logContext)
throws IOException
identifier - the identifier for this instancefileBackedStream - the FileBackedOutputStream containing the serialized data to slicemessageSliceSize - the maximum size (in bytes) for a message slicemaxRetries - the maximum number of retriesreplyTarget - the user-defined target for sliced message repliesonFailureCallback - the callback to notify on failurelogContext - the context for log messagesIOException - if an error occurs opening the input streampublic int getCurrentSliceIndex()
public int getLastSliceHashCode()
public int getTotalSlices()
public org.opendaylight.yangtools.concepts.Identifier getIdentifier()
public T getReplyTarget()
public Consumer<Throwable> getOnFailureCallback()
public boolean canRetry()
public boolean isLastSlice(int index)
index - the slice index to testpublic byte[] getNextSlice()
throws IOException
IOException - if an error occurs reading the datapublic void reset()
throws IOException
IOException - if an error occurs resetting the input streampublic void close()
close in interface AutoCloseableCopyright © 2019 OpenDaylight. All rights reserved.