Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How pass commonParams in PySpark? #2

Open
luisfsantana opened this issue Mar 13, 2018 · 1 comment
Open

How pass commonParams in PySpark? #2

luisfsantana opened this issue Mar 13, 2018 · 1 comment

Comments

@luisfsantana
Copy link

Hi, I am trying to do with pyspark, but I don't know how pass the variable commonParams that you use. I need pass the protocol SASL_PLAINTEXT and "sasl.kerberos.service.name" -> "kafka".

Thank you.

@osboo
Copy link

osboo commented Jun 5, 2018

hi @luisfsantana,
If you use Structured Streaming in Python then following code works:

lines = spark \
    .readStream \
    .format("kafka") \
    .option("kafka.bootstrap.servers", KAFKA_BOOTSTRAP_SERVER) \
    .option("kafka.security.protocol", "SASL_SSL") \
    .option("kafka.sasl.kerberos.service.name", "kafka") \
    .option("kafka.ssl.truststore.location", "/usr/lib/jvm/jdk1.8.0_162/jre/lib/security/jssecacerts") \
    .option("kafka.ssl.truststore.password", "changeit") \
    .option("subscribe", KAFKA_TOPIC_NAME) \
    .load()

Kafka options should be prefixed by kafka. .

For DirectStreams there is python dictionary that looks exactly as in Scala:

transactions_kafka_stream = KafkaUtils.createDirectStream(ssc,                                                                  self.config.KAFKA_SETTINGS.KAFKA_TOPIC_NAME],
                                                                  {"metadata.broker.list":
                                                                   self.config.KAFKA_SETTINGS.KAFKA_SERVER,
                                                                   'auto.commit.enable': 'true',
                                                                   'auto.offset.reset': 'largest'})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants