OUT - Data type to produce into Kinesis Streams@PublicEvolving
public class FlinkKinesisProducer<OUT>
extends org.apache.flink.streaming.api.functions.sink.RichSinkFunction<OUT>
implements org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
| Modifier and Type | Field and Description |
|---|---|
static String |
KINESIS_PRODUCER_METRIC_GROUP |
static String |
METRIC_BACKPRESSURE_CYCLES |
static String |
METRIC_OUTSTANDING_RECORDS_COUNT |
| Constructor and Description |
|---|
FlinkKinesisProducer(KinesisSerializationSchema<OUT> schema,
Properties configProps)
Create a new FlinkKinesisProducer.
|
FlinkKinesisProducer(org.apache.flink.api.common.serialization.SerializationSchema<OUT> schema,
Properties configProps)
Create a new FlinkKinesisProducer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected com.amazonaws.services.kinesis.producer.KinesisProducer |
getKinesisProducer(com.amazonaws.services.kinesis.producer.KinesisProducerConfiguration producerConfig)
Creates a
KinesisProducer. |
void |
initializeState(org.apache.flink.runtime.state.FunctionInitializationContext context) |
void |
invoke(OUT value,
org.apache.flink.streaming.api.functions.sink.SinkFunction.Context context) |
void |
open(org.apache.flink.configuration.Configuration parameters) |
void |
setCustomPartitioner(KinesisPartitioner<OUT> partitioner) |
void |
setDefaultPartition(String defaultPartition)
Set default partition id.
|
void |
setDefaultStream(String defaultStream)
Set a default stream name.
|
void |
setFailOnError(boolean failOnError)
If set to true, the producer will immediately fail with an exception on any error.
|
void |
setQueueLimit(int queueLimit)
The
KinesisProducer holds an unbounded queue internally. |
void |
snapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context) |
getIterationRuntimeContext, getRuntimeContext, setRuntimeContextpublic static final String KINESIS_PRODUCER_METRIC_GROUP
public static final String METRIC_BACKPRESSURE_CYCLES
public static final String METRIC_OUTSTANDING_RECORDS_COUNT
public FlinkKinesisProducer(org.apache.flink.api.common.serialization.SerializationSchema<OUT> schema, Properties configProps)
SerializationSchema.schema - Serialization schema for the data typeconfigProps - The properties used to configure KinesisProducer, including AWS credentials and AWS regionpublic FlinkKinesisProducer(KinesisSerializationSchema<OUT> schema, Properties configProps)
KinesisSerializationSchema.schema - Kinesis serialization schema for the data typeconfigProps - The properties used to configure KinesisProducer, including AWS credentials and AWS regionpublic void setFailOnError(boolean failOnError)
failOnError - Error behavior flagpublic void setQueueLimit(int queueLimit)
KinesisProducer holds an unbounded queue internally. To avoid memory
problems under high loads, a limit can be employed above which the internal queue
will be flushed, thereby applying backpressure.queueLimit - The maximum length of the internal queue before backpressuringpublic void setDefaultStream(String defaultStream)
defaultStream - Name of the default Kinesis streampublic void setDefaultPartition(String defaultPartition)
defaultPartition - Name of the default partitionpublic void setCustomPartitioner(KinesisPartitioner<OUT> partitioner)
public void open(org.apache.flink.configuration.Configuration parameters)
throws Exception
open in interface org.apache.flink.api.common.functions.RichFunctionopen in class org.apache.flink.api.common.functions.AbstractRichFunctionExceptionpublic void invoke(OUT value, org.apache.flink.streaming.api.functions.sink.SinkFunction.Context context) throws Exception
public void close()
throws Exception
close in interface org.apache.flink.api.common.functions.RichFunctionclose in class org.apache.flink.api.common.functions.AbstractRichFunctionExceptionpublic void initializeState(org.apache.flink.runtime.state.FunctionInitializationContext context)
throws Exception
initializeState in interface org.apache.flink.streaming.api.checkpoint.CheckpointedFunctionExceptionpublic void snapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context)
throws Exception
snapshotState in interface org.apache.flink.streaming.api.checkpoint.CheckpointedFunctionException@VisibleForTesting protected com.amazonaws.services.kinesis.producer.KinesisProducer getKinesisProducer(com.amazonaws.services.kinesis.producer.KinesisProducerConfiguration producerConfig)
KinesisProducer.
Exposed so that tests can inject mock producers easily.Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.