Package org.apache.druid.frame.channel
Class ComposingWritableFrameChannel
java.lang.Object
org.apache.druid.frame.channel.ComposingWritableFrameChannel
- All Implemented Interfaces:
Closeable,AutoCloseable,WritableFrameChannel
A composed writable channel to write frames. The channel can encapsulate multiple writable channels in it and
automatically switches to next channels once the current write channel cannot allow more writes.
-
Field Summary
Fields inherited from interface org.apache.druid.frame.channel.WritableFrameChannel
NO_PARTITION -
Constructor Summary
ConstructorsConstructorDescriptionComposingWritableFrameChannel(Integer partitionNumber, List<Supplier<OutputChannel>> outputChannelSuppliers, List<Supplier<PartitionedOutputChannel>> partitionedOutputChannelSuppliers, List<Supplier<WritableFrameChannel>> writableChannelSuppliers, Map<Integer, HashSet<Integer>> partitionToChannelMap) Create a new channel. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Finish writing to this channel.voidCalled prior toWritableFrameChannel.close()if the writer has failed.booleanisClosed()WhetherWritableFrameChannel.close()has been called on this channel.com.google.common.util.concurrent.ListenableFuture<?>Returns a future that resolves whenWritableFrameChannel.write(org.apache.druid.query.rowsandcols.RowsAndColumns, int)is able to receive a new batch of data without blocking or throwing an exception.voidwrite(RowsAndColumns rac, int partitionNum) Writes a batch of data with an attached partition number.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.frame.channel.WritableFrameChannel
write, write, write
-
Constructor Details
-
ComposingWritableFrameChannel
public ComposingWritableFrameChannel(@Nullable Integer partitionNumber, @Nullable List<Supplier<OutputChannel>> outputChannelSuppliers, @Nullable List<Supplier<PartitionedOutputChannel>> partitionedOutputChannelSuppliers, List<Supplier<WritableFrameChannel>> writableChannelSuppliers, Map<Integer, HashSet<Integer>> partitionToChannelMap) Create a new channel.- Parameters:
partitionNumber- partition number for a single-partition channel, or null for a multi-partition channeloutputChannelSuppliers- one supplier per composed channel, if this is a single-partition channelpartitionedOutputChannelSuppliers- one supplier per composed channel, if this is a multi-partition channelwritableChannelSuppliers- one supplier per composed channelpartitionToChannelMap- empty map that will be populated with the set of valid channels for each partition
-
-
Method Details
-
write
Description copied from interface:WritableFrameChannelWrites a batch of data with an attached partition number. May throw an exception ifWritableFrameChannel.writabilityFuture()is unresolved.- Specified by:
writein interfaceWritableFrameChannel- Throws:
IOException
-
fail
Description copied from interface:WritableFrameChannelCalled prior toWritableFrameChannel.close()if the writer has failed. Must be followed by a call toWritableFrameChannel.close().- Specified by:
failin interfaceWritableFrameChannel- Parameters:
cause- optional cause of failure. Used by the in-memory channelBlockingQueueFrameChannel.Writableto propagate exeptions to downstream processors. Most other channels ignore the provided cause.- Throws:
IOException
-
close
Description copied from interface:WritableFrameChannelFinish writing to this channel. When this method is called withoutWritableFrameChannel.fail(Throwable)having previously been called, the writer is understood to have completed successfully. After calling this method, no additional calls toWritableFrameChannel.write(org.apache.druid.query.rowsandcols.RowsAndColumns, int),WritableFrameChannel.fail(Throwable), or this method are permitted.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceWritableFrameChannel- Throws:
IOException
-
isClosed
public boolean isClosed()Description copied from interface:WritableFrameChannelWhetherWritableFrameChannel.close()has been called on this channel.- Specified by:
isClosedin interfaceWritableFrameChannel
-
writabilityFuture
public com.google.common.util.concurrent.ListenableFuture<?> writabilityFuture()Description copied from interface:WritableFrameChannelReturns a future that resolves whenWritableFrameChannel.write(org.apache.druid.query.rowsandcols.RowsAndColumns, int)is able to receive a new batch of data without blocking or throwing an exception. The future never resolves to an exception.- Specified by:
writabilityFuturein interfaceWritableFrameChannel
-