Skip to content

Commit 901636c

Browse files
author
Greg Palmer
committed
Added kafka-consumer support.
1 parent 682fda4 commit 901636c

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

-163 KB
Binary file not shown.

scripts/run-sample-spark-kafka-job.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# SCRIPT: run-sample-spark-kafka-job.sh
44
#
55

6-
dcos spark run --name 'spark' --submit-args='--conf spark.eventLog.enabled=true --conf spark.eventLog.dir=hdfs://hdfs/history --conf Dspark.mesos.coarse=true --conf spark.cores.max=4 --conf spark.executor.memory=1g --driver-cores 1 --driver-memory 1g --class HDFSWordCount http://infinity-artifacts.s3.amazonaws.com/spark/sparkjob-assembly-1.0.jar hdfs:///test-data/test-data.txt'
6+
dcos spark run --submit-args='--conf spark.eventLog.enabled=true --conf spark.eventLog.dir=hdfs://hdfs/history --conf Dspark.mesos.coarse=true --conf spark.cores.max=4 --conf spark.executor.memory=1g --driver-cores 1 --driver-memory 1g --class org.apache.spark.examples.streaming.KafkaWordCount https://downloads.mesosphere.com/spark/assets/spark-examples_2.10-1.4.0-SNAPSHOT.jar mesos://leader.mesos:5050 zk-1.zk,zk-2.zk,zk-3.zk my-consumer-group my-topic 1'
77

88
# End of script

scripts/start-smackstack.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,43 @@ do
200200
sleep 10
201201
done
202202

203+
echo
204+
echo " #####################################"
205+
echo " ### Starting Kafka Consumer ###"
206+
echo " #####################################"
207+
echo
208+
echo
209+
echo " Waiting for Kafka service to start. "
210+
while true
211+
do
212+
task_status=$(dcos task |grep 'kafka-0-broker ' | awk '{print $4}')
213+
214+
if [ "$task_status" != "R" ]
215+
then
216+
printf "."
217+
else
218+
echo " Kafka service is running."
219+
break
220+
fi
221+
sleep 10
222+
done
223+
224+
dcos marathon app add config/kafka-consumer.json
225+
226+
sleep 5
227+
203228
echo
204229
echo " #############################################################"
205-
echo " ### Smack Stack start up complete. ###"
230+
echo " ### SMACK Stack start up complete. ###"
206231
echo " ### If you would like to run a Spark job that reads ###"
207-
echo " ### from the HDFS file system, run the following command: ###"
232+
echo " ### from the HDFS file system or from a Kafka queue, ###"
233+
echo " ### run the following commands: ###"
208234
echo " #############################################################"
209235
echo
210236

211237
echo " $ scripts/run-sample-spark-hdfs-job.sh "
238+
echo
239+
echo " $ scripts/run-sample-spark-kafka-job.sh "
212240

213241
echo
214242

scripts/stop-smackstack.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ echo " ### Stopping HDFS "
3636
sleep 2
3737
dcos package uninstall hdfs --app-id='hdfs' --yes
3838

39+
echo
40+
echo " ### Stopping Kafka Consumer "
41+
42+
dcos marathon app remove kafka-consumer
43+
3944
echo
4045
echo " ### Stopping Kafka "
4146

@@ -50,7 +55,6 @@ echo " ### Stopping Cassandra "
5055
sleep 2
5156
dcos package uninstall cassandra --app-id='cassandra' --yes
5257

53-
5458
# Zookeeper cleanup
5559
# First, make sure all services are removed
5660

0 commit comments

Comments
 (0)