1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
data = [9]
kafkaStream = KafkaUtils.createDirectStream(ssc, [topic], {
'bootstrap.servers': 'localhost:9092',
'group.id': 'video-group',
'fetch.message.max.bytes': '15728640',
'auto.offset.reset': 'largest'})
lines = kafkaStream.map(lambda x: x[1])
flag = lines.map(lambda line: line.split(",")).map(lambda v : v[0])
flag.pprint()
if flag == "9" :
vl = lines.map(lambda line: line.split(",")).map(lambda v: v[1])
vl.pprint() #je lance une fonction F1
else:
#je lance une fonction F2
lines.pprint() |
Partager