Skip to content

Commit 4ce6f5c

Browse files
committed
MINOR: Improve ProcessorContext JavaDocs (#20042)
Clarify that state stores are sharded, and shards cannot be shared across Processors. Reviewers: Lucas Brutschy <[email protected]>
1 parent 6351bc0 commit 4ce6f5c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

streams/src/main/java/org/apache/kafka/streams/processor/ProcessorContext.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ void register(final StateStore store,
101101
/**
102102
* Get the state store given the store name.
103103
*
104+
* <p>The returned state store represent one shard of the overall state, which belongs to the current task.
105+
* The returned shard of the state store may only be used by the current
106+
* {@link org.apache.kafka.streams.kstream.Transformer}, {@link org.apache.kafka.streams.kstream.ValueTransformer},
107+
* or {@link org.apache.kafka.streams.kstream.ValueTransformerWithKey} instance.
108+
* Sharing a shard across different transformers (ie, from different "sibling" tasks; same sub-topology but different
109+
* partition) may lead to data corruption and/or data loss.
110+
*
104111
* @param name The store name
105112
* @param <S> The type or interface of the store to return
106113
* @return The state store instance

streams/src/main/java/org/apache/kafka/streams/processor/api/ProcessingContext.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ public interface ProcessingContext {
107107
/**
108108
* Get the state store given the store name.
109109
*
110+
* <p>The returned state store represent one shard of the overall state, which belongs to the current task.
111+
* The returned shard of the state store may only be used by the current {@link Processor} or
112+
* {@link FixedKeyProcessor} instance.
113+
* Sharing a shard across different processors (ie, from different "sibling" tasks; same sub-topology but different
114+
* partition) may lead to data corruption and/or data loss.
115+
*
110116
* @param name The store name
111117
* @param <S> The type or interface of the store to return
112118
* @return The state store instance

0 commit comments

Comments
 (0)