Interface Sink.InitContext
-
@PublicEvolving public static interface Sink.InitContextThe interface exposes some runtime info for creating aSinkWriter.
-
-
Field Summary
Fields Modifier and Type Field Description static longINITIAL_CHECKPOINT_IDThe first checkpoint id when an application is started and not recovered from a previously taken checkpoint or savepoint.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description SerializationSchema.InitializationContextasSerializationSchemaInitializationContext()Provides a view on this context as aSerializationSchema.InitializationContext.<IN> TypeSerializer<IN>createInputSerializer()Creates a serializer for the type of sink's input.intgetAttemptNumber()Gets the attempt number of this parallel subtask.JobIDgetJobId()The ID of the current job.MailboxExecutorgetMailboxExecutor()Returns the mailbox executor that allows to executeRunnables inside the task thread in between record processing.intgetNumberOfParallelSubtasks()ProcessingTimeServicegetProcessingTimeService()Returns aProcessingTimeServicethat can be used to get the current time and register timers.OptionalLonggetRestoredCheckpointId()Returns id of the restored checkpoint, if state was restored from the snapshot of a previous execution.intgetSubtaskId()UserCodeClassLoadergetUserCodeClassLoader()Gets theUserCodeClassLoaderto load classes that are not in system's classpath, but are part of the jar file of a user job.booleanisObjectReuseEnabled()Returns whether object reuse has been enabled or disabled.default <MetaT> Optional<java.util.function.Consumer<MetaT>>metadataConsumer()Returns a metadata consumer, theSinkWritercan publish metadata events of typeSink.InitContextto the consumer.org.apache.flink.metrics.groups.SinkWriterMetricGroupmetricGroup()
-
-
-
Field Detail
-
INITIAL_CHECKPOINT_ID
static final long INITIAL_CHECKPOINT_ID
The first checkpoint id when an application is started and not recovered from a previously taken checkpoint or savepoint.- See Also:
- Constant Field Values
-
-
Method Detail
-
getUserCodeClassLoader
UserCodeClassLoader getUserCodeClassLoader()
Gets theUserCodeClassLoaderto load classes that are not in system's classpath, but are part of the jar file of a user job.- See Also:
UserCodeClassLoader
-
getMailboxExecutor
MailboxExecutor getMailboxExecutor()
Returns the mailbox executor that allows to executeRunnables inside the task thread in between record processing.Note that this method should not be used per-record for performance reasons in the same way as records should not be sent to the external system individually. Rather, implementers are expected to batch records and only enqueue a single
Runnableper batch to handle the result.
-
getProcessingTimeService
ProcessingTimeService getProcessingTimeService()
Returns aProcessingTimeServicethat can be used to get the current time and register timers.
-
getSubtaskId
int getSubtaskId()
- Returns:
- The id of task where the writer is.
-
getNumberOfParallelSubtasks
int getNumberOfParallelSubtasks()
- Returns:
- The number of parallel Sink tasks.
-
getAttemptNumber
int getAttemptNumber()
Gets the attempt number of this parallel subtask. First attempt is numbered 0.- Returns:
- Attempt number of the subtask.
-
metricGroup
org.apache.flink.metrics.groups.SinkWriterMetricGroup metricGroup()
- Returns:
- The metric group this writer belongs to.
-
getRestoredCheckpointId
OptionalLong getRestoredCheckpointId()
Returns id of the restored checkpoint, if state was restored from the snapshot of a previous execution.
-
asSerializationSchemaInitializationContext
SerializationSchema.InitializationContext asSerializationSchemaInitializationContext()
Provides a view on this context as aSerializationSchema.InitializationContext.
-
isObjectReuseEnabled
boolean isObjectReuseEnabled()
Returns whether object reuse has been enabled or disabled.
-
createInputSerializer
<IN> TypeSerializer<IN> createInputSerializer()
Creates a serializer for the type of sink's input.
-
getJobId
JobID getJobId()
The ID of the current job. Note that Job ID can change in particular upon manual restart. The returned ID should NOT be used for any job management tasks.
-
metadataConsumer
@Experimental default <MetaT> Optional<java.util.function.Consumer<MetaT>> metadataConsumer()
Returns a metadata consumer, theSinkWritercan publish metadata events of typeSink.InitContextto the consumer.It is recommended to use a separate thread pool to publish the metadata because enqueuing a lot of these messages in the mailbox may lead to a performance decrease. thread, and the
Consumer.accept(T)method is executed very fast.
-
-