1
+ /*
2
+ * Copyright 2018-present HiveMQ GmbH
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
1
17
package com .hivemq .extensions .kafka .api .services ;
2
18
19
+ import com .hivemq .extension .sdk .api .annotations .DoNotImplement ;
3
20
import com .hivemq .extension .sdk .api .annotations .Immutable ;
4
21
import com .hivemq .extension .sdk .api .annotations .NotNull ;
5
22
6
23
import java .util .Map ;
7
24
import java .util .Set ;
8
25
9
26
/**
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.
27
+ * The KafkaTopicService enables the programmatic interaction with Kafka topics. All methods act on the Kafka cluster,
28
+ * that the calling transformer is associated with.
12
29
*
13
30
* @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>.
31
+ * @see <a href=https://www.hivemq.com/docs/kafka/latest/enterprise-extension-for-kafka/kafka.html#kafka-clusters>Kafka
32
+ * Cluster configuration</a></a>.
15
33
* @since 4.4.0
16
34
*/
35
+ @ DoNotImplement
17
36
public interface KafkaTopicService {
18
37
19
38
/**
@@ -23,7 +42,8 @@ public interface KafkaTopicService {
23
42
*
24
43
* @param topic the name of a Kafka topic.
25
44
* @return the {@link KafkaTopicState} of the topic. Possible values here are {@link KafkaTopicState#FAILURE},
26
- * {@link KafkaTopicState#EXISTS} and {@link KafkaTopicState#MISSING}.
45
+ * {@link KafkaTopicState#EXISTS} and {@link KafkaTopicState#MISSING}.
46
+ * @since 4.4.0
27
47
*/
28
48
@ NotNull KafkaTopicState getKafkaTopicState (@ NotNull String topic );
29
49
@@ -35,59 +55,74 @@ public interface KafkaTopicService {
35
55
* This method can block the calling transformer.
36
56
*
37
57
* @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}.
58
+ * @return a mapping of the queried Kafka topics to their {@link KafkaTopicState}. Possible values here are {@link
59
+ * KafkaTopicState#FAILURE}, {@link KafkaTopicState#EXISTS} and {@link KafkaTopicState#MISSING}.
60
+ * @throws NullPointerException if {@code topics} is or contains null.
61
+ * @since 4.4.0
40
62
*/
41
63
@ Immutable @ NotNull Map <String , @ NotNull KafkaTopicState > getKafkaTopicStates (@ NotNull Set <@ NotNull String > topics );
42
64
43
65
/**
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.
66
+ * Create a single Kafka topic on the associated cluster. Use {@link KafkaTopicService#getKafkaTopicState(String)}
67
+ * if you would like to check, whether the topic already exists.
46
68
* <p>
47
69
* This method can block the calling transformer.
48
70
* <p>
49
71
*
50
72
* @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}.
73
+ * @return the {@link KafkaTopicState} of the topic after this methods completes. Possible values here are {@link
74
+ * KafkaTopicState#FAILURE}, {@link KafkaTopicState#EXISTS} and {@link KafkaTopicState#CREATED}.
75
+ * @since 4.4.0
53
76
*/
54
77
@ NotNull KafkaTopicState createKafkaTopic (@ NotNull String topic );
55
78
56
79
/**
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.
80
+ * Create multiple Kafka topics on the associated cluster. Use {@link KafkaTopicService#getKafkaTopicStates(Set)} if
81
+ * you would like to check, whether the topics already exists.
60
82
* <p>
61
83
* * The returned map contains exactly one entry per queried topic in the argument set.
62
84
* <p>
63
85
* This method can block the calling transformer.
64
86
*
65
87
* @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}.
88
+ * @return a mapping of the Kafka topics to their {@link KafkaTopicState} after this method completes. Possible
89
+ * values here are {@link KafkaTopicState#FAILURE}, {@link KafkaTopicState#EXISTS} and {@link
90
+ * KafkaTopicState#CREATED}.
91
+ * @throws NullPointerException if {@code topics} is or contains null.
92
+ * @since 4.4.0
68
93
*/
69
94
@ NotNull Map <String , @ NotNull KafkaTopicState > createKafkaTopics (@ NotNull Set <@ NotNull String > topics );
70
95
71
96
/**
72
97
* KafkaTopicState encodes the current known state of a Kafka topic on the associated cluster.
98
+ *
99
+ * @since 4.4.0
73
100
*/
74
101
enum KafkaTopicState {
75
102
/**
76
103
* FAILURE signals that the operation for the topic was not successful. No possible information about the true
77
104
* state of this topic on the Kafka cluster can be assumed.
105
+ *
106
+ * @since 4.4.0
78
107
*/
79
108
FAILURE ,
80
109
/**
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.
110
+ * This topic is missing from the associated Kafka cluster and may need to be created before a record can be
111
+ * published to it.
112
+ *
113
+ * @since 4.4.0
83
114
*/
84
115
MISSING ,
85
116
/**
86
117
* This topic already exists on the associated Kafka cluster.
118
+ *
119
+ * @since 4.4.0
87
120
*/
88
121
EXISTS ,
89
122
/**
90
123
* This topic was created on the associated Kafka cluster.
124
+ *
125
+ * @since 4.4.0
91
126
*/
92
127
CREATED ,
93
128
}
0 commit comments