Package com.hazelcast.jet.mongodb
Class MongoSinkBuilder<T>
- java.lang.Object
-
- com.hazelcast.jet.mongodb.MongoSinkBuilder<T>
-
- Type Parameters:
T
- type of the items the sink will accept
public final class MongoSinkBuilder<T> extends java.lang.Object
- Since:
- 5.3
-
-
Field Summary
Fields Modifier and Type Field Description static RetryStrategy
DEFAULT_COMMIT_RETRY_STRATEGY
Default retry strategy used by the processors.static com.mongodb.TransactionOptions
DEFAULT_TRANSACTION_OPTION
Default transaction options used by the processors.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Sink<T>
build()
Creates and returns the MongoDBSink
with the components you supplied to this builder.MongoSinkBuilder<T>
checkResourceExistence(ResourceChecks checkResourceExistence)
IfResourceChecks.NEVER
, the database and collection will be automatically created on the first usage.MongoSinkBuilder<T>
commitRetryStrategy(RetryStrategy commitRetryStrategy)
Sets the retry strategy in case of commit failure.MongoSinkBuilder<T>
identifyDocumentBy(java.lang.String fieldName, FunctionEx<T,java.lang.Object> documentIdentityFn)
Sets the filter that decides which document in the collection is equal to processed document.MongoSinkBuilder<T>
into(FunctionEx<T,java.lang.String> selectDatabaseNameFn, FunctionEx<T,java.lang.String> selectCollectionNameFn)
MongoSinkBuilder<T>
into(java.lang.String databaseName, java.lang.String collectionName)
MongoSinkBuilder<T>
preferredLocalParallelism(int preferredLocalParallelism)
MongoSinkBuilder<T>
transactionOptions(SupplierEx<com.mongodb.TransactionOptions> transactionOptionsSup)
Sets options which will be used by MongoDB transaction mechanism.MongoSinkBuilder<T>
withCustomReplaceOptions(ConsumerEx<com.mongodb.client.model.ReplaceOptions> adjustConsumer)
Provides an option to adjust options used in replace action.MongoSinkBuilder<T>
writeMode(WriteMode writeMode)
Sets write mode used by the connector.
-
-
-
Field Detail
-
DEFAULT_TRANSACTION_OPTION
public static final com.mongodb.TransactionOptions DEFAULT_TRANSACTION_OPTION
Default transaction options used by the processors.
-
DEFAULT_COMMIT_RETRY_STRATEGY
public static final RetryStrategy DEFAULT_COMMIT_RETRY_STRATEGY
Default retry strategy used by the processors.
-
-
Method Detail
-
into
@Nonnull public MongoSinkBuilder<T> into(@Nonnull FunctionEx<T,java.lang.String> selectDatabaseNameFn, @Nonnull FunctionEx<T,java.lang.String> selectCollectionNameFn)
- Parameters:
selectDatabaseNameFn
- selects database name for each item individuallyselectCollectionNameFn
- selects collection name for each item individually
-
into
@Nonnull public MongoSinkBuilder<T> into(@Nonnull java.lang.String databaseName, @Nonnull java.lang.String collectionName)
- Parameters:
databaseName
- database name to which objects will be inserted/updated.collectionName
- collection name to which objects will be inserted/updated.
-
preferredLocalParallelism
@Nonnull public MongoSinkBuilder<T> preferredLocalParallelism(int preferredLocalParallelism)
-
withCustomReplaceOptions
@Nonnull public MongoSinkBuilder<T> withCustomReplaceOptions(@Nonnull ConsumerEx<com.mongodb.client.model.ReplaceOptions> adjustConsumer)
Provides an option to adjust options used in replace action. By default upsert is only enabled.
-
identifyDocumentBy
@Nonnull public MongoSinkBuilder<T> identifyDocumentBy(@Nonnull java.lang.String fieldName, @Nonnull FunctionEx<T,java.lang.Object> documentIdentityFn)
Sets the filter that decides which document in the collection is equal to processed document.- Parameters:
fieldName
- field name in the collection, that will be used for comparisondocumentIdentityFn
- function that extracts ID from given item; will be compared againstfieldName
-
commitRetryStrategy
@Nonnull public MongoSinkBuilder<T> commitRetryStrategy(@Nonnull RetryStrategy commitRetryStrategy)
Sets the retry strategy in case of commit failure.MongoDB by default retries simple operations, but commits must be retried manually.
This option is taken into consideration only if ProcessingGuarantee.EXACTLY_ONCE is used.
Default value is DEFAULT_COMMIT_RETRY_STRATEGY.
-
transactionOptions
@Nonnull public MongoSinkBuilder<T> transactionOptions(@Nonnull SupplierEx<com.mongodb.TransactionOptions> transactionOptionsSup)
Sets options which will be used by MongoDB transaction mechanism.This option is taken into consideration only if ProcessingGuarantee.EXACTLY_ONCE is used.
Default value is DEFAULT_TRANSACTION_OPTION.
-
writeMode
@Nonnull public MongoSinkBuilder<T> writeMode(@Nonnull WriteMode writeMode)
Sets write mode used by the connector. Default value is WriteMode.REPLACE.
-
checkResourceExistence
@Nonnull public MongoSinkBuilder<T> checkResourceExistence(ResourceChecks checkResourceExistence)
IfResourceChecks.NEVER
, the database and collection will be automatically created on the first usage. Otherwise, querying for a database or collection that don't exist will cause an error. Default value isResourceChecks.ONCE_PER_JOB
.- Parameters:
checkResourceExistence
- mode of resource existence checks; whether exception should be thrown when database or collection does not exist and when the check will be performed.- Since:
- 5.4
-
-