Skip to content

Commit cf84a02

Browse files
StateRestoreCallback Contract
1 parent d0f9adf commit cf84a02

5 files changed

+85
-18
lines changed

SUMMARY.adoc

+9-5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
. link:kafka-streams-DelegatingStateRestoreListener.adoc[DelegatingStateRestoreListener]
4040
. link:kafka-streams-CompositeRestoreListener.adoc[CompositeRestoreListener]
4141

42+
. link:kafka-streams-internals-StateRestoreCallbackAdapter.adoc[StateRestoreCallbackAdapter]
43+
4244
== Demos
4345

4446
. link:kafka-streams-demo-creating-topology-with-state-store-logging-enabled.adoc[Creating Topology with State Store with Logging Enabled]
@@ -148,11 +150,6 @@
148150
. link:kafka-streams-Cancellable.adoc[Cancellable]
149151

150152
. link:kafka-streams-ProcessorSupplier.adoc[ProcessorSupplier Contract]
151-
. link:kafka-streams-StateRestoreCallback.adoc[StateRestoreCallback]
152-
153-
. link:kafka-streams-StateRestoreListener.adoc[StateRestoreListener]
154-
.. link:kafka-streams-AbstractNotifyingBatchingRestoreCallback.adoc[AbstractNotifyingBatchingRestoreCallback]
155-
.. link:kafka-streams-AbstractNotifyingRestoreCallback.adoc[AbstractNotifyingRestoreCallback]
156153

157154
. link:kafka-streams-StreamPartitioner.adoc[StreamPartitioner]
158155

@@ -167,6 +164,13 @@
167164
. link:kafka-streams-PartitionGrouper.adoc[PartitionGrouper Contract]
168165
.. link:kafka-streams-DefaultPartitionGrouper.adoc[DefaultPartitionGrouper]
169166

167+
. link:kafka-streams-StateRestoreCallback.adoc[StateRestoreCallback]
168+
.. link:kafka-streams-BatchingStateRestoreCallback.adoc[BatchingStateRestoreCallback]
169+
170+
. link:kafka-streams-StateRestoreListener.adoc[StateRestoreListener]
171+
.. link:kafka-streams-AbstractNotifyingBatchingRestoreCallback.adoc[AbstractNotifyingBatchingRestoreCallback]
172+
.. link:kafka-streams-AbstractNotifyingRestoreCallback.adoc[AbstractNotifyingRestoreCallback]
173+
170174
== Monitoring Kafka Streams Applications
171175

172176
. link:kafka-streams-StateListener.adoc[StateListener -- KafkaStreams State Listener]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
== [[BatchingStateRestoreCallback]] BatchingStateRestoreCallback
2+
3+
`BatchingStateRestoreCallback` is...FIXME
+59-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
1-
== [[StateRestoreCallback]] StateRestoreCallback
1+
== [[StateRestoreCallback]] StateRestoreCallback Contract
22

3-
`StateRestoreCallback` is...FIXME
3+
`StateRestoreCallback` is the <<contract, abstraction>> of <<implementations, objects>> that can <<restore, restore>>.
4+
5+
[[contract]]
6+
.StateRestoreCallback Contract
7+
[cols="30m,70",options="header",width="100%"]
8+
|===
9+
| Method
10+
| Description
11+
12+
| restore
13+
a| [[restore]]
14+
15+
[source, java]
16+
----
17+
void restore(
18+
byte[] key,
19+
byte[] value)
20+
----
21+
22+
Used exclusively when <<kafka-streams-internals-StateRestoreCallbackAdapter.adoc#, StateRestoreCallbackAdapter>> is created (_adapted_ from a <<kafka-streams-StateRestoreCallback.adoc#, StateRestoreCallback>>)
23+
24+
|===
25+
26+
=== [[implementations]] Functional Interface and StateRestoreCallback's Implementations
27+
28+
`StateRestoreCallback` is a *functional interface* in Java.
29+
30+
https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.8[Functional interface] is an interface that has just one abstract method (aside from the methods of `java.lang.Object`), and thus represents a single function contract.
31+
32+
In addition to the usual process of creating an interface instance by declaring and instantiating a class, instances of functional interfaces can be created with method reference expressions and lambda expressions.
33+
34+
Because of this simplification of the Java language, `StateRestoreCallback` implementations are _usually_ anonymous classes and are defined and used in the following <<kafka-streams-StateStore.adoc#, state stores>>:
35+
36+
* <<kafka-streams-internals-InMemoryKeyValueStore.adoc#init, InMemoryKeyValueStore>>
37+
38+
* <<kafka-streams-internals-InMemorySessionStore.adoc#init, InMemorySessionStore>>
39+
40+
* <<kafka-streams-internals-InMemoryTimeOrderedKeyValueBuffer.adoc#init, InMemoryTimeOrderedKeyValueBuffer>>
41+
42+
* <<kafka-streams-internals-InMemoryWindowStore.adoc#init, InMemoryWindowStore>>
43+
44+
* <<kafka-streams-internals-MemoryLRUCache.adoc#init, MemoryLRUCache>>
45+
46+
The following are the regular named implementations.
47+
48+
.StateRestoreCallbacks (Direct Implementations and Extensions Only)
49+
[cols="30,70",options="header",width="100%"]
50+
|===
51+
| StateRestoreCallback
52+
| Description
53+
54+
| <<kafka-streams-AbstractNotifyingRestoreCallback.adoc#, AbstractNotifyingRestoreCallback>>
55+
| [[AbstractNotifyingRestoreCallback]]
56+
57+
| <<kafka-streams-BatchingStateRestoreCallback.adoc#, BatchingStateRestoreCallback>>
58+
| [[BatchingStateRestoreCallback]]
59+
60+
|===

kafka-streams-StateRestoreListener.adoc

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ a| [[onBatchRestored]]
1717
[source, java]
1818
----
1919
void onBatchRestored(
20-
final TopicPartition topicPartition,
21-
final String storeName,
22-
final long batchEndOffset,
23-
final long numRestored)
20+
TopicPartition topicPartition,
21+
String storeName,
22+
long batchEndOffset,
23+
long numRestored)
2424
----
2525

2626
Used when:
@@ -35,9 +35,9 @@ a| [[onRestoreEnd]]
3535
[source, java]
3636
----
3737
void onRestoreEnd(
38-
final TopicPartition topicPartition,
39-
final String storeName,
40-
final long totalRestored)
38+
TopicPartition topicPartition,
39+
String storeName,
40+
long totalRestored)
4141
----
4242

4343
Used when:
@@ -52,10 +52,10 @@ a| [[onRestoreStart]]
5252
[source, java]
5353
----
5454
void onRestoreStart(
55-
final TopicPartition topicPartition,
56-
final String storeName,
57-
final long startingOffset,
58-
final long endingOffset)
55+
TopicPartition topicPartition,
56+
String storeName,
57+
long startingOffset,
58+
long endingOffset)
5959
----
6060

6161
Used when:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
== [[StateRestoreCallbackAdapter]] StateRestoreCallbackAdapter
2+
3+
`StateRestoreCallbackAdapter` is...FIXME

0 commit comments

Comments
 (0)