@NotThreadSafe public class AssembledMessageState extends Object implements AutoCloseable
Constructor and Description |
---|
AssembledMessageState(org.opendaylight.yangtools.concepts.Identifier identifier,
int totalSlices,
FileBackedOutputStreamFactory fileBackedStreamFactory,
String logContext)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addSlice(int sliceIndex,
byte[] data,
int lastSliceHashCode)
Adds a slice to the assembled stream.
|
void |
close() |
com.google.common.io.ByteSource |
getAssembledBytes()
Returns the assembled bytes as a ByteSource.
|
org.opendaylight.yangtools.concepts.Identifier |
getIdentifier()
Returns the identifier of this instance.
|
public AssembledMessageState(org.opendaylight.yangtools.concepts.Identifier identifier, int totalSlices, FileBackedOutputStreamFactory fileBackedStreamFactory, String logContext)
identifier
- the identifier for this instancetotalSlices
- the total number of slices to expectfileBackedStreamFactory
- factory for creating the FileBackedOutputStream instance used for streaminglogContext
- the context for log messagespublic org.opendaylight.yangtools.concepts.Identifier getIdentifier()
public boolean addSlice(int sliceIndex, byte[] data, int lastSliceHashCode) throws MessageSliceException
sliceIndex
- the index of the slicedata
- the sliced datalastSliceHashCode
- the hash code of the last slice sentMessageSliceException
- AssemblerSealedException
- if this instance is already sealed (ie has received all the slices)AssemblerClosedException
- if this instance is already closedpublic com.google.common.io.ByteSource getAssembledBytes() throws IOException
IOException
- if an error occurs obtaining the assembled bytesIllegalStateException
- is this instance is not sealedpublic void close()
close
in interface AutoCloseable
Copyright © 2019 OpenDaylight. All rights reserved.