Package io.pravega.connectors.flink.sink
Class PravegaSinkBuilder<T>
- java.lang.Object
-
- io.pravega.connectors.flink.sink.PravegaSinkBuilder<T>
-
- Type Parameters:
T
- the element type.
public class PravegaSinkBuilder<T> extends java.lang.Object
A builder forPravegaEventSink
andPravegaTransactionalSink
.
-
-
Field Summary
Fields Modifier and Type Field Description protected static long
DEFAULT_TXN_LEASE_RENEWAL_PERIOD_MILLIS
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PravegaSink<T>
build()
Builds aPravegaSink
based on the configuration.PravegaSinkBuilder<T>
forStream(io.pravega.client.stream.Stream stream)
Add a stream to be written to by the sink.PravegaSinkBuilder<T>
forStream(java.lang.String streamSpec)
Add a stream to be written to by the sink.io.pravega.client.stream.Stream
resolveStream()
Resolves the stream to be provided to the sink, based on the configured default scope.PravegaSinkBuilder<T>
withEventRouter(PravegaEventRouter<T> eventRouter)
Sets the event router.PravegaSinkBuilder<T>
withPravegaConfig(PravegaConfig pravegaConfig)
Set the Pravega client configuration, which includes connection info, security info, and a default scope.PravegaSinkBuilder<T>
withSerializationSchema(org.apache.flink.api.common.serialization.SerializationSchema<T> serializationSchema)
Sets the serialization schema.PravegaSinkBuilder<T>
withTxnLeaseRenewalPeriod(org.apache.flink.api.common.time.Time period)
Sets the transaction lease renewal period.PravegaSinkBuilder<T>
withWriterMode(PravegaWriterMode writerMode)
Sets the writer mode to provide at-least-once or exactly-once guarantees.
-
-
-
Field Detail
-
DEFAULT_TXN_LEASE_RENEWAL_PERIOD_MILLIS
protected static final long DEFAULT_TXN_LEASE_RENEWAL_PERIOD_MILLIS
- See Also:
- Constant Field Values
-
-
Method Detail
-
withPravegaConfig
public PravegaSinkBuilder<T> withPravegaConfig(PravegaConfig pravegaConfig)
Set the Pravega client configuration, which includes connection info, security info, and a default scope.The default client configuration is obtained from
PravegaConfig.fromDefaults()
.- Parameters:
pravegaConfig
- the configuration to use.- Returns:
- A builder to configure and create a sink.
-
forStream
public PravegaSinkBuilder<T> forStream(java.lang.String streamSpec)
Add a stream to be written to by the sink.- Parameters:
streamSpec
- the unqualified or qualified name of the stream.- Returns:
- A builder to configure and create a sink.
-
forStream
public PravegaSinkBuilder<T> forStream(io.pravega.client.stream.Stream stream)
Add a stream to be written to by the sink.- Parameters:
stream
- the stream.- Returns:
- A builder to configure and create a sink.
-
withWriterMode
public PravegaSinkBuilder<T> withWriterMode(PravegaWriterMode writerMode)
Sets the writer mode to provide at-least-once or exactly-once guarantees.- Parameters:
writerMode
- The writer mode ofBEST_EFFORT
,ATLEAST_ONCE
, orEXACTLY_ONCE
.- Returns:
- A builder to configure and create a sink.
-
withTxnLeaseRenewalPeriod
public PravegaSinkBuilder<T> withTxnLeaseRenewalPeriod(org.apache.flink.api.common.time.Time period)
Sets the transaction lease renewal period. When the writer mode is set toEXACTLY_ONCE
, transactions are used to persist events to the Pravega stream. The transaction interval corresponds to the Flink checkpoint interval. Throughout that interval, the transaction is kept alive with a lease that is periodically renewed. This configuration setting sets the lease renewal period. The default value is 30 seconds.- Parameters:
period
- the lease renewal period- Returns:
- A builder to configure and create a sink.
-
withSerializationSchema
public PravegaSinkBuilder<T> withSerializationSchema(org.apache.flink.api.common.serialization.SerializationSchema<T> serializationSchema)
Sets the serialization schema.- Parameters:
serializationSchema
- the deserialization schema to use.- Returns:
- A builder to configure and create a sink.
-
withEventRouter
public PravegaSinkBuilder<T> withEventRouter(PravegaEventRouter<T> eventRouter)
Sets the event router.- Parameters:
eventRouter
- the event router which produces a key per event.- Returns:
- A builder to configure and create a sink.
-
resolveStream
public io.pravega.client.stream.Stream resolveStream()
Resolves the stream to be provided to the sink, based on the configured default scope.- Returns:
- the resolved stream instance.
-
build
public PravegaSink<T> build()
Builds aPravegaSink
based on the configuration.- Returns:
- An instance of either
PravegaEventSink
orPravegaTransactionalSink
. - Throws:
java.lang.IllegalStateException
- if the configuration is invalid.
-
-