Package org.apache.druid.frame.channel
Class ComposingWritableFrameChannel
- java.lang.Object
-
- org.apache.druid.frame.channel.ComposingWritableFrameChannel
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,WritableFrameChannel
public class ComposingWritableFrameChannel extends Object implements 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.
-
-
Constructor Summary
Constructors Constructor Description ComposingWritableFrameChannel(List<Supplier<OutputChannel>> outputChannelSuppliers, List<Supplier<PartitionedOutputChannel>> partitionedOutputChannelSuppliers, List<Supplier<WritableFrameChannel>> writableChannelSuppliers, Map<Integer,HashSet<Integer>> partitionToChannelMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Finish writing to this channel.void
fail(Throwable cause)
Called prior toWritableFrameChannel.close()
if the writer has failed.boolean
isClosed()
WhetherWritableFrameChannel.close()
has been called on this channel.com.google.common.util.concurrent.ListenableFuture<?>
writabilityFuture()
Returns a future that resolves whenWritableFrameChannel.write(org.apache.druid.frame.channel.FrameWithPartition)
is able to receive a new frame without blocking or throwing an exception.void
write(FrameWithPartition frameWithPartition)
Writes a frame with an attached partition number.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.frame.channel.WritableFrameChannel
write
-
-
-
-
Constructor Detail
-
ComposingWritableFrameChannel
public ComposingWritableFrameChannel(@Nullable List<Supplier<OutputChannel>> outputChannelSuppliers, @Nullable List<Supplier<PartitionedOutputChannel>> partitionedOutputChannelSuppliers, List<Supplier<WritableFrameChannel>> writableChannelSuppliers, Map<Integer,HashSet<Integer>> partitionToChannelMap)
-
-
Method Detail
-
write
public void write(FrameWithPartition frameWithPartition) throws IOException
Description copied from interface:WritableFrameChannel
Writes a frame with an attached partition number. May throw an exception ifWritableFrameChannel.writabilityFuture()
is unresolved.- Specified by:
write
in interfaceWritableFrameChannel
- Throws:
IOException
-
fail
public void fail(@Nullable Throwable cause) throws IOException
Description copied from interface:WritableFrameChannel
Called prior toWritableFrameChannel.close()
if the writer has failed. Must be followed by a call toWritableFrameChannel.close()
.- Specified by:
fail
in interfaceWritableFrameChannel
- Parameters:
cause
- optional cause of failure. Used by the in-memory channelBlockingQueueFrameChannel.Writable
to propagate exeptions to downstream processors. Most other channels ignore the provided cause.- Throws:
IOException
-
close
public void close() throws IOException
Description copied from interface:WritableFrameChannel
Finish 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.frame.channel.FrameWithPartition)
,WritableFrameChannel.fail(Throwable)
, or this method are permitted.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceWritableFrameChannel
- Throws:
IOException
-
isClosed
public boolean isClosed()
Description copied from interface:WritableFrameChannel
WhetherWritableFrameChannel.close()
has been called on this channel.- Specified by:
isClosed
in interfaceWritableFrameChannel
-
writabilityFuture
public com.google.common.util.concurrent.ListenableFuture<?> writabilityFuture()
Description copied from interface:WritableFrameChannel
Returns a future that resolves whenWritableFrameChannel.write(org.apache.druid.frame.channel.FrameWithPartition)
is able to receive a new frame without blocking or throwing an exception. The future never resolves to an exception.- Specified by:
writabilityFuture
in interfaceWritableFrameChannel
-
-