Skip to content

Commit 0360347

Browse files
committed
Kafka Components Zookeeper, Kafka Server, Producer & Consumber using Command Line Interface(CLI)
0 parents  commit 0360347

30 files changed

+1382
-0
lines changed

.gitattributes

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# These are explicitly windows files and should use crlf
5+
*.bat text eol=crlf
6+

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
**/build/
6+
!src/**/build/
7+
8+
# Ignore Gradle GUI config
9+
gradle-app.setting
10+
11+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
12+
!gradle-wrapper.jar
13+
14+
# Cache of project
15+
.gradletasknamecache
16+
17+
# Ignore the logs
18+
kafka/logs
19+
20+
# Ignore bin
21+
bin/
22+
23+
# Java
24+
.classpath
25+
.project
26+
.settings

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "automatic"
3+
}

build.gradle

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
allprojects {
6+
group 'kafka.training'
7+
version '1.0-SNAPSHOT'
8+
repositories {
9+
jcenter()
10+
mavenCentral()
11+
}
12+
}
13+
14+
subprojects {
15+
apply plugin: 'java'
16+
java {
17+
sourceCompatibility = JavaVersion.VERSION_11
18+
targetCompatibility = JavaVersion.VERSION_11
19+
}
20+
dependencies {
21+
implementation 'ch.qos.logback:logback-classic:1.2.3'
22+
implementation 'org.apache.kafka:kafka-clients:2.5.0'
23+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
24+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
25+
}
26+
test {
27+
useJUnitPlatform()
28+
}
29+
}

kafka/LICENSE

+396
Large diffs are not rendered by default.

kafka/NOTICE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Apache Kafka
2+
Copyright 2020 The Apache Software Foundation.
3+
4+
This product includes software developed at
5+
The Apache Software Foundation (https://www.apache.org/).
6+
7+
This distribution has a binary dependency on jersey, which is available under the CDDL
8+
License. The source code of jersey can be found at https://github.com/jersey/jersey/.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. 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+
name=local-console-sink
17+
connector.class=org.apache.kafka.connect.file.FileStreamSinkConnector
18+
tasks.max=1
19+
topics=connect-test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. 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+
name=local-console-source
17+
connector.class=org.apache.kafka.connect.file.FileStreamSourceConnector
18+
tasks.max=1
19+
topic=connect-test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
##
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
##
17+
18+
# This file contains some of the configurations for the Kafka Connect distributed worker. This file is intended
19+
# to be used with the examples, and some settings may differ from those used in a production system, especially
20+
# the `bootstrap.servers` and those specifying replication factors.
21+
22+
# A list of host/port pairs to use for establishing the initial connection to the Kafka cluster.
23+
bootstrap.servers=localhost:9092
24+
25+
# unique name for the cluster, used in forming the Connect cluster group. Note that this must not conflict with consumer group IDs
26+
group.id=connect-cluster
27+
28+
# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will
29+
# need to configure these based on the format they want their data in when loaded from or stored into Kafka
30+
key.converter=org.apache.kafka.connect.json.JsonConverter
31+
value.converter=org.apache.kafka.connect.json.JsonConverter
32+
# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply
33+
# it to
34+
key.converter.schemas.enable=true
35+
value.converter.schemas.enable=true
36+
37+
# Topic to use for storing offsets. This topic should have many partitions and be replicated and compacted.
38+
# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
39+
# the topic before starting Kafka Connect if a specific topic configuration is needed.
40+
# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
41+
# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
42+
# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
43+
offset.storage.topic=connect-offsets
44+
offset.storage.replication.factor=1
45+
#offset.storage.partitions=25
46+
47+
# Topic to use for storing connector and task configurations; note that this should be a single partition, highly replicated,
48+
# and compacted topic. Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
49+
# the topic before starting Kafka Connect if a specific topic configuration is needed.
50+
# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
51+
# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
52+
# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
53+
config.storage.topic=connect-configs
54+
config.storage.replication.factor=1
55+
56+
# Topic to use for storing statuses. This topic can have multiple partitions and should be replicated and compacted.
57+
# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
58+
# the topic before starting Kafka Connect if a specific topic configuration is needed.
59+
# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
60+
# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
61+
# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
62+
status.storage.topic=connect-status
63+
status.storage.replication.factor=1
64+
#status.storage.partitions=5
65+
66+
# Flush much faster than normal, which is useful for testing/debugging
67+
offset.flush.interval.ms=10000
68+
69+
# These are provided to inform the user about the presence of the REST host and port configs
70+
# Hostname & Port for the REST API to listen on. If this is set, it will bind to the interface used to listen to requests.
71+
#rest.host.name=
72+
#rest.port=8083
73+
74+
# The Hostname & Port that will be given out to other workers to connect to i.e. URLs that are routable from other servers.
75+
#rest.advertised.host.name=
76+
#rest.advertised.port=
77+
78+
# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins
79+
# (connectors, converters, transformations). The list should consist of top level directories that include
80+
# any combination of:
81+
# a) directories immediately containing jars with plugins and their dependencies
82+
# b) uber-jars with plugins and their dependencies
83+
# c) directories immediately containing the package directory structure of classes of plugins and their dependencies
84+
# Examples:
85+
# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
86+
#plugin.path=
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. 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+
name=local-file-sink
17+
connector.class=FileStreamSink
18+
tasks.max=1
19+
file=test.sink.txt
20+
topics=connect-test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. 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+
name=local-file-source
17+
connector.class=FileStreamSource
18+
tasks.max=1
19+
file=test.txt
20+
topic=connect-test

kafka/config/connect-log4j.properties

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. 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+
log4j.rootLogger=INFO, stdout, connectAppender
17+
18+
# Send the logs to the console.
19+
#
20+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
21+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
22+
23+
# Send the logs to a file, rolling the file at midnight local time. For example, the `File` option specifies the
24+
# location of the log files (e.g. ${kafka.logs.dir}/connect.log), and at midnight local time the file is closed
25+
# and copied in the same directory but with a filename that ends in the `DatePattern` option.
26+
#
27+
log4j.appender.connectAppender=org.apache.log4j.DailyRollingFileAppender
28+
log4j.appender.connectAppender.DatePattern='.'yyyy-MM-dd-HH
29+
log4j.appender.connectAppender.File=${kafka.logs.dir}/connect.log
30+
log4j.appender.connectAppender.layout=org.apache.log4j.PatternLayout
31+
32+
# The `%X{connector.context}` parameter in the layout includes connector-specific and task-specific information
33+
# in the log message, where appropriate. This makes it easier to identify those log messages that apply to a
34+
# specific connector. Simply add this parameter to the log layout configuration below to include the contextual information.
35+
#
36+
connect.log.pattern=[%d] %p %m (%c:%L)%n
37+
#connect.log.pattern=[%d] %p %X{connector.context}%m (%c:%L)%n
38+
39+
log4j.appender.stdout.layout.ConversionPattern=${connect.log.pattern}
40+
log4j.appender.connectAppender.layout.ConversionPattern=${connect.log.pattern}
41+
42+
log4j.logger.org.apache.zookeeper=ERROR
43+
log4j.logger.org.reflections=ERROR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Licensed to the Apache Software Foundation (ASF) under A or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. 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+
# see org.apache.kafka.clients.consumer.ConsumerConfig for more details
16+
17+
# Sample MirrorMaker 2.0 top-level configuration file
18+
# Run with ./bin/connect-mirror-maker.sh connect-mirror-maker.properties
19+
20+
# specify any number of cluster aliases
21+
clusters = A, B
22+
23+
# connection information for each cluster
24+
# This is a comma separated host:port pairs for each cluster
25+
# for e.g. "A_host1:9092, A_host2:9092, A_host3:9092"
26+
A.bootstrap.servers = A_host1:9092, A_host2:9092, A_host3:9092
27+
B.bootstrap.servers = B_host1:9092, B_host2:9092, B_host3:9092
28+
29+
# enable and configure individual replication flows
30+
A->B.enabled = true
31+
32+
# regex which defines which topics gets replicated. For eg "foo-.*"
33+
A->B.topics = .*
34+
35+
B->A.enabled = true
36+
B->A.topics = .*
37+
38+
# Setting replication factor of newly created remote topics
39+
replication.factor=1
40+
41+
############################# Internal Topic Settings #############################
42+
# The replication factor for mm2 internal topics "heartbeats", "B.checkpoints.internal" and
43+
# "mm2-offset-syncs.B.internal"
44+
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.
45+
checkpoints.topic.replication.factor=1
46+
heartbeats.topic.replication.factor=1
47+
offset-syncs.topic.replication.factor=1
48+
49+
# The replication factor for connect internal topics "mm2-configs.B.internal", "mm2-offsets.B.internal" and
50+
# "mm2-status.B.internal"
51+
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.
52+
offset.storage.replication.factor=1
53+
status.storage.replication.factor=1
54+
config.storage.replication.factor=1
55+
56+
# customize as needed
57+
# replication.policy.separator = _
58+
# sync.topic.acls.enabled = false
59+
# emit.heartbeats.interval.seconds = 5
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. 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+
# These are defaults. This file just demonstrates how to override some settings.
17+
bootstrap.servers=localhost:9092
18+
19+
# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will
20+
# need to configure these based on the format they want their data in when loaded from or stored into Kafka
21+
key.converter=org.apache.kafka.connect.json.JsonConverter
22+
value.converter=org.apache.kafka.connect.json.JsonConverter
23+
# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply
24+
# it to
25+
key.converter.schemas.enable=true
26+
value.converter.schemas.enable=true
27+
28+
offset.storage.file.filename=/tmp/connect.offsets
29+
# Flush much faster than normal, which is useful for testing/debugging
30+
offset.flush.interval.ms=10000
31+
32+
# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins
33+
# (connectors, converters, transformations). The list should consist of top level directories that include
34+
# any combination of:
35+
# a) directories immediately containing jars with plugins and their dependencies
36+
# b) uber-jars with plugins and their dependencies
37+
# c) directories immediately containing the package directory structure of classes of plugins and their dependencies
38+
# Note: symlinks will be followed to discover dependencies or plugins.
39+
# Examples:
40+
# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
41+
#plugin.path=

0 commit comments

Comments
 (0)