Skip to content

Commit d85cba3

Browse files
committed
Added javadocs to the KafkaTopicService.
1 parent 4082a59 commit d85cba3

File tree

1 file changed

+75
-2
lines changed

1 file changed

+75
-2
lines changed
Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,94 @@
11
package com.hivemq.extensions.kafka.api.services;
22

3+
import com.hivemq.extension.sdk.api.annotations.Immutable;
34
import com.hivemq.extension.sdk.api.annotations.NotNull;
45

56
import java.util.Map;
67
import java.util.Set;
78

9+
/**
10+
* The KafkaTopicService enables the programmatic interaction with Kafka topics.
11+
* All methods act on the Kafka cluster, that the calling transformer is associated with.
12+
*
13+
* @author Georg Held
14+
* @see <a href=https://www.hivemq.com/docs/kafka/latest/enterprise-extension-for-kafka/kafka.html#kafka-clusters>Kafka Cluster configuration</a></a>.
15+
* @since 4.4.0
16+
*/
817
public interface KafkaTopicService {
918

19+
/**
20+
* Query the state of a single Kafka topic on the associated cluster.
21+
* <p>
22+
* This method can block the calling transformer.
23+
*
24+
* @param topic the name of a Kafka topic.
25+
* @return the {@link KafkaTopicState} of the topic. Possible values here are {@link KafkaTopicState#FAILURE},
26+
* {@link KafkaTopicState#EXISTS} and {@link KafkaTopicState#MISSING}.
27+
*/
1028
@NotNull KafkaTopicState getKafkaTopicState(@NotNull String topic);
1129

12-
@NotNull Map<String, @NotNull KafkaTopicState> getKafkaTopicStates(@NotNull Set<@NotNull String> topics);
30+
/**
31+
* Query the states of multiple Kafka topics on the associated cluster.
32+
* <p>
33+
* The returned map contains exactly one entry per queried topic in the argument set.
34+
* <p>
35+
* This method can block the calling transformer.
36+
*
37+
* @param topics a set containing the names of Kafka topics.
38+
* @return a mapping of the queried Kafka topics to their {@link KafkaTopicState}. Possible values here are
39+
* {@link KafkaTopicState#FAILURE}, {@link KafkaTopicState#EXISTS} and {@link KafkaTopicState#MISSING}.
40+
*/
41+
@Immutable @NotNull Map<String, @NotNull KafkaTopicState> getKafkaTopicStates(@NotNull Set<@NotNull String> topics);
1342

43+
/**
44+
* Create a single Kafka topic on the associated cluster.
45+
* Use {@link KafkaTopicService#getKafkaTopicState(String)} if you would like to check, whether the topic already exists.
46+
* <p>
47+
* This method can block the calling transformer.
48+
* <p>
49+
*
50+
* @param topic the name of a new Kafka topic.
51+
* @return the {@link KafkaTopicState} of the topic after this methods completes. Possible values here are {@link KafkaTopicState#FAILURE},
52+
* {@link KafkaTopicState#EXISTS} and {@link KafkaTopicState#CREATED}.
53+
*/
1454
@NotNull KafkaTopicState createKafkaTopic(@NotNull String topic);
1555

56+
/**
57+
* Create multiple Kafka topics on the associated cluster.
58+
* Use {@link KafkaTopicService#getKafkaTopicStates(Set)} if you would like to check, whether the topics already
59+
* exists.
60+
* <p>
61+
* * The returned map contains exactly one entry per queried topic in the argument set.
62+
* <p>
63+
* This method can block the calling transformer.
64+
*
65+
* @param topics a set containing the names of new Kafka topics.
66+
* @return a mapping of the Kafka topics to their {@link KafkaTopicState} after this method completes. Possible values
67+
* here are {@link KafkaTopicState#FAILURE}, {@link KafkaTopicState#EXISTS} and {@link KafkaTopicState#CREATED}.
68+
*/
1669
@NotNull Map<String, @NotNull KafkaTopicState> createKafkaTopics(@NotNull Set<@NotNull String> topics);
1770

71+
/**
72+
* KafkaTopicState encodes the current known state of a Kafka topic on the associated cluster.
73+
*/
1874
enum KafkaTopicState {
19-
FAILURE, EXISTS, CREATED, MISSING,
75+
/**
76+
* FAILURE signals that the operation for the topic was not successful. No possible information about the true
77+
* state of this topic on the Kafka cluster can be assumed.
78+
*/
79+
FAILURE,
80+
/**
81+
* This topic is missing from the associated Kafka cluster and may need to be created before a record can be published
82+
* to it.
83+
*/
84+
MISSING,
85+
/**
86+
* This topic already exists on the associated Kafka cluster.
87+
*/
88+
EXISTS,
89+
/**
90+
* This topic was created on the associated Kafka cluster.
91+
*/
92+
CREATED,
2093
}
2194
}

0 commit comments

Comments
 (0)