Skip to content

Commit 2d1c574

Browse files
committed
Added more descriptions.
1 parent d85cba3 commit 2d1c574

File tree

9 files changed

+244
-19
lines changed

9 files changed

+244
-19
lines changed

.idea/codeStyles/Project.xml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/hivemq/extensions/kafka/api/services/KafkaTopicService.java

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
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+
117
package com.hivemq.extensions.kafka.api.services;
218

19+
import com.hivemq.extension.sdk.api.annotations.DoNotImplement;
320
import com.hivemq.extension.sdk.api.annotations.Immutable;
421
import com.hivemq.extension.sdk.api.annotations.NotNull;
522

623
import java.util.Map;
724
import java.util.Set;
825

926
/**
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.
1229
*
1330
* @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>.
1533
* @since 4.4.0
1634
*/
35+
@DoNotImplement
1736
public interface KafkaTopicService {
1837

1938
/**
@@ -23,7 +42,8 @@ public interface KafkaTopicService {
2342
*
2443
* @param topic the name of a Kafka topic.
2544
* @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
2747
*/
2848
@NotNull KafkaTopicState getKafkaTopicState(@NotNull String topic);
2949

@@ -35,59 +55,74 @@ public interface KafkaTopicService {
3555
* This method can block the calling transformer.
3656
*
3757
* @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
4062
*/
4163
@Immutable @NotNull Map<String, @NotNull KafkaTopicState> getKafkaTopicStates(@NotNull Set<@NotNull String> topics);
4264

4365
/**
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.
4668
* <p>
4769
* This method can block the calling transformer.
4870
* <p>
4971
*
5072
* @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
5376
*/
5477
@NotNull KafkaTopicState createKafkaTopic(@NotNull String topic);
5578

5679
/**
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.
6082
* <p>
6183
* * The returned map contains exactly one entry per queried topic in the argument set.
6284
* <p>
6385
* This method can block the calling transformer.
6486
*
6587
* @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
6893
*/
6994
@NotNull Map<String, @NotNull KafkaTopicState> createKafkaTopics(@NotNull Set<@NotNull String> topics);
7095

7196
/**
7297
* KafkaTopicState encodes the current known state of a Kafka topic on the associated cluster.
98+
*
99+
* @since 4.4.0
73100
*/
74101
enum KafkaTopicState {
75102
/**
76103
* FAILURE signals that the operation for the topic was not successful. No possible information about the true
77104
* state of this topic on the Kafka cluster can be assumed.
105+
*
106+
* @since 4.4.0
78107
*/
79108
FAILURE,
80109
/**
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
83114
*/
84115
MISSING,
85116
/**
86117
* This topic already exists on the associated Kafka cluster.
118+
*
119+
* @since 4.4.0
87120
*/
88121
EXISTS,
89122
/**
90123
* This topic was created on the associated Kafka cluster.
124+
*
125+
* @since 4.4.0
91126
*/
92127
CREATED,
93128
}

src/main/java/com/hivemq/extensions/kafka/api/transformers/Transformer.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,26 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.hivemq.extensions.kafka.api.transformers;
1718

19+
import com.hivemq.extension.sdk.api.annotations.DoNotImplement;
1820
import com.hivemq.extension.sdk.api.annotations.NotNull;
1921

2022
/**
23+
* This is the base interface for all HiveMQ Enterprise Extension for Kafka transformer.
24+
*
2125
* @author Christoph Schäbel
26+
* @author Georg Held
2227
*/
28+
@DoNotImplement
2329
public interface Transformer<I extends TransformerInitInput> {
30+
31+
/**
32+
* Use the init method to set up static runtime context for the execution of your transformer.
33+
*
34+
* @param input see the specific input e.g. {@link com.hivemq.extensions.kafka.api.transformers.mqtttokafka.MqttToKafkaInitInput}.
35+
*/
2436
default void init(@NotNull I input) {
2537
}
2638
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,43 @@
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+
117
package com.hivemq.extensions.kafka.api.transformers.mqtttokafka;
218

319
import com.hivemq.extension.sdk.api.annotations.NotNull;
20+
import com.hivemq.extensions.kafka.api.model.KafkaCluster;
421
import com.hivemq.extensions.kafka.api.services.KafkaTopicService;
522
import com.hivemq.extensions.kafka.api.transformers.TransformerInitInput;
623

724
/**
25+
* Provides context for the set up of a {@link MqttToKafkaTransformer}.
26+
*
827
* @author Georg Held
28+
* @since 4.4.0
929
*/
1030
public interface MqttToKafkaInitInput extends TransformerInitInput {
1131

32+
/**
33+
* @return the {@link KafkaCluster} this transformer is associated with.
34+
* @since 4.4.0
35+
*/
36+
@NotNull KafkaCluster getKafkaCluster();
37+
38+
/**
39+
* @return the {@link KafkaTopicService} to interact with topics on the Kafka cluster.
40+
* @since 4.4.0
41+
*/
1242
@NotNull KafkaTopicService getKafkaTopicService();
1343
}

src/main/java/com/hivemq/extensions/kafka/api/transformers/mqtttokafka/MqttToKafkaInput.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,45 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.hivemq.extensions.kafka.api.transformers.mqtttokafka;
1718

19+
import com.hivemq.extension.sdk.api.annotations.DoNotImplement;
20+
import com.hivemq.extension.sdk.api.annotations.Immutable;
1821
import com.hivemq.extension.sdk.api.annotations.NotNull;
1922
import com.hivemq.extension.sdk.api.packets.publish.PublishPacket;
2023
import com.hivemq.extensions.kafka.api.model.KafkaCluster;
2124
import com.hivemq.extensions.kafka.api.services.KafkaTopicService;
2225

2326
/**
27+
* The input parameter of the {@link MqttToKafkaTransformer}. It contains the information of the to be transformed
28+
* {@link PublishPacket}.
29+
* <p>
30+
* The MqttToKafkaInput allows access to the {@link KafkaCluster} and the {@link KafkaTopicService} for this cluster.
31+
*
2432
* @author Christoph Schäbel
33+
* @author Georg Held
34+
* @since 4.4.0
2535
*/
36+
@Immutable
37+
@DoNotImplement
2638
public interface MqttToKafkaInput {
2739

40+
/**
41+
* @return the {@link KafkaTopicService} to interact with topics on the Kafka cluster.
42+
* @since 4.4.0
43+
*/
2844
@NotNull KafkaTopicService getKafkaTopicService();
2945

46+
/**
47+
* @return the {@link PublishPacket} that triggered this transformer call.
48+
* @since 4.4.0
49+
*/
3050
@NotNull PublishPacket getPublishPacket();
3151

52+
/**
53+
* @return the {@link KafkaCluster} this transformer is associated with.
54+
* @since 4.4.0
55+
*/
3256
@NotNull KafkaCluster getKafkaCluster();
3357
}

src/main/java/com/hivemq/extensions/kafka/api/transformers/mqtttokafka/MqttToKafkaOutput.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,58 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.hivemq.extensions.kafka.api.transformers.mqtttokafka;
1718

19+
import com.hivemq.extension.sdk.api.annotations.DoNotImplement;
1820
import com.hivemq.extension.sdk.api.annotations.NotNull;
1921
import com.hivemq.extensions.kafka.api.builders.KafkaRecordBuilder;
2022
import com.hivemq.extensions.kafka.api.model.KafkaRecord;
2123

2224
import java.util.List;
2325

2426
/**
27+
* The output parameter of the {@link MqttToKafkaTransformer}. It allows access to the {@link KafkaRecordBuilder}.
28+
* <p>
29+
* After the {@link MqttToKafkaTransformer#transformMqttToKafka(MqttToKafkaInput, MqttToKafkaOutput)} method returns the
30+
* {@link KafkaRecord}s given to this output will be published to the associated Kafka cluster by the HiveMQ Enterprise
31+
* Extension for Kafka.
32+
*
2533
* @author Christoph Schäbel
34+
* @author Georg Held
35+
* @since 4.4.0
2636
*/
37+
@DoNotImplement
2738
public interface MqttToKafkaOutput {
2839

40+
/**
41+
* Create a new {@link KafkaRecordBuilder}. One {@link KafkaRecordBuilder} can be used to build multiple Kafka
42+
* records.
43+
*
44+
* @return an empty instance of the {@link KafkaRecordBuilder}.
45+
* @since 4.4.0
46+
*/
2947
@NotNull KafkaRecordBuilder newKafkaRecordBuilder();
3048

31-
void setKafkaRecords(@NotNull List<@NotNull KafkaRecord> kafkaRecord);
49+
/**
50+
* Sets the {@link KafkaRecord}s, that will be pushed to the associated Kafka cluster after the {@link
51+
* MqttToKafkaTransformer#transformMqttToKafka(MqttToKafkaInput, MqttToKafkaOutput)} call returns. The HiveMQ
52+
* Enterprise Extension for Kafka will publish these records in the order provided by the {@code kafkaRecords}
53+
* argument.
54+
* <p>
55+
* If desired, the same record can occupy multiple places in the {@code kafkaRecords} list. When no record shall be
56+
* pushed to the associated Kafka cluster for a {@link com.hivemq.extension.sdk.api.packets.publish.PublishPacket},
57+
* call this method with an empty list.
58+
* <p>
59+
* Use the {@link KafkaRecordBuilder} to create new records as desired.
60+
* <p>
61+
* Each additional call of this method will overwrite the previous one.
62+
*
63+
* @param kafkaRecords a list of to be published {@link KafkaRecord}s.
64+
* @throws NullPointerException if {@code kafkaRecords} or any element of it is null.
65+
* @throws IllegalArgumentException if any element in {@code kafkaRecords} was not created via a {@link
66+
* KafkaRecordBuilder}.
67+
* @since 4.4.0
68+
*/
69+
void setKafkaRecords(@NotNull List<@NotNull KafkaRecord> kafkaRecords);
3270
}

0 commit comments

Comments
 (0)