Package com.linkedin.venice.producer
Class AbstractVeniceProducer<K,V>
- java.lang.Object
-
- com.linkedin.venice.producer.AbstractVeniceProducer<K,V>
-
- All Implemented Interfaces:
VeniceProducer<K,V>
,java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
OnlineVeniceProducer
public abstract class AbstractVeniceProducer<K,V> extends java.lang.Object implements VeniceProducer<K,V>
A generic implementation of theVeniceProducer
interface- See Also:
VeniceProducer
-
-
Constructor Summary
Constructors Constructor Description AbstractVeniceProducer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<DurableWrite>
asyncDelete(long logicalTime, K key)
A write operation to delete the record for a key.java.util.concurrent.CompletableFuture<DurableWrite>
asyncDelete(K key)
A write operation to delete the record for a key.java.util.concurrent.CompletableFuture<DurableWrite>
asyncPut(long logicalTime, K key, V value)
A write operation where a full value is written to replace the existing value.java.util.concurrent.CompletableFuture<DurableWrite>
asyncPut(K key, V value)
A write operation where a full value is written to replace the existing value.java.util.concurrent.CompletableFuture<DurableWrite>
asyncUpdate(long logicalTime, K key, java.util.function.Consumer<UpdateBuilder> updateFunction)
A write operation to modify a subset of fields in the record for a key.java.util.concurrent.CompletableFuture<DurableWrite>
asyncUpdate(K key, java.util.function.Consumer<UpdateBuilder> updateFunction)
A write operation to modify a subset of fields in the record for a key.void
close()
protected void
configure(java.lang.String storeName, VeniceProperties producerConfigs, io.tehuti.metrics.MetricsRepository metricsRepository, SchemaReader schemaReader, SchemaReader kmeSchemaReader)
protected VeniceWriter<byte[],byte[],byte[]>
constructVeniceWriter(java.util.Properties properties, VeniceWriterOptions writerOptions)
protected RecordSerializer<java.lang.Object>
getSerializer(org.apache.avro.Schema schema)
protected boolean
isClosed()
protected abstract VersionCreationResponse
requestTopic()
This function should return aVersionCreationResponse
to determine the PubSub topic and the characteristics that the producer should follow.
-
-
-
Method Detail
-
configure
protected void configure(java.lang.String storeName, VeniceProperties producerConfigs, io.tehuti.metrics.MetricsRepository metricsRepository, SchemaReader schemaReader, SchemaReader kmeSchemaReader)
-
constructVeniceWriter
protected VeniceWriter<byte[],byte[],byte[]> constructVeniceWriter(java.util.Properties properties, VeniceWriterOptions writerOptions)
-
getSerializer
protected RecordSerializer<java.lang.Object> getSerializer(org.apache.avro.Schema schema)
-
asyncPut
public java.util.concurrent.CompletableFuture<DurableWrite> asyncPut(K key, V value)
Description copied from interface:VeniceProducer
A write operation where a full value is written to replace the existing value.- Specified by:
asyncPut
in interfaceVeniceProducer<K,V>
- Parameters:
key
- Key of the record that needs to be updatedvalue
- The full value that needs to be written- Returns:
- A
CompletableFuture
that completes when the write operation is durable. It does not imply that the data is available to readers.
-
asyncPut
public java.util.concurrent.CompletableFuture<DurableWrite> asyncPut(long logicalTime, K key, V value)
Description copied from interface:VeniceProducer
A write operation where a full value is written to replace the existing value. It offers the writers to specify a logical time. This value is used to specify the ordering of operations and perform conflict resolution in Active/Active replication.- Specified by:
asyncPut
in interfaceVeniceProducer<K,V>
- Parameters:
logicalTime
- The value used during conflict resolution in Active/Active replicationkey
- Key of the record that needs to be updatedvalue
- The full value that needs to be written- Returns:
- A
CompletableFuture
that completes when the write operation is durable. It does not imply that the data is available to readers.
-
asyncDelete
public java.util.concurrent.CompletableFuture<DurableWrite> asyncDelete(K key)
Description copied from interface:VeniceProducer
A write operation to delete the record for a key.- Specified by:
asyncDelete
in interfaceVeniceProducer<K,V>
- Parameters:
key
- The key associated with the record that should be deleted- Returns:
- A
CompletableFuture
that completes when the write operation is durable. It does not imply that the data is available to readers.
-
asyncDelete
public java.util.concurrent.CompletableFuture<DurableWrite> asyncDelete(long logicalTime, K key)
Description copied from interface:VeniceProducer
A write operation to delete the record for a key. It offers the writers to specify a logical time. This value is used to specify the ordering of operations and perform conflict resolution in Active/Active replication.- Specified by:
asyncDelete
in interfaceVeniceProducer<K,V>
- Parameters:
logicalTime
- The value used during conflict resolution in Active/Active replicationkey
- Key of the record that needs to be deleted- Returns:
- A
CompletableFuture
that completes when the write operation is durable. It does not imply that the data is available to readers.
-
asyncUpdate
public java.util.concurrent.CompletableFuture<DurableWrite> asyncUpdate(K key, java.util.function.Consumer<UpdateBuilder> updateFunction)
Description copied from interface:VeniceProducer
A write operation to modify a subset of fields in the record for a key.- Specified by:
asyncUpdate
in interfaceVeniceProducer<K,V>
- Parameters:
key
- Key of the record that needs to be updatedupdateFunction
- AConsumer
that takes in anUpdateBuilder
object and updates it to specify which fields to modify and the operations that must be done on them.- Returns:
- A
CompletableFuture
that completes when the write operation is durable. It does not imply that the data is available to readers.
-
asyncUpdate
public java.util.concurrent.CompletableFuture<DurableWrite> asyncUpdate(long logicalTime, K key, java.util.function.Consumer<UpdateBuilder> updateFunction)
Description copied from interface:VeniceProducer
A write operation to modify a subset of fields in the record for a key. It offers the writers to specify a logical time. This value is used to specify the ordering of operations and perform conflict resolution in Active/Active replication.- Specified by:
asyncUpdate
in interfaceVeniceProducer<K,V>
- Parameters:
logicalTime
- The value used during conflict resolution in Active/Active replicationkey
- Key of the record that needs to be updatedupdateFunction
- AConsumer
that takes in anUpdateBuilder
object and updates it to specify which fields to modify and the operations that must be done on them.- Returns:
- A
CompletableFuture
that completes when the write operation is durable. It does not imply that the data is available to readers.
-
requestTopic
protected abstract VersionCreationResponse requestTopic()
This function should return aVersionCreationResponse
to determine the PubSub topic and the characteristics that the producer should follow.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
isClosed
protected boolean isClosed()
-
-