gaborgsomogyi commented on a change in pull request #25412: 
[SPARK-28691][EXAMPLES] Add Java/Scala DirectKerberizedKafkaWordCount examples
URL: https://github.com/apache/spark/pull/25412#discussion_r317533705
 
 

 ##########
 File path: 
examples/src/main/scala/org/apache/spark/examples/streaming/DirectKerberizedKafkaWordCount.scala
 ##########
 @@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// scalastyle:off println
+package org.apache.spark.examples.streaming
+
+import org.apache.kafka.clients.CommonClientConfigs
+import org.apache.kafka.clients.consumer.ConsumerConfig
+import org.apache.kafka.common.security.auth.SecurityProtocol
+import org.apache.kafka.common.serialization.StringDeserializer
+
+import org.apache.spark.SparkConf
+import org.apache.spark.streaming._
+import org.apache.spark.streaming.kafka010._
+
+/**
+ * Consumes messages from one or more topics in Kafka and does wordcount.
+ * Usage: DirectKerberizedKafkaWordCount <brokers> <topics>
+ *   <brokers> is a list of one or more Kafka brokers
+ *   <groupId> is a consumer group name to consume from topics
+ *   <topics> is a list of one or more kafka topics to consume from
+ *
+ * Example:
+ *   Yarn client:
+ *    $ bin/run-example --files 
${jaas_path}/kafka_jaas.conf,${keytab_path}/kafka.service.keytab \
+ *      --driver-java-options 
"-Djava.security.auth.login.config=${path}/kafka_driver_jaas.conf" \
+ *      --conf \
+ *      
"spark.executor.extraJavaOptions=-Djava.security.auth.login.config=./kafka_jaas.conf"
 \
+ *      --master yarn
+ *      streaming.DirectKerberizedKafkaWordCount 
broker1-host:port,broker2-host:port \
+ *      consumer-group topic1,topic2
+ *   Yarn cluster:
+ *    $ bin/run-example --files \
+ *      
${jaas_path}/kafka_jaas.conf,${keytab_path}/kafka.service.keytab,${krb5_path}/krb5.conf
 \
+ *      --driver-java-options \
+ *      "-Djava.security.auth.login.config=./kafka_jaas.conf \
+ *      -Djava.security.krb5.conf=./krb5.conf" \
+ *      --conf \
+ *      
"spark.executor.extraJavaOptions=-Djava.security.auth.login.config=./kafka_jaas.conf"
 \
+ *      --master yarn --deploy-mode cluster \
+ *      streaming.DirectKerberizedKafkaWordCount 
broker1-host:port,broker2-host:port \
+ *      consumer-group topic1,topic2
+ *
+ * kafka_jaas.conf can manually create, template as:
+ *   KafkaClient {
+ *     com.sun.security.auth.module.Krb5LoginModule required
+ *     keyTab="./kafka.service.keytab"
+ *     useKeyTab=true
+ *     storeKey=true
+ *     useTicketCache=false
+ *     serviceName="kafka"
+ *     principal="kafka/h...@example.com";
+ *   };
+ * kafka_driver_jaas.conf (used by yarn client) and kafka_jaas.conf are 
basically the same
+ * except for some differences at 'keyTab'. In kafka_driver_jaas.conf, 
'keyTab' should be
+ * "${keytab_path}/kafka.service.keytab".
+ * In addition, for IBM JVMs, please use 
'com.ibm.security.auth.module.Krb5LoginModule' 
+ * instead of 'com.sun.security.auth.module.Krb5LoginModule'.
+ *
+ * Note that this example uses SASL_PLAINTEXT for simplicity; however,
+ * SASL_PLAINTEXT has no SSL encryption and likely be less secure. Please 
consider
+ * using SASL_SSL in production.
+ */
+object DirectKerberizedKafkaWordCount {
+  def main(args: Array[String]) {
+    if (args.length < 3) {
+      System.err.println(s"""
+                            |Usage: DirectKerberizedKafkaWordCount <brokers> 
<groupId> <topics>
 
 Review comment:
   Final nit: indent.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to