kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raghav Joshi <rag...@infoobjects.com>
Subject Fwd: Spark Streaming + kakfa (Check that you get the data from kafka producer)
Date Fri, 19 Jun 2015 08:24:31 GMT
lines.foreachRDD(new Function<JavaRDD<String>, Void>() {
@Override
public Void call(JavaRDD<String> rdd) throws Exception {
List<String> collect = rdd.collect();
for (String data : collect) {
try {
// save data in the log.txt file
Path filePath = Paths
.get(rdd save file);
if (!Files.exists(filePath)) {
Files.createFile(filePath);
}
String temp = "Text to be added" + " data is " + data;
Files.write(filePath, temp.getBytes(),
StandardOpenOption.APPEND);
 } catch (IOException e) {
e.printStackTrace();
}
}
 return null;
}
});

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message