-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from keyko-io/feature/create-topics-starting
Create topics when the streaming process start
- Loading branch information
Showing
6 changed files
with
109 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/io/keyko/monitoring/preprocessing/TopicCreation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.keyko.monitoring.preprocessing; | ||
|
||
import org.apache.kafka.clients.admin.AdminClient; | ||
import org.apache.kafka.clients.admin.AdminClientConfig; | ||
import org.apache.kafka.clients.admin.NewTopic; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
public class TopicCreation { | ||
|
||
public static void createTopics(List<String> topicNames, String kafkaServer) { | ||
Properties props = new Properties(); | ||
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaServer); | ||
AdminClient a = AdminClient.create(props); | ||
a.createTopics(convertToNewTopics(topicNames)); | ||
} | ||
|
||
public static List<NewTopic> convertToNewTopics(List<String> topicNames) { | ||
List<NewTopic> topics = new ArrayList<NewTopic>(); | ||
for (String i : topicNames) { | ||
topics.add(new NewTopic(i, 1, (short) 1)); | ||
} | ||
return topics; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
log4j.rootLogger=INFO, stdout, file | ||
|
||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%p %m (%c:%L) %n | ||
|
||
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender | ||
log4j.appender.file.DatePattern=yyyy-MM-dd | ||
log4j.appender.file.encoding=UTF-8 | ||
log4j.appender.file.append=true | ||
log4j.appender.file.file=./celo-stremer.log | ||
log4j.appender.file.threshold=INFO | ||
log4j.appender.file.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n | ||
|
||
log4j.logger.org.apache.kafka.clients.consumer.ConsumerConfig=DEBUG |