IN
- The type of the input elements.@Internal public class PulsarWriter<IN> extends Object implements TwoPhaseCommittingSink.PrecommittingSinkWriter<IN,PulsarCommittable>
DeliveryGuarantee
s.SinkWriter.Context
Constructor and Description |
---|
PulsarWriter(SinkConfiguration sinkConfiguration,
PulsarSerializationSchema<IN> serializationSchema,
TopicMetadataListener metadataListener,
TopicRouter<IN> topicRouter,
MessageDelayer<IN> messageDelayer,
Sink.InitContext initContext)
Constructor creating a Pulsar writer.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush(boolean endOfInput)
Called on checkpoint or end of input so that the writer to flush all pending data for
at-least-once.
|
Collection<PulsarCommittable> |
prepareCommit()
Prepares for a commit.
|
void |
write(IN element,
SinkWriter.Context context)
Adds an element to the writer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
writeWatermark
public PulsarWriter(SinkConfiguration sinkConfiguration, PulsarSerializationSchema<IN> serializationSchema, TopicMetadataListener metadataListener, TopicRouter<IN> topicRouter, MessageDelayer<IN> messageDelayer, Sink.InitContext initContext)
It will throw a RuntimeException
if PulsarSerializationSchema#open(InitializationContext, PulsarSinkContext, SinkConfiguration)
fails.
sinkConfiguration
- The configuration to configure the Pulsar producer.serializationSchema
- Transform the incoming records into different message properties.metadataListener
- The listener for querying topic metadata.topicRouter
- Topic router to choose topic by incoming records.initContext
- Context to provide information about the runtime environment.public void write(IN element, SinkWriter.Context context) throws IOException, InterruptedException
SinkWriter
write
in interface SinkWriter<IN>
element
- The input recordcontext
- The additional information about the input recordIOException
- if fail to add an element.InterruptedException
public void flush(boolean endOfInput) throws IOException, InterruptedException
SinkWriter
flush
in interface SinkWriter<IN>
IOException
InterruptedException
public Collection<PulsarCommittable> prepareCommit()
TwoPhaseCommittingSink.PrecommittingSinkWriter
This method will be called after SinkWriter.flush(boolean)
and before StatefulSink.StatefulSinkWriter.snapshotState(long)
.
prepareCommit
in interface TwoPhaseCommittingSink.PrecommittingSinkWriter<IN,PulsarCommittable>
public void close() throws Exception
close
in interface AutoCloseable
Exception
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.