- All Superinterfaces:
AutoCloseable
,Closeable
,HttpBody
,Releasable
- Enclosing interface:
- HttpBody
Stream is a lazy-loaded content. Stream supports only single handler, this handler must be
set before requesting next chunk.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.http.HttpBody
HttpBody.ByteRefHttpBody, HttpBody.ChunkHandler, HttpBody.Full, HttpBody.Stream
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTracingHandler
(HttpBody.ChunkHandler chunkHandler) Adds tracing chunk handler.handler()
Returns current handlervoid
next()
Request next chunk of data from the network.void
setHandler
(HttpBody.ChunkHandler chunkHandler) Sets handler that can handle next chunkMethods inherited from interface org.elasticsearch.core.Releasable
close
-
Method Details
-
handler
Returns current handler -
addTracingHandler
Adds tracing chunk handler. Tracing handler will be invoked before main handler, and should never release or call for next chunk. It should be used for monitoring and logging purposes. -
setHandler
Sets handler that can handle next chunk -
next
void next()Request next chunk of data from the network. The size of the chunk depends on following factors. If request is not compressed then chunk size will be up toHttpTransportSettings.SETTING_HTTP_MAX_CHUNK_SIZE
. If request is compressed then chunk size will be up to max_chunk_size * compression_ratio. Multiple calls can be deduplicated when next chunk is not yet available. It's recommended to call "next" once for every chunk.stream.setHandler((chunk, isLast) -> { processChunk(chunk); if (isLast == false) { stream.next(); } });
-