kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rusty <rag...@infoobjects.com>
Subject Re: JavaKafkaWordCount not working under Spark Streaming
Date Fri, 19 Jun 2015 08:29:53 GMT
Check that you get the data from kafka producer

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
View raw message